From 9dcb38e8079aa5258fb9abeccd8d1d23cf94376c Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 15 Feb 2010 23:04:03 -0800 Subject: [PATCH] Add utility for HTML results. --- build-pspp | 55 ++++++++++++----- results2html | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 203 insertions(+), 15 deletions(-) create mode 100755 results2html diff --git a/build-pspp b/build-pspp index 724221cebd..634364fd6b 100755 --- a/build-pspp +++ b/build-pspp @@ -1,8 +1,10 @@ #! /usr/bin/env perl +use Cwd; +use File::Spec; use Getopt::Long qw(:config bundling no_ignore_case); +use IO::Handle; use POSIX; -use Cwd; use strict; use warnings; @@ -10,9 +12,13 @@ use warnings; my $help = 0; my $build_binary = 1; my $batch = 0; +my $builddir; +my $build_number; GetOptions ("h|help" => \$help, "binary!" => \$build_binary, - "batch!" => \$batch); + "batch!" => \$batch, + "o|output=s" => \$builddir, + "build-number=i" => \$build_number); usage () if $help; @@ -23,19 +29,28 @@ my $builder = `hostname`; chomp $builder; # Select build number. -my $build_number = POSIX::strftime("%Y%m%d%H%M%S", localtime); -print "$build_number\n" if $batch; +if (!defined ($build_number)) { + $build_number = POSIX::strftime("%Y%m%d%H%M%S", localtime); +} my $topdir = getcwd (); # Create build directory. -my $builddir = "builds/$build_number"; -mkdir "builds" or die "builds: mkdir: $!\n" if ! -d "builds"; -mkdir $builddir or die "$builddir: mkdir: $!\n"; +if (!defined ($builddir)) { + $builddir = "builds/$build_number"; + mkdir "builds" or die "builds: mkdir: $!\n" if ! -d "builds"; +} +-d $builddir or mkdir $builddir or die "$builddir: mkdir: $!\n"; +my $abs_builddir = File::Spec->rel2abs ($builddir); our $resultsdir = "$builddir/results"; mkdir $resultsdir or die "$resultsdir: mkdir: $!\n"; mkdir "$resultsdir/vars" or die "$resultsdir/vars: mkdir: $!\n"; +my $abs_resultsdir = File::Spec->rel2abs ($resultsdir); + +my $varsfile = "$resultsdir/VARS"; +open (VARS, '>', $varsfile) or die "creating $varsfile failed: $!\n"; +VARS->autoflush (1); my $logfile = "$resultsdir/LOG"; open (LOG, '>', $logfile) or die "creating $logfile failed: $!\n"; @@ -51,21 +66,29 @@ sub start_step { sub set_var { my ($var, $value) = @_; + + print VARS "$var=$value\n"; + + print "\t$var=$value\n" unless $batch; + open (VAR, '>', "$resultsdir/vars/$var") or die "creating $resultsdir/$var failed: $!\n"; print VAR "$value\n"; close VAR; - print LOG "$var=$value\n"; - print "\t$var=$value\n" unless $batch; +} + +sub saved_result { + my ($product) = @_; + start_step ("Saving $product"); } sub save_result { my ($src, $rm_src) = @_; - my ($dst) = $src; - $dst =~ s(^.*/)(); - $dst = "$resultsdir/$dst"; + my ($basename) = $src; + $basename =~ s(^.*/)(); + my ($dst) = "$resultsdir/$basename"; - start_step ("Saving $src"); + saved_result ($basename); run ("cp -R $src $dst"); if (defined ($rm_src) && $rm_src) { @@ -221,11 +244,13 @@ EOF # Build user manual start_step ("Build user manual"); run ("cd $builddir/pspp$build_number && cp _build/doc/*.texi doc/"); - run ("cd $builddir/pspp$build_number && GENDOCS_TEMPLATE_DIR=$topdir $topdir/gendocs.sh -s doc/pspp.texinfo -o $topdir/$builddir/results/user-manual --email bug-gnu-pspp\@gnu.org pspp \"GNU PSPP User Manual\"", "user-manual"); + run ("cd $builddir/pspp$build_number && GENDOCS_TEMPLATE_DIR=$topdir $topdir/gendocs.sh -s doc/pspp.texinfo -o $abs_resultsdir/user-manual --email bug-gnu-pspp\@gnu.org pspp \"GNU PSPP User Manual\"", "user-manual"); + saved_result ("user-manual"); # Build developer's guide start_step ("Build developers guide"); - run ("cd $builddir/pspp$build_number && GENDOCS_TEMPLATE_DIR=$topdir $topdir/gendocs.sh -s doc/pspp-dev.texinfo -o $topdir/$builddir/results/dev-guide --email bug-gnu-pspp\@gnu.org pspp-dev \"GNU PSPP Developers Guide\"", "dev-guide"); + run ("cd $builddir/pspp$build_number && GENDOCS_TEMPLATE_DIR=$topdir $topdir/gendocs.sh -s doc/pspp-dev.texinfo -o $abs_resultsdir/dev-guide --email bug-gnu-pspp\@gnu.org pspp-dev \"GNU PSPP Developers Guide\"", "dev-guide"); + saved_result ("dev-guide"); } else { $tarball = $ARGV[0]; } diff --git a/results2html b/results2html new file mode 100755 index 0000000000..1b4622137f --- /dev/null +++ b/results2html @@ -0,0 +1,163 @@ +#! /usr/bin/env perl + +use strict; +use warnings; + +use HTML::Entities; + +open (LOG, '<', "LOG"); +open (INDEX, '>','index.html'); +open (LOG_HTML, '>', "log.html"); + +print INDEX < + + + + +
    +EOF + +print LOG_HTML < + + + + +EOF +print LOG_HTML "
    ";
    +
    +my ($n_products) = 0;
    +my ($n_steps) = 0;
    +my ($new_page) = 0;
    +while () {
    +    my $ln = $.;
    +    chomp;
    +
    +    if (/^$/) {
    +	$new_page = 1;
    +	print LOG_HTML "

    \n";
    +	next;
    +    }
    +
    +    my $log_class;
    +    if ($new_page) {
    +	$new_page = 0;
    +	$log_class = "step";
    +	if (my ($product) = /^Saving (.*)$/) {
    +	    print INDEX "\n  " if !$n_steps;
    +	    print INDEX "
  1. ", encode_entities ($_); + print INDEX " (log)"; + $n_products = 0; + } + } else { + if (my ($diagnostic) = /(error|warning):/) { + if ($n_products) { + print INDEX " \n"; + $n_products = 0; + } + print INDEX "

    "; + print INDEX ""; + print INDEX encode_entities ($_); + print INDEX "

    \n"; + $log_class = "$diagnostic"; + } + } + printf LOG_HTML "%4d ", $ln, $ln; + if (defined ($log_class)) { + print LOG_HTML "", encode_entities ($_), "\n"; + } else { + print LOG_HTML encode_entities ($_), "\n"; + } +} +print INDEX " \n" if $n_products; +print INDEX "
  2. \n" if $n_steps; +print INDEX < + + +EOF + +print LOG_HTML < + + +EOF + +open (CSS, '>', "build.css"); +print CSS <p { + margin: 0pt 0pt 0pt 0em +} +body>p + p { + text-indent: 1.5em; +} +H1 { + font-size: 150%; + margin-left: -1.33em +} +H2 { + font-size: 125%; + font-weight: bold; + margin-left: -.8em +} +H3 { + font-size: 100%; + font-weight: bold; + margin-left: -.5em } +H4 { + font-size: 100%; + margin-left: 0em +} +H1, H2, H3, H4, H5, H6 { + font-family: sans-serif; + color: blue +} +html { + margin: 0 +} + +a:link { + color: blue; + text-decoration: none; +} +a:visited { + color: gray; + text-decoration: none; +} +a:active { + color: black; + text-decoration: none; +} +a:hover { + text-decoration: underline +} + +.step { + font-weight: bold +} +.warning { + background: yellow; + margin-top: 0; + margin-bottom: 0 +} +.error { + background: orange; + margin-top: 0; + margin-bottom: 0 +} +EOF -- 2.30.2