diff -r 02d78c9f018e -r 3f65fd25dfd4 deprecated/buildtools/commonbldutils/sbsv2htmlscanlog/sbsv2htmlscanlog.pl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/deprecated/buildtools/commonbldutils/sbsv2htmlscanlog/sbsv2htmlscanlog.pl Mon Oct 18 16:16:46 2010 +0800
@@ -0,0 +1,1367 @@
+# Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+# summarise an automated build log
+use strict;
+use Getopt::Long;
+use HTML::Entities;
+use Carp;
+use File::stat;
+use FindBin; # for FindBin::Bin
+
+# Add the directory contain this perl script into the path to find modules
+use lib $FindBin::Bin;
+use sbsv2scanlog;
+
+# For Date calculations
+use lib "$FindBin::Bin/../lib"; # For running in source
+use lib "$FindBin::Bin/build/lib"; # For running in epoc32\tools
+
+use XML::Parser;
+
+# Variables
+my $line;
+my $iSlurp;
+my %Components;
+my %Commands;
+my $component;
+my $command;
+my %errors;
+my %warnings;
+my %remarks;
+my %migrationNotes;
+my %AdvisoryNotes;
+my %CmdErrors;
+my %CmdWarnings;
+my %CmdRemarks;
+my %CmdMigrationNotes;
+my %CmdAdvisoryNotes;
+my %missing;
+my %not_built;
+my $starttime;
+my $duration;
+my $currentfiletime;
+my $warningcount;
+my $errorcount;
+my $remarkcount;
+my $migrationNoteCount;
+my $AdvisoryNoteCount;
+my ($iStatus, $iName);
+my $warningmigrated;
+my %htmlColours=(
+"errors" =>"#ff0000",
+"warnings" =>"#fff000",
+"remarks" =>"#ffccff",
+"migrationNotes" =>"#ffcc99",
+"AdvisoryNotes" => "#ffa500"
+);
+my $MigrateNextExitCode = 0;
+my $inRecipe = 0;
+my $RetryInProgress = 0;
+
+# Package variables - these can also be accessed the from package "SubHandlers"
+use vars qw($component $command %Components %Commands);
+our $iLog;
+
+my $Dsec;
+
+# Main section
+
+my ($iOutput, $iTitle, $iVerbose, @iLogs) =&ProcessCommandLine();
+
+# Open Output file
+ open (HTML, ">$iOutput") or die "Couldn't open $iOutput for writing: $!\n";
+
+
+# Parse each log File
+foreach $iLog (@iLogs) # parses through all logs
+{
+ # Check the log file exists
+ if (-e $iLog)
+ {
+ # Process the logs
+ &ProcessLog();
+ } else {
+ print "WARNING: $iLog does not exist\n";
+ }
+
+
+}
+
+&PrintResults($iTitle);
+
+# Print HTML Footer
+&PrintHTMLFooter();
+
+
+# ProcessLog
+#
+# Inputs
+# $iLog - Logfile name
+#
+# Outputs
+#
+# Description
+# This function processes the commandline
+sub ProcessLog()
+{
+ #Clear current file time as starting processing a new log
+ $currentfiletime = 0;
+
+ print "Processing: $iLog\n";
+
+ my $iParser = XML::Parser->new(Style => 'Subs', Pkg => 'MySubs' , ErrorContext => 2,
+ Handlers => {Char => \&char_handler});
+
+ # Supply the XML Parser the data source
+ eval {
+ $iParser->parsefile($iLog);
+ };
+
+ #Set current component and command to special values to record log processing errors/warnings/etc
+ $component = 'sbsv2scanlog';
+ $command = 'sbsv2scanlog';
+
+ #Check for parse errors
+ if ($@)
+ {
+ #Generate error in log as the file time stamps are duff
+ &do_error($iLog, "No_linenumer", "XML Parse error:$@");
+ $Components{$component} = '0';
+ $Commands{$command} ='0';
+ }
+
+ # Calculate the Total Duration
+ # $currentfiletime is set from the info tags at the end of the log.
+ $duration += $currentfiletime;
+
+ #Clear current component and command
+ $component = '';
+ $command = '';
+}
+
+
+# PrintResults
+#
+# Inputs
+# $iTitle (Title for Log file)
+#
+# Outputs
+#
+# Description
+# This function prints all the data as HTML
+sub PrintResults
+{
+ my ($iTitle) = @_;
+
+ my $title;
+
+ # Print Heading of Log File
+ my $heading ="Overall";
+ print HTML qq{
$iTitle
\n};
+ print HTML qq{$heading
\n};
+
+ # Calculate the total number of remarks messages
+ $remarkcount = 0;
+ foreach $component (sort {lc $a cmp lc $b} keys %remarks)
+ {
+ $remarkcount += scalar(@{$remarks{$component}});
+ }
+ # Calculate the Total number of errors
+ $errorcount = 0;
+ foreach $component (sort {lc $a cmp lc $b} keys %errors)
+ {
+ $errorcount += scalar(@{$errors{$component}});
+ }
+ # Calculate the total number of warnings
+ $warningcount = 0;
+ foreach $component (sort {lc $a cmp lc $b} keys %warnings)
+ {
+ $warningcount += scalar(@{$warnings{$component}});
+ }
+
+ # Calculate the total number of migration notes
+ $migrationNoteCount=0;
+ foreach $component (sort {lc $a cmp lc $b} keys %migrationNotes)
+ {
+ $migrationNoteCount += scalar(@{$migrationNotes{$component}});
+ }
+
+ # Calculate the total number of Advisory notes
+ $AdvisoryNoteCount=0;
+ foreach $component (sort {lc $a cmp lc $b} keys %AdvisoryNotes)
+ {
+ $AdvisoryNoteCount += scalar(@{$AdvisoryNotes{$component}});
+ }
+
+ # Start the Table
+ &StartHTMLTable();
+
+ # Print the Totals
+ &HTMLTableRow($heading,"Total", $duration, $errorcount, $warningcount, $AdvisoryNoteCount, $remarkcount, $migrationNoteCount);
+
+ # End the Table
+ print HTML qq{\n};
+
+
+
+ # By Component
+ print HTML qq{By Component
\n};
+
+ # Start the Table
+ $title="Component";
+ &StartHTMLTable($title);
+
+ # Print the by Component Data
+ foreach $component (sort {lc $a cmp lc $b} keys %Components)
+ {
+ # Calculate the number errors and warnings
+ my $totalerrors;
+ my $totalwarnings;
+ my $totalremarks;
+ my $totalMigrationNotes;
+ my $totalAdvisoryNotes;
+ if (!defined $remarks{$component})
+ {
+ # No Remarks were recorded, set total to zero
+ $totalremarks = 0;
+ } else {
+ $totalremarks = scalar(@{$remarks{$component}});
+ }
+ if (!defined $errors{$component})
+ {
+ # No errors were recorded, set total to zero
+ $totalerrors = 0;
+ } else {
+ $totalerrors = scalar(@{$errors{$component}});
+ }
+ if (!defined $warnings{$component})
+ {
+ # No Warnings were recorded, set total to zero
+ $totalwarnings = 0;
+ } else {
+ $totalwarnings = scalar(@{$warnings{$component}});
+ }
+
+ if (!defined $migrationNotes{$component})
+ {
+ # No MigrationNotes were recorded, set total to zero
+ $totalMigrationNotes=0;
+ }
+ else
+ {
+ $totalMigrationNotes = scalar(@{$migrationNotes{$component}});
+ }
+
+ if (!defined $AdvisoryNotes{$component})
+ {
+ # No AdvisoryNotes were recorded, set total to zero
+ $totalAdvisoryNotes=0;
+ }
+ else
+ {
+ $totalAdvisoryNotes = scalar(@{$AdvisoryNotes{$component}});
+ }
+
+
+
+ # Print the Table Row
+ &HTMLTableRow($title,$component, $Components{$component}, $totalerrors, $totalwarnings, $totalAdvisoryNotes,$totalremarks, $totalMigrationNotes);
+
+ }
+
+ # End the Table
+ print HTML qq{\n};
+
+ # By Command
+ print HTML qq{By Command
\n};
+
+ # Start the Table
+ $title="Command";
+ &StartHTMLTable($title);
+
+ # Print the by Command Data
+ foreach $command (sort {lc $a cmp lc $b} keys %Commands)
+ {
+ # Calculate the number errors, warnings and remarks
+ my $totalerrors;
+ my $totalwarnings;
+ my $totalremarks;
+ my $totalMigrationNotes;
+ my $totalAdvisoryNotes;
+ if (!defined $CmdRemarks{$command})
+ {
+ # No Remarks were recorded, set total to zero
+ $totalremarks = 0;
+ } else {
+ $totalremarks = scalar(@{$CmdRemarks{$command}});
+ }
+ if (!defined $CmdErrors{$command})
+ {
+ # No errors were recorded, set total to zero
+ $totalerrors = 0;
+ } else {
+ $totalerrors = scalar(@{$CmdErrors{$command}});
+ }
+ if (!defined $CmdWarnings{$command})
+ {
+ # No Warnings were recorded, set total to zero
+ $totalwarnings = 0;
+ } else {
+ $totalwarnings = scalar(@{$CmdWarnings{$command}});
+ }
+
+ if (!defined $CmdMigrationNotes{$command})
+ {
+ # No MigrationNotes were recorded, set total to zero
+ $totalMigrationNotes=0;
+ }
+ else
+ {
+ $totalMigrationNotes = scalar(@{$CmdMigrationNotes{$command}});
+ }
+
+ if (!defined $CmdAdvisoryNotes{$command})
+ {
+ # No AdvisoryNotes were recorded, set total to zero
+ $totalAdvisoryNotes=0;
+ }
+ else
+ {
+ $totalAdvisoryNotes = scalar(@{$CmdAdvisoryNotes{$command}});
+ }
+
+ # Print the Table Row
+ &HTMLTableRow($title,$command, $Commands{$command}, $totalerrors, $totalwarnings, $totalAdvisoryNotes, $totalremarks, $totalMigrationNotes);
+ }
+
+
+ # End the Table
+ print HTML qq{\n};
+
+ # Print Things Missing
+ if (scalar %missing)
+ {
+ my $count = scalar keys %missing;
+ print HTML qq{Things Missing ($count)
\n};
+ print HTML "Don't know how to make...\n";
+ foreach my $file (sort {lc $a cmp lc $b} keys %missing)
+ {
+ printf HTML "%d\t%s\n", $missing{$file}, $file;
+ }
+ }
+ print HTML qq{\n};
+
+ # Print Things Not Built
+ if (scalar %not_built)
+ {
+ my $count = scalar keys %not_built;
+ print HTML qq{Things Not Built ($count)
\n};
+ foreach my $file (sort {lc $a cmp lc $b} keys %not_built)
+ {
+ print HTML "MISSING: $file ($not_built{$file})\n";
+ }
+ }
+
+
+ # Print the Actual Errors by Component
+ if ($iVerbose > 0)
+ {
+ # Only Print the header if there are some errors
+ if (scalar(keys %errors))
+ {
+ print HTML qq{\n};
+ foreach $component (sort {lc $a cmp lc $b} keys %errors)
+ {
+ my ($HTML) = $component;
+ $HTML =~ s/\s+$//;
+ encode_entities($HTML);
+ my $count = scalar @{$errors{$component}};
+ print HTML qq{\n};
+ foreach $line (@{$errors{$component}})
+ {
+ encode_entities($line);
+ print HTML $line.qq{};
+ }
+ print HTML qq{\n};
+ }
+ }
+ }
+
+ # Print the Actual Warning by Component
+ if ($iVerbose > 1)
+ {
+ # Only Print the header if there are some warnings
+ if (scalar(keys %warnings))
+ {
+ print HTML qq{\n};
+ foreach $component (sort {lc $a cmp lc $b} keys %warnings)
+ {
+ my ($HTML) = $component;
+ $HTML =~ s/\s+$//;
+ encode_entities($HTML);
+ my $count = scalar @{$warnings{$component}};
+ print HTML qq{\n};
+ foreach $line (@{$warnings{$component}})
+ {
+ encode_entities($line);
+ print HTML $line.qq{};
+ }
+ print HTML qq{\n};
+ }
+ }
+ }
+
+ # Print the Actual Advisory Notes by Component
+ if ($iVerbose > 1)
+ {
+ # Only Print the header if there are some warnings
+ if (scalar(keys %AdvisoryNotes))
+ {
+ print HTML qq{\n};
+ foreach $component (sort {lc $a cmp lc $b} keys %AdvisoryNotes)
+ {
+ my ($HTML) = $component;
+ $HTML =~ s/\s+$//;
+ encode_entities($HTML);
+ my $count = scalar @{$AdvisoryNotes{$component}};
+ print HTML qq{\n};
+ foreach $line (@{$AdvisoryNotes{$component}})
+ {
+ encode_entities($line);
+ print HTML $line.qq{};
+ }
+ print HTML qq{\n};
+ }
+ }
+ }
+
+ # Print the Actual Remarks by Component
+ if ($iVerbose > 1)
+ {
+ # Only Print the header if there are some errors
+ if (scalar(keys %remarks))
+ {
+ print HTML qq{\n};
+ foreach $component (sort {lc $a cmp lc $b} keys %remarks)
+ {
+ my ($HTML) = $component;
+ $HTML =~ s/\s+$//;
+ encode_entities($HTML);
+ my $count = scalar @{$remarks{$component}};
+ print HTML qq{\n};
+ foreach $line (@{$remarks{$component}})
+ {
+ encode_entities($line);
+ print HTML $line.qq{};
+ }
+ print HTML qq{\n};
+ }
+ }
+ }
+
+ # Print the Actual Migration Notes by Component
+if ($iVerbose > 1)
+ {
+ # Only Print the header if there are some warnings
+ if (scalar(keys %migrationNotes))
+ {
+ print HTML qq{\n};
+ foreach $component (sort {lc $a cmp lc $b} keys %migrationNotes)
+ {
+ my ($HTML) = $component;
+ $HTML =~ s/\s+$//;
+ encode_entities($HTML);
+ my $count = scalar @{$migrationNotes{$component}};
+ print HTML qq{\n};
+ foreach $line (@{$migrationNotes{$component}})
+ {
+ encode_entities($line);
+ print HTML $line.qq{};
+ }
+ print HTML qq{\n};
+ }
+ }
+ }
+
+ # Print the Actual Errors by Command
+ if ($iVerbose > 0)
+ {
+ # Only Print the header if there are some errors
+ if (scalar(keys %CmdErrors))
+ {
+ print HTML qq{Error Details by Command
\n};
+ foreach $command (sort {lc $a cmp lc $b} keys %CmdErrors)
+ {
+ my ($HTML) = $command;
+ $HTML =~ s/\s+$//;
+ encode_entities($HTML);
+ print HTML qq{\n};
+ foreach $line (@{$CmdErrors{$command}})
+ {
+ encode_entities($line);
+ print HTML $line.qq{};
+ }
+ print HTML qq{\n};
+ }
+ }
+ }
+
+ # Print the Actual Warning by Command
+ if ($iVerbose > 1)
+ {
+ # Only Print the header if there are some warnings
+ if (scalar(keys %CmdWarnings))
+ {
+ print HTML qq{Warning Details by Command
\n};
+ foreach $command (sort {lc $a cmp lc $b} keys %CmdWarnings)
+ {
+ my ($HTML) = $command;
+ $HTML =~ s/\s+$//;
+ encode_entities($HTML);
+ print HTML qq{\n};
+ foreach $line (@{$CmdWarnings{$command}})
+ {
+ encode_entities($line);
+ print HTML $line.qq{};
+ }
+ print HTML qq{\n};
+ }
+ }
+ }
+
+ # Print the Actual Advisory Notes by Command
+ if ($iVerbose >1)
+ {
+ # Only Print the header if there are some errors
+ if (scalar(keys %CmdAdvisoryNotes))
+ {
+ print HTML qq{Advisory Note Details by Command
\n};
+
+ foreach $command (sort {lc $a cmp lc $b} keys %CmdAdvisoryNotes)
+ {
+ my ($HTML) = $command;
+ $HTML =~ s/\s+$//;
+ encode_entities($HTML);
+ print HTML qq{\n};
+ foreach $line (@{$CmdAdvisoryNotes{$command}})
+ {
+ encode_entities($line);
+ print HTML $line.qq{};
+ }
+ print HTML qq{\n}
+ }
+ }
+ }
+
+ # Print the Actual Remarks by Command
+ if ($iVerbose > 1)
+ {
+ # Only Print the header if there are some errors
+ if (scalar(keys %CmdRemarks))
+ {
+ print HTML qq{Remarks Details by Command
\n};
+ foreach $command (sort {lc $a cmp lc $b} keys %CmdRemarks)
+ {
+ my ($HTML) = $command;
+ $HTML =~ s/\s+$//;
+ encode_entities($HTML);
+ print HTML qq{\n};
+ foreach $line (@{$CmdRemarks{$command}})
+ {
+ encode_entities($line);
+ print HTML $line.qq{};
+ }
+ print HTML qq{\n};
+ }
+ }
+ }
+
+ # Print the Actual Migration Notes by Command
+ if ($iVerbose >1)
+ {
+ # Only Print the header if there are some errors
+ if (scalar(keys %CmdMigrationNotes))
+ {
+ print HTML qq{Migration Note Details by Command
\n};
+
+ foreach $command (sort {lc $a cmp lc $b} keys %CmdMigrationNotes)
+ {
+ my ($HTML) = $command;
+ $HTML =~ s/\s+$//;
+ encode_entities($HTML);
+ print HTML qq{\n};
+ foreach $line (@{$CmdMigrationNotes{$command}})
+ {
+ encode_entities($line);
+ print HTML $line.qq{};
+ }
+ print HTML qq{\n}
+ }
+ }
+ }
+
+
+}
+
+
+# StartHTMLTable
+#
+# Inputs
+# $iC1Title (Column 1 Title)
+#
+# Outputs
+#
+# Description
+# This function prints the start of the HTML Table
+sub StartHTMLTable
+{
+ my ($iC1Title) = @_;
+
+ if ($iC1Title eq '')
+ {
+ $iC1Title = " ";
+ } else {
+ encode_entities($iC1Title);
+ }
+
+ # Start the Table
+ print HTML qq{\n};
+
+ # Print the Header Row
+ print HTML qq{\n};
+ print HTML qq{\t$iC1Title | \n};
+ print HTML qq{\tTime | \n};
+ print HTML qq{\tErrors | \n};
+ print HTML qq{\tWarnings | \n};
+ print HTML qq{\tAdvisory Notes | \n};
+ print HTML qq{\tRemarks | \n};
+ print HTML qq{\tMigration Notes | \n};
+
+ print HTML qq{
\n};
+}
+
+# HTMLTableCell
+#
+# Inputs
+# $iType (errors,warnings,remarks,migration_notes)
+# $iCount (number of errors)
+# $iLink (empty string or linktype)
+#
+# Outputs
+# Returns HTML table data element with appropriate link & background color
+#
+# Description
+# Constructs HTML table element - used by HTMLTableRow to handle the formatting
+# of the data cells, complete with colouring and links where appropriate.
+sub HTMLTableCell
+{
+ my ($iType,$iCount,$iLink)= @_;
+ my $td = qq{td width="8%" align="center"}; # implied by the TH elements already?
+ if ($iCount != 0)
+ {
+ $td = "$td BGCOLOR=$htmlColours{$iType}";
+ }
+ if ($iLink eq "" || $iCount == 0)
+ {
+ return qq{<$td>$iCount};
+ }
+ $iLink = $iType."By".$iLink;
+ return qq{<$td>$iCount};
+}
+
+# HTMLTableRow
+#
+# Inputs
+# $iTitle (Need to differentiate between command and component to provide correct anchors)
+# $iC1Data(Column 1 Data)
+# $iC2Data(Column 2 Data) (Time in seconds)
+# $iC3Data(Column 3 Data) (Number of errors)
+# $iC4Data(Column 4 Data) (Number of warnings)
+# $iC5Data(Column 5 Data) (Number of Advisory notes )
+# $iC6Data(Column 6 Data) (Number of remarks )
+# $iC7Data(Column 7 Data) (Number of migration notes )
+#
+# Outputs
+#
+# Description
+# This function prints a line of the HTML Table
+sub HTMLTableRow
+{
+ my ($iTitle,$iC1Data, $iC2Data, $iC3Data, $iC4Data,$iC5Data, $iC6Data, $iC7Data) = @_;
+
+ #print "$iC2Data\n";
+
+ # Convert the seconds in hh:mm:ss format
+ $iC2Data = &ConvertSeconds($iC2Data);
+
+ # HTML encode the text
+ encode_entities($iC1Data);
+ encode_entities($iC2Data);
+ encode_entities($iC3Data);
+ encode_entities($iC4Data);
+ encode_entities($iC5Data);
+ encode_entities($iC6Data);
+ encode_entities($iC7Data);
+
+ my $linkname = "$iTitle"."_"."$iC1Data";
+
+ # Print the Row, including summary in a script comment
+ print HTML qq{\n};
+ print HTML qq{\n};
+ print HTML qq{\t$iC1Data | \n};
+ print HTML qq{\t$iC2Data | \n};
+
+ print HTML "\t",&HTMLTableCell("errors", $iC3Data,$linkname),"\n";
+ print HTML "\t",&HTMLTableCell("warnings",$iC4Data,$linkname),"\n";
+ print HTML "\t",&HTMLTableCell("AdvisoryNotes", $iC5Data,$linkname),"\n";
+ print HTML "\t",&HTMLTableCell("remarks", $iC6Data,$linkname),"\n";
+ print HTML "\t",&HTMLTableCell("migrationNotes", $iC7Data,$linkname),"\n";
+
+
+ print HTML qq{
\n};
+}
+
+# ConvertSeconds
+#
+# Inputs
+# $iSeconds
+#
+# Outputs
+# $iString (seconds in hh:mm:ss)
+#
+# Description
+# This function processes the commandline
+sub ConvertSeconds
+{
+ my ($iSeconds) = @_;
+
+ my ($iString);
+ my ($ih) = int($iSeconds/3600);
+ my ($im) = int(($iSeconds-($ih*3600))/60);
+ my ($is) = $iSeconds-($ih*3600)-($im*60);
+ # Print the correct format if the data is HiRes (has a decimal point in the string)
+ if ($is =~ /\d+\.\d+/)
+ {
+ $iString = sprintf "%d:%02d:%06.3f", $ih, $im, $is;
+ } else {
+ $iString = sprintf "%d:%02d:%02d", $ih, $im, $is;
+ }
+ return $iString;
+}
+
+# ProcessCommandLine
+#
+# Inputs
+#
+# Outputs
+# $iOutput (Output filename)
+# $iVerbose (Verbose Level)
+# $iLogs (Log files to process)
+#
+# Description
+# This function processes the commandline
+
+sub ProcessCommandLine {
+ my ($iHelp, @iLogs, $iOutput, $iTitle, $iVerbose);
+ GetOptions('h' => \$iHelp, 'l=s' =>\@iLogs, 'o=s' => \$iOutput, 't=s' => \$iTitle, 'v+' => \$iVerbose);
+
+ if (($iHelp) || (!defined @iLogs) || (!defined $iOutput))
+ {
+ Usage();
+ } elsif (-e $iOutput) {
+ die "$iOutput already exists";
+ }
+
+ foreach my $iLog (@iLogs)
+ {
+ warn "$iLog does not exist" if (! -e $iLog);
+ }
+
+ # Set default title
+ if ($iTitle eq '')
+ {
+ $iTitle = "Log File Summary";
+ }
+
+ return($iOutput, $iTitle, $iVerbose, @iLogs);
+}
+
+# Usage
+#
+# Output Usage Information.
+#
+
+sub Usage {
+ print <
+
+$iTitle
+
+
+
+HTML_EOF
+}
+
+# PrintHTMLFooter
+#
+# Inputs
+#
+# Outputs
+#
+# Description
+# This function print the HTML Footer
+
+sub PrintHTMLFooter {
+ print HTML <
+
+