LT 80: auto-build now generates valid XHTML 1.1 + CSS.

Index: ChangeLog from Clement Vasseur <clement.vasseur@lrde.epita.fr> * auto-build/auto-build: Make it generate valid XHTML 1.1 + CSS. Suggested by Akim Demaille. * auto-build/packages.list: Use the rm-build-dir option. Add color highlighting for test-suites. Index: auto-build/auto-build --- auto-build/auto-build (revision 79) +++ auto-build/auto-build (working copy) @@ -36,7 +36,7 @@ =head1 SYNOPSIS -auto-build [options] packages.list +auto-build [options] packages.list [style.css] -m, --man display the manual -h, --help print this help and exit @@ -61,6 +61,7 @@ my %deps; my $packages; +my $css; my $man = 0; my $help = 0; my $delay = 0; @@ -70,17 +71,26 @@ 'help|h|?' => \$help, 'version|V' => \&version, 'delay|d=i' => \$delay, - '<>' => sub { $packages = $_[0] }, ) or pod2usage(-verbose => 0); pod2usage(-verbose => 1) if $help; -pod2usage(-verbose => 2) if $man; +pod2usage(-exitstatus => 0, -verbose => 2) if $man; + +($packages, $css) = @ARGV; pod2usage(-verbose => 0) unless defined $packages; &read_pkg_list($packages); &create_dir($report_dir); &create_dir($build_dir); &create_dir($inst_dir); + +if (defined $css) { + system("/bin/cp \"$css\" \"$report_dir/style.css\"") + and die "$0: unable to cp `$css' to `$report_dir/style.css'"; +} else { + &print_css; +} + &prepare_pkgs; while (1) { @@ -95,6 +105,7 @@ foreach my $pkg (@packages) { print "$pkg->{'name'}\n"; + &ch_dir($build_dir); next if &check_revision($pkg); &gen_pkg_report($pkg); @@ -131,14 +142,20 @@ } sub header { - my ($filename, $title) = @_; + my ($filename, $title, $css) = @_; my $FILE = &xopen(">$filename"); select $FILE; + $css = ("../" x $css) . 'style.css'; + print <<HTML; +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" +"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> <title>$title</title> + <link rel="stylesheet" type="text/css" href="$css"/> </head> <body> HTML @@ -148,8 +165,7 @@ sub footer { print <<HTML; - <hr/> - <h4>Generated by <i>auto-build</i> version $VERSION</h4> + <h4>Generated by <em>auto-build</em> version $VERSION</h4> </body> </html> HTML @@ -276,30 +292,20 @@ } sub gen_summary { - my $SUMMARY = &header("$report_dir/index.html", "Auto Build System"); + my $SUMMARY = &header("$report_dir/index.html", "Auto Build System", 0); my $section = ''; print <<HTML; <h1>Auto Build System</h1> - <hr/> <table> HTML foreach my $pkg (@packages) { if ($pkg->{'section'} ne $section) { - if ($section ne '') { - print <<HTML; - <tr> - <td> - - </td> - </tr> -HTML - } $section = $pkg->{'section'}; print <<HTML; <tr> - <td> + <td colspan="3"> <h3>$section</h3> </td> </tr> @@ -308,108 +314,99 @@ $pkg->{'status'} = '' unless defined $pkg->{'status'}; - my $color = "black"; my $time = &time_to_str($pkg->{'time'}); - $color = "red" if $pkg->{'status'} eq "failed"; - $color = "green" if $pkg->{'status'} eq "succeeded"; - $color = "gray" if $pkg->{'status'} eq "skipped"; - print <<HTML; - <tr> - <td><a href=\"$pkg->{'name'}/$pkg->{'name'}.html\">$pkg->{'name'}</a></td> - <td> </td> - <td><font color=\"$color\">$pkg->{'status'}</font></td> - <td> </td> - <td><font color=\"gray\">$time</font></td> + <tr class="body"> + <td style="width:10em"> + <a href=\"$pkg->{'name'}/index.html\">$pkg->{'name'}</a> + </td> + <td style="width:6em" class="st_$pkg->{'status'}">$pkg->{'status'}</td> + <td style="width:6em" class="time">$time</td> </tr> HTML } - print " </table>\n"; + print <<HTML; + </table> +HTML &footer($SUMMARY); } sub gen_pkg_report { my $pkg = shift; - my $filename = "$report_dir/$pkg->{'name'}/$pkg->{'name'}.html"; - my $REPORT = &header("$filename", "$pkg->{'name'} report"); + my $filename = "$report_dir/$pkg->{'name'}/index.html"; + my $REPORT = &header("$filename", "$pkg->{'name'} report", 1); my ($ts, $tf) = ('', ''); $ts = localtime $pkg->{'time_started'} if defined $pkg->{'time_started'}; $tf = localtime $pkg->{'time_finished'} if defined $pkg->{'time_finished'}; - print <<HTML; - <h1>$pkg->{'name'}</h1> - <hr/> - <h3>Build started: $ts</h3> - <table cellpadding=\"8\"> -HTML + print " <h1>$pkg->{'name'}</h1>\n"; + + if (defined $pkg->{'archives'}) { + foreach (@{$pkg->{'archives'}}) { + print " <a href=\"$_\">$_</a><br/>\n" if -f $_; + } + } + + print " <h5>Build started: $ts</h5>\n" if $ts; + print " <table cellpadding=\"8\">\n"; foreach my $step (@{$pkg->{'steps'}}) { next unless defined $step->{'name'}; if (defined $step->{'status'}) { - my $color = "black"; - $color = "green" if $step->{'status'} eq "succeeded"; - $color = "red" if $step->{'status'} eq "failed"; - my $time = &time_to_str($step->{'time'}); print <<HTML; - <tr> - <td><a href=\"$step->{'name'}.html\">$step->{'name'}</a></td> - <td><font color=\"$color\">$step->{'status'}</font></td> - <td><font color=\"gray\">$time</font></td> + <tr class="body"> + <td style="width:8em"> + <a href=\"$step->{'name'}.html\">$step->{'name'}</a> + </td> + <td style="width:6em" class="st_$step->{'status'}">$step->{'status'}</td> + <td style="width:6em" class="time">$time</td> </tr> HTML } else { print <<HTML; - <tr> - <td>$step->{'name'}</td> + <tr class="body"> + <td style="width:8em">$step->{'name'}</td> + <td style="width:6em" /> + <td style="width:6em" /> </tr> HTML } } - print <<HTML; - </table> - <h3>Build finished: $tf</h3> -HTML - - if (defined $pkg->{'archives'}) { - foreach (@{$pkg->{'archives'}}) { - print " <a href=\"$_\">$_</a><br/>\n" if -f $_; - } - } - + print " </table>\n"; + print " <h5>Build finished: $tf</h5>\n" if $tf; &footer($REPORT); } sub set_status { $_[0]->{'status'} = $_[1]; + system("echo \"$_[1]\" > \"$build_dir/$_[0]->{'name'}/.status\"") + and die "$0: unable to create `$build_dir/$_[0]->{'name'}/.status'\n"; print " $_[1]\n"; &gen_summary; } sub gen_log_page { - my $pkg = shift; - my $step = shift; + my ($pkg, $step) = @_; my $filename = "$report_dir/$pkg->{'name'}/$step->{'name'}.html"; - my $REPORT = &header("$filename", "$pkg->{'name'} - $step->{'name'}"); + my $REPORT = &header("$filename", "$pkg->{'name'} - $step->{'name'}", 1); print <<HTML; - <h1>$step->{'name'}</h1> - <h4>$step->{'cmd'}</h4> - <hr/> - <a href="$step->{'name'}.log">Log</a> + <h1>$pkg->{'name'} - $step->{'name'}</h1> + <h5>$step->{'cmd'}</h5> + <a href="$step->{'name'}.log">View log</a> HTML &footer($REPORT); } sub run { - my $pkg = shift; - my $step = shift; + my ($pkg, $step) = @_; my $status = $step->{'name'}; my $out = "$report_dir/$pkg->{'name'}/$status"; @@ -420,12 +417,11 @@ my $exit_code = system("$step->{'cmd'} >$out.log 2>&1"); $step->{'time'} = time - $t; - my $REPORT = &header("$out.html", "$pkg->{'name'} - $status"); + my $REPORT = &header("$out.html", "$pkg->{'name'} - $status", 1); print <<HTML; - <h1>$step->{'name'}</h1> - <h4>$step->{'cmd'}</h4> - <hr/> + <h1>$pkg->{'name'} - $step->{'name'}</h1> + <h5>$step->{'cmd'}</h5> <pre> HTML @@ -433,12 +429,13 @@ my $archives_ready; while (<$LOG>) { - my $color; foreach my $c (@colors) { - $color = $c->[1] if m/^$c->[0]/; - last if defined $color; + if (m/$c->[0]/) { + s/^(.*?)($c->[0])(.*)$/$1<font color=\"$c->[1]\">$2<\/font>$3/g; + last; + } } - if ($status eq 'check') { + if ($status eq 'distcheck') { if (($archives_ready and m/^($archives_ready\.tar\.(gz|bz2))$/) or m/^(.*\.tar\.(gz|bz2)) is ready for distribution$/) { push @{$pkg->{'archives'}}, $1; @@ -447,9 +444,7 @@ } $archives_ready = $1 if m/^(.*) archives ready for distribution: $/; } - print "<font color=\"$color\">" if $color; print; - print "</font>" if $color; } print " </pre>\n"; @@ -461,14 +456,15 @@ sub check_revision { my $pkg = shift; - my $revfile = "$inst_dir/$pkg->{'name'}/.rev"; + my $revfile = "$build_dir/$pkg->{'name'}/.rev"; my $rev; if ($pkg->{'url'} =~ m|^svn:(.*/([^/]+))$|) { chomp($rev = `svn log -q \"https:$1\" 2>/dev/null | grep '^r' | head -n 1`) ; $rev =~ s/^r(\d+).*$/$1/; - } elsif ($pkg->{'url'} =~ m/^((ht|f)tp:.*)$/) { - chomp($rev = `wget -qnv -O - \"$1\" | md5sum`); + } elsif ($pkg->{'url'} =~ m/^((ht|f)tp:.*\/([^\/]+))$/) { + chomp($rev = `wget -q -N -P \"$build_dir/$pkg->{'name'}\" \"$1\" && + md5sum \"$build_dir/$pkg->{'name'}/$3\"`); } $pkg->{'rev'} = $rev; @@ -477,8 +473,9 @@ unlink $revfile if $pkg->{'rev'} ne $rev; } if (-f $revfile) { - chomp($pkg->{'time'} = `cat \"$inst_dir/$pkg->{'name'}/.time\"`); - &set_status($pkg, 'succeeded'); + chomp($pkg->{'time'} = `cat \"$build_dir/$pkg->{'name'}/.time\"`); + chomp($pkg->{'status'} = `cat \"$build_dir/$pkg->{'name'}/.status\"`); + &set_status($pkg, $pkg->{'status'}); return 1; } return undef; @@ -494,7 +491,7 @@ $_ = "file://$1"; push @steps, { 'name' => 'download', - 'cmd' => "wget -nv \"$pkg->{'url'}\"" + 'cmd' => "wget -N \"$pkg->{'url'}\"" }; } @@ -502,8 +499,8 @@ my $file = $_ = $1; my $c; - $c = "z" if m/\.tar\.gz$/ or m/\.tgz$/; - $c = "j" if m/\.tar\.bz2$/ or m/\.tbz2$/; + $c = "z" if m/\.tar\.gz$/; + $c = "j" if m/\.tar\.bz2$/; $pkg->{'dir'} = $file; if (defined $c) { @@ -551,33 +548,42 @@ foreach my $pkg (@packages) { my @steps = &get_package($pkg); my $dir = "$report_dir/$pkg->{'name'}"; + &create_dir("$build_dir/$pkg->{'name'}"); &create_dir($dir); push @steps, { 'name' => 'patch', 'cmd' => "patch -p0 -t -i \"$pkg->{'dif'}\"" } if defined $pkg->{'dif'}; + push @steps, { 'name' => 'configure', 'cmd' => "./configure --prefix=$inst_dir/$pkg->{'name'} $pkg->{'cfg'}" }, { 'name' => 'build', 'cmd' => 'make' }; + my $dcf = ''; defined $pkg->{'cfg'} and $pkg->{'cfg'} ne '' and $dcf = "DISTCHECK_CONFIGURE_FLAGS=\"$pkg->{'cfg'}\" "; + push @steps, { 'name' => 'check', - 'cmd' => "make ${dcf}distcheck" + 'cmd' => 'make -k check' + }, { + 'name' => 'distcheck', + 'cmd' => "make -k ${dcf}distcheck" } unless $pkg->{'opt'} =~ m/\bno-check\b/; + push @steps, { - 'rm' => "$inst_dir/$pkg->{'name'}" - },{ - 'name' => 'install', 'cmd' => 'make install' + 'rm' => "$inst_dir/$pkg->{'name'}", + 'name' => 'install', + 'cmd' => 'make install' }; + $pkg->{'steps'} = \@steps; next if &check_revision($pkg); - &gen_pkg_report($pkg) unless -f "$dir/$pkg->{'name'}.html"; + &gen_pkg_report($pkg) unless -f "$dir/index.html"; } } @@ -601,6 +607,7 @@ &create_dir($dir); &ch_dir($dir); $pkg->{'time_started'} = time; + foreach my $step (@{$pkg->{'steps'}}) { $step->{'status'} = "running"; &gen_pkg_report($pkg); @@ -625,11 +632,11 @@ &gen_pkg_report($pkg); &ch_dir($build_dir); &set_status($pkg, $st); - if ($st eq "succeeded") { - system("echo \"$pkg->{'rev'}\" > \"$inst_dir/$pkg->{'name'}/.rev\""); - system("echo \"$pkg->{'time'}\" > \"$inst_dir/$pkg->{'name'}/.time\""); - &delete_dir($pkg->{'name'}); + foreach ('rev', 'time', 'status') { + system("echo \"$pkg->{$_}\" > \"$build_dir/$pkg->{'name'}/.$_\""); } + &delete_dir("$pkg->{'name'}/$pkg->{'dir'}") if ($st eq "succeeded") + and ($pkg->{'opt'} =~ m/\brm-build-dir\b/); } sub version { @@ -641,3 +648,34 @@ "PARTICULAR PURPOSE.\n"; exit 0; } + +sub print_css { + my $CSS = &xopen(">$report_dir/style.css"); + print $CSS <<CSS; +body { + text-align: center; + background-color: #EEEEEE; + font-family: Verdana, Helvetica, sans-serif; +} + +h1,h2,h3,h4,h5,h6 { + font-family: Verdana, Helvetica, sans-serif; + color: #003377; +} + +table { margin-left:auto; margin-right:auto; } +h1,h4 { text-align: center; background-color: #CCCCFF; } +h3 { text-indent: 1em } +a { text-decoration: none; color: #003377; } +a:hover { text-decoration: underline; color: #003377; } +pre { font-family: Courier, monospace; } +tr { text-indent: 0em; } +td { text-indent: 0em; font-family: Verdana, Helvetica, sans-serif; } +tr.body { background-color: #E5E5E5; } +td.time { color: gray } +td.st_succeeded { color: green } +td.st_failed { color: red } +td.st_skipped { color: gray } +CSS + &xclose($CSS); +} Index: auto-build/packages.list --- auto-build/packages.list (revision 79) +++ auto-build/packages.list (working copy) @@ -4,35 +4,21 @@ /mnt/ghost/stud/vasseu_c/www/build # build directory -/work/nitro/auto-build/src +/work/auto-build/src # inst directory -/work/nitro/auto-build/usr +/work/auto-build/usr ### Color highlighting ######################################################## -color red "make.*: \*\*\* " -color red "SdfChecker:error: " -color maroon "warning:" -color maroon "SdfChecker:warning: " -color gray "make.*:" - -### Tiger ##################################################################### - -section "Tiger" - -#------------------------------------------------------------------------------ - -havm - - url: svn://svn.lrde.epita.fr/svn/havm/trunk - dif: /home/lrde/lrde-2005/vasseu_c/havm.diff - -#------------------------------------------------------------------------------ - -nolimips - - url: svn://svn.lrde.epita.fr/svn/nolimips/trunk +color red "^make.*: \*\*\* .*$" +color red "^SdfChecker:error:.*$" +color maroon "^warning:.*$" +color maroon "^SdfChecker:warning:.*$" +color gray "^make.*:.*$" +color green "^PASS:" +color blue "^XPASS:" +color red "^FAIL:" ### StrategoXT ################################################################ @@ -44,6 +30,7 @@ url: http://www.cwi.nl/projects/MetaEnv/aterm/aterm-2.2.tar.gz cfg: --with-gcc + opt: rm-build-dir #------------------------------------------------------------------------------ @@ -51,7 +38,7 @@ url: ftp://ftp.stratego-language.org/pub/stratego/sdf2/sdf2-bundle-2.2.tar.gz cfg: --with-aterm=${aterm} - opt: no-check + opt: no-check, rm-build-dir #------------------------------------------------------------------------------ @@ -60,7 +47,7 @@ url: http://losser.st-lab.cs.uu.nl/~mbravenb/dailydist/strategoxt/src/stratego xt-head.tar.gz cfg: --with-aterm=${aterm}\ --with-sdf=${sdf} - opt: no-check + opt: no-check, rm-build-dir #------------------------------------------------------------------------------ @@ -71,6 +58,7 @@ --with-sdf=${sdf}\ --with-strategoxt=${strategoxt} env: PATH="${strategoxt}/bin:$PATH" + opt: rm-build-dir ### Transformers ############################################################## @@ -212,6 +200,23 @@ --with-sdf-astgen=${sdf-astgen} env: PATH="${strategoxt}/bin:$PATH" +### Tiger ##################################################################### + +section "Tiger" + +#------------------------------------------------------------------------------ + +havm + + url: svn://svn.lrde.epita.fr/svn/havm/trunk + dif: /home/lrde/lrde-2005/vasseu_c/havm.diff + +#------------------------------------------------------------------------------ + +nolimips + + url: svn://svn.lrde.epita.fr/svn/nolimips/trunk + ### Olena ##################################################################### section "Olena" @@ -232,7 +237,6 @@ vaucanson url: svn://svn.lrde.epita.fr/svn/vaucanson/trunk - cfg: --with-xml env: PATH="/home/lrde/lrde-2005/vasseu_c/usr/bin/old:$PATH" #------------------------------------------------------------------------------

"Clement" == Clement Vasseur <nitro@epita.fr> writes:
+if (defined $css) { + system("/bin/cp \"$css\" \"$report_dir/style.css\"") + and die "$0: unable to cp `$css' to `$report_dir/style.css'"; +} else { + &print_css; +} +
You should have a look at File::Copy.
participants (2)
-
Akim Demaille
-
Clement Vasseur