7 use HTML::Entities qw();
11 return HTML::Entities::encode_entities($_[0], "<&>'\"");
14 my $gitweb_url = 'http://benpfaff.org/cgi-bin/gitweb.cgi?p=pspp;a=blob;f=[FILE];hb=[BRANCH]#l[LINE]';
16 open (LOG, '<', "LOG");
17 open (LOG_HTML, '>', "log.html");
22 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
23 <link rel="stylesheet" href="build.css">
27 print LOG_HTML "<pre>";
32 if (open (VARS, "<", $file)) {
35 my ($key, $value) = /^([^=]+)=(.*)/ or next;
42 my (%vars) = read_vars ('VARS');
47 my ($result) = "failure";
58 print LOG_HTML "</pre><hr><pre>\n";
62 if (/Entering directory `(.*)'$/) {
64 } elsif (/Leaving directory `(.*)'$/) {
72 if (my ($name, $product) = /^Saving(?:\s+([^:]*):)?\s+(.*)$/) {
73 my $href = "$product/index.html";
74 $href = $product if ! -e $href;
77 $p{NAME} = $name if defined ($name);
78 $p{PRODUCT} = $product;
81 push (@products, \%p);
82 push (@{$steps[$#steps]{CHILDREN}}, \%p);
84 if (defined ($name) && $name eq 'source distribution') {
85 open (DIST, '-|', "zcat $product | tar tf -");
86 while (my $line = <DIST>) {
88 $line =~ s%^([./])*%%; # Trim leading ./
89 $dist_files{$line} = 1;
90 if (!defined ($dist_dir)) {
91 $dist_dir = (split ('/', $line))[0];
102 $result = 'success' if $_ eq 'Success';
104 if (my ($diagnostic) = /(error|warning):/i) {
106 $d{DIAGNOSTIC} = lc ($diagnostic);
110 if (@dirstack && defined ($dist_dir)
111 && (my ($match, $file, $line) = /^(([^\s:]+):(\d+):)/)) {
112 $file = File::Spec->rel2abs ($file, $dirstack[$#dirstack]);
113 my (@path) = grep ($_ ne '' && $_ ne '.', split ('/', $file));
114 for (my $i = 1; $i <= $#path; ) {
115 if ($path[$i] eq '..') {
116 splice (@path, $i - 1, 2);
123 for (my $i = $#path; $i >= 0; $i--) {
124 if ($path[$i] eq $dist_dir) {
125 my $dist_file = join ('/', @path[$i..$#path]);
126 if (exists ($dist_files{$dist_file})) {
127 $d{MATCH} = length ($match);
129 $d{FILE} = $dist_file;
135 push (@{$steps[$#steps]{CHILDREN}}, \%d);
137 $log_class = "$diagnostic";
140 printf LOG_HTML "<a name=\"%d\"><tt>%4d</tt></a> ", $ln, $ln;
141 if (defined ($log_class)) {
142 print LOG_HTML "<span class=\"$log_class\">", encode_entities ($_), "</span>\n";
144 print LOG_HTML encode_entities ($_), "\n";
148 open (INDEX, '>','index.html');
153 <link rel="stylesheet" href="build.css">
158 print INDEX "<h1>Build ", $vars{"build_number"}, ": $result</h1>\n";
160 print INDEX "<h2>Build Properties</h2>\n";
161 print INDEX "<table>\n";
162 print INDEX "<tr><th>Name</th><th>Value</th></tr>\n";
163 foreach my $key (sort (keys (%vars))) {
165 print INDEX "<td>", encode_entities ($key), "</td>";
166 print INDEX "<td>", encode_entities ($vars{$key}), "</td>";
167 print INDEX "</tr>\n";
169 print INDEX "</table>\n";
171 print INDEX "<h2>Build Products</h2>\n";
172 print INDEX "<ul>\n";
173 foreach my $p (@products) {
175 print INDEX encode_entities ($p->{NAME}), ": " if defined ($p->{NAME});
176 print INDEX "<a href=\"", encode_entities ($p->{HREF}), "\">";
177 print INDEX encode_entities ($p->{PRODUCT});
178 print INDEX "</a></li>\n";
180 print INDEX "</ul>\n";
184 return "<small><a href=\"log.html#$ln\">(log)</a></small>";
187 print INDEX "<h2>Build Summary</h2>\n";
188 print INDEX "<ol>\n";
189 foreach my $s (@steps) {
190 print INDEX "<li>", encode_entities ($s->{TITLE});
191 print INDEX " ", log_link ($s->{LN});
192 foreach my $c (@{$s->{CHILDREN}}) {
193 if (defined ($c->{DIAGNOSTIC})) {
194 print INDEX "<p class=\"$c->{DIAGNOSTIC}\">";
195 if (defined ($c->{MATCH})) {
196 my $href = $gitweb_url;
197 $href =~ s/\[FILE\]/uri_escape ($c->{FILE})/ge;
198 $href =~ s/\[LINE\]/$c->{LINE}/g;
199 $href =~ s/\[BRANCH\]/uri_escape ($vars{'dist_commit'})/e;
201 print INDEX '<a href="', encode_entities ($href), '">';
202 print INDEX encode_entities (substr ($c->{MESSAGE},
205 print INDEX encode_entities (substr ($c->{MESSAGE},
208 print INDEX encode_entities ($c->{MESSAGE});
210 print INDEX " ", log_link ($c->{LN});
211 print INDEX "</p>\n";
213 print INDEX "<p>→ <a href=\"", encode_entities ($c->{HREF}), "\">";
214 print INDEX encode_entities ($c->{PRODUCT});
216 print INDEX log_link ($c->{LN});
217 print INDEX "</p>\n";
220 print INDEX "</li>\n";
222 print INDEX "</ol>\n";
229 print LOG_HTML <<EOF;
235 open (CSS, '>', "build.css");
240 padding: 0em 3em 0em 3em;
244 margin: 0pt 0pt 0pt 0em
266 H1, H2, H3, H4, H5, H6 {
267 font-family: sans-serif;
276 text-decoration: none;
280 text-decoration: none;
284 text-decoration: none;
287 text-decoration: underline