X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=results2html;h=c6aaab634d1724057a80e7c0676dc76c237c2283;hb=8e8f500a7d956de742daa3a7709ef815d6ce10b6;hp=4bf398d35c49b9734d92578e3abdc4a6c71f37d2;hpb=ec687b924f4a605bc8c2bc441105f47757a7c6cf;p=pspp diff --git a/results2html b/results2html index 4bf398d35c..c6aaab634d 100755 --- a/results2html +++ b/results2html @@ -5,6 +5,9 @@ use warnings; use File::Spec; use HTML::Entities; +use URI::Escape; + +my $gitweb_url = 'http://benpfaff.org/cgi-bin/gitweb.cgi?p=pspp;a=blob;f=[FILE];hb=[BRANCH]#l[LINE]'; open (LOG, '<', "LOG"); open (LOG_HTML, '>', "log.html"); @@ -35,20 +38,14 @@ my (%vars) = read_vars ('VARS'); my (@products); my (@steps); -my ($new_page) = 0; my ($result) = "failure"; +my (%dist_files); +my ($dist_dir); 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 `(.*)'$/) {
@@ -56,10 +53,9 @@ while () {
     }
 
     my $log_class;
-    if ($new_page) {
-	$new_page = 0;
+    if (my ($title) = /^## (.*) ##$/) {
 	$log_class = "step";
-	if (my ($name, $product) = /^Saving(?:([^:]*):)?\s+(.*)$/) {
+	if (my ($name, $product) = $title =~ /^Saving(?:\s+([^:]*):)?\s+(.*)$/) {
 	    my $href = "$product/index.html";
 	    $href = $product if ! -e $href;
 
@@ -70,13 +66,27 @@ while () {
 	    $p{LN} = $ln;
 	    push (@products, \%p);
 	    push (@{$steps[$#steps]{CHILDREN}}, \%p);
-	} else {
+
+	    if (defined ($name) && $name eq 'source distribution') {
+		open (DIST, '-|', "zcat $product | tar tf -");
+		while (my $line = ) {
+		    chomp $line;
+		    $line =~ s%^([./])*%%; # Trim leading ./
+		    $dist_files{$line} = 1;
+		    if (!defined ($dist_dir)) {
+			$dist_dir = (split ('/', $line))[0];
+		    }
+		}
+		close (DIST);
+	    }
+	} elsif ($title eq 'Success') {
+	    $result = 'success';
+	} elsif ($title !~ /^-+$/) {
 	    my (%s);
-	    $s{TITLE} = $_;
+	    $s{TITLE} = $title;
 	    $s{LN} = $ln;
 	    push (@steps, \%s);
 	}
-	$result = 'success' if $_ eq 'Success';
     } else {
 	if (my ($diagnostic) = /(error|warning):/i) {
 	    my (%d);
@@ -84,19 +94,30 @@ while () {
 	    $d{MESSAGE} = $_;
 	    $d{LN} = $ln;
 
-	    if (@dirstack && (my ($file, $line) = /^([^\s:]+):(\d+):\s/)) {
+	    if (@dirstack && defined ($dist_dir)
+		&& (my ($match, $file, $line) = /^(([^\s:]+):(\d+):)/)) {
 		$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);
+		for (my $i = 1; $i <= $#path; ) {
+		    if ($path[$i] eq '..') {
+			splice (@path, $i - 1, 2);
+			$i-- if $i > 1;
 		    } else {
 			$i++;
 		    }
 		}
 
-		$d{LINE} = $line;
-		$d{FILE} = join ('/', @path);
+		for (my $i = $#path; $i >= 0; $i--) {
+		    if ($path[$i] eq $dist_dir) {
+			my $dist_file = join ('/', @path[$i..$#path]);
+			if (exists ($dist_files{$dist_file})) {
+			    $d{MATCH} = length ($match);
+			    $d{LINE} = $line;
+			    $d{FILE} = $dist_file;
+			}
+			last;
+		    }
+		}
 	    }
 	    push (@{$steps[$#steps]{CHILDREN}}, \%d);
 
@@ -158,12 +179,22 @@ foreach my $s (@steps) {
     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}"; + if (defined ($c->{MATCH})) { + my $href = $gitweb_url; + $href =~ s/\[FILE\]/uri_escape ($c->{FILE})/ge; + $href =~ s/\[LINE\]/$c->{LINE}/g; + $href =~ s/\[BRANCH\]/uri_escape ($vars{'dist_commit'})/e; + + print INDEX ''; + print INDEX encode_entities (substr ($c->{MESSAGE}, + 0, $c->{MATCH})); + print INDEX ''; + print INDEX encode_entities (substr ($c->{MESSAGE}, + $c->{MATCH})); + } else { + print INDEX encode_entities ($c->{MESSAGE}); } + print INDEX " ", log_link ($c->{LN}); print INDEX "

\n"; } else { print INDEX "

{HREF}), "\">"; @@ -188,6 +219,11 @@ print LOG_HTML < EOF +open (HTACCESS, '>', '.htaccess'); +print HTACCESS <', "build.css"); print CSS <