10 my $gitweb_url = 'http://benpfaff.org/cgi-bin/gitweb.cgi?p=pspp;a=blob;f=[FILE];hb=[BRANCH]#l[LINE]';
12 open (LOG, '<', "LOG");
13 open (LOG_HTML, '>', "log.html");
18 <link rel="stylesheet" href="build.css">
22 print LOG_HTML "<pre>";
27 if (open (VARS, "<", $file)) {
30 my ($key, $value) = /^([^=]+)=(.*)/ or next;
37 my (%vars) = read_vars ('VARS');
42 my ($result) = "failure";
53 print LOG_HTML "</pre><hr><pre>\n";
57 if (/Entering directory `(.*)'$/) {
59 } elsif (/Leaving directory `(.*)'$/) {
67 if (my ($name, $product) = /^Saving(?:\s+([^:]*):)?\s+(.*)$/) {
68 my $href = "$product/index.html";
69 $href = $product if ! -e $href;
72 $p{NAME} = $name if defined ($name);
73 $p{PRODUCT} = $product;
76 push (@products, \%p);
77 push (@{$steps[$#steps]{CHILDREN}}, \%p);
79 if (defined ($name) && $name eq 'source distribution') {
80 open (DIST, '-|', "zcat $product | tar tf -");
81 while (my $line = <DIST>) {
83 $line =~ s%^([./])*%%; # Trim leading ./
84 $dist_files{$line} = 1;
85 if (!defined ($dist_dir)) {
86 $dist_dir = (split ('/', $line))[0];
97 $result = 'success' if $_ eq 'Success';
99 if (my ($diagnostic) = /(error|warning):/i) {
101 $d{DIAGNOSTIC} = lc ($diagnostic);
105 if (@dirstack && defined ($dist_dir)
106 && (my ($match, $file, $line) = /^(([^\s:]+):(\d+):)/)) {
107 $file = File::Spec->rel2abs ($file, $dirstack[$#dirstack]);
108 my (@path) = grep ($_ ne '' && $_ ne '.', split ('/', $file));
109 for (my $i = 1; $i <= $#path; ) {
110 if ($path[$i] eq '..') {
111 splice (@path, $i - 1, 2);
118 for (my $i = $#path; $i >= 0; $i--) {
119 if ($path[$i] eq $dist_dir) {
120 my $dist_file = join ('/', @path[$i..$#path]);
121 if (exists ($dist_files{$dist_file})) {
122 $d{MATCH} = length ($match);
124 $d{FILE} = $dist_file;
130 push (@{$steps[$#steps]{CHILDREN}}, \%d);
132 $log_class = "$diagnostic";
135 printf LOG_HTML "<a name=\"%d\"><tt>%4d</tt></a> ", $ln, $ln;
136 if (defined ($log_class)) {
137 print LOG_HTML "<span class=\"$log_class\">", encode_entities ($_), "</span>\n";
139 print LOG_HTML encode_entities ($_), "\n";
143 open (INDEX, '>','index.html');
148 <link rel="stylesheet" href="build.css">
153 print INDEX "<h1>Build ", $vars{"build_number"}, ": $result</h1>\n";
155 print INDEX "<h2>Build Properties</h2>\n";
156 print INDEX "<table>\n";
157 print INDEX "<tr><th>Name</th><th>Value</th></tr>\n";
158 foreach my $key (sort (keys (%vars))) {
160 print INDEX "<td>", encode_entities ($key), "</td>";
161 print INDEX "<td>", encode_entities ($vars{$key}), "</td>";
162 print INDEX "</tr>\n";
164 print INDEX "</table>\n";
166 print INDEX "<h2>Build Products</h2>\n";
167 print INDEX "<ul>\n";
168 foreach my $p (@products) {
170 print INDEX encode_entities ($p->{NAME}), ": " if defined ($p->{NAME});
171 print INDEX "<a href=\"", encode_entities ($p->{HREF}), "\">";
172 print INDEX encode_entities ($p->{PRODUCT});
173 print INDEX "</a></li>\n";
175 print INDEX "</ul>\n";
179 return "<small><a href=\"log.html#$ln\">(log)</a></small>";
182 print INDEX "<h2>Build Summary</h2>\n";
183 print INDEX "<ol>\n";
184 foreach my $s (@steps) {
185 print INDEX "<li>", encode_entities ($s->{TITLE});
186 print INDEX " ", log_link ($s->{LN});
187 foreach my $c (@{$s->{CHILDREN}}) {
188 if (defined ($c->{DIAGNOSTIC})) {
189 print INDEX "<p class=\"$c->{DIAGNOSTIC}\">";
190 if (defined ($c->{MATCH})) {
191 my $href = $gitweb_url;
192 $href =~ s/\[FILE\]/uri_escape ($c->{FILE})/ge;
193 $href =~ s/\[LINE\]/$c->{LINE}/g;
194 $href =~ s/\[BRANCH\]/uri_escape ($vars{'dist_commit'})/e;
196 print INDEX '<a href="', encode_entities ($href), '">';
197 print INDEX encode_entities (substr ($c->{MESSAGE},
200 print INDEX encode_entities (substr ($c->{MESSAGE},
203 print INDEX encode_entities ($c->{MESSAGE});
205 print INDEX " ", log_link ($c->{LN});
206 print INDEX "</p>\n";
208 print INDEX "<p>→ <a href=\"", encode_entities ($c->{HREF}), "\">";
209 print INDEX encode_entities ($c->{PRODUCT});
211 print INDEX log_link ($c->{LN});
212 print INDEX "</p>\n";
215 print INDEX "</li>\n";
217 print INDEX "</ol>\n";
224 print LOG_HTML <<EOF;
230 open (CSS, '>', "build.css");
235 padding: 0em 3em 0em 3em;
239 margin: 0pt 0pt 0pt 0em
261 H1, H2, H3, H4, H5, H6 {
262 font-family: sans-serif;
271 text-decoration: none;
275 text-decoration: none;
279 text-decoration: none;
282 text-decoration: underline