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 int SysCall(
const std::string& cmd,
const std::string& args,
bool errmsg =
true) {
112 std::string cmdline=cmd;
113 #ifdef FAUDES_WINDOWS
117 std::replace(cmdline.begin(), cmdline.end(),
'/',
'\\');
123 int sysret=std::system(cmdline.c_str());
124 if((sysret!=0) && errmsg) {
125 std::cerr <<
"flxinstall: syscall [[" << cmdline <<
"]] failed" << std::endl;
132 void MakeDirectory(
const std::string& rPath,
const std::string& rDir=
"") {
135 std::cerr <<
"flxinstall: creating dir \"" << dir <<
"\"" << std::endl;
136 int sysret=
SysCall(
"mkdir",dir);
138 std::cerr <<
"flxinstall: error while creating directory \"" << dir <<
"\"" << std::endl;
145 std::set < std::string > EraseHiddenFiles(
const std::set < std::string > & src) {
146 std::set < std::string > res;
147 for(std::set < std::string >::iterator fit=src.begin(); fit!=src.end(); fit++) {
148 if(*fit==
"")
continue;
149 if((*fit).at(0)==
'.')
continue;
161 void Lua2ref(
const std::string& rLuaFile,
const std::string& rRefFile=
"") {
164 std::cerr <<
"flxinstall: ignoring lua script \"" << rLuaFile <<
"\"" << std::endl;
168 std::string dst=rRefFile;
173 std::cerr <<
"flxinstall: converting lua script \"" << rLuaFile <<
"\"" << std::endl;
176 std::cerr <<
"flxinstall: error while converting lua script \"" << rLuaFile <<
"\"" << std::endl;
186 void Gen2ref(
const std::string& rGenFile,
const std::string& rRefFile=
"") {
187 std::cerr <<
"flxinstall: converting generator file \"" << rGenFile <<
"\"" << std::endl;
190 std::string dst=rRefFile;
207 tw.WriteCharacterData(
"<h1> Example Date: "+bas+
".gen </h1>\n");
209 tw.WriteCharacterData(
"<h3> Dot-processed graph as SVG-image </h3>\n");
210 tw.WriteCharacterData(
"<object type=\"image/svg+xml\" name=\"graph\" data=\""+bas+
".svg\">\n");
211 tw.WriteCharacterData(
"<a class=\"faudes_image\" href=\""+bas+
".svg\">\n");
212 tw.WriteCharacterData(
"<img src=\"$genfile.png\" title=\"Click on image to download SVG formated file.\" />\n");
213 tw.WriteCharacterData(
"</a></object>");
215 tw.WriteCharacterData(
"<h3>Token IO</h3>\n");
217 tw.WriteBegin(
"pre");
219 tr.ReadSection(genstr);
220 tw.WriteText(genstr);
223 tw.WriteCharacterData(
"<p> </p><p> </p>\n");
224 tw.WriteEnd(
"ReferencePage");
226 std::cerr <<
"flxinstall: error while converting generator \"" << rGenFile <<
"\"" << std::endl;
277 rTr.
ReadBegin(
"LuaFunctionDefinition",btag);
283 rTw.
WriteEnd(
"LuaFunctionDefinition");
286 rTr.
ReadEnd(
"LuaFunctionDefinition");
307 rTr.
Streamp()->seekg(0, std::ios::end);
308 std::streampos last = rTr.
Streamp()->tellg();
309 rTr.
Streamp()->seekg(0, std::ios::beg);
310 std::streampos first = rTr.
Streamp()->tellg();
311 size=(
long int) last-first;
312 buffer =
new char[last-first];
313 rTr.
Streamp()->read(buffer, last-first);
315 }
catch (std::ios::failure&) {
316 std::cerr <<
"flxinstall: io error when reading \"" << rTr.
FileName() <<
"\": ERROR." << std::endl;
320 std::string bufferstr;
321 bufferstr.assign(buffer,size);
331 if(buffer!=0)
delete[] buffer;
343 rTr.
Streamp()->seekg(0, std::ios::end);
344 std::streampos last = rTr.
Streamp()->tellg();
345 rTr.
Streamp()->seekg(0, std::ios::beg);
346 std::streampos first = rTr.
Streamp()->tellg();
347 size=(
long int) last-first;
348 buffer =
new char[last-first];
349 rTr.
Streamp()->read(buffer, last-first);
351 }
catch (std::ios::failure&) {
352 std::cerr <<
"flxinstall: io error when reading \"" << rTr.
FileName() <<
"\": ERROR." << std::endl;
367 if(buffer!=0)
delete[] buffer;
379 rTr.
Streamp()->seekg(0, std::ios::end);
380 std::streampos last = rTr.
Streamp()->tellg();
381 rTr.
Streamp()->seekg(0, std::ios::beg);
382 std::streampos first = rTr.
Streamp()->tellg();
383 size=(
long int) last-first;
384 buffer =
new char[last-first];
385 rTr.
Streamp()->read(buffer, last-first);
387 }
catch (std::ios::failure&) {
388 std::cerr <<
"flxinstall: io error when reading \"" << rTr.
FileName() <<
"\": ERROR." << std::endl;
403 if(buffer!=0)
delete[] buffer;
415 void CreateExtensionFile(
void) {
430 std::cerr <<
"flxinstall: scanning full generator image \"" << pbas <<
".*\"" << std::endl;
436 if(! ((ext==
"png") || (ext==
"svg") || (ext==
"jpeg") || (ext==
"jpg") ))
continue;
438 std::cerr <<
"flxinstall: scanning image file \"" << *fit <<
"\"" << std::endl;
448 std::cerr <<
"flxinstall: scanning luafunction \"" << *fit <<
"\"" << std::endl;
451 tr.ReadBegin(
"LuaFunctionDefinition",btag);
453 std::cerr <<
"flxinstall: name not specified " << tr.FileLine() <<
": ERROR." << std::endl;
460 size_t pos=name.find(
"::");
461 if(pos!=std::string::npos) {
462 space=name.substr(0,pos);
463 name=name.substr(pos+2);
467 std::cerr <<
"flxinstall: namespace must match extension name" << tr.FileLine() <<
": ERROR." << std::endl;
472 tr.ReadEnd(
"LuaFunctionDefinition");
482 std::cerr <<
"flxinstall: scanning reference page \"" << *fit <<
"\"" << std::endl;
485 tr.ReadBegin(
"ReferencePage",btag);
487 std::cerr <<
"flxinstall: page not specified " << tr.FileLine() <<
": ERROR." << std::endl;
491 std::cerr <<
"flxinstall: title not specified " << tr.FileLine() << std::endl;
496 std::cerr <<
"flxinstall: chapter must be \"Reference\" " << tr.FileLine() <<
": ERROR." << std::endl;
505 std::cerr <<
"flxinstall: section name \"" <<
mExtensionName <<
"\" expected "
506 << tr.FileLine() <<
": ERROR." << std::endl;
510 std::transform(page.begin(), page.end(), page.begin(), tolower);
512 std::string ppage=page;
513 std::size_t upos = ppage.find_first_of(
"_");
514 std::size_t dpos = 0;
515 for(; dpos < ppage.size();dpos++)
516 if(!isdigit(ppage.at(dpos)))
break;
517 if(upos!=std::string::npos)
519 if(upos+1<ppage.size())
520 ppage=ppage.substr(upos+1,ppage.size()-upos-1);
523 std::cerr <<
"flxinstall: double page label \"" << ppage <<
"\" "
524 << tr.FileLine() <<
": ERROR." << std::endl;
528 tr.ReadEnd(
"ReferencePage");
532 std::cerr <<
"flxinstall: missing index page, will be generated on installation." << std::endl;
563 std::cerr <<
"flxinstall: appending reference page from \"" << *fit <<
"\"" << std::endl;
564 *ptw <<
"\n" <<
"\n";
568 *ptw->
Streamp() <<
"<!-- reference page from source \"" << *fit <<
"\" -->" << std::endl;
575 std::cerr <<
"flxinstall: appending lua function from \"" << *fit <<
"\"" << std::endl;
576 *ptw <<
"\n" <<
"\n";
580 *ptw->
Streamp() <<
"<!-- lua function from source \"" << *fit <<
"\" -->" << std::endl;
582 InsertLuaFunction(tr,*ptw);
587 std::cerr <<
"flxinstall: appending image/binary file from \"" << *fit <<
"\"" << std::endl;
588 *ptw <<
"\n" <<
"\n";
592 *ptw->
Streamp() <<
"<!-- binary file from source \"" << *fit <<
"\" -->" << std::endl;
594 InsertImageFile(tr,*ptw);
599 std::cerr <<
"flxinstall: appending full generator from \"" << pbas <<
".*\"" << std::endl;
600 *ptw <<
"\n" <<
"\n";
604 *ptw->
Streamp() <<
"<!-- full generator image from source \"" << pbas <<
".*\" -->" << std::endl;
606 InsertImageFile(trg,*ptw);
609 InsertImageFile(trs,*ptw);
612 InsertImageFile(trp,*ptw);
618 std::cerr <<
"flxinstall: appending tutorial from \"" << *fit <<
"\"" << std::endl;
619 *ptw <<
"\n" <<
"\n";
623 *ptw->
Streamp() <<
"<!-- tutorial from source \"" << *fit <<
"\" -->" << std::endl;
625 InsertLuaTutorial(tr,*ptw);
629 if(ext==
"" && bas==
"data") {
631 datafiles=EraseHiddenFiles(datafiles);
632 if(datafiles.size()==0)
continue;
633 std::cerr <<
"flxinstall: appending data files \"" << *fit <<
"\"" << std::endl;
634 *ptw <<
"\n" <<
"\n";
638 *ptw->
Streamp() <<
"<!-- data from source \"" << *fit <<
"\" -->" << std::endl;
639 std::set< std::string >::iterator dit;
640 for(dit=datafiles.begin();dit!=datafiles.end();dit++) {
643 InsertDataFile(tr,*ptw);
648 *ptw <<
"\n" <<
"\n";
659 void TestLuafaudes(
void) {
662 std::cerr <<
"flxinstall: cannot open libfaudes binary path \"" <<
mFaudesBin <<
"\": ERROR." << std::endl;
668 if(binfiles.find(
"luafaudes.exe")!= binfiles.end()) {
671 if(binfiles.find(
"luafaudes")!= binfiles.end()) {
675 std::cerr <<
"flxinstall: warning: cannot open luafaudes in \"" <<
mFaudesBin <<
"\"" << std::endl;
681 void TestFaudesTarget(
void) {
685 if(faudesfiles.empty()) {
686 std::cerr <<
"flxinstall: cannot open target directory \"" <<
mFaudesBase <<
"\": ERROR." << std::endl;
692 if(faudesfiles.find(
"bin")!= faudesfiles.end())
697 std::cerr <<
"flxinstall: cannot open libfaudes binary path \"" <<
mFaudesBin <<
"\": ERROR." << std::endl;
703 if(faudesfiles.find(
"tools")!= faudesfiles.end())
708 std::cerr <<
"flxinstall: cannot open libfaudes tools path in \"" <<
mFaudesTools <<
"\": ERROR." << std::endl;
714 if(binfiles.find(
"ref2html.exe")!= binfiles.end()) {
717 if(binfiles.find(
"ref2html")!= binfiles.end()) {
721 std::cerr <<
"flxinstall: cannot open ref2html tool in \"" <<
mFaudesBin <<
"\": ERROR." << std::endl;
733 if(faudesfiles.find(
"doc")!= faudesfiles.end()) {
735 }
else if(faudesfiles.find(
"Doc")!= faudesfiles.end()) {
737 }
else if(faudesfiles.find(
"Documentation")!= faudesfiles.end()) {
743 std::cerr <<
"flxinstall: cannot open libfaudes documentation path at \"" <<
mFaudesDoc <<
"\": ERROR." << std::endl;
753 if(docfiles.find(
"reference")!= docfiles.end()) {
755 }
else if(docfiles.find(
"Reference")!= docfiles.end()) {
759 std::cerr <<
"flxinstall: cannot open libfaudes reference path in " <<
766 if(docfiles.find(
"luafaudes")!= docfiles.end()) {
768 }
else if(docfiles.find(
"Luafaudes")!= docfiles.end()) {
778 std::cerr <<
"flxinstall: cannot find converter \"lua2ref.lua\"" << std::endl;
789 std::cerr <<
"flxinstall: cannot find converter \"lua2ref.pl\"" << std::endl;
795 std::cerr <<
"flxinstall: cannot process lua tutorial sources: ERROR." << std::endl;
798 std::cerr <<
"flxinstall: using \"" <<
mFaudesBinLua2ref <<
"\" to convert lua tutorials," << std::endl;
802 if(docfiles.find(
"images")!= docfiles.end()) {
805 std::cerr <<
"flxinstall: cannot open images in \"" <<
mFaudesDoc <<
"\": ERROR." << std::endl;
810 if(docfiles.find(
"refsrc")!= docfiles.end()) {
813 std::cerr <<
"flxinstall: cannot open refsrc in \"" <<
mFaudesDoc <<
"\": ERROR." << std::endl;
820 std::cerr <<
"flxinstall: cannot open libfaudes.rti at \"" <<
mFaudesDocRti <<
"\": ERROR." << std::endl;
828 std::cerr <<
"flxinstall: cannot open navigation file \"" <<
mFaudesDocNav <<
"\": ERROR." << std::endl;
833 if(docfiles.find(
"tmp_flx")== docfiles.end()) {
834 std::cerr <<
"flxinstall: creating temp dir \"" <<
mFaudesDocTemp <<
"\"" << std::endl;
846 void XtractReferencePages(
TokenReader& rTr,
const std::string& rDstDir) {
852 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << rTr.
FileLine() <<
": ERROR." << std::endl;
857 while(!rTr.
Eos(
"LuaExtension")) {
871 std::string title=
"libFAUDES Reference";
874 std::string chapter=
"Reference";
877 std::string section=
"";
884 if(page==
"" || section==
"") {
885 std::cerr <<
"flxinstall: skipping undefined page at " << rTr.
FileLine() << std::endl;
891 std::transform(section.begin(), section.end(), section.begin(), tolower);
892 std::transform(page.begin(), page.end(), page.begin(), tolower);
894 std::string ppage=page;
895 std::size_t upos = ppage.find_first_of(
"_");
896 std::size_t dpos = 0;
897 for(; dpos < ppage.size();dpos++)
898 if(!isdigit(ppage.at(dpos)))
break;
899 if(upos!=std::string::npos)
901 if(upos+1<ppage.size())
902 ppage=ppage.substr(upos+1,ppage.size()-upos-1);
904 std::string basename= section +
"_" + ppage;
907 std::string dstfile=
PrependPath(rDstDir,basename +
".fref");
908 std::cerr <<
"flxinstall: extracting reference page to \"" << dstfile <<
"\"" << std::endl;
910 InsertReferencePage(rTr,dst);
919 void XtractImageFiles(
TokenReader& rTr,
const std::string& rDstDir) {
925 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << rTr.
FileLine() <<
": ERROR." << std::endl;
930 while(!rTr.
Eos(
"LuaExtension")) {
947 std::cerr <<
"flxinstall: image file must specify name " << rTr.
FileLine() << std::endl;
953 if(ext!=
"png" && ext!=
"svg" && ext!=
"jpg" && ext!=
"jpeg") {
961 std::cerr <<
"flxinstall: skipping invalid image data " << rTr.
FileLine() << std::endl;
966 std::transform(name.begin(), name.end(), name.begin(), tolower);
968 std::cerr <<
"flxinstall: extracting image to \"" << dstfile <<
"\"" << std::endl;
973 fsout.exceptions(std::ios::badbit|std::ios::failbit);
975 fsout.open(dstfile.c_str(), std::ios::out | std::ios::binary);
979 catch (std::ios::failure&) {
980 std::cerr <<
"flxinstall: file io error when writing \"" << dstfile <<
"\"" << std::endl;
987 void XtractImageGenFiles(
TokenReader& rTr,
const std::string& rDstDir) {
993 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << rTr.
FileLine() <<
": ERROR." << std::endl;
998 while(!rTr.
Eos(
"LuaExtension")) {
1015 std::cerr <<
"flxinstall: image file must specify name " << rTr.
FileLine() << std::endl;
1029 std::cerr <<
"flxinstall: skipping invalid image data " << rTr.
FileLine() << std::endl;
1034 std::transform(name.begin(), name.end(), name.begin(), tolower);
1036 std::cerr <<
"flxinstall: extracting image to \"" << dstfile <<
"\"" << std::endl;
1041 fsout.exceptions(std::ios::badbit|std::ios::failbit);
1043 fsout.open(dstfile.c_str(), std::ios::out | std::ios::binary);
1047 catch (std::ios::failure&) {
1048 std::cerr <<
"flxinstall: file io error when writing \"" << dstfile <<
"\"" << std::endl;
1068 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << rTr.
FileLine() <<
": ERROR." << std::endl;
1073 while(!rTr.
Eos(
"LuaExtension")) {
1091 size_t pos=name.find(
"::");
1092 if(pos!=std::string::npos) {
1093 space=name.substr(0,pos);
1094 name=name.substr(pos+2);
1099 std::cerr <<
"flxinstall: skipping undefined lua function at " << rTr.
FileLine() << std::endl;
1100 rTr.
ReadBegin(
"LuaFunctionDefinition",btag);
1101 rTr.
ReadEnd(
"LuafunctionDefinition");
1116 std::cerr <<
"flxinstall: extracting lua function \"" << name <<
"\"" << std::endl;
1119 *rTw.
Streamp() <<
"<!-- lua function from lua-extension " << rTr.
FileLine() <<
" -->" << std::endl;
1120 InsertLuaFunction(rTr,rTw);
1128 void XtractLuaTutorials(
TokenReader& rTr,
const std::string& rDstDir) {
1134 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << rTr.
FileLine() <<
": ERROR." << std::endl;
1139 while(!rTr.
Eos(
"LuaExtension")) {
1155 std::cerr <<
"flxinstall: lua tutorial must specify name " << rTr.
FileLine() << std::endl;
1160 std::transform(name.begin(), name.end(), name.begin(), tolower);
1162 std::cerr <<
"flxinstall: extracting lua tutorial to \"" << dstfile <<
"\"" << std::endl;
1164 InsertPlainLuaTutorial(rTr,tw);
1172 void DefaultIndexPage(
const std::string& rDstDir) {
1175 std::transform(index.begin(), index.end(), index.begin(), tolower);
1178 std::cerr <<
"flxinstall: index page provided" << std::endl;
1183 std::cerr <<
"flxinstall: reference page missing: \"" << index <<
".fref\": ERROR" << std::endl;
1187 std::cerr <<
"flxinstall: generate index page" << std::endl;
1189 *tw.Streamp() <<
"<!-- flxinstall " <<
VersionString() <<
": auto generated index -->" << std::endl;
1190 *tw.Streamp() <<
"<ReferencePage chapter=\"Reference\" section=\"" <<
mExtensionName <<
1191 "\" page=\"0_Index\" title=\""<<
mExtensionName <<
" Index\" >" << std::endl;
1193 *tw.Streamp() <<
"<h1> " <<
mExtensionName <<
": Functions </h1>" << std::endl;
1195 std::set< std::string >::iterator fit;
1197 *tw.Streamp() <<
"<ffnct_reference name=\"" << *fit <<
"\" />" << std::endl;
1200 *tw.Streamp() <<
"</ReferencePage>" << std::endl;
1211 void InstallExtensionFiles(
void) {
1218 for(std::set < std::string >::iterator fit=tmpfiles.begin(); fit!=tmpfiles.end(); fit++) {
1221 std::cerr <<
"flxinstall: failed to remove \"" << *fit <<
"\"" << std::endl;
1229 std::set< std::string > srcfiles;
1231 std::string sfile = *fit;
1233 srcfiles.insert(sfile);
1237 sdir=EraseHiddenFiles(sdir);
1238 for(std::set < std::string >::iterator dit=sdir.begin();dit!=sdir.end();dit++) {
1240 srcfiles.insert(sfile);
1245 for(std::set < std::string >::iterator fit=srcfiles.begin(); fit!=srcfiles.end(); fit++) {
1251 std::cerr <<
"flxinstall: extracting lua-extension from \"" << *fit <<
"\"" << std::endl;
1262 XtractLuaFunctions(rTr,*twflx);
1274 std::cerr <<
"flxinstall: generating list of source files" << std::endl;
1277 std::set< std::string > tocsource;
1279 std::set< std::string > frefbase;
1283 std::set< std::string > docsource;
1285 for(std::set < std::string >::iterator fit=docrefsrc.begin(); fit!=docrefsrc.end(); fit++) {
1289 if(ext!=
"fref")
continue;
1290 if(frefbase.find(bas)!=frefbase.end()){
1291 std::cerr <<
"flxinstall: reference file doublet \"" << *fit <<
"\" from std dist: ERROR." << std::endl;
1294 docsource.insert(ffile);
1295 tocsource.insert(ffile);
1296 frefbase.insert(bas);
1300 std::set< std::string > docrefsource;
1302 for(std::set < std::string >::iterator fit=docrefsrcref.begin(); fit!=docrefsrcref.end(); fit++) {
1306 if(ext!=
"fref")
continue;
1307 if(frefbase.find(bas)!=frefbase.end()){
1308 std::cerr <<
"flxinstall: reference file doublet \"" << *fit <<
"\" from std dist: ERROR." << std::endl;
1311 docrefsource.insert(ffile);
1312 tocsource.insert(ffile);
1313 frefbase.insert(bas);
1316 for(std::set < std::string >::iterator fit=doctmpdir.begin(); fit!=doctmpdir.end(); fit++) {
1320 if(ext!=
"fref")
continue;
1321 if(frefbase.find(bas)!=frefbase.end()){
1322 std::cerr <<
"flxinstall: reference file doublet \"" << *fit <<
"\" from ext: ERROR." << std::endl;
1325 docrefsource.insert(ffile);
1326 tocsource.insert(ffile);
1327 frefbase.insert(bas);
1332 std::set< std::string > docluasource;
1334 for(std::set < std::string >::iterator fit=docrefsrclua.begin(); fit!=docrefsrclua.end(); fit++) {
1338 if(ext!=
"fref")
continue;
1339 if(frefbase.find(bas)!=frefbase.end()){
1340 std::cerr <<
"flxinstall: reference file doublet \"" << *fit <<
"\" from lua doc: ERROR." << std::endl;
1343 docluasource.insert(ffile);
1344 tocsource.insert(ffile);
1345 frefbase.insert(bas);
1348 for(std::set < std::string >::iterator fit=tmpfiles.begin(); fit!=tmpfiles.end(); fit++) {
1354 if(ext!=
"lua")
continue;
1357 if(tmpfiles.find(fref)!=tmpfiles.end())
continue;
1359 Lua2ref(lfile,ffile);
1362 docluasource.insert(ffile);
1363 tocsource.insert(ffile);
1364 frefbase.insert(bas);
1369 std::set< std::string > docimgsource;
1371 for(std::set < std::string >::iterator fit=docrefsrcimg.begin(); fit!=docrefsrcimg.end(); fit++) {
1375 if(ext!=
"fref")
continue;
1376 docimgsource.insert(ffile);
1379 for(std::set < std::string >::iterator fit=imgfiles.begin(); fit!=imgfiles.end(); fit++) {
1385 if(ext!=
"gen")
continue;
1389 Gen2ref(gfile,ffile);
1392 docimgsource.insert(ffile);
1397 std::string tocsrcs;
1398 for(std::set < std::string >::iterator fit=tocsource.begin(); fit!=tocsource.end(); fit++)
1399 tocsrcs+=
" " + *fit;
1400 std::string tocargs =
1403 std::cerr <<
"flxinstall: creating toc" << std::endl;
1405 std::cerr <<
"flxinstall: error setting up toc: ERROR." << std::endl;
1408 std::cerr <<
"flxinstall: creating toc: done" << std::endl;
1412 std::string docsrcs;
1413 for(std::set < std::string >::iterator fit=docsource.begin(); fit!=docsource.end(); fit++) {
1414 docsrcs +=
" " + *fit;
1416 std::string docargs =
1420 std::cerr <<
"flxinstall: processing doc base" << std::endl;
1422 std::cerr <<
"flxinstall: error while processing doc base: ERROR." << std::endl;
1425 std::cerr <<
"flxinstall: processing doc base: done" << std::endl;
1428 std::string refsrcs;
1429 for(std::set < std::string >::iterator fit=docrefsource.begin(); fit!=docrefsource.end(); fit++) {
1430 refsrcs +=
" " + *fit;
1432 std::string refargs =
1436 std::cerr <<
"flxinstall: processing user reference" << std::endl;
1438 std::cerr <<
"flxinstall: error while processing user reference: ERROR." << std::endl;
1441 std::cerr <<
"flxinstall: processing user reference: done" << std::endl;
1445 std::string luasrcs;
1446 for(std::set < std::string >::iterator fit=docluasource.begin(); fit!=docluasource.end(); fit++) {
1447 luasrcs +=
" " + *fit;
1449 std::string luaargs=
1453 std::cerr <<
"flxinstall: processing lua tutorial" << std::endl;
1455 std::cerr <<
"flxinstall: error while processing lua tutorial: ERROR." << std::endl;
1458 std::cerr <<
"flxinstall: processing lua tutorial: done" << std::endl;
1463 std::cerr <<
"flxinstall: processing image files" << std::endl;
1465 std::set < std::string >::iterator fit=docimgsource.begin();
1466 while(fit!=docimgsource.end()) {
1467 std::string imgsrcs;
1468 for(; fit!=docimgsource.end(); fit++) {
1469 imgsrcs +=
" " + *fit;
1470 if(imgsrcs.length()>500)
break;
1472 std::string imgargs =
1477 std::cerr <<
"flxinstall: error while processing image files: ERROR." << std::endl;
1481 std::cerr <<
"flxinstall: processing image files: done" << std::endl;
1488 std::string procargs=
1492 std::cerr <<
"flxinstall: fix html index " << std::endl;
1494 std::cerr <<
"flxinstall: error when processing index.html: ERROR." <<std::endl;
1502 std::string procargs=
1506 std::cerr <<
"flxinstall: fix html index " << std::endl;
1508 std::cerr <<
"flxinstall: error when processing index.html: ERROR." <<std::endl;
1516 std::string procargs=
1520 std::cerr <<
"flxinstall: fix html index " << std::endl;
1522 std::cerr <<
"flxinstall: error when processing index.html: ERROR." <<std::endl;
1536 std::cerr <<
"flxinstall: done" << std::endl;
1545 void ExtractExtensionFile(
void) {
1551 usage_exit(
"extract must specify a *.flx source");
1555 tr.ReadBegin(
"LuaExtension",btag);
1557 std::cerr <<
"flxinstall: lua-extension must have a name attribute " << tr.FileLine() <<
": ERROR." << std::endl;
1562 while(!tr.Eos(
"LuaExtension")) {
1573 std::cerr <<
"flxinstall: skipping referencepage without page attribute" << std::endl;
1579 std::transform(page.begin(), page.end(), page.begin(), tolower);
1581 std::cerr <<
"flxinstall: extracting reference page to \"" << dstname <<
"\"" << std::endl;
1591 std::cerr <<
"flxinstall: skipping lua function without name attribute" << std::endl;
1597 size_t pos=name.find(
"::");
1598 if(pos!=std::string::npos) name=name.substr(pos+2);
1599 name = name +
".rti";
1600 std::transform(name.begin(), name.end(), name.begin(), tolower);
1602 std::cerr <<
"flxinstall: extracting lua function to \"" << dstname <<
"\"" << std::endl;
1605 InsertLuaFunction(tr,tw);
1612 std::cerr <<
"flxinstall: skipping image file without name attribute" << std::endl;
1618 std::transform(name.begin(), name.end(), name.begin(), tolower);
1620 std::cerr <<
"flxinstall: extracting image file to \"" << dstname <<
"\"" << std::endl;
1623 tr.ReadBegin(
"ImageFile");
1630 fsout.exceptions(std::ios::badbit|std::ios::failbit);
1632 fsout.open(dstname.c_str(), std::ios::out | std::ios::binary);
1636 catch (std::ios::failure&) {
1637 std::cerr <<
"flxinstall: file io error when writing \"" << dstname <<
"\"" << std::endl;
1640 tr.ReadEnd(
"ImageFile");
1647 std::cerr <<
"flxinstall: skipping data file without name attribute" << std::endl;
1653 std::transform(name.begin(), name.end(), name.begin(), tolower);
1654 std::string dstname;
1657 std::cerr <<
"flxinstall: extracting data file to \"" << dstname <<
"\"" << std::endl;
1659 MakeDirectory(
mTarget,
"data");
1662 tr.ReadBegin(
"DataFile");
1670 fsout.exceptions(std::ios::badbit|std::ios::failbit);
1672 fsout.open(dstname.c_str(), std::ios::out | std::ios::binary);
1675 }
catch (std::ios::failure&) {
1676 std::cerr <<
"flxinstall: file io error when writing \"" << dstname <<
"\"" << std::endl;
1686 std::cerr <<
"flxinstall: skipping invalid data " << tr.FileLine() << std::endl;
1689 tr.ReadEnd(
"DataFile");
1696 std::cerr <<
"flxinstall: skipping tutorial without name attribute" << std::endl;
1702 std::transform(name.begin(), name.end(), name.begin(), tolower);
1704 std::cerr <<
"flxinstall: extracting tutorial to \"" << dstname <<
"\"" << std::endl;
1707 InsertPlainLuaTutorial(tr,tw);
1715 tr.ReadEnd(
"LuaExtension");
1724 void RunTestCases() {
1727 std::cerr <<
"flxinstall: cannot execute luafaudes" << std::endl;
1732 std::set< std::string > luascripts;
1733 for(std::set < std::string >::iterator fit=allfiles.begin(); fit!=allfiles.end(); fit++)
1736 for(std::set < std::string >::iterator fit=luascripts.begin(); fit!=luascripts.end(); fit++) {
1738 std::string args =
"-x " +
mSourceFile +
" " + *fit;
1740 std::cerr <<
"flxinstall: test case: " <<
mSourceFile << std::endl;
1743 std::cerr <<
"flxinstall: error while running lua script \"" << *fit <<
"\"" << std::endl;
1756 int main(
int argc,
char *argv[]) {
1770 for(i=1; i<argc; i++) {
1771 std::string option(argv[i]);
1773 if(option==
"-tdoc") {
1779 if(option==
"-tbin") {
1785 if(option==
"-trti") {
1791 if(option==
"-tcnav") {
1797 if(option==
"-tcss") {
1803 if(option==
"-tapp") {
1833 if((option==
"-?") || (option==
"--help")) {
1839 if(option.at(0)==
'-') {
1844 usage_exit(
"must set either -c, -i, -r, -x or -t mode" );
1850 for(;i<argc-1;i++) {
1855 std::set< std::string > srcfiles =
ReadDirectory(std::string(argv[i-1]));
1856 srcfiles=EraseHiddenFiles(srcfiles);
1857 if(srcfiles.size()>0) {
1859 for(std::set < std::string >::iterator fit=srcfiles.begin(); fit!=srcfiles.end(); fit++)
1865 usage_exit(
"target *.flx-file not specified");
1871 usage_exit(
"target *.flx-file not specified");
1873 CreateExtensionFile();
1881 std::cerr <<
"flxinstall: no sources specified" << std::endl;
1883 for(;i<argc-1;i++) {
1888 std::set< std::string > srcfiles =
ReadDirectory(std::string(argv[i-1]));
1889 srcfiles=EraseHiddenFiles(srcfiles);
1890 if(srcfiles.size()>0) {
1892 for(std::set < std::string >::iterator fit=srcfiles.begin(); fit!=srcfiles.end(); fit++)
1900 usage_exit(
"sources must be *.flx-files: "+ *fit);
1905 InstallExtensionFiles();
1918 InstallExtensionFiles();
1927 usage_exit(
"source and destination must be specified");
1933 mTarget=std::string(argv[i++]);
1939 ExtractExtensionFile();
1947 usage_exit(
"source and temp dir must be specified");
1953 mTarget=std::string(argv[i++]);
1959 usage_exit(
"target must be \".\" or \"./\"");
1961 if(curdir.size()!=0)
1966 ExtractExtensionFile();
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 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.
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 SysCall(const std::string &cmd, const std::string &args, bool errmsg=true)
std::string mFaudesDocCss
std::string mFaudesBinRef2html
std::set< std::string > mLuaFunctions
std::string mXmlSeparator
std::string mFaudesBinLua2ref
std::string mFaudesDocNav
std::string mFaudesBinLuafaudes
std::string mFaudesDocRti
std::string mFaudesDocToc
std::string mFaudesDocTemp
std::string mFaudesDocReference
std::string mFaudesDocImages
std::set< std::string > mSourceFiles
void usage_exit(const std::string &rMessage="")
std::string mFaudesBinLuaflx
std::string mExtensionName
std::string mFaudesDocRefsrc
std::set< std::string > mImageFiles
std::set< std::string > mGeneratorFiles
std::string mFaudesDocLuafaudes
int main(int argc, char *argv[])
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; i.e., remove the last separator and anything thereafer.
std::string PrependPath(const std::string &rLeft, const std::string &rRight)
Prepend one path before another.
std::string ExtractBasename(const std::string &rFullPath)
Extract file basename from full path.
bool FileCopy(const std::string &rFromFile, const std::string &rToFile)
Copy file.
std::string ExtractFilename(const std::string &rFullPath)
Extract file name from full path.
bool FileDelete(const std::string &rFilename)
Delete file.
std::string ExtractSuffix(const std::string &rFullPath)
Extract extension from full path, i.e.
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.