deprecated/buildtools/buildsystemtools/scanlog/scanlog.pl
changeset 655 3f65fd25dfd4
equal deleted inserted replaced
649:02d78c9f018e 655:3f65fd25dfd4
       
     1 # Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # summarise an automated build log
       
    15 # documentation available in generic\tools\e32toolp\docs\scanlog.txt
       
    16 # please update the documentation when modifying this file
       
    17 # RegEx's in Scanlog Module
       
    18 # 
       
    19 #
       
    20 
       
    21 use strict;
       
    22 use FindBin;		# for FindBin::Bin
       
    23 
       
    24 # Add the directory contain this perl script into the path to find modules
       
    25 use lib $FindBin::Bin;
       
    26 
       
    27 use Scanlog;
       
    28 
       
    29 my $line;
       
    30 my $iSlurp;
       
    31 my $phase;
       
    32 my $match_phase='';
       
    33 my $command='???';
       
    34 my $starttime;
       
    35 my $duration;
       
    36 my $errorcount=0;
       
    37 my $component='???';
       
    38 my %errors;
       
    39 my %missing;
       
    40 my %not_built;
       
    41 my $totalduration = 0;
       
    42 my $totalerrors = 0;
       
    43 my $warningcount=0;
       
    44 my %warnings;
       
    45 my $totalwarnings = 0;
       
    46 my $remarkscount=0;
       
    47 my %remarks;
       
    48 my $totalremarks = 0;
       
    49 my $migrationnotescount=0;
       
    50 my %migrationnotes;
       
    51 my $totalmigrationnotes = 0;
       
    52 my ($iStatus, $iName);
       
    53 
       
    54 my $verbose = 0;
       
    55 my $argc = scalar(@ARGV);
       
    56 if ($argc>0 and $ARGV[0]=~/^\s*\-v\s*$/)
       
    57 	{
       
    58 	$verbose = 1;
       
    59 	shift @ARGV;
       
    60 	}
       
    61 elsif ($argc>0 and $ARGV[0]=~/^\s*\-V\s*$/)
       
    62 	{
       
    63 	$verbose = 2;
       
    64 	shift @ARGV;
       
    65 	}
       
    66 	
       
    67 sub do_remarks()
       
    68 	{
       
    69 	$remarkscount += 1;
       
    70 	if (!defined $remarks{$component})
       
    71 		{
       
    72 		$remarks{$component} = ();
       
    73 		}
       
    74 	push @{$remarks{$component}}, $line;
       
    75 	}
       
    76 	
       
    77 sub do_migrationnotes()
       
    78 	{
       
    79 	$migrationnotescount += 1;
       
    80 	if (!defined $migrationnotes{$component})
       
    81 		{
       
    82 		$migrationnotes{$component} = ();
       
    83 		}
       
    84 	push @{$migrationnotes{$component}}, $line;
       
    85 	}
       
    86 	
       
    87 sub do_warning()
       
    88 	{
       
    89 	$warningcount += 1;
       
    90 	if (!defined $warnings{$component})
       
    91 		{
       
    92 		$warnings{$component} = ();
       
    93 		}
       
    94 	push @{$warnings{$component}}, $line;
       
    95 	}
       
    96 	
       
    97 sub do_error()
       
    98 	{
       
    99 	$errorcount += 1;
       
   100 	if (!defined $errors{$component})
       
   101 		{
       
   102 		$errors{$component} = ();
       
   103 		}
       
   104 	push @{$errors{$component}}, $line;
       
   105 	}
       
   106 
       
   107 # Read a number of lines in the log ignoreing the content
       
   108 sub do_slurp
       
   109 {
       
   110   my ($num_lines) =@_;
       
   111   for (my $i = 0; $i < $num_lines; $i++)
       
   112   {
       
   113     <>;
       
   114   }
       
   115 }
       
   116 
       
   117 sub print_command_summary($;$)
       
   118 	{
       
   119 	my ($command, $duration) = @_;
       
   120 	
       
   121 	return if ($command eq '???' && $errorcount==0 && $warningcount==0 && $remarkscount==0 && $migrationnotescount==0 );
       
   122 	
       
   123 	my $elapsed = '??:??:??';
       
   124 	if (defined($duration))
       
   125 		{
       
   126 		$totalduration += $duration;
       
   127 		my ($sec,$min,$hour) = gmtime($duration);
       
   128 		$elapsed = sprintf("%02d:%02d:%02d", $hour, $min, $sec);
       
   129 		}
       
   130 
       
   131 	printf "%-28s\t%s\t%6d\t%6d\t%6d\t%6d\n", $command, $elapsed, $errorcount, $warningcount, $remarkscount, $migrationnotescount;
       
   132 	$totalerrors += $errorcount;
       
   133 	$totalwarnings += $warningcount;
       
   134 	$totalremarks += $remarkscount;
       
   135 	$totalmigrationnotes += $migrationnotescount;
       
   136 	$errorcount = 0;
       
   137 	$warningcount = 0;
       
   138 	$remarkscount = 0;
       
   139 	$migrationnotescount = 0;
       
   140 	}
       
   141 	
       
   142 printf "%-28s\t%-8s\t%-6s\t%-6s\t%-6s\t%-6s   %s\n", 'Command', 'Time', 'Errors', 'Warning','Remarks','Migration-Notes';
       
   143 
       
   144 while ($line=<>)
       
   145 	{
       
   146 
       
   147 	# ===-------------------------------------------------
       
   148 	# === baseline_bldfiles   
       
   149 	# ===-------------------------------------------------
       
   150 	# === bldfiles started Sat Jul 24 01:38:03 1999.
       
   151 
       
   152 	if ($line =~ /^===------/)
       
   153 		{
       
   154 		print_command_summary($command);
       
   155 		$line = <>;
       
   156 		$line =~ /=== (.*)$/;
       
   157 		$command = $1;
       
   158 		<>;
       
   159 		$line = <>;
       
   160 		$line =~ /^=== (.+) started ... ... .. (..):(..):(..)/;
       
   161 		$phase = $1;
       
   162 		$starttime = ($2*60 + $3)*60 + $4;
       
   163 		$match_phase=$phase;
       
   164 		$match_phase=~s-\\-\\\\-go;
       
   165 		next;
       
   166 		}
       
   167 
       
   168 	# === bldfiles finished Sat Jul 24 01:38:56 1999.
       
   169 	if ($line =~ /^=== $match_phase finished ... ... .. (..):(..):(..)/)
       
   170 		{
       
   171 		$duration = ($1*60 + $2)*60 + $3 - $starttime;
       
   172 		if ($duration < 0)
       
   173 			{
       
   174 			$duration += 24*60*60;
       
   175 			}
       
   176 		
       
   177 		print_command_summary($command,$duration);
       
   178 		$command = '???';
       
   179 		$component = '???';
       
   180 		next;
       
   181 		}
       
   182 
       
   183 	# === resource == gdtran 036
       
   184 
       
   185 	if ($line =~ /=== $match_phase == (\S+)/)
       
   186 		{
       
   187 		$component = $1;
       
   188 		$component =~ /(.*)[\\]$/;
       
   189 		$component = $1;
       
   190 		next;
       
   191 		}
       
   192 
       
   193 	# Lines to Ignore
       
   194   ($iStatus) =&Scanlog::CheckForIgnore($line);
       
   195 	if($iStatus)
       
   196 	{
       
   197 		next;
       
   198 	}
       
   199   
       
   200 	# migrationnotes
       
   201   ($iStatus, $iSlurp) =&Scanlog::CheckForMigrationNotes($line);
       
   202 	if ($iStatus)
       
   203 	{
       
   204 		do_migrationnotes();
       
   205     do_slurp($iSlurp);
       
   206 		next;
       
   207 	}
       
   208 	# Remarks
       
   209   ($iStatus, $iSlurp) =&Scanlog::CheckForRemarks($line);
       
   210 	if ($iStatus)
       
   211 	{
       
   212 		do_remarks();
       
   213     do_slurp($iSlurp);
       
   214 		next;
       
   215 	}
       
   216 	# Errors
       
   217   ($iStatus) =&Scanlog::CheckForErrors($line);
       
   218 	if ($iStatus)
       
   219 	{
       
   220 		do_error();
       
   221 		next;
       
   222 	}
       
   223 
       
   224 	# Warnings
       
   225   ($iStatus) =&Scanlog::CheckForWarnings($line);
       
   226 	if ($iStatus)
       
   227 	{
       
   228 		do_warning();
       
   229 		next;
       
   230 	}
       
   231 
       
   232 	# Things Not Built
       
   233   ($iStatus, $iName) =&Scanlog::CheckForNotBuilt($line);
       
   234 	if ($iStatus)
       
   235 	{
       
   236 		do_error();
       
   237 		$not_built{$iName} = "$component";
       
   238 		next;
       
   239 	}
       
   240 
       
   241 	# Things missing
       
   242   ($iStatus, $iName) =&Scanlog::CheckForMissing($line);
       
   243 	if ($iStatus)
       
   244 	{
       
   245 		do_error();
       
   246 		$missing{$iName} += 1;
       
   247 		next;
       
   248 	}
       
   249 
       
   250 }
       
   251 
       
   252 print_command_summary($command);
       
   253 print "\n";
       
   254 my ($sec,$min,$hour, $mday) = gmtime($totalduration);
       
   255 $hour+=($mday-1)*24;	# to allow for builds taking longer than 24 hours!
       
   256 
       
   257 printf "%-28s\t%02d:%02d:%02d\t%6d\t%6d\t%6d\t%6d\n\n", "Total", $hour, $min, $sec, $totalerrors, $totalwarnings, $totalremarks, $totalmigrationnotes;
       
   258 
       
   259 if (scalar %errors)
       
   260 	{
       
   261 	print "Fatal Errors by Component\n";
       
   262 	$errorcount = 0;
       
   263 	foreach $component (sort keys %errors)
       
   264 		{
       
   265 		printf "%-16s\t%6d\n", $component, scalar(@{$errors{$component}});
       
   266 		$errorcount += scalar(@{$errors{$component}});
       
   267 		}
       
   268 	if ($verbose>0)
       
   269 		{
       
   270 		print "\nError details";
       
   271 		foreach $component (sort keys %errors)
       
   272 			{
       
   273 			print "\n----------------------------\n$component\n";
       
   274 			foreach $line (@{$errors{$component}})
       
   275 				{
       
   276 				print $line;
       
   277 				}
       
   278 			}
       
   279 		}
       
   280 	}
       
   281 
       
   282 if (scalar %missing)
       
   283 	{
       
   284 	print "\nDon't know how to make...\n";
       
   285 	foreach my $file (sort keys %missing)
       
   286 		{
       
   287 		printf "%d\t%s\n", $missing{$file}, $file;
       
   288 		}
       
   289 	}
       
   290 
       
   291 if (scalar %not_built)
       
   292 	{
       
   293 	print "\nThings not built...\n";
       
   294 	foreach my $file (sort keys %not_built)
       
   295 		{
       
   296 		print "MISSING: $file ($not_built{$file})\n";
       
   297 		}
       
   298 	print "\n\n";
       
   299 	}
       
   300 
       
   301 if (scalar %warnings)
       
   302 	{
       
   303 	print "\nWarnings by Component\n";
       
   304 	$warningcount = 0;
       
   305 	foreach $component (sort keys %warnings)
       
   306 		{
       
   307 		printf "%-16s\t%6d\n", $component, scalar @{$warnings{$component}};
       
   308 		}
       
   309 	if ($verbose>1)
       
   310 		{
       
   311 		print "\nWarning details";
       
   312 		foreach $component (sort keys %warnings)
       
   313 			{
       
   314 			print "\n----------------------------\n$component\n";
       
   315 			foreach $line (@{$warnings{$component}})
       
   316 				{
       
   317 				print $line;
       
   318 				}
       
   319 			}
       
   320 		}
       
   321 	}
       
   322 if (scalar %remarks)
       
   323 	{
       
   324 	print "\nRemarks by Component\n";
       
   325 	$remarkscount = 0;
       
   326 	foreach $component (sort keys %remarks)
       
   327 		{
       
   328 		printf "%-16s\t%6d\n", $component, scalar @{$remarks{$component}};
       
   329 		}
       
   330 	if ($verbose>1)
       
   331 		{
       
   332 		print "\nRemarks details";
       
   333 		foreach $component (sort keys %remarks)
       
   334 			{
       
   335 			print "\n----------------------------\n$component\n";
       
   336 			foreach $line (@{$remarks{$component}})
       
   337 				{
       
   338 				print $line;
       
   339 				}
       
   340 			}
       
   341 		}
       
   342 	}
       
   343 
       
   344 if (scalar %migrationnotes)
       
   345 	{
       
   346 	print "\nMigration Notes by Component\n";
       
   347 	$migrationnotescount = 0;
       
   348 	foreach $component (sort keys %migrationnotes)
       
   349 		{
       
   350 		printf "%-16s\t%6d\n", $component, scalar @{$migrationnotes{$component}};
       
   351 		}
       
   352 	if ($verbose>1)
       
   353 		{
       
   354 		print "\nMigration Notes Details";
       
   355 		foreach $component (sort keys %migrationnotes)
       
   356 			{
       
   357 			print "\n----------------------------\n$component\n";
       
   358 			foreach $line (@{$migrationnotes{$component}})
       
   359 				{
       
   360 				print $line;
       
   361 				}
       
   362 			}
       
   363 		}
       
   364 	}
       
   365