42 std::cerr <<
"" << std::endl;
43 std::cerr <<
"flxinstall: " << rMessage <<
": ERROR." << std::endl;
44 std::cerr <<
"" << std::endl;
48 std::cerr <<
"" << std::endl;
49 std::cerr <<
"utility to create/install/remove faudes-lua-extension "<< std::endl;
50 std::cerr << std::endl <<
"usage: " << std::endl;
51 std::cerr <<
"flxinstall <advanced options> <mode> <input-file(s)> <output-file/path>" << std::endl;
52 std::cerr <<
"with <mode> as follows:" << std::endl;
53 std::cerr <<
" -c create extension (*.flx file) from input files" << std::endl;
54 std::cerr <<
" -i install extension (*.flx file) to libFAUDES installation" << std::endl;
55 std::cerr <<
" -r remove extensions from libFAUDES installation" << std::endl;
56 std::cerr <<
" -x extract extension (*.flx file) to output directory" << std::endl;
57 std::cerr <<
" -t extract and test extension (*.flx file) to output directory" << std::endl;
58 std::cerr << std::endl;
59 std::cerr <<
"advanced options for non-standard target layout" << std::endl;
60 std::cerr <<
" -tbin <path> location of binaries, default $target/bin" << std::endl;
70 std::string
mXmlSeparator =
"<!-- ================================================================================ -->";
111 std::string dir = rPath;
114 std::cerr <<
"flxinstall: creating dir \"" << dir <<
"\"" << std::endl;
115 int sysret=std::system(std::string(
"mkdir " + dir).c_str());
117 std::cerr <<
"flxinstall: error while creating directory \"" << dir <<
"\"" << std::endl;
125 std::set < std::string > res;
126 for(std::set < std::string >::iterator fit=src.begin(); fit!=src.end(); fit++) {
127 if(*fit==
"")
continue;
128 if((*fit).at(0)==
'.')
continue;
140 void Lua2ref(
const std::string& rLuaFile,
const std::string& rRefFile=
"") {
143 std::cerr <<
"flxinstall: ignoring lua script \"" << rLuaFile <<
"\"" << std::endl;
147 std::string dst=rRefFile;
154 std::cerr <<
"flxinstall: converting lua script \"" << rLuaFile <<
"\"" << std::endl;
155 int sysret=std::system(cmd.c_str());
157 std::cerr <<
"flxinstall: error while converting lua script \"" << rLuaFile <<
"\"" << std::endl;
167 void Gen2ref(
const std::string& rGenFile,
const std::string& rRefFile=
"") {
168 std::cerr <<
"flxinstall: converting generator file \"" << rGenFile <<
"\"" << std::endl;
171 std::string dst=rRefFile;
191 tw.
WriteCharacterData(
"<object type=\"image/svg+xml\" name=\"graph\" data=\""+bas+
".svg\">\n");
193 tw.
WriteCharacterData(
"<img src=\"$genfile.png\" title=\"Click on image to download SVG formated file.\" />\n");
207 std::cerr <<
"flxinstall: error while converting generator \"" << rGenFile <<
"\"" << std::endl;
258 rTr.
ReadBegin(
"LuaFunctionDefinition",btag);
264 rTw.
WriteEnd(
"LuaFunctionDefinition");
267 rTr.
ReadEnd(
"LuaFunctionDefinition");
288 rTr.
Streamp()->seekg(0, std::ios::end);
289 std::streampos last = rTr.
Streamp()->tellg();
290 rTr.
Streamp()->seekg(0, std::ios::beg);
291 std::streampos first = rTr.
Streamp()->tellg();
292 size=(
long int) last-first;
293 buffer =
new char[last-first];
294 rTr.
Streamp()->read(buffer, last-first);
296 }
catch (std::ios::failure&) {
297 std::cerr <<
"flxinstall: io error when reading \"" << rTr.
FileName() <<
"\": ERROR." << std::endl;
301 std::string bufferstr;
302 bufferstr.assign(buffer,size);
324 rTr.
Streamp()->seekg(0, std::ios::end);
325 std::streampos last = rTr.
Streamp()->tellg();
326 rTr.
Streamp()->seekg(0, std::ios::beg);
327 std::streampos first = rTr.
Streamp()->tellg();
328 size=(
long int) last-first;
329 buffer =
new char[last-first];
330 rTr.
Streamp()->read(buffer, last-first);
332 }
catch (std::ios::failure&) {
333 std::cerr <<
"flxinstall: io error when reading \"" << rTr.
FileName() <<
"\": ERROR." << std::endl;
360 rTr.
Streamp()->seekg(0, std::ios::end);
361 std::streampos last = rTr.
Streamp()->tellg();
362 rTr.
Streamp()->seekg(0, std::ios::beg);
363 std::streampos first = rTr.
Streamp()->tellg();
364 size=(
long int) last-first;
365 buffer =
new char[last-first];
366 rTr.
Streamp()->read(buffer, last-first);
368 }
catch (std::ios::failure&) {
369 std::cerr <<
"flxinstall: io error when reading \"" << rTr.
FileName() <<
"\": ERROR." << std::endl;
411 std::cerr <<
"flxinstall: scanning full generator image \"" << pbas <<
".*\"" << std::endl;
417 if(! ((ext==
"png") || (ext==
"svg") || (ext==
"jpeg") || (ext==
"jpg") ))
continue;
419 std::cerr <<
"flxinstall: scanning image file \"" << *fit <<
"\"" << std::endl;
429 std::cerr <<
"flxinstall: scanning luafunction \"" << *fit <<
"\"" << std::endl;
432 tr.
ReadBegin(
"LuaFunctionDefinition",btag);
434 std::cerr <<
"flxinstall: name not specified " << tr.
FileLine() <<
": ERROR." << std::endl;
441 size_t pos=name.find(
"::");
442 if(pos!=std::string::npos) {
443 space=name.substr(0,pos);
444 name=name.substr(pos+2);
448 std::cerr <<
"flxinstall: namespace must match extension name" << tr.
FileLine() <<
": ERROR." << std::endl;
453 tr.
ReadEnd(
"LuaFunctionDefinition");
463 std::cerr <<
"flxinstall: scanning reference page \"" << *fit <<
"\"" << std::endl;
468 std::cerr <<
"flxinstall: page not specified " << tr.
FileLine() <<
": ERROR." << std::endl;
472 std::cerr <<
"flxinstall: title not specified " << tr.
FileLine() << std::endl;
477 std::cerr <<
"flxinstall: chapter must be \"Reference\" " << tr.
FileLine() <<
": ERROR." << std::endl;
486 std::cerr <<
"flxinstall: section name \"" <<
mExtensionName <<
"\" expected "
487 << tr.
FileLine() <<
": ERROR." << std::endl;
491 std::transform(page.begin(), page.end(), page.begin(), tolower);
493 std::string ppage=page;
494 std::size_t upos = ppage.find_first_of(
"_");
495 std::size_t dpos = 0;
496 for(; dpos < ppage.size();dpos++)
497 if(!isdigit(ppage.at(dpos)))
break;
498 if(upos!=std::string::npos)
500 if(upos+1<ppage.size())
501 ppage=ppage.substr(upos+1,ppage.size()-upos-1);
504 std::cerr <<
"flxinstall: double page label \"" << ppage <<
"\" "
505 << tr.
FileLine() <<
": ERROR." << std::endl;
513 std::cerr <<
"flxinstall: missing index page, will be generated on installation." << std::endl;
544 std::cerr <<
"flxinstall: appending reference page from \"" << *fit <<
"\"" << std::endl;
545 *ptw <<
"\n" <<
"\n";
549 *ptw->
Streamp() <<
"<!-- reference page from source \"" << *fit <<
"\" -->" << std::endl;
556 std::cerr <<
"flxinstall: appending lua function from \"" << *fit <<
"\"" << std::endl;
557 *ptw <<
"\n" <<
"\n";
561 *ptw->
Streamp() <<
"<!-- lua function from source \"" << *fit <<
"\" -->" << std::endl;
568 std::cerr <<
"flxinstall: appending image/binary file from \"" << *fit <<
"\"" << std::endl;
569 *ptw <<
"\n" <<
"\n";
573 *ptw->
Streamp() <<
"<!-- binary file from source \"" << *fit <<
"\" -->" << std::endl;
580 std::cerr <<
"flxinstall: appending full generator from \"" << pbas <<
".*\"" << std::endl;
581 *ptw <<
"\n" <<
"\n";
585 *ptw->
Streamp() <<
"<!-- full generator image from source \"" << pbas <<
".*\" -->" << std::endl;
599 std::cerr <<
"flxinstall: appending tutorial from \"" << *fit <<
"\"" << std::endl;
600 *ptw <<
"\n" <<
"\n";
604 *ptw->
Streamp() <<
"<!-- tutorial from source \"" << *fit <<
"\" -->" << std::endl;
610 if(ext==
"" && bas==
"data") {
613 if(datafiles.size()==0)
continue;
614 std::cerr <<
"flxinstall: appending data files \"" << *fit <<
"\"" << std::endl;
615 *ptw <<
"\n" <<
"\n";
619 *ptw->
Streamp() <<
"<!-- data from source \"" << *fit <<
"\" -->" << std::endl;
620 std::set< std::string >::iterator dit;
621 for(dit=datafiles.begin();dit!=datafiles.end();dit++) {
629 *ptw <<
"\n" <<
"\n";
643 std::cerr <<
"flxinstall: cannot open libfaudes binary path \"" <<
mFaudesBin <<
"\": ERROR." << std::endl;
649 if(binfiles.find(
"luafaudes.exe")!= binfiles.end()) {
652 if(binfiles.find(
"luafaudes")!= binfiles.end()) {
656 std::cerr <<
"flxinstall: warning: cannot open luafaudes in \"" <<
mFaudesBin <<
"\"" << std::endl;
666 if(faudesfiles.empty()) {
667 std::cerr <<
"flxinstall: cannot open target directory \"" <<
mFaudesBase <<
"\": ERROR." << std::endl;
673 if(faudesfiles.find(
"bin")!= faudesfiles.end())
677 std::cerr <<
"flxinstall: cannot open libfaudes binary path in \"" <<
mFaudesBin <<
"\": ERROR." << std::endl;
683 if(binfiles.find(
"ref2html.exe")!= binfiles.end()) {
686 if(binfiles.find(
"ref2html")!= binfiles.end()) {
690 std::cerr <<
"flxinstall: cannot open ref2html tool in \"" <<
mFaudesBin <<
"\": ERROR." << std::endl;
702 if(faudesfiles.find(
"doc")!= faudesfiles.end()) {
704 }
else if(faudesfiles.find(
"Doc")!= faudesfiles.end()) {
706 }
else if(faudesfiles.find(
"Documentation")!= faudesfiles.end()) {
710 std::cerr <<
"flxinstall: cannot open libfaudes documentation path in \"" <<
mFaudesBase <<
"\": ERROR." << std::endl;
715 std::cerr <<
"flxinstall: cannot open libfaudes documentation path at \"" <<
mFaudesDoc <<
"\": ERROR." << std::endl;
724 if(docfiles.find(
"reference")!= docfiles.end()) {
726 }
else if(docfiles.find(
"Reference")!= faudesfiles.end()) {
730 std::cerr <<
"flxinstall: cannot open libfaudes reference path in \"" <<
mFaudesDoc <<
"\": ERROR." << std::endl;
736 if(docfiles.find(
"luafaudes")!= docfiles.end()) {
738 }
else if(docfiles.find(
"Luafaudes")!= docfiles.end()) {
748 std::cerr <<
"flxinstall: cannot find converter \"lua2ref.lua\"" << std::endl;
757 std::cerr <<
"flxinstall: cannot find converter \"lua2ref.pl\"" << std::endl;
762 std::cerr <<
"flxinstall: cannot process lua tutorial sources: ERROR." << std::endl;
766 if(docfiles.find(
"images")!= docfiles.end()) {
769 std::cerr <<
"flxinstall: cannot open images in \"" <<
mFaudesDoc <<
"\": ERROR." << std::endl;
774 if(docfiles.find(
"refsrc")!= docfiles.end()) {
777 std::cerr <<
"flxinstall: cannot open refsrc in \"" <<
mFaudesDoc <<
"\": ERROR." << std::endl;
784 std::cerr <<
"flxinstall: cannot open libfaudes.rti at \"" <<
mFaudesDocRti <<
"\": ERROR." << std::endl;
792 std::cerr <<
"flxinstall: cannot open navigation file \"" <<
mFaudesDocNav <<
"\": ERROR." << std::endl;
797 if(docfiles.find(
"tmp_flx")== docfiles.end()) {
798 std::cerr <<
"flxinstall: creating temp dir \"" <<
mFaudesDocTemp <<
"\"" << std::endl;
816 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << rTr.
FileLine() <<
": ERROR." << std::endl;
821 while(!rTr.
Eos(
"LuaExtension")) {
835 std::string title=
"libFAUDES Reference";
838 std::string chapter=
"Reference";
841 std::string section=
"";
848 if(page==
"" || section==
"") {
849 std::cerr <<
"flxinstall: skipping undefined page at " << rTr.
FileLine() << std::endl;
855 std::transform(section.begin(), section.end(), section.begin(), tolower);
856 std::transform(page.begin(), page.end(), page.begin(), tolower);
858 std::string ppage=page;
859 std::size_t upos = ppage.find_first_of(
"_");
860 std::size_t dpos = 0;
861 for(; dpos < ppage.size();dpos++)
862 if(!isdigit(ppage.at(dpos)))
break;
863 if(upos!=std::string::npos)
865 if(upos+1<ppage.size())
866 ppage=ppage.substr(upos+1,ppage.size()-upos-1);
868 std::string basename= section +
"_" + ppage;
871 std::string dstfile=rDstDir +
faudes_pathsep() + basename +
".fref";
872 std::cerr <<
"flxinstall: extracting reference page to \"" << dstfile <<
"\"" << std::endl;
889 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << rTr.
FileLine() <<
": ERROR." << std::endl;
894 while(!rTr.
Eos(
"LuaExtension")) {
911 std::cerr <<
"flxinstall: image file must specify name " << rTr.
FileLine() << std::endl;
917 if(ext!=
"png" && ext!=
"svg" && ext!=
"jpg" && ext!=
"jpeg") {
925 std::cerr <<
"flxinstall: skipping invalid image data " << rTr.
FileLine() << std::endl;
930 std::transform(name.begin(), name.end(), name.begin(), tolower);
932 std::cerr <<
"flxinstall: extracting image to \"" << dstfile <<
"\"" << std::endl;
937 fsout.exceptions(std::ios::badbit|std::ios::failbit);
939 fsout.open(dstfile.c_str(), std::ios::out | std::ios::binary);
943 catch (std::ios::failure&) {
944 std::cerr <<
"flxinstall: file io error when writing \"" << dstfile <<
"\"" << std::endl;
957 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << rTr.
FileLine() <<
": ERROR." << std::endl;
962 while(!rTr.
Eos(
"LuaExtension")) {
979 std::cerr <<
"flxinstall: image file must specify name " << rTr.
FileLine() << std::endl;
993 std::cerr <<
"flxinstall: skipping invalid image data " << rTr.
FileLine() << std::endl;
998 std::transform(name.begin(), name.end(), name.begin(), tolower);
1000 std::cerr <<
"flxinstall: extracting image to \"" << dstfile <<
"\"" << std::endl;
1005 fsout.exceptions(std::ios::badbit|std::ios::failbit);
1007 fsout.open(dstfile.c_str(), std::ios::out | std::ios::binary);
1011 catch (std::ios::failure&) {
1012 std::cerr <<
"flxinstall: file io error when writing \"" << dstfile <<
"\"" << std::endl;
1032 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << rTr.
FileLine() <<
": ERROR." << std::endl;
1037 while(!rTr.
Eos(
"LuaExtension")) {
1055 size_t pos=name.find(
"::");
1056 if(pos!=std::string::npos) {
1057 space=name.substr(0,pos);
1058 name=name.substr(pos+2);
1063 std::cerr <<
"flxinstall: skipping undefined lua function at " << rTr.
FileLine() << std::endl;
1064 rTr.
ReadBegin(
"LuaFunctionDefinition",btag);
1065 rTr.
ReadEnd(
"LuafunctionDefinition");
1080 std::cerr <<
"flxinstall: extracting lua function \"" << name <<
"\"" << std::endl;
1083 *rTw.
Streamp() <<
"<!-- lua function from lua-extension " << rTr.
FileLine() <<
" -->" << std::endl;
1098 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << rTr.
FileLine() <<
": ERROR." << std::endl;
1103 while(!rTr.
Eos(
"LuaExtension")) {
1119 std::cerr <<
"flxinstall: lua tutorial must specify name " << rTr.
FileLine() << std::endl;
1124 std::transform(name.begin(), name.end(), name.begin(), tolower);
1126 std::cerr <<
"flxinstall: extracting lua tutorial to \"" << dstfile <<
"\"" << std::endl;
1139 std::transform(index.begin(), index.end(), index.begin(), tolower);
1142 std::cerr <<
"flxinstall: index page provided" << std::endl;
1147 std::cerr <<
"flxinstall: reference page missing: \"" << index <<
".fref\": ERROR" << std::endl;
1151 std::cerr <<
"flxinstall: generate index page" << std::endl;
1153 *tw.
Streamp() <<
"<!-- flxinstall " <<
VersionString() <<
": auto generated index -->" << std::endl;
1155 "\" page=\"0_Index\" title=\""<<
mExtensionName <<
" Index\" >" << std::endl;
1159 std::set< std::string >::iterator fit;
1161 *tw.
Streamp() <<
"<ffnct_reference name=\"" << *fit <<
"\" />" << std::endl;
1164 *tw.
Streamp() <<
"</ReferencePage>" << std::endl;
1182 for(std::set < std::string >::iterator fit=tmpfiles.begin(); fit!=tmpfiles.end(); fit++) {
1185 std::cerr <<
"flxinstall: failed to remove \"" << *fit <<
"\"" << std::endl;
1193 std::set< std::string > srcfiles;
1195 std::string sfile = *fit;
1197 srcfiles.insert(sfile);
1202 for(std::set < std::string >::iterator dit=sdir.begin();dit!=sdir.end();dit++) {
1204 srcfiles.insert(sfile);
1209 for(std::set < std::string >::iterator fit=srcfiles.begin(); fit!=srcfiles.end(); fit++) {
1215 std::cerr <<
"flxinstall: extracting lua-extension from \"" << *fit <<
"\"" << std::endl;
1238 std::cerr <<
"flxinstall: generating list of source files" << std::endl;
1241 std::set< std::string > tocsource;
1243 std::set< std::string > frefbase;
1247 std::set< std::string > docsource;
1249 for(std::set < std::string >::iterator fit=docrefsrc.begin(); fit!=docrefsrc.end(); fit++) {
1253 if(ext!=
"fref")
continue;
1254 if(frefbase.find(bas)!=frefbase.end()){
1255 std::cerr <<
"flxinstall: reference file doublet \"" << *fit <<
"\" from std dist: ERROR." << std::endl;
1258 docsource.insert(ffile);
1259 tocsource.insert(ffile);
1260 frefbase.insert(bas);
1264 std::set< std::string > docrefsource;
1266 for(std::set < std::string >::iterator fit=docrefsrcref.begin(); fit!=docrefsrcref.end(); fit++) {
1270 if(ext!=
"fref")
continue;
1271 if(frefbase.find(bas)!=frefbase.end()){
1272 std::cerr <<
"flxinstall: reference file doublet \"" << *fit <<
"\" from std dist: ERROR." << std::endl;
1275 docrefsource.insert(ffile);
1276 tocsource.insert(ffile);
1277 frefbase.insert(bas);
1280 for(std::set < std::string >::iterator fit=doctmpdir.begin(); fit!=doctmpdir.end(); fit++) {
1284 if(ext!=
"fref")
continue;
1285 if(frefbase.find(bas)!=frefbase.end()){
1286 std::cerr <<
"flxinstall: reference file doublet \"" << *fit <<
"\" from ext: ERROR." << std::endl;
1289 docrefsource.insert(ffile);
1290 tocsource.insert(ffile);
1291 frefbase.insert(bas);
1296 std::set< std::string > docluasource;
1298 for(std::set < std::string >::iterator fit=docrefsrclua.begin(); fit!=docrefsrclua.end(); fit++) {
1302 if(ext!=
"fref")
continue;
1303 if(frefbase.find(bas)!=frefbase.end()){
1304 std::cerr <<
"flxinstall: reference file doublet \"" << *fit <<
"\" from lua doc: ERROR." << std::endl;
1307 docluasource.insert(ffile);
1308 tocsource.insert(ffile);
1309 frefbase.insert(bas);
1312 for(std::set < std::string >::iterator fit=tmpfiles.begin(); fit!=tmpfiles.end(); fit++) {
1318 if(ext!=
"lua")
continue;
1321 if(tmpfiles.find(fref)!=tmpfiles.end())
continue;
1326 docluasource.insert(ffile);
1327 tocsource.insert(ffile);
1328 frefbase.insert(bas);
1333 std::set< std::string > docimgsource;
1335 for(std::set < std::string >::iterator fit=docrefsrcimg.begin(); fit!=docrefsrcimg.end(); fit++) {
1339 if(ext!=
"fref")
continue;
1340 docimgsource.insert(ffile);
1343 for(std::set < std::string >::iterator fit=imgfiles.begin(); fit!=imgfiles.end(); fit++) {
1349 if(ext!=
"gen")
continue;
1356 docimgsource.insert(ffile);
1362 for(std::set < std::string >::iterator fit=tocsource.begin(); fit!=tocsource.end(); fit++) {
1363 toccmd+=
" " + *fit;
1367 std::cerr <<
"flxinstall: creating toc" << std::endl;
1368 if(std::system(toccmd.c_str())!=0) {
1369 std::cerr <<
"flxinstall: processing" << std::endl << toccmd << std::endl;
1370 std::cerr <<
"flxinstall: error setting up toc: ERROR." << std::endl;
1373 std::cerr <<
"flxinstall: creating toc: done" << std::endl;
1378 for(std::set < std::string >::iterator fit=docsource.begin(); fit!=docsource.end(); fit++) {
1379 doccmd +=
" " + *fit;
1385 std::cerr <<
"flxinstall: processing doc base" << std::endl;
1386 if(std::system(doccmd.c_str())!=0) {
1387 std::cerr <<
"flxinstall: processing" << std::endl << doccmd << std::endl;
1388 std::cerr <<
"flxinstall: error while processing doc base: ERROR." << std::endl;
1391 std::cerr <<
"flxinstall: processing doc base: done" << std::endl;
1395 for(std::set < std::string >::iterator fit=docrefsource.begin(); fit!=docrefsource.end(); fit++) {
1396 refcmd +=
" " + *fit;
1402 std::cerr <<
"flxinstall: processing user reference" << std::endl;
1403 if(std::system(refcmd.c_str())!=0) {
1404 std::cerr <<
"flxinstall: processing" << std::endl << refcmd << std::endl;
1405 std::cerr <<
"flxinstall: error while processing user reference: ERROR." << std::endl;
1408 std::cerr <<
"flxinstall: processing user reference: done" << std::endl;
1413 for(std::set < std::string >::iterator fit=docluasource.begin(); fit!=docluasource.end(); fit++) {
1414 luacmd +=
" " + *fit;
1420 std::cerr <<
"flxinstall: processing lua tutorial" << std::endl;
1421 if(std::system(luacmd.c_str())!=0) {
1422 std::cerr <<
"flxinstall: processing" << std::endl << luacmd << std::endl;
1423 std::cerr <<
"flxinstall: error while processing lua tutorial: ERROR." << std::endl;
1426 std::cerr <<
"flxinstall: processing lua tutorial: done" << std::endl;
1431 std::cerr <<
"flxinstall: processing image files" << std::endl;
1433 std::set < std::string >::iterator fit=docimgsource.begin();
1434 while(fit!=docimgsource.end()) {
1436 for(; fit!=docimgsource.end(); fit++) {
1437 imgcmd +=
" " + *fit;
1438 if(imgcmd.length()>500)
break;
1444 if(std::system(imgcmd.c_str())!=0) {
1445 std::cerr <<
"flxinstall: processing" << std::endl << imgcmd << std::endl;
1446 std::cerr <<
"flxinstall: error while processing image files: ERROR." << std::endl;
1450 std::cerr <<
"flxinstall: processing image files: done" << std::endl;
1461 std::cerr <<
"flxinstall: fix html index " << std::endl;
1462 if(std::system(proccmd.c_str())!=0) {
1463 std::cerr <<
"flxinstall: error when processing index.html: ERROR." <<std::endl;
1475 std::cerr <<
"flxinstall: fix html index " << std::endl;
1476 if(std::system(proccmd.c_str())!=0) {
1477 std::cerr <<
"flxinstall: error when processing index.html: ERROR." <<std::endl;
1489 std::cerr <<
"flxinstall: fix html index " << std::endl;
1490 if(std::system(proccmd.c_str())!=0) {
1491 std::cerr <<
"flxinstall: error when processing index.html: ERROR." <<std::endl;
1505 std::cerr <<
"flxinstall: done" << std::endl;
1520 usage_exit(
"extract must specify a *.flx source");
1526 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << tr.
FileLine() <<
": ERROR." << std::endl;
1531 while(!tr.
Eos(
"LuaExtension")) {
1542 std::cerr <<
"flxinstall: skipping referencepage without page attribute" << std::endl;
1548 std::transform(page.begin(), page.end(), page.begin(), tolower);
1550 std::cerr <<
"flxinstall: extracting reference page to \"" << dstname <<
"\"" << std::endl;
1560 std::cerr <<
"flxinstall: skipping lua function without name attribute" << std::endl;
1566 size_t pos=name.find(
"::");
1567 if(pos!=std::string::npos) name=name.substr(pos+2);
1568 name = name +
".rti";
1569 std::transform(name.begin(), name.end(), name.begin(), tolower);
1571 std::cerr <<
"flxinstall: extracting lua function to \"" << dstname <<
"\"" << std::endl;
1581 std::cerr <<
"flxinstall: skipping image file without name attribute" << std::endl;
1587 std::transform(name.begin(), name.end(), name.begin(), tolower);
1589 std::cerr <<
"flxinstall: extracting image file to \"" << dstname <<
"\"" << std::endl;
1599 fsout.exceptions(std::ios::badbit|std::ios::failbit);
1601 fsout.open(dstname.c_str(), std::ios::out | std::ios::binary);
1605 catch (std::ios::failure&) {
1606 std::cerr <<
"flxinstall: file io error when writing \"" << dstname <<
"\"" << std::endl;
1616 std::cerr <<
"flxinstall: skipping data file without name attribute" << std::endl;
1622 std::transform(name.begin(), name.end(), name.begin(), tolower);
1624 std::cerr <<
"flxinstall: extracting data file to \"" << dstname <<
"\"" << std::endl;
1637 fsout.exceptions(std::ios::badbit|std::ios::failbit);
1639 fsout.open(dstname.c_str(), std::ios::out | std::ios::binary);
1642 }
catch (std::ios::failure&) {
1643 std::cerr <<
"flxinstall: file io error when writing \"" << dstname <<
"\"" << std::endl;
1653 std::cerr <<
"flxinstall: skipping invalid data " << tr.
FileLine() << std::endl;
1663 std::cerr <<
"flxinstall: skipping tutorial without name attribute" << std::endl;
1669 std::transform(name.begin(), name.end(), name.begin(), tolower);
1671 std::cerr <<
"flxinstall: extracting tutorial to \"" << dstname <<
"\"" << std::endl;
1694 std::cerr <<
"flxinstall: cannot execute luafaudes" << std::endl;
1699 std::set< std::string > luascripts;
1700 for(std::set < std::string >::iterator fit=allfiles.begin(); fit!=allfiles.end(); fit++)
1703 for(std::set < std::string >::iterator fit=luascripts.begin(); fit!=luascripts.end(); fit++) {
1707 std::cerr <<
"flxinstall: execute: " << cmd << std::endl;
1708 int sysret=std::system(cmd.c_str());
1710 std::cerr <<
"flxinstall: error while running lua script \"" << *fit <<
"\"" << std::endl;
1737 for(i=1; i<argc; i++) {
1738 std::string option(argv[i]);
1740 if(option==
"-tdoc") {
1746 if(option==
"-tbin") {
1752 if(option==
"-trti") {
1758 if(option==
"-tcnav") {
1764 if(option==
"-tcss") {
1770 if(option==
"-tapp") {
1800 if((option==
"-?") || (option==
"--help")) {
1806 if(option.at(0)==
'-') {
1811 usage_exit(
"must set either -c, -i, -r, -x or -t mode" );
1817 for(;i<argc-1;i++) {
1822 std::set< std::string > srcfiles =
ReadDirectory(std::string(argv[i-1]));
1824 if(srcfiles.size()>0) {
1826 for(std::set < std::string >::iterator fit=srcfiles.begin(); fit!=srcfiles.end(); fit++)
1832 usage_exit(
"target *.flx-file not specified");
1838 usage_exit(
"target *.flx-file not specified");
1848 std::cerr <<
"flxinstall: no sources specified" << std::endl;
1850 for(;i<argc-1;i++) {
1855 std::set< std::string > srcfiles =
ReadDirectory(std::string(argv[i-1]));
1857 if(srcfiles.size()>0) {
1859 for(std::set < std::string >::iterator fit=srcfiles.begin(); fit!=srcfiles.end(); fit++)
1867 usage_exit(
"sources must be *.flx-files: "+ *fit);
1894 usage_exit(
"source and destination must be specified");
1900 mTarget=std::string(argv[i++]);
1914 usage_exit(
"source and temp dir must be specified");
1920 mTarget=std::string(argv[i++]);
1926 usage_exit(
"target must be \".\" or \"./\"");
1928 if(curdir.size()!=0)
A TokenReader reads sequential tokens from a file or string.
std::string FileLine(void) const
Return "filename:line".
bool Eos(const std::string &rLabel)
Peek a token and check whether it ends the specified section.
void ReadVerbatim(const std::string &rLabel, std::string &rText)
Read verbatim text.
void ReadEnd(const std::string &rLabel)
Close the current section by matching the previous ReadBegin().
void Rewind(void)
Rewind stream.
void ReadSection(std::string &rSectionString)
Read XML section.
void ReadBegin(const std::string &rLabel)
Open a section by specified label.
bool Get(Token &token)
Get next token.
bool Peek(Token &token)
Peek next token.
std::istream * Streamp(void)
Access C++ stream.
std::string FileName(void) const
Access the filename.
A TokenWriter writes sequential tokens to a file, a string or stdout.
void WriteText(const std::string &rText)
Write text.
void WriteCharacterData(const std::string &rCharData)
Write character data.
void Write(Token &rToken)
Write next token.
void Endl(void)
Write endl separator.
std::ostream * Streamp(void)
Access C++ stream.
void WriteEnd(const std::string &rLabel)
Write end label.
void WriteBinary(const char *pData, long int len)
Write comment.
void WriteVerbatim(Token &rBeginTag, const std::string &rText)
Write verbatim text section.
void WriteBegin(const std::string &rLabel)
Write begin label.
Tokens model atomic data for stream IO.
bool IsBinary(void) const
Test token Type.
const std::string & StringValue(void) const
Get string value of a name token.
bool ExistsAttributeString(const std::string &name)
Test attibute existence.
bool IsBegin(void) const
Test token Type.
void SetBegin(const std::string &rName)
Initialize as Begin token.
void InsAttributeString(const std::string &name, const std::string &value)
Insert named attribute with string value.
const std::string & AttributeStringValue(const std::string &name)
Access attribute value.
Includes all libFAUDES headers, no plugins.
std::set< std::string > mReferencePages
int main(int argc, char *argv[])
void Lua2ref(const std::string &rLuaFile, const std::string &rRefFile="")
void CreateExtensionFile(void)
std::string mFaudesDocCss
std::string mFaudesBinRef2html
std::set< std::string > mLuaFunctions
std::string mXmlSeparator
void ExtractExtensionFile(void)
void XtractLuaTutorials(TokenReader &rTr, const std::string &rDstDir)
std::string mFaudesBinLua2ref
std::string mFaudesDocNav
std::string mFaudesBinLuafaudes
std::string mFaudesDocRti
void XtractReferencePages(TokenReader &rTr, const std::string &rDstDir)
std::string mFaudesDocToc
void XtractLuaFunctions(TokenReader &rTr, TokenWriter &rTw)
std::string mFaudesDocTemp
std::string mFaudesDocReference
void InsertSection(TokenReader &rTr, TokenWriter &rTw, const std::string &mLabel)
void InsertDataFile(TokenReader &rTr, TokenWriter &rTw)
void DefaultIndexPage(const std::string &rDstDir)
std::set< std::string > EraseHiddenFiles(const std::set< std::string > &src)
std::string mFaudesDocImages
void InsertReferencePage(TokenReader &rTr, TokenWriter &rTw, const std::string mSection="")
void MakeDirectory(const std::string &rPath, const std::string &rDir="")
std::set< std::string > mSourceFiles
void InsertImageFile(TokenReader &rTr, TokenWriter &rTw)
void InstallExtensionFiles(void)
void XtractImageGenFiles(TokenReader &rTr, const std::string &rDstDir)
void XtractImageFiles(TokenReader &rTr, const std::string &rDstDir)
void usage_exit(const std::string &rMessage="")
std::string mFaudesBinLuaflx
std::string mExtensionName
std::string mFaudesDocRefsrc
void TestFaudesTarget(void)
void Gen2ref(const std::string &rGenFile, const std::string &rRefFile="")
std::set< std::string > mImageFiles
std::set< std::string > mGeneratorFiles
void InsertLuaFunction(TokenReader &rTr, TokenWriter &rTw)
void InsertPlainLuaTutorial(TokenReader &rTr, TokenWriter &rTw)
void InsertLuaTutorial(TokenReader &rTr, TokenWriter &rTw)
std::string mFaudesDocLuafaudes
libFAUDES resides within the namespace faudes.
std::string VersionString()
Return FAUDES_VERSION as std::string.
std::string ExtractDirectory(const std::string &rFullPath)
Extract directory from full path.
bool RemoveFile(const std::string &rFileName)
Delete a file.
std::string ExtractExtension(const std::string &rFullPath)
Extract file name from full path.
std::string ExtractBasename(const std::string &rFullPath)
Extract file name from full path.
bool FileCopy(const std::string &rFromFile, const std::string &rToFile)
Copy file.
std::string PrependDirectory(const std::string &rDirectory, const std::string &rFileName)
Construct full path from directory and filename.
std::string ExtractFilename(const std::string &rFullPath)
Extract file name from full path.
bool FileDelete(const std::string &rFilename)
Delete file.
std::set< std::string > ReadDirectory(const std::string &rDirectory)
Read the contents of the specified directors.
bool DirectoryExists(const std::string &rDirectory)
Test existence of directory.
bool FileExists(const std::string &rFilename)
Test existence of file.