Line 163... |
Line 163... |
163 |
print "\n"; |
163 |
print "\n"; |
164 |
print "Parameters are: \n"; |
164 |
print "Parameters are: \n"; |
165 |
print " EnableApache={0|1} - Enable to run in Apache\n"; |
165 |
print " EnableApache={0|1} - Enable to run in Apache\n"; |
166 |
print " SourceDir=path - path to asm source directory\n"; |
166 |
print " SourceDir=path - path to asm source directory\n"; |
167 |
print " SourceAsm=file - name of top level asm source file\n"; |
167 |
print " SourceAsm=file - name of top level asm source file\n"; |
- |
|
168 |
print " SvnInfoFileName - name of Svn Info File\n"; |
168 |
print " TemplateDir=path - path to HTML template\n"; |
169 |
print " TemplateDir=path - path to HTML template\n"; |
169 |
print " DestinationDir=path - path to destination HTML\n"; |
170 |
print " DestinationDir=path - path to destination HTML\n"; |
170 |
Error("\n"); |
171 |
Error("\n"); |
171 |
} |
172 |
} |
172 |
|
173 |
|
173 |
|
174 |
|
174 |
function Parameters(&$CFG) |
175 |
function Parameters(&$CFG) |
175 |
// Function process Command Line parameters |
176 |
// Function process Command Line parameters |
176 |
{ |
177 |
{ |
177 |
// Info |
- |
|
178 |
print "Parameters\n"; |
- |
|
179 |
// Dummy values |
178 |
// Dummy values |
180 |
$CFG["EnableApache"] = 0; // Do not allow run in Apache |
179 |
$CFG["EnableApache"] = 0; // Do not allow run in Apache |
181 |
$CFG["SourceDir"] = ""; |
180 |
$CFG["SourceDir"] = ""; |
182 |
$CFG["SourceAsm"] = ""; |
181 |
$CFG["SourceAsm"] = ""; |
- |
|
182 |
$CFG["SvnInfoFileName"] = ""; |
183 |
$CFG["TemplateDir"] = ""; |
183 |
$CFG["TemplateDir"] = ""; |
184 |
$CFG["DestinationDir"] = ""; |
184 |
$CFG["DestinationDir"] = ""; |
185 |
// Default values (in cfg file) |
185 |
// Default values (in cfg file) |
186 |
@include_once("GenerateHTML.cfg"); |
186 |
@include_once("GenerateHTML.cfg"); |
187 |
// Command Line parameters |
187 |
// Command Line parameters |
Line 206... |
Line 206... |
206 |
return "Invalid Parameter: $Value"; |
206 |
return "Invalid Parameter: $Value"; |
207 |
} |
207 |
} |
208 |
} |
208 |
} |
209 |
} |
209 |
} |
210 |
|
210 |
|
- |
|
211 |
// Check if alowed to run in Apache |
- |
|
212 |
if ($_SERVER["argc"]==0 & ! $CFG["EnableApache"]) |
- |
|
213 |
return "<b>This Script is configured so that it will not run in Apache.</b>"; |
- |
|
214 |
|
- |
|
215 |
// Info |
- |
|
216 |
print "Parameters\n"; |
- |
|
217 |
|
211 |
// Correct paths and existence |
218 |
// Correct paths and existence |
212 |
foreach($CFG as $Key => $Value) |
219 |
foreach($CFG as $Key => $Value) |
213 |
{ |
220 |
{ |
214 |
if (stripos($Key,"Dir")) |
221 |
if (stripos($Key,"Dir")) |
215 |
{ |
222 |
{ |
Line 231... |
Line 238... |
231 |
if (count(CFG)) |
238 |
if (count(CFG)) |
232 |
foreach($CFG as $Key => $Value) |
239 |
foreach($CFG as $Key => $Value) |
233 |
print " $Key=$Value\n"; |
240 |
print " $Key=$Value\n"; |
234 |
print "\n"; |
241 |
print "\n"; |
235 |
|
242 |
|
236 |
// Check if alowed to run in Apache |
- |
|
237 |
if ($_SERVER["argc"]==0 & ! $CFG["Apache"]) |
- |
|
238 |
return "This Script is configured so that it will not run in Apache."; |
- |
|
239 |
|
- |
|
240 |
// No Error |
243 |
// No Error |
241 |
return ""; |
244 |
return ""; |
242 |
} |
245 |
} |
243 |
|
246 |
|
244 |
|
247 |
|
Line 426... |
Line 429... |
426 |
print "\n"; |
429 |
print "\n"; |
427 |
return ""; |
430 |
return ""; |
428 |
} |
431 |
} |
429 |
|
432 |
|
430 |
|
433 |
|
431 |
function GenerateWordList($TemplateDir, $DestinationDir, &$LabelList, &$WordList) |
434 |
function GenerateWordList($TemplateDir, $SvnInfoFileName, $DestinationDir, &$LabelList, &$WordList) |
432 |
// Creates HTML pages with Word List |
435 |
// Creates HTML pages with Word List |
433 |
// Returns Error String |
436 |
// Returns Error String |
434 |
// IN $TemplateDir - template directory (file WordList.*.html) |
437 |
// IN $TemplateDir - template directory (file WordList.*.html) |
435 |
// IN $LabelList - list of labels (Label, FileName, LineNumber) |
438 |
// IN $LabelList - list of labels (Label, FileName, LineNumber) |
436 |
// IN $WordList - list of words (ShortLabel, Word, Comment, Label, FileName) |
439 |
// IN $WordList - list of words (ShortLabel, Word, Comment, Label, FileName) |
Line 447... |
Line 450... |
447 |
// Read template file |
450 |
// Read template file |
448 |
$Error=MyReadFileString($FileName, $FileContent); |
451 |
$Error=MyReadFileString($FileName, $FileContent); |
449 |
if ($Error!="") |
452 |
if ($Error!="") |
450 |
return $Error; |
453 |
return $Error; |
451 |
|
454 |
|
- |
|
455 |
// Find <<SvnInfo>> |
- |
|
456 |
if (!preg_match("/( *)(<<SvnInfo>>)/i",$FileContent,$Matches)) |
- |
|
457 |
{ |
- |
|
458 |
unset($FileContent); |
- |
|
459 |
return "Missing <<SvnInfo>> in template file"; |
- |
|
460 |
} |
- |
|
461 |
$Indent=$Matches[1]; |
- |
|
462 |
|
- |
|
463 |
// Read Svn Info file |
- |
|
464 |
$Error=MyReadFileString($SvnInfoFileName, $SvnInfoFile); |
- |
|
465 |
if ($Error!="") |
- |
|
466 |
{ |
- |
|
467 |
// We do not have Svn Info File |
- |
|
468 |
$SvnInfoFile=""; |
- |
|
469 |
} |
- |
|
470 |
else |
- |
|
471 |
{ |
- |
|
472 |
// We have Svn Info File |
- |
|
473 |
$SvnInfoFile=preg_replace("/^((?:URL|Repository|Last)[^:]*):(.*$)|^.*$/im","<tr><td>$1</td><td>$2</td></tr>",$SvnInfoFile); |
- |
|
474 |
$SvnInfoFile=preg_replace("~<tr><td></td><td></td></tr>\n~i","",$SvnInfoFile); |
- |
|
475 |
$SvnInfoFile="<tr><th colspan=\"2\">Subversion Info</th></tr>".$SvnInfoFile; |
- |
|
476 |
} |
- |
|
477 |
|
- |
|
478 |
// Put Svn Info into HTML template |
- |
|
479 |
$FileContent=str_ireplace("<<SvnInfo>>", $SvnInfoFile, $FileContent); |
- |
|
480 |
#print $FileContent; |
- |
|
481 |
|
- |
|
482 |
|
452 |
// Find <<WordList>> |
483 |
// Find <<WordList>> |
453 |
if (!preg_match("/( *)(<<WordList>>)/i",$FileContent,$Matches)) |
484 |
if (!preg_match("/( *)(<<WordList>>)/i",$FileContent,$Matches)) |
454 |
{ |
485 |
{ |
455 |
unset($FileContent); |
486 |
unset($FileContent); |
456 |
return "Missing <<WordList>> in template file"; |
487 |
return "Missing <<WordList>> in template file"; |
Line 485... |
Line 516... |
485 |
$WordListHTML[]="</table>"; |
516 |
$WordListHTML[]="</table>"; |
486 |
|
517 |
|
487 |
// Indent and Concatenate lines |
518 |
// Indent and Concatenate lines |
488 |
foreach($WordListHTML as $Key => $Value) |
519 |
foreach($WordListHTML as $Key => $Value) |
489 |
{ |
520 |
{ |
- |
|
521 |
if ($Key>0) |
490 |
$WordListHTML[$Key]=$Indent.preg_replace("/\n/","<br>",$Value); |
522 |
$WordListHTML[$Key]=$Indent.preg_replace("/\n/","<br>",$Value); |
491 |
} |
523 |
} |
492 |
$WordListHTML=implode("\n",$WordListHTML); |
524 |
$WordListHTML=implode("\n",$WordListHTML); |
493 |
|
525 |
|
494 |
// Put it into HTML template |
526 |
// Put it into HTML template |
495 |
$FileContent=str_ireplace("<<WordList>>", $WordListHTML, $FileContent); |
527 |
$FileContent=str_ireplace("<<WordList>>", $WordListHTML, $FileContent); |
Line 584... |
Line 616... |
584 |
|
616 |
|
585 |
// Destilate Labels and Words |
617 |
// Destilate Labels and Words |
586 |
Error(CreateWordList($CFG["SourceDir"], $LabelList, $WordList)); |
618 |
Error(CreateWordList($CFG["SourceDir"], $LabelList, $WordList)); |
587 |
|
619 |
|
588 |
// Create HTML WordList |
620 |
// Create HTML WordList |
- |
|
621 |
Error(GenerateWordList( |
- |
|
622 |
$CFG["TemplateDir"], |
589 |
Error(GenerateWordList($CFG["TemplateDir"], $CFG["DestinationDir"], $LabelList, $WordList)); |
623 |
$CFG["SourceDir"].$CFG["SvnInfoFileName"], |
- |
|
624 |
$CFG["DestinationDir"], |
- |
|
625 |
$LabelList, $WordList)); |
590 |
|
626 |
|
591 |
// Copy ASM files and convert them into HTML |
627 |
// Copy ASM files and convert them into HTML |
592 |
Error(GenerateAsmFiles($CFG["TemplateDir"], $CFG["SourceDir"], $SourceAsmFiles, $CFG["DestinationDir"])); |
628 |
Error(GenerateAsmFiles($CFG["TemplateDir"], $CFG["SourceDir"], $SourceAsmFiles, $CFG["DestinationDir"])); |
593 |
|
629 |
|
594 |
// Finish |
630 |
// Finish |
595 |
print "O.K.\n"; |
631 |
print "O.K.\n"; |
596 |
return |
632 |
return |
597 |
|
633 |
|
598 |
// Zpracování readme autora + verze |
634 |
// Zpracování readme autora |
- |
|
635 |
// Vyplatilo by se udělat samostatny formatovaci a nahrazovaci mechanizmus |
599 |
// Zpracování templejtů do samostatného podprogramu (vyřešit indent...) |
636 |
// Zpracování templejtů do samostatného podprogramu (vyřešit indent...) |
600 |
// tím se vyřeší i en/cs verze Asm souboru |
637 |
// tím se vyřeší i en/cs verze Asm souboru |
601 |
// Generovat log do souboru místo printu (zvážit) oddělit chyby a varování |
638 |
// Generovat log do souboru místo printu (zvážit) oddělit chyby a varování |
602 |
// Vyčistit cílový adresář |
639 |
// Vyčistit cílový adresář |
603 |
// Process all FORTH files |
640 |
// Process all FORTH files |