1999-06-25 02:07:54 +04:00
|
|
|
#! /usr/bonsaitools/bin/perl
|
1999-06-25 02:33:33 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla Public License
|
|
|
|
# Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
# compliance with the License. You may obtain a copy of the License at
|
|
|
|
# http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS IS"
|
|
|
|
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing rights and limitations
|
|
|
|
# under the License.
|
|
|
|
#
|
|
|
|
# The Original Code is Tinderbox
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
# Corporation. Portions created by Netscape are Copyright (C) 1999
|
|
|
|
# Netscape Communications Corporation. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): Stephen Lamm <slamm@mozilla.org>
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-08-02 22:04:23 +04:00
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# Run this script on lounge.mozilla.org. To run it there,
|
|
|
|
# cd to /opt/webtools/tinderbox and run it without
|
|
|
|
# any arguments:
|
|
|
|
#
|
1999-08-26 20:27:45 +04:00
|
|
|
# ./warnings.pl [--debug]
|
1999-08-02 22:04:23 +04:00
|
|
|
#
|
|
|
|
|
1999-06-25 02:07:54 +04:00
|
|
|
use FileHandle;
|
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
# A few global variables are used in the program.
|
1999-09-09 03:40:40 +04:00
|
|
|
#
|
1999-10-22 22:53:56 +04:00
|
|
|
# %warnings - Main warnings data structure
|
|
|
|
# $warnings{$file}{$line} => {
|
|
|
|
# first_seen_line =>, # First place in build log where warning is seen.
|
|
|
|
# count =>, # Number of warnings attributed to this line.
|
|
|
|
# ignorecount =>, # Number of ignored warnings for this line.
|
|
|
|
# list => [ { # Array of hash tables for each warning.
|
|
|
|
# log_file =>, # Then name of the log file from which the warning came.
|
|
|
|
# warning_text =>, # The actual text of the warning
|
|
|
|
# ignore =>, # Is this warning ignored? (values are 0 or 1)
|
|
|
|
# }, {...}, ... ]
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# %warnings_by_who - Like %warnings, but adds indexing by who, and blame fields.
|
|
|
|
# $warnings_by_who{$who}{$file}{$line} => {
|
|
|
|
# first_seen_line =>,
|
|
|
|
# count =>,
|
|
|
|
# ignorecount =>,
|
|
|
|
# list => [ {
|
|
|
|
# log_file =>,
|
|
|
|
# warning_text =>,
|
|
|
|
# ignore =>,
|
|
|
|
# }, {...}, ... ]
|
|
|
|
# line_rev =>, # CVS revision number of line
|
|
|
|
# source =>, # Five lines of source code centered on the line
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# %who_count - Number of warnings attributed to each email address
|
|
|
|
# $who_count{$who} = $count
|
|
|
|
#
|
|
|
|
# @ignore - Array of regexp's of warnings to ignore
|
1999-11-09 20:58:56 +03:00
|
|
|
# @ignore_dir - Array of hashes of warnings matched with directories
|
|
|
|
# @ignore_dir = (
|
|
|
|
# { warning=>'<warning pattern>', dir=>'<source patter>' },
|
|
|
|
# {...}, ...
|
|
|
|
# )
|
1999-10-22 22:53:56 +04:00
|
|
|
# @ignore_match - Array of hashes of warnings matched with source to ignore
|
|
|
|
# @ignore_match = (
|
|
|
|
# { warning=>'<warning pattern>', source=>'<source patter>' },
|
|
|
|
# {...}, ...
|
|
|
|
# )
|
|
|
|
|
2000-01-08 05:04:26 +03:00
|
|
|
sub usage {
|
2000-02-18 02:27:17 +03:00
|
|
|
warn "usage: warnings.pl <tree/logfile>\n";
|
2000-01-08 05:04:26 +03:00
|
|
|
}
|
1999-09-09 03:40:40 +04:00
|
|
|
|
1999-08-26 21:13:49 +04:00
|
|
|
# This is for gunzip (should add a configure script to handle this).
|
2000-04-19 02:20:30 +04:00
|
|
|
$ENV{PATH} .= "/bin:/usr/local/bin";
|
1999-08-26 21:13:49 +04:00
|
|
|
|
2000-01-08 05:04:26 +03:00
|
|
|
$debug = 1, shift @ARGV if $ARGV[0] eq '--debug';
|
|
|
|
|
|
|
|
&usage, die "Error: Not enough arguments\n" if $#ARGV == -1;
|
1999-08-26 20:27:45 +04:00
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
# Load tinderbox build data.
|
|
|
|
# (So we can find the last successful build for the tree of intestest.)
|
2000-02-18 02:27:17 +03:00
|
|
|
$log_file = shift @ARGV;
|
1999-07-23 23:36:38 +04:00
|
|
|
# tinderbox/tbglobals.pl uses many shameful globals
|
2000-02-18 02:27:17 +03:00
|
|
|
|
|
|
|
&usage, die "Logfile does not exist, $log_file\n" unless -e $log_file;
|
|
|
|
|
|
|
|
($tree, $log_file) = split '/', $log_file;
|
1999-06-25 02:07:54 +04:00
|
|
|
$form{tree} = $tree;
|
2000-02-18 02:27:17 +03:00
|
|
|
|
|
|
|
&usage, die "Tree does not exist, $tree\n" unless -d $tree;
|
|
|
|
|
1999-07-23 23:36:38 +04:00
|
|
|
require 'tbglobals.pl';
|
1999-10-22 22:53:56 +04:00
|
|
|
require "$tree/treedata.pl";
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-11-17 06:52:53 +03:00
|
|
|
$source_root = 'mozilla';
|
1999-09-09 03:19:42 +04:00
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
# ===================================================================
|
|
|
|
# Warnings to ignore
|
|
|
|
|
2000-02-18 02:27:17 +03:00
|
|
|
@mac_ignore = (
|
|
|
|
'function has no prototype',
|
|
|
|
'inline function call .* not inlined',
|
|
|
|
);
|
|
|
|
|
1999-06-26 00:21:17 +04:00
|
|
|
@ignore = (
|
|
|
|
'location of the previous definition',
|
1999-07-08 04:06:26 +04:00
|
|
|
'\' was hidden',
|
1999-10-22 21:34:16 +04:00
|
|
|
#'declaration of \`index\' shadows global',
|
1999-11-03 21:52:13 +03:00
|
|
|
'declaration of \`ws\' shadows global', # From istream
|
|
|
|
'declaration of \`free\' shadows global', # From strstream.h
|
|
|
|
'declaration of \`(?:y0|y1|j1|remainder)\' shadows global', #From mathcalls.h
|
1999-10-15 22:42:27 +04:00
|
|
|
'is not \(any longer\) pertinent', # cvs warning we can safely ignore
|
1999-10-22 21:34:16 +04:00
|
|
|
'ANSI C forbids long long integer constants', # js uses long long constants
|
1999-06-26 00:21:17 +04:00
|
|
|
);
|
1999-10-22 22:53:56 +04:00
|
|
|
|
1999-11-09 20:58:56 +03:00
|
|
|
# Patterns that need to match warning text and source directory
|
|
|
|
#
|
|
|
|
@ignore_dir = (
|
|
|
|
# mailnews is stuck with this
|
1999-11-09 21:01:26 +03:00
|
|
|
{ warning=>'aggregate has a partly bracketed initializer',
|
1999-11-17 07:12:00 +03:00
|
|
|
dir=>'mailnews/mime/' }
|
1999-11-09 20:58:56 +03:00
|
|
|
);
|
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
# Patterns that need to match warning text and source code text
|
|
|
|
#
|
1999-08-26 20:27:45 +04:00
|
|
|
@ignore_match = (
|
1999-09-09 03:52:32 +04:00
|
|
|
{ warning=>'statement with no effect', source=>'(?:JS_|PR_)?ASSERT'},
|
1999-08-26 20:27:45 +04:00
|
|
|
);
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
|
|
|
|
# ===================================================================
|
|
|
|
# beginning of main
|
|
|
|
|
|
|
|
|
|
|
|
# Build a hash table of all the files in the tree.
|
|
|
|
# We need this because the warnings do not always give the full
|
|
|
|
# paths to files.
|
|
|
|
#
|
1999-06-25 02:07:54 +04:00
|
|
|
print STDERR "Building hash of file names...";
|
2000-03-24 00:14:51 +03:00
|
|
|
($file_bases, $file_fullpaths) = build_file_hash($cvs_root, @cvs_modules);
|
1999-06-25 02:07:54 +04:00
|
|
|
print STDERR "done.\n";
|
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
# Find the build we want and generate warnings for it
|
|
|
|
#
|
2000-02-18 02:27:17 +03:00
|
|
|
$br = find_build_record($tree,$log_file);
|
|
|
|
|
|
|
|
%warnings = ();
|
|
|
|
%warnings_by_who = ();
|
|
|
|
%who_count = ();
|
|
|
|
$total_warnings_count = 0;
|
|
|
|
$total_ignored_count = 0;
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
# Parse the build log for warnings
|
|
|
|
#
|
2000-02-18 02:27:17 +03:00
|
|
|
warn "Parsing $br->{buildname}, $log_file\n";
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-07-23 02:17:28 +04:00
|
|
|
$fh = new FileHandle "gunzip -c $tree/$log_file |"
|
|
|
|
or die "Unable to open $tree/$log_file\n";
|
2000-02-18 02:27:17 +03:00
|
|
|
if ($br->{errorparser} eq 'unix') {
|
|
|
|
gcc_parser($fh, $cvs_root, $tree, $log_file, $file_bases, $file_fullpaths);
|
|
|
|
} elsif ($br->{errorparser} eq 'mac') {
|
|
|
|
mac_parser($fh, $cvs_root, $tree, $log_file, $file_bases, $file_fullpaths);
|
|
|
|
}
|
1999-06-25 02:33:33 +04:00
|
|
|
$fh->close;
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
# Attach blame to all the warnings
|
|
|
|
# (Yes, global variables are flying around.)
|
2000-03-24 00:14:51 +03:00
|
|
|
&build_blame($cvs_root, $file_fullpaths);
|
1999-06-25 02:33:33 +04:00
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
# Come up with the temporary filenames for the output
|
|
|
|
#
|
1999-06-25 02:33:33 +04:00
|
|
|
my $warn_file = "$tree/warn$log_file";
|
1999-09-09 03:40:40 +04:00
|
|
|
$warn_file =~ s/\.gz$/.html/;
|
|
|
|
my $warn_file_by_file = $warn_file;
|
|
|
|
$warn_file_by_file =~ s/\.html$/-by-file.html/;
|
1999-06-25 02:33:33 +04:00
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
# Write the warnings indexed by who
|
|
|
|
#
|
1999-06-25 02:33:33 +04:00
|
|
|
$fh->open(">$warn_file") or die "Unable to open $warn_file: $!\n";
|
1999-09-09 03:40:40 +04:00
|
|
|
my $time_str = print_html_by_who($fh, $br);
|
1999-06-25 02:33:33 +04:00
|
|
|
$fh->close;
|
1999-07-22 01:09:41 +04:00
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
# Write the warnings indexed by file
|
|
|
|
#
|
1999-09-09 03:40:40 +04:00
|
|
|
# $fh->open(">$warn_file_by_file")
|
|
|
|
# or die "Unable to open $warn_file_by_file: $!\n";
|
|
|
|
# print_html_by_file($fh, $br);
|
|
|
|
# $fh->close;
|
1999-07-22 01:09:41 +04:00
|
|
|
|
2000-02-18 03:16:52 +03:00
|
|
|
my $total_unignored_warnings = $total_warnings_count - $total_ignored_count;
|
|
|
|
|
|
|
|
if ($total_unignored_warnings > 0) {
|
|
|
|
# Add an entry to the warning log
|
|
|
|
#
|
|
|
|
my $warn_log = "$tree/warnings.dat";
|
|
|
|
$fh->open(">>$warn_log") or die "Unable to open $warn_log: $!\n";
|
|
|
|
print $fh "$log_file|$total_unignored_warnings\n";
|
|
|
|
$fh->close;
|
|
|
|
}
|
1999-06-25 02:07:54 +04:00
|
|
|
|
|
|
|
# end of main
|
|
|
|
# ===================================================================
|
|
|
|
|
|
|
|
sub build_file_hash {
|
2000-03-24 00:14:51 +03:00
|
|
|
my ($cvs_root, @modules) = @_;
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-10-11 23:42:53 +04:00
|
|
|
read_cvs_modules_file();
|
1999-06-25 02:07:54 +04:00
|
|
|
|
2000-03-24 00:14:51 +03:00
|
|
|
local %bases = (); # Set in find_cvs_files
|
|
|
|
local %fullpath = (); # Set in find_cvs_files
|
1999-06-25 02:07:54 +04:00
|
|
|
|
2000-03-24 00:14:51 +03:00
|
|
|
for my $module_item (@modules) {
|
|
|
|
my $module = $module_item->[0];
|
|
|
|
local $tag = $module_item->[1]; # Used in find_cvs_files
|
|
|
|
|
|
|
|
my @include_list = ();
|
|
|
|
my @exclude_list = ();
|
|
|
|
|
|
|
|
if (-d "$cvs_root/$module") {
|
|
|
|
$include_list[0] = $module
|
|
|
|
} else {
|
|
|
|
expand_cvs_modules($module, \@include_list, \@exclude_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
local $exclude_pat = join '|', @exclude_list; # Used in find_cvs_files
|
|
|
|
|
2000-04-19 01:40:55 +04:00
|
|
|
use Cwd;
|
|
|
|
my $save_dir = cwd;
|
|
|
|
|
2000-03-24 00:14:51 +03:00
|
|
|
use File::Find;
|
|
|
|
for my $include (@include_list) {
|
|
|
|
$include .= ",v" unless -d "$cvs_root/$include";
|
|
|
|
&find(\&find_cvs_files, "$cvs_root/$include");
|
|
|
|
}
|
2000-04-19 01:40:55 +04:00
|
|
|
|
|
|
|
chdir $save_dir;
|
1999-10-11 23:42:53 +04:00
|
|
|
}
|
|
|
|
return \%bases, \%fullpath;
|
|
|
|
}
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-10-11 23:42:53 +04:00
|
|
|
sub read_cvs_modules_file
|
|
|
|
{
|
|
|
|
local $_;
|
1999-10-22 22:53:56 +04:00
|
|
|
open MODULES, "$cvs_root/CVSROOT/modules"
|
|
|
|
or die "Unable to open modules file: $cvs_root/CVSROOT/modules\n";
|
1999-10-11 23:42:53 +04:00
|
|
|
while (<MODULES>) {
|
|
|
|
if (/ -a /) {
|
|
|
|
while (/\\$/) {
|
|
|
|
chomp;
|
|
|
|
chop;
|
|
|
|
$_ .= <MODULES>;
|
|
|
|
}
|
|
|
|
chomp;
|
|
|
|
my ($module_name, $list) = split /\s+-a\s+/, $_, 2;
|
|
|
|
$modules{$module_name} = [ split /\s+/, $list ];
|
|
|
|
} } }
|
|
|
|
|
|
|
|
sub expand_cvs_modules {
|
|
|
|
my ($module_name, $include_list, $exclude_list) = @_;
|
|
|
|
warn "no module named $module_name\n" unless defined $modules{$module_name};
|
|
|
|
for my $member (@{$modules{$module_name}}) {
|
|
|
|
next if $member eq '';
|
|
|
|
if (defined $modules{$member}) {
|
|
|
|
expand_cvs_modules($member, $include_list, $exclude_list);
|
1999-06-25 02:07:54 +04:00
|
|
|
} else {
|
1999-10-11 23:42:53 +04:00
|
|
|
if ($member =~ /^!/) {
|
|
|
|
push @$exclude_list, substr $member, 1;
|
|
|
|
} else {
|
|
|
|
push @$include_list, $member;
|
|
|
|
} } } }
|
|
|
|
|
|
|
|
sub find_cvs_files {
|
|
|
|
$File::Find::prune = 1 if /.OBJ$/ or /^CVS$/ or /^Attic$/;
|
|
|
|
if (-d $_) {
|
2000-03-24 00:14:51 +03:00
|
|
|
$File::Find::prune = 1 if $seen{$File::Find::name};
|
|
|
|
$File::Find::prune = 1 if $exclude_pat ne '' and /$exclude_pat/o;
|
1999-10-11 23:42:53 +04:00
|
|
|
$seen{$File::Find::name} = 1;
|
2000-03-24 00:14:51 +03:00
|
|
|
|
1999-10-11 23:42:53 +04:00
|
|
|
return;
|
1999-06-25 02:07:54 +04:00
|
|
|
}
|
1999-10-11 23:42:53 +04:00
|
|
|
my $dir = $File::Find::dir;
|
1999-11-17 06:52:53 +03:00
|
|
|
$dir =~ s|^$cvs_root/$source_root/||o;
|
1999-10-11 23:42:53 +04:00
|
|
|
$dir =~ s|/$||;
|
|
|
|
my $file = substr $_, 0, -2;
|
|
|
|
|
|
|
|
if (defined $module_files{$file}) {
|
|
|
|
$bases{$file} = '[multiple]';
|
|
|
|
} else {
|
|
|
|
$bases{$file} = $dir;
|
|
|
|
}
|
2000-03-24 00:14:51 +03:00
|
|
|
$fullpath{"$dir/$file"} = $tag;
|
1999-06-25 02:07:54 +04:00
|
|
|
}
|
|
|
|
|
2000-02-18 02:27:17 +03:00
|
|
|
sub find_build_record {
|
1999-06-25 02:07:54 +04:00
|
|
|
my $tree = shift;
|
2000-02-18 02:27:17 +03:00
|
|
|
my $log_file = shift;
|
1999-06-25 02:07:54 +04:00
|
|
|
my @build_records = ();
|
|
|
|
my $br;
|
|
|
|
|
1999-07-23 03:14:15 +04:00
|
|
|
$maxdate = time;
|
|
|
|
$mindate = $maxdate - 5*60*60; # Go back 5 hours
|
2000-02-18 02:27:17 +03:00
|
|
|
|
1999-06-25 02:07:54 +04:00
|
|
|
print STDERR "Loading build data...";
|
1999-10-29 22:52:04 +04:00
|
|
|
tb_load_data();
|
1999-06-25 02:07:54 +04:00
|
|
|
print STDERR "done\n";
|
2000-02-18 02:27:17 +03:00
|
|
|
|
2000-02-18 03:49:45 +03:00
|
|
|
for (my $ii=0; $ii <= $name_count; $ii++) {
|
|
|
|
for (my $tt=0; $tt <= $time_count; $tt++) {
|
1999-06-25 02:07:54 +04:00
|
|
|
if (defined($br = $build_table->[$tt][$ii])
|
2000-02-18 02:27:17 +03:00
|
|
|
and $br->{logfile} eq $log_file) {
|
|
|
|
return $br;
|
1999-06-25 02:07:54 +04:00
|
|
|
} } }
|
2000-02-18 02:27:17 +03:00
|
|
|
return undef;
|
1999-06-25 02:07:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub gcc_parser {
|
1999-10-22 22:53:56 +04:00
|
|
|
my ($fh, $cvs_root, $tree, $log_file, $file_bases, $file_fullnames) = @_;
|
1999-09-09 03:19:42 +04:00
|
|
|
my $build_dir = '';
|
1999-10-22 22:53:56 +04:00
|
|
|
my $ignore_pat = "(?:".join('|',@ignore).")";
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-07-20 00:46:17 +04:00
|
|
|
PARSE_TOP: while (<$fh>) {
|
1999-06-25 02:07:54 +04:00
|
|
|
# Directory
|
|
|
|
#
|
1999-09-09 03:19:42 +04:00
|
|
|
if (/^gmake\[\d\]: Entering directory \`(.*)\'$/) {
|
|
|
|
$build_dir = $1;
|
1999-11-17 06:52:53 +03:00
|
|
|
$build_dir =~ s|^.*/$source_root/||o;
|
1999-09-09 03:19:42 +04:00
|
|
|
}
|
1999-07-16 03:59:33 +04:00
|
|
|
|
1999-06-25 02:07:54 +04:00
|
|
|
# Now only match lines with "warning:"
|
|
|
|
next unless /warning:/;
|
|
|
|
|
|
|
|
chomp; # Yum, yum
|
|
|
|
|
1999-08-26 20:27:45 +04:00
|
|
|
warn "debug> $_\n" if $debug;
|
|
|
|
|
1999-06-25 02:07:54 +04:00
|
|
|
my ($filename, $line, $warning_text);
|
1999-06-26 01:05:52 +04:00
|
|
|
($filename, $line, undef, $warning_text) = split /:\s*/, $_, 4;
|
1999-06-25 02:07:54 +04:00
|
|
|
$filename =~ s/.*\///;
|
|
|
|
|
1999-06-26 00:21:17 +04:00
|
|
|
# Special case for Makefiles
|
|
|
|
$filename =~ s/Makefile$/Makefile.in/;
|
|
|
|
|
1999-08-26 20:27:45 +04:00
|
|
|
# Look up the file name to determine the directory
|
1999-06-26 00:52:50 +04:00
|
|
|
my $dir = '';
|
1999-11-17 07:09:19 +03:00
|
|
|
|
1999-06-26 00:52:50 +04:00
|
|
|
if ($file_fullnames->{"$build_dir/$filename"}) {
|
1999-06-25 02:07:54 +04:00
|
|
|
$dir = $build_dir;
|
|
|
|
} else {
|
1999-06-26 00:52:50 +04:00
|
|
|
unless(defined($dir = $file_bases->{$filename})) {
|
1999-06-26 00:21:17 +04:00
|
|
|
$dir = '[no_match]';
|
1999-06-25 02:07:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
my $file = "$dir/$filename";
|
|
|
|
|
1999-07-20 00:46:17 +04:00
|
|
|
# Special case for "`foo' was hidden\nby `foo2'"
|
1999-09-09 03:40:40 +04:00
|
|
|
$warning_text = "...was hidden $warning_text" if $warning_text =~ /^by \`/;
|
1999-08-26 20:27:45 +04:00
|
|
|
|
|
|
|
# Remember line of first occurrence in the build log
|
1999-10-22 22:53:56 +04:00
|
|
|
unless (defined $warnings{$file}{$line}) {
|
1999-10-22 23:16:40 +04:00
|
|
|
$warnings{$file}{$line}->{first_seen_line} = $.;
|
|
|
|
$warnings{$file}{$line}->{ignorecount} = 0;
|
1999-10-22 22:53:56 +04:00
|
|
|
}
|
1999-09-09 03:40:40 +04:00
|
|
|
my $ignore_it = /$ignore_pat/o;
|
1999-11-09 20:58:56 +03:00
|
|
|
unless ($ignore_it) {
|
|
|
|
# Now check if the warning should be ignored based on directory
|
|
|
|
for $ignore_rec (@ignore_dir) {
|
|
|
|
next unless $dir =~ /^$ignore_rec->{dir}/;
|
|
|
|
next unless /$ignore_rec->{warning}/;
|
|
|
|
$ignore_it = 1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
1999-09-09 03:40:40 +04:00
|
|
|
if ($ignore_it) {
|
|
|
|
$warnings{$file}{$line}->{ignorecount}++;
|
|
|
|
$total_ignored_count++;
|
|
|
|
}
|
|
|
|
|
1999-09-09 02:48:54 +04:00
|
|
|
$warnings{$file}{$line}->{count}++;
|
2000-02-18 02:27:17 +03:00
|
|
|
$total_warnings_count++;
|
|
|
|
|
|
|
|
# Do not re-add this warning if it has been seen before
|
|
|
|
for my $rec (@{ $warnings{$file}{$line}->{list} }) {
|
|
|
|
next PARSE_TOP if $rec->{warning_text} eq $warning_text;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Remember where in the build log the warning occured
|
|
|
|
push @{ $warnings{$file}{$line}->{list} }, {
|
|
|
|
log_file => $log_file,
|
|
|
|
warning_text => $warning_text,
|
|
|
|
ignore => $ignore_it,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
warn "debug> $. lines read\n" if $debug;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub mac_parser {
|
|
|
|
my ($fh, $cvs_root, $tree, $log_file, $file_bases, $file_fullnames) = @_;
|
|
|
|
my $build_dir = '';
|
|
|
|
|
|
|
|
my $ignore_pat = "(?:".join('|',@mac_ignore).")";
|
|
|
|
|
|
|
|
PARSE_TOP: while (<$fh>) {
|
|
|
|
# Now only match lines with "warning:"
|
|
|
|
next unless /^Warning :/;
|
|
|
|
#print STDERR "Found a warning: $_";
|
|
|
|
chomp; # Yum, yum
|
|
|
|
|
|
|
|
warn "debug> $_\n" if $debug;
|
|
|
|
|
|
|
|
my ($filename, $line, $warning_text);
|
|
|
|
(undef, $warning_text) = split /:\s*/, $_, 2;
|
|
|
|
$_ = <$fh>;
|
|
|
|
while (not /^\S+ line \d+/) {
|
|
|
|
next PARSE_TOP if /^\S*$/;
|
|
|
|
chomp;
|
|
|
|
$warning_text .= " $_";
|
|
|
|
$_ = <$fh>;
|
|
|
|
}
|
|
|
|
($filename, undef, $line, undef) = split;
|
|
|
|
|
|
|
|
# Look up the file name to determine the directory
|
|
|
|
my $dir = '';
|
|
|
|
unless(defined($dir = $file_bases->{$filename})) {
|
|
|
|
$dir = '[no_match]';
|
|
|
|
}
|
|
|
|
my $file = "$dir/$filename";
|
|
|
|
|
|
|
|
# Remember line of first occurrence in the build log
|
|
|
|
unless (defined $warnings{$file}{$line}) {
|
|
|
|
$warnings{$file}{$line}->{first_seen_line} = $.;
|
|
|
|
$warnings{$file}{$line}->{ignorecount} = 0;
|
|
|
|
}
|
|
|
|
$ignore_it = 0;
|
|
|
|
$ignore_it = 1 if $warning_text =~ /^$ignore_pat$/o;
|
|
|
|
if (0) { # unless ($ignore_it) {
|
|
|
|
# Now check if the warning should be ignored based on directory
|
|
|
|
for $ignore_rec (@ignore_dir) {
|
|
|
|
next unless $dir =~ /^$ignore_rec->{dir}/;
|
|
|
|
next unless /$ignore_rec->{warning}/;
|
|
|
|
$ignore_it = 1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($ignore_it) {
|
|
|
|
$warnings{$file}{$line}->{ignorecount}++;
|
|
|
|
$total_ignored_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
$warnings{$file}{$line}->{count}++;
|
1999-09-09 02:48:54 +04:00
|
|
|
$total_warnings_count++;
|
|
|
|
|
1999-09-09 03:47:37 +04:00
|
|
|
# Do not re-add this warning if it has been seen before
|
|
|
|
for my $rec (@{ $warnings{$file}{$line}->{list} }) {
|
|
|
|
next PARSE_TOP if $rec->{warning_text} eq $warning_text;
|
|
|
|
}
|
|
|
|
|
1999-07-20 00:46:17 +04:00
|
|
|
# Remember where in the build log the warning occured
|
|
|
|
push @{ $warnings{$file}{$line}->{list} }, {
|
|
|
|
log_file => $log_file,
|
|
|
|
warning_text => $warning_text,
|
1999-09-09 03:40:40 +04:00
|
|
|
ignore => $ignore_it,
|
1999-07-20 00:46:17 +04:00
|
|
|
};
|
1999-06-25 02:07:54 +04:00
|
|
|
}
|
1999-08-26 20:27:45 +04:00
|
|
|
warn "debug> $. lines read\n" if $debug;
|
1999-06-25 02:07:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub build_blame {
|
2000-03-24 00:14:51 +03:00
|
|
|
my ($cvs_root, $tags) = @_;
|
1999-10-22 22:53:56 +04:00
|
|
|
|
1999-06-25 02:07:54 +04:00
|
|
|
use lib '../bonsai';
|
|
|
|
require 'utils.pl';
|
|
|
|
require 'cvsblame.pl';
|
|
|
|
|
1999-06-25 23:39:31 +04:00
|
|
|
while (($file, $lines_hash) = each %warnings) {
|
|
|
|
|
1999-11-17 07:09:19 +03:00
|
|
|
my $rcs_filename = "$cvs_root/$source_root/$file,v";
|
1999-06-25 02:07:54 +04:00
|
|
|
|
|
|
|
unless (-e $rcs_filename) {
|
1999-09-09 04:01:39 +04:00
|
|
|
warn "Unable to find $rcs_filename\n";
|
1999-06-25 23:39:31 +04:00
|
|
|
$unblamed{$file} = 1;
|
1999-06-25 02:07:54 +04:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2000-03-24 00:14:51 +03:00
|
|
|
$::opt_rev = $tags->{$file} if defined $tags->{$file};
|
2000-04-20 23:05:56 +04:00
|
|
|
my $revision = 0;
|
|
|
|
eval {
|
|
|
|
$revision = &parse_cvs_file($rcs_filename);
|
|
|
|
};
|
|
|
|
if ($@) {
|
|
|
|
warn "Error parsing $rcs_filename: $@\n";
|
|
|
|
$unblamed{$file} = 1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
my @text = &extract_revision($revision);
|
1999-09-09 03:40:40 +04:00
|
|
|
LINE: while (my ($line, $line_rec) = each %{$lines_hash}) {
|
1999-06-25 02:07:54 +04:00
|
|
|
my $line_rev = $revision_map[$line-1];
|
|
|
|
my $who = $revision_author{$line_rev};
|
1999-06-28 22:23:51 +04:00
|
|
|
my $source_text = join '', @text[$line-3..$line+1];
|
1999-07-07 23:11:02 +04:00
|
|
|
$source_text =~ s/\t/ /g;
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-06-26 02:13:43 +04:00
|
|
|
$who = "$who%netscape.com" unless $who =~ /[%]/;
|
|
|
|
|
1999-09-09 03:40:40 +04:00
|
|
|
$line_rec->{line_rev} = $line_rev;
|
|
|
|
$line_rec->{source} = $source_text;
|
|
|
|
|
|
|
|
for $ignore_rec (@ignore_match) {
|
|
|
|
for my $warn_rec (@{ $line_rec->{list}}) {
|
|
|
|
if ($warn_rec->{warning_text} =~ /$ignore_rec->{warning}/
|
1999-09-09 04:01:39 +04:00
|
|
|
and $source_text =~ /$ignore_rec->{source}/
|
1999-09-09 03:40:40 +04:00
|
|
|
and not $warn_rec->{ignore}) {
|
|
|
|
$warn_rec->{ignore} = 1;
|
|
|
|
$line_rec->{ignorecount}++;
|
|
|
|
next LINE;
|
|
|
|
}
|
|
|
|
}
|
1999-08-26 20:27:45 +04:00
|
|
|
}
|
|
|
|
|
1999-09-09 03:40:40 +04:00
|
|
|
$warnings_by_who{$who}{$file}{$line} = $line_rec;
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-09-09 03:40:40 +04:00
|
|
|
$who_count{$who} += $line_rec->{count} - $line_rec->{ignorecount};
|
1999-06-25 02:07:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-09 05:51:51 +04:00
|
|
|
sub print_summary_table
|
|
|
|
{
|
|
|
|
my ($who_list_ref, $who_count_hash_ref) = @_;
|
1999-10-22 21:34:16 +04:00
|
|
|
my $num_whos = $#{$who_list_ref} + 1;
|
1999-09-09 05:51:51 +04:00
|
|
|
|
|
|
|
# Summary Table (name, count)
|
|
|
|
#
|
|
|
|
use POSIX;
|
1999-09-14 03:55:17 +04:00
|
|
|
print "<table border=0 cellpadding=1 cellspacing=0 bgcolor=white>\n";
|
|
|
|
my $num_columns = 3;
|
1999-09-09 05:51:51 +04:00
|
|
|
my $num_rows = ceil($num_whos / $num_columns);
|
|
|
|
for (my $ii=0; $ii < $num_rows; $ii++) {
|
|
|
|
print "<tr>";
|
|
|
|
for (my $jj=0; $jj < $num_columns; $jj++) {
|
|
|
|
my $index = $ii + $jj * $num_rows;
|
|
|
|
next if $index > $num_whos;
|
|
|
|
my $name = $who_list_ref->[$index];
|
1999-11-09 20:58:56 +03:00
|
|
|
next unless defined $name;
|
1999-09-09 05:51:51 +04:00
|
|
|
my $count = $who_count_hash_ref->{$name};
|
1999-11-09 20:58:56 +03:00
|
|
|
next unless $count;
|
1999-09-14 03:55:17 +04:00
|
|
|
#warn "$ii\t$jj\t$index\t$name\t$count\n";
|
1999-09-09 05:51:51 +04:00
|
|
|
$name =~ s/%.*//;
|
|
|
|
print " " x $jj;
|
|
|
|
print "<td><a href='#$name'>$name</a>";
|
|
|
|
print "</td><td>";
|
|
|
|
print "$count";
|
1999-09-14 03:55:17 +04:00
|
|
|
print "</td><td> </td>\n";
|
1999-09-09 05:51:51 +04:00
|
|
|
}
|
|
|
|
print "</tr>\n";
|
|
|
|
}
|
|
|
|
print "</table><p>\n";
|
|
|
|
}
|
|
|
|
|
1999-09-09 03:40:40 +04:00
|
|
|
sub print_html_by_who {
|
1999-06-25 03:34:56 +04:00
|
|
|
my ($fh, $br) = @_;
|
|
|
|
my ($buildname, $buildtime) = ($br->{buildname}, $br->{buildtime});
|
1999-06-25 02:07:54 +04:00
|
|
|
|
|
|
|
my $time_str = print_time( $buildtime );
|
|
|
|
|
1999-06-25 02:33:33 +04:00
|
|
|
# Change the default destination for print to $fh
|
|
|
|
my $old_fh = select($fh);
|
|
|
|
|
1999-09-09 03:40:40 +04:00
|
|
|
my $total_unignored_count = $total_warnings_count - $total_ignored_count;
|
1999-09-14 03:55:17 +04:00
|
|
|
for $who (sort { $who_count{$b} <=> $who_count{$a}
|
|
|
|
|| $a cmp $b } keys %who_count) {
|
|
|
|
next if $who_count{$who} == 0;
|
|
|
|
push @who_list, $who;
|
|
|
|
}
|
1999-06-25 02:07:54 +04:00
|
|
|
print <<"__END_HEADER";
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Blamed Build Warnings</title>
|
|
|
|
</head>
|
1999-09-14 03:55:17 +04:00
|
|
|
<body BGCOLOR="#FFFFFF" TEXT="#000000"
|
|
|
|
LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000">
|
1999-06-25 02:07:54 +04:00
|
|
|
<font size="+2" face="Helvetica,Arial"><b>
|
|
|
|
Blamed Build Warnings
|
|
|
|
</b></font><br>
|
|
|
|
<font size="+1" face="Helvetica,Arial">
|
1999-06-25 23:39:31 +04:00
|
|
|
$buildname on $time_str<br>
|
1999-09-09 03:40:40 +04:00
|
|
|
$total_unignored_count total warnings
|
1999-06-25 02:07:54 +04:00
|
|
|
</font><p>
|
|
|
|
|
1999-09-14 03:57:14 +04:00
|
|
|
<table cellspacing=0 cellpadding=0 border=0><tr bgcolor="#F0A000"><td>
|
1999-09-14 03:55:17 +04:00
|
|
|
<table cellpadding=2 cellspacing=2 border=0><tr bgcolor="#FFFFFF">
|
|
|
|
<th colspan=2><font size="+1" face="Helvetica,Arial">
|
|
|
|
Summary</font></th></tr>
|
1999-09-14 05:47:17 +04:00
|
|
|
<tr bgcolor="#FFFFFF"><td><font face="Helvetica,Arial"><b>
|
|
|
|
by count</b></font>
|
1999-06-25 02:07:54 +04:00
|
|
|
__END_HEADER
|
1999-09-09 05:51:51 +04:00
|
|
|
print_summary_table(\@who_list, \%who_count);
|
1999-09-14 05:47:17 +04:00
|
|
|
print "</td><td><font face='Helvetica,Arial'><b>";
|
|
|
|
print "by name</b></font>";
|
1999-09-14 03:55:17 +04:00
|
|
|
print_summary_table([sort @who_list], \%who_count);
|
|
|
|
print "</td></tr></table>";
|
|
|
|
print "</td></tr></table>";
|
1999-06-26 01:42:22 +04:00
|
|
|
|
1999-07-08 04:06:26 +04:00
|
|
|
# Count Unblamed warnings
|
|
|
|
#
|
|
|
|
for my $file (keys %unblamed) {
|
|
|
|
for my $linenum (keys %{$warnings{$file}}) {
|
1999-09-09 03:40:40 +04:00
|
|
|
$who_count{Unblamed} += $warnings{$file}{$linenum}{count};
|
|
|
|
$who_count{Unblamed} -= $warnings{$file}{$linenum}{ignorecount};
|
1999-07-08 04:06:26 +04:00
|
|
|
$warnings_by_who{Unblamed}{$file}{$linenum} = $warnings{$file}{$linenum};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-26 01:42:22 +04:00
|
|
|
# Print all the warnings
|
|
|
|
#
|
1999-07-08 04:06:26 +04:00
|
|
|
for $who (@who_list, "Unblamed") {
|
|
|
|
my $total_count = $who_count{$who};
|
1999-09-09 03:40:40 +04:00
|
|
|
|
|
|
|
next if $total_count == 0;
|
|
|
|
|
1999-06-25 02:07:54 +04:00
|
|
|
my ($name, $email);
|
|
|
|
($name = $who) =~ s/%.*//;
|
|
|
|
($email = $who) =~ s/%/@/;
|
|
|
|
|
1999-06-28 22:23:51 +04:00
|
|
|
print "<h2>";
|
1999-07-08 04:06:26 +04:00
|
|
|
print "<a name='$name' href='mailto:$email'>" unless $name eq 'Unblamed';
|
|
|
|
print "$name";
|
|
|
|
print "</a>" unless $name eq 'Unblamed';
|
|
|
|
print " (1 warning)" if $total_count == 1;
|
|
|
|
print " ($total_count warnings)" if $total_count > 1;
|
1999-06-28 22:23:51 +04:00
|
|
|
print "</h2>";
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-07-08 04:06:26 +04:00
|
|
|
print "\n<table>\n";
|
|
|
|
my $count = 1;
|
1999-06-25 02:07:54 +04:00
|
|
|
for $file (sort keys %{$warnings_by_who{$who}}) {
|
|
|
|
for $linenum (sort keys %{$warnings_by_who{$who}{$file}}) {
|
1999-09-09 03:40:40 +04:00
|
|
|
my $line_rec = $warnings_by_who{$who}{$file}{$linenum};
|
1999-09-16 21:38:07 +04:00
|
|
|
my $count_for_line = $line_rec->{count} - $line_rec->{ignorecount};
|
|
|
|
next if $count_for_line == 0;
|
|
|
|
print_count($count, $count_for_line);
|
1999-09-09 03:40:40 +04:00
|
|
|
print_warning($tree, $br, $file, $linenum, $line_rec);
|
|
|
|
print_source_code($linenum, $line_rec) unless $unblamed{$file};
|
1999-09-16 21:38:07 +04:00
|
|
|
$count += $count_for_line;
|
1999-06-25 02:07:54 +04:00
|
|
|
}
|
|
|
|
}
|
1999-07-08 04:06:26 +04:00
|
|
|
print "</table>\n";
|
1999-06-25 23:39:31 +04:00
|
|
|
}
|
|
|
|
|
1999-06-25 02:07:54 +04:00
|
|
|
print <<"__END_FOOTER";
|
|
|
|
<p>
|
|
|
|
<hr align=left>
|
|
|
|
Send questions or comments to
|
|
|
|
<<a href="mailto:slamm\@netscape.com?subject=About the Blamed Build Warnings">slamm\@netcape.com</a>>.
|
|
|
|
</body></html>
|
|
|
|
__END_FOOTER
|
1999-06-25 02:33:33 +04:00
|
|
|
|
|
|
|
# Change default destination back.
|
|
|
|
select($old_fh);
|
1999-07-22 01:09:41 +04:00
|
|
|
|
1999-09-09 03:40:40 +04:00
|
|
|
return $time_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub print_html_by_file {
|
|
|
|
my ($fh, $br) = @_;
|
|
|
|
my ($buildname, $buildtime) = ($br->{buildname}, $br->{buildtime});
|
|
|
|
|
|
|
|
my $time_str = print_time( $buildtime );
|
|
|
|
|
|
|
|
# Change the default destination for print to $fh
|
|
|
|
my $old_fh = select($fh);
|
|
|
|
|
|
|
|
my $total_unignored_count = $total_warnings_count - $total_ignored_count;
|
|
|
|
print <<"__END_HEADER";
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Build Warnings By File</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<font size="+2" face="Helvetica,Arial"><b>
|
|
|
|
Build Warnings By File
|
|
|
|
</b></font><br>
|
|
|
|
<font size="+1" face="Helvetica,Arial">
|
|
|
|
$buildname on $time_str<br>
|
|
|
|
$total_unignored_count total warnings
|
|
|
|
</font><p>
|
|
|
|
|
|
|
|
__END_HEADER
|
|
|
|
|
|
|
|
# Print all the warnings
|
|
|
|
#
|
|
|
|
for $who (@who_list, "Unblamed") {
|
|
|
|
my $total_count = $who_count{$who};
|
|
|
|
my ($name, $email);
|
|
|
|
($name = $who) =~ s/%.*//;
|
|
|
|
($email = $who) =~ s/%/@/;
|
|
|
|
|
|
|
|
print "<h2>";
|
|
|
|
print "<a name='$name' href='mailto:$email'>" unless $name eq 'Unblamed';
|
|
|
|
print "$name";
|
|
|
|
print "</a>" unless $name eq 'Unblamed';
|
|
|
|
print " (1 warning)" if $total_count == 1;
|
|
|
|
print " ($total_count warnings)" if $total_count > 1;
|
|
|
|
print "</h2>";
|
|
|
|
|
|
|
|
print "\n<table>\n";
|
|
|
|
my $count = 1;
|
|
|
|
for $file (sort keys %{$warnings_by_who{$who}}) {
|
|
|
|
for $linenum (sort keys %{$warnings_by_who{$who}{$file}}) {
|
|
|
|
my $line_rec = $warnings_by_who{$who}{$file}{$linenum};
|
1999-09-16 21:38:07 +04:00
|
|
|
my $count_for_line = $line_rec->{count} - $line_rec->{ignorecount};
|
|
|
|
next if $count_for_line == 0;
|
|
|
|
print_count($count, $count_for_line);
|
1999-09-09 03:40:40 +04:00
|
|
|
print_warning($tree, $br, $file, $linenum, $line_rec);
|
|
|
|
print_source_code($linenum, $line_rec) unless $unblamed{$file};
|
1999-09-16 21:38:07 +04:00
|
|
|
$count += $count_for_line;
|
1999-09-09 03:40:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
print "</table>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print <<"__END_FOOTER";
|
|
|
|
<p>
|
|
|
|
<hr align=left>
|
|
|
|
Send questions or comments to
|
|
|
|
<<a href="mailto:slamm\@netscape.com?subject=About the Blamed Build Warnings">slamm\@netcape.com</a>>.
|
|
|
|
</body></html>
|
|
|
|
__END_FOOTER
|
|
|
|
|
|
|
|
# Change default destination back.
|
|
|
|
select($old_fh);
|
1999-06-25 02:07:54 +04:00
|
|
|
}
|
|
|
|
|
1999-07-08 04:06:26 +04:00
|
|
|
sub print_count {
|
|
|
|
my ($start, $count) = @_;
|
|
|
|
print "<tr><td align=right>$start";
|
|
|
|
print "-".($start+$count-1) if $count > 1;
|
|
|
|
print ".</td>";
|
|
|
|
}
|
|
|
|
|
1999-06-25 23:39:31 +04:00
|
|
|
sub print_warning {
|
1999-09-09 03:40:40 +04:00
|
|
|
my ($tree, $br, $file, $linenum, $line_rec) = @_;
|
1999-06-25 23:39:31 +04:00
|
|
|
|
1999-07-08 04:06:26 +04:00
|
|
|
print "<td>";
|
1999-06-25 23:39:31 +04:00
|
|
|
|
|
|
|
# File link
|
1999-06-26 01:54:24 +04:00
|
|
|
if ($file =~ /\[multiple\]/) {
|
1999-06-28 22:38:51 +04:00
|
|
|
$file =~ s/\[multiple\]\///;
|
1999-06-28 22:23:51 +04:00
|
|
|
print "<a href='http://lxr.mozilla.org/seamonkey/find?string=$file'>";
|
1999-06-26 01:54:24 +04:00
|
|
|
print "$file:$linenum";
|
|
|
|
print "</a> (multiple file matches)";
|
|
|
|
} elsif ($file =~ /\[no_match\]/) {
|
1999-06-28 22:38:51 +04:00
|
|
|
$file =~ s/\[no_match\]\///;
|
|
|
|
print "<b>$file:$linenum</b> (no file match)";
|
1999-06-26 01:54:24 +04:00
|
|
|
} else {
|
1999-06-28 22:23:51 +04:00
|
|
|
print "<a href='"
|
1999-06-26 01:54:24 +04:00
|
|
|
.file_url($file,$linenum)."'>";
|
|
|
|
print "$file:$linenum";
|
|
|
|
print "</a> ";
|
|
|
|
}
|
1999-07-20 00:46:17 +04:00
|
|
|
|
1999-06-25 23:39:31 +04:00
|
|
|
# Build log link
|
1999-09-09 03:40:40 +04:00
|
|
|
my $log_line = $line_rec->{first_seen_line};
|
1999-06-25 23:39:31 +04:00
|
|
|
print " (<a href='"
|
1999-07-20 00:46:17 +04:00
|
|
|
.build_url($tree, $br, $log_line)
|
|
|
|
."'>";
|
1999-09-16 21:21:24 +04:00
|
|
|
my $count = $line_rec->{count} - $line_rec->{ignorecount};
|
|
|
|
if ($count == 1) {
|
1999-06-28 22:23:51 +04:00
|
|
|
print "See build log excerpt";
|
1999-06-25 23:39:31 +04:00
|
|
|
} else {
|
1999-09-16 21:21:24 +04:00
|
|
|
print "See 1st of $count warnings in build log";
|
1999-07-20 00:46:17 +04:00
|
|
|
}
|
|
|
|
print "</a>)";
|
|
|
|
|
|
|
|
print "</td></tr><tr><td></td><td>";
|
|
|
|
|
1999-09-09 03:40:40 +04:00
|
|
|
for my $warn_rec (@{ $line_rec->{list}}) {
|
1999-09-16 21:21:24 +04:00
|
|
|
next if $warn_rec->{ignore};
|
1999-09-09 03:40:40 +04:00
|
|
|
my $warning = $warn_rec->{warning_text};
|
1999-07-20 00:46:17 +04:00
|
|
|
|
|
|
|
# Warning text
|
|
|
|
print "\u$warning<br>";
|
1999-06-25 23:39:31 +04:00
|
|
|
}
|
1999-07-20 00:46:17 +04:00
|
|
|
print "</td></tr>";
|
1999-06-25 23:39:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub print_source_code {
|
1999-09-09 03:40:40 +04:00
|
|
|
my ($linenum, $line_rec) = @_;
|
1999-06-25 23:39:31 +04:00
|
|
|
|
|
|
|
# Source code fragment
|
|
|
|
#
|
1999-07-08 04:06:26 +04:00
|
|
|
print "<tr><td></td><td bgcolor=#ededed>";
|
1999-09-09 03:40:40 +04:00
|
|
|
print "<pre>";
|
1999-06-25 23:39:31 +04:00
|
|
|
|
1999-09-09 03:40:40 +04:00
|
|
|
my $source_text = trim_common_leading_whitespace($line_rec->{source});
|
1999-07-07 23:11:02 +04:00
|
|
|
$source_text =~ s/&/&/gm;
|
|
|
|
$source_text =~ s/</</gm;
|
|
|
|
$source_text =~ s/>/>/gm;
|
1999-09-09 03:40:40 +04:00
|
|
|
# Highlight the warning's keyword
|
|
|
|
for my $warn_rec (@{ $line_rec->{list}}) {
|
|
|
|
my $warning = $warn_rec->{warning_text};
|
|
|
|
my ($keyword) = $warning =~ /\`([^\']*)\'/;
|
1999-11-03 21:52:13 +03:00
|
|
|
next unless defined $keyword and $keyword ne '';
|
1999-09-09 03:40:40 +04:00
|
|
|
$source_text =~ s|\b\Q$keyword\E\b|<b>$keyword</b>|gm;
|
|
|
|
last;
|
|
|
|
}
|
1999-06-28 22:23:51 +04:00
|
|
|
my $line_index = $linenum - 2;
|
1999-07-07 23:11:02 +04:00
|
|
|
$source_text =~ s/^(.*)$/$line_index++." $1"/gme;
|
|
|
|
$source_text =~ s|^($linenum.*)$|<font color='red'>\1</font>|gm;
|
|
|
|
chomp $source_text;
|
|
|
|
print $source_text;
|
|
|
|
|
1999-06-28 22:23:51 +04:00
|
|
|
#print "</pre>";
|
1999-07-08 04:06:26 +04:00
|
|
|
print "</td></tr>\n";
|
1999-06-25 23:39:31 +04:00
|
|
|
}
|
|
|
|
|
1999-06-25 02:07:54 +04:00
|
|
|
sub build_url {
|
1999-06-25 03:30:34 +04:00
|
|
|
my ($tree, $br, $linenum) = @_;
|
|
|
|
|
|
|
|
my $name = $br->{buildname};
|
|
|
|
$name =~ s/ /%20/g;
|
1999-06-25 02:07:54 +04:00
|
|
|
|
1999-07-07 01:30:20 +04:00
|
|
|
return "../showlog.cgi?log=$tree/$br->{logfile}:$linenum";
|
1999-06-25 02:07:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub file_url {
|
|
|
|
my ($file, $linenum) = @_;
|
|
|
|
|
2000-03-02 03:01:47 +03:00
|
|
|
return "http://bonsai.mozilla.org/cvsblame.cgi"
|
1999-11-23 20:42:19 +03:00
|
|
|
."?file=mozilla/$file&mark=$linenum#".($linenum-10);
|
1999-06-25 02:07:54 +04:00
|
|
|
|
|
|
|
}
|
1999-07-07 23:11:02 +04:00
|
|
|
|
|
|
|
sub trim_common_leading_whitespace {
|
|
|
|
# Adapted from dequote() in Perl Cookbook by Christiansen and Torkington
|
|
|
|
local $_ = shift;
|
|
|
|
my $white; # common whitespace
|
|
|
|
if (/(?:(\s*).*\n)(?:(?:\1.*\n)|(?:\s*\n))+$/) {
|
|
|
|
$white = $1;
|
|
|
|
} else {
|
|
|
|
$white = /^(\s+)/;
|
|
|
|
}
|
1999-11-09 20:58:56 +03:00
|
|
|
s/^(?:$white)?//gm unless $white eq '';
|
1999-07-07 23:11:02 +04:00
|
|
|
s/^\s+$//gm;
|
|
|
|
return $_;
|
|
|
|
}
|
|
|
|
|
1999-10-22 22:53:56 +04:00
|
|
|
# Print big numbers with commas (e.g. 3,314).
|
|
|
|
sub commify {
|
|
|
|
my $text = reverse $_[0];
|
|
|
|
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
|
|
|
|
return scalar reverse $text;
|
|
|
|
}
|
|
|
|
|