--- loncom/build/lpml_parse.pl 2001/10/30 22:27:32 1.13 +++ loncom/build/lpml_parse.pl 2001/11/05 02:57:21 1.14 @@ -5,6 +5,8 @@ # May 2001 # 06/19/2001,06/20,06/24 - Scott Harrison # 9/5/2001,9/6,9/7,9/8 - Scott Harrison +# 9/17,9/18 - Scott Harrison +# 11/4 - Scott Harrison ############################################################################### ## ## @@ -14,6 +16,8 @@ ## 3. First pass through (grab distribution-specific information) ## ## 4. Second pass through (parse out what is not necessary) ## ## 5. Third pass through (translate markup according to specified mode) ## +## 6. Functions (most all just format contents of different markup tags) ## +## 7. POD (plain old documentation, CPAN style) ## ## ## ############################################################################### @@ -220,6 +224,7 @@ my $target; my $source; my $note; my $build; +my $buildlink; my $commands; my $command; my $status; @@ -277,6 +282,7 @@ $parser->{textify}={ build => \&format_build, status => \&format_status, dependencies => \&format_dependencies, + buildlink => \&format_buildlink, glob => \&format_glob, sourcedir => \&format_sourcedir, filenames => \&format_filenames, @@ -301,6 +307,9 @@ while ($token = $parser->get_tag('lpml') } exit; +# ---------- Functions (most all just format contents of different markup tags) + +# ------------------------ Final output at end of markup parsing and formatting sub end { if ($mode eq 'html') { return "
THE END\n"; @@ -329,9 +338,11 @@ sub format_lpml { print ' by Scott Harrison 2001'."\n"; print '# This file was automatically generated on '.`date`; print "\n".$invocation; + $lpml .= "SHELL=\"/bin/bash\"\n\n"; } elsif ($mode eq 'build') { - $lpml = "# Dynamic Makefile generated by LON-CAPA build process\n"; + $lpml = "# LPML build targets. Linux Packaging Markup Language,"; + $lpml .= ' by Scott Harrison 2001'."\n"; $lpml .= '# This file was automatically generated on '.`date`; $lpml .= "\n"; $lpml .= "SHELL=\"/bin/sh\"\n\n"; @@ -654,7 +665,8 @@ sub format_files { elsif ($mode eq 'configinstall') { return "\n".'configfiles: '. join(' ',@configall). - "\n\n".$text; + "\n\n".$text. + "\n\nalwaysrun:\n\n"; } elsif ($mode eq 'build') { my $binfo; @@ -662,23 +674,39 @@ sub format_files { my $command2; my @deps; foreach my $bi (@buildinfo) { - my ($source,$command,$trigger,@deps)=split(/\;/,$bi); + my ($target,$source,$command,$trigger,@deps)=split(/\;/,$bi); $tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; $command=~s/\/([^\/]*)$//; $command2="cd $command; sh ./$1;\\"; my $depstring; + my $depstring2="\t\t\@echo '';\\\n"; + my $olddep; foreach my $dep (@deps) { + unless ($olddep) { + $olddep=$deps[$#deps]; + } $depstring.="\telif !(test -r $command/$dep);\\\n"; $depstring.="\t\tthen echo ". - "\"**** LON-CAPA WARNING **** missing the file: ". + "\"**** WARNING **** missing the file: ". "$command/$dep\";\\\n"; + $depstring.="\t\ttest -e $source || test -e $target || echo ". + "'**** ERROR **** neither source=$source nor target=". + "$target exist and they cannot be built';\\\n"; + $depstring.="\t\tmake -f Makefile.build ${source}___DEPS;\\\n"; + if ($olddep) { + $depstring2.="\t\tECODE=0;\\\n"; + $depstring2.="\t\t! test -e $source && test -r $command/$olddep &&". + " { perl filecompare.pl -B $command/$olddep $target || ECODE=\$\$?; } && { [ \$\$ECODE != \"2\" ] || echo \"**** WARNING **** dependency $command/$olddep is newer than target file $target; SOMETHING MAY BE WRONG\"; };\\\n"; + } + $olddep=$dep; } $binfo.="$source: $tword\n". "\t\@if !(echo \"\");\\\n\t\tthen echo ". - "\"**** LON-CAPA WARNING **** Strange shell. ". + "\"**** WARNING **** Strange shell. ". "Check your path settings.\";\\\n". $depstring. "\telse \\\n\t\t$command2\n\tfi\n\n"; + $binfo.="${source}___DEPS:\n".$depstring2."\t\tECODE=0;\n\n"; } return 'all: '.join(' ',@buildall)."\n\n". $text. @@ -714,6 +742,7 @@ sub format_file { $file=''; $source=''; $target=''; $categoryname=''; $description=''; $note=''; $build=''; $status=''; $dependencies=''; my $text=&trim($parser->get_text('/file')); + my $buildtest; if ($source) { $parser->get_tag('/file'); if ($mode eq 'html') { @@ -723,30 +752,79 @@ sub format_file { "\nEND FILE"); } elsif ($mode eq 'install' && $categoryname ne 'conf') { - return "\t".'@test -e '.$sourceroot.'/'.$source. - ' && install '. - $categoryhash{$categoryname}.' '. - $sourceroot.'/'.$source.' '. - $targetroot.'/'.$target. - ' || echo "**** LON-CAPA WARNING '. - '**** CVS source file does not exist: '.$sourceroot.'/'. - $source.'"'."\n"; + if ($build) { + my $bi=$sourceroot.'/'.$source.';'.$build.';'. + $dependencies; + my ($source2,$command,$trigger,@deps)=split(/\;/,$bi); + $tword=''; $tword=' alwaysrun' if $trigger eq 'always run'; + $command=~s/\/([^\/]*)$//; + $command2="cd $command; sh ./$1;\\"; + my $depstring; + foreach my $dep (@deps) { + $depstring.=<get_text('/buildlink')); + if ($text) { + $parser->get_tag('/buildlink'); + $buildlink=$sourceroot.'/'.$text; + } + return ''; +} # ------------------------------------------------------- Format status section sub format_status { my @tokeninfo=@_; @@ -933,3 +1022,5 @@ sub htmlsafe { sub trim { my ($s)=@_; $s=~s/^\s*//; $s=~s/\s*$//; return $s; } + +# ----------------------------------- POD (plain old documentation, CPAN style)