X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=blobdiff_plain;f=results2html;h=4bf398d35c49b9734d92578e3abdc4a6c71f37d2;hp=1b4622137f65ceb6a2b660000700a6fee5b1ef46;hb=215d09f8d91f75eac208d4945906a959bc508701;hpb=9dcb38e8079aa5258fb9abeccd8d1d23cf94376c diff --git a/results2html b/results2html index 1b4622137f..4bf398d35c 100755 --- a/results2html +++ b/results2html @@ -3,21 +3,12 @@ use strict; use warnings; +use File::Spec; use HTML::Entities; open (LOG, '<', "LOG"); -open (INDEX, '>','index.html'); open (LOG_HTML, '>', "log.html"); -print INDEX < - - - - -
    -EOF - print LOG_HTML < @@ -27,47 +18,88 @@ print LOG_HTML <"; -my ($n_products) = 0; -my ($n_steps) = 0; +sub read_vars { + my ($file) = @_; + my %vars = (); + if (open (VARS, "<", $file)) { + while () { + chomp; + my ($key, $value) = /^([^=]+)=(.*)/ or next; + $vars{$key} = $value; + } + close (VARS); + } + return %vars; +} +my (%vars) = read_vars ('VARS'); + +my (@products); +my (@steps); my ($new_page) = 0; +my ($result) = "failure"; +my @dirstack; while () { my $ln = $.; chomp; if (/^ $/) { $new_page = 1; + @dirstack = (); print LOG_HTML "
    \n";
     	next;
         }
     
    +    if (/Entering directory `(.*)'$/) {
    +        push (@dirstack, $1);
    +    } elsif (/Leaving directory `(.*)'$/) {
    +        pop (@dirstack);
    +    }
    +
         my $log_class;
         if ($new_page) {
     	$new_page = 0;
     	$log_class = "step";
    -	if (my ($product) = /^Saving (.*)$/) {
    -	    print INDEX "\n  
      \n" if !$n_products++; + if (my ($name, $product) = /^Saving(?:([^:]*):)?\s+(.*)$/) { my $href = "$product/index.html"; $href = $product if ! -e $href; - print INDEX "
    • "; - print INDEX encode_entities ($product), ""; - print INDEX " (log)"; - print INDEX "
    • \n"; + + my (%p); + $p{NAME} = $name if defined ($name); + $p{PRODUCT} = $product; + $p{HREF} = $href; + $p{LN} = $ln; + push (@products, \%p); + push (@{$steps[$#steps]{CHILDREN}}, \%p); } else { - print INDEX "
    " if !$n_steps; - print INDEX "
  1. ", encode_entities ($_); - print INDEX " (log)"; - $n_products = 0; + my (%s); + $s{TITLE} = $_; + $s{LN} = $ln; + push (@steps, \%s); } + $result = 'success' if $_ eq 'Success'; } else { - if (my ($diagnostic) = /(error|warning):/) { - if ($n_products) { - print INDEX " \n"; - $n_products = 0; + if (my ($diagnostic) = /(error|warning):/i) { + my (%d); + $d{DIAGNOSTIC} = lc ($diagnostic); + $d{MESSAGE} = $_; + $d{LN} = $ln; + + if (@dirstack && (my ($file, $line) = /^([^\s:]+):(\d+):\s/)) { + $file = File::Spec->rel2abs ($file, $dirstack[$#dirstack]); + my (@path) = grep ($_ ne '' && $_ ne '.', split ('/', $file)); + for (my $i = 0; $i < $#path; ) { + if ($path[$i + 1] eq '..') { + splice (@path, $i, 2); + } else { + $i++; + } + } + + $d{LINE} = $line; + $d{FILE} = join ('/', @path); } - print INDEX "

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

    \n"; + push (@{$steps[$#steps]{CHILDREN}}, \%d); + $log_class = "$diagnostic"; } } @@ -78,10 +110,74 @@ while () { print LOG_HTML encode_entities ($_), "\n"; } } -print INDEX " \n" if $n_products; -print INDEX "
  2. \n" if $n_steps; + +open (INDEX, '>','index.html'); + +print INDEX < + + + + +EOF + +print INDEX "

    Build ", $vars{"build_number"}, ": $result

    \n"; + +print INDEX "

    Build Properties

    \n"; +print INDEX "\n"; +print INDEX "\n"; +foreach my $key (sort (keys (%vars))) { + print INDEX ""; + print INDEX ""; + print INDEX ""; + print INDEX "\n"; +} +print INDEX "
    NameValue
    ", encode_entities ($key), "", encode_entities ($vars{$key}), "
    \n"; + +print INDEX "

    Build Products

    \n"; +print INDEX "\n"; + +sub log_link { + my ($ln) = @_; + return "(log)"; +} + +print INDEX "

    Build Summary

    \n"; +print INDEX "
      \n"; +foreach my $s (@steps) { + print INDEX "
    1. ", encode_entities ($s->{TITLE}); + print INDEX " ", log_link ($s->{LN}); + foreach my $c (@{$s->{CHILDREN}}) { + if (defined ($c->{DIAGNOSTIC})) { + print INDEX "

      {DIAGNOSTIC}\">"; + print INDEX "{LN}\">"; + print INDEX encode_entities ($c->{MESSAGE}); + print INDEX ""; + if (exists $c->{FILE}) { + print INDEX " in $c->{FILE}"; + } + print INDEX "

      \n"; + } else { + print INDEX "

      {HREF}), "\">"; + print INDEX encode_entities ($c->{PRODUCT}); + print INDEX " "; + print INDEX log_link ($c->{LN}); + print INDEX "

      \n"; + } + } + print INDEX "
    2. \n"; +} +print INDEX "
    \n"; + print INDEX < EOF @@ -97,7 +193,7 @@ print CSS <p { @@ -147,17 +243,17 @@ a:hover { text-decoration: underline } +ol>li>p { + margin-top: 0; + margin-bottom: 0 +} .step { font-weight: bold } .warning { - background: yellow; - margin-top: 0; - margin-bottom: 0 + background: yellow } .error { - background: orange; - margin-top: 0; - margin-bottom: 0 + background: orange } EOF