devicediagnostics/group/parse_build_warnings.pl
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 #
       
    16 ######################################################################
       
    17 # ****************************************Script info : See footer.****************************************
       
    18 ######################################################################
       
    19 
       
    20 use strict;
       
    21 use Getopt::Long;
       
    22 
       
    23 my($log_file,$warning_file,$help,$line,%warnings,$comp_path,%type_by_comp);
       
    24 
       
    25 GetOptions (
       
    26             'log_file=s' => \$log_file,
       
    27 			'warning_file=s' => \$warning_file,
       
    28             'help' => \$help
       
    29             );
       
    30 
       
    31 usage() if($help);
       
    32 
       
    33 if(!$log_file){
       
    34     print "ERROR : No log file parse! Exiting...\n";
       
    35     usage();
       
    36 } #if
       
    37 
       
    38 $warning_file=$log_file.".warnings.csv" if(!$warning_file);
       
    39 
       
    40 open(IN,$log_file) || die "Cannot open $log_file\n";
       
    41 while($line=<IN>){
       
    42 	my $key="";
       
    43 	my $val="";
       
    44 	chomp($line);
       
    45 	if($line =~ /^Chdir\s+(.*)/i){
       
    46 		$comp_path=$1;
       
    47 		$comp_path=~ s/\\group$//i;
       
    48 		#$type_by_comp{$comp_path};
       
    49 	}#if
       
    50 	if($line =~ /\bwarning\b/ig){
       
    51 		if($line =~ /\bwarning\s+(\w+\d+)\:/i || $line =~ /\bwarning\:\s+(\#\d+\-\w+)\:/i || $line =~ /\bwarning\:\s+(\w+\d+\w+)\:/i){
       
    52 			$key=$1;
       
    53 			if(exists $warnings{$key}){
       
    54 				$warnings{$key}++;
       
    55 			}
       
    56 			else{
       
    57 				$warnings{$key}=1;
       
    58 			}#if
       
    59 		# }
       
    60 		# else{
       
    61 			# push @other_warnings,($val);
       
    62 		}#if
       
    63 		if ($key ne ""){
       
    64 			if(exists $type_by_comp{$comp_path}{$key}){
       
    65 				$type_by_comp{$comp_path}{$key}++;
       
    66 			}
       
    67 			else{
       
    68 				$type_by_comp{$comp_path}{$key}=1;
       
    69 			}#if
       
    70 		}#if
       
    71 	}#if
       
    72 
       
    73 }#while
       
    74 close(IN);
       
    75 
       
    76 open(OUT,">".$warning_file) || die "Cannot open $warning_file\n";
       
    77 
       
    78 print OUT "\nCOUNTING WARNINGS BY TYPE\n\n";
       
    79 print OUT "Warning,Count\n";
       
    80 for my $w ( sort keys %warnings ) {
       
    81 	print OUT "$w,$warnings{$w}\n";
       
    82 }#for
       
    83 print OUT "\n";
       
    84 
       
    85 print OUT "\nSHOWING SPECIFIC WARNINGS BY COMPONENT AND TYPE\n\n";
       
    86 print OUT "Component,Total warnings by component,Warnings\n";
       
    87 
       
    88 for my $co ( sort keys %type_by_comp ) {
       
    89     print OUT "\n$co,";
       
    90     my @ctvals=values %{ $type_by_comp{$co} };
       
    91     my $ctsum=0;
       
    92     foreach my $cval(@ctvals){
       
    93     	$ctsum+=$cval;
       
    94     }#foreach
       
    95     print OUT "$ctsum,";
       
    96     for my $ty ( sort keys %{ $type_by_comp{$co} } ) {
       
    97          print OUT " $ty=$type_by_comp{$co}{$ty} ";
       
    98 	}#for
       
    99 }#for
       
   100 print OUT "\n\n";
       
   101 
       
   102 close(OUT);
       
   103 
       
   104 #--------------------------------------------------------------#
       
   105 
       
   106 sub usage{
       
   107 	while(<DATA>){
       
   108 		print;
       
   109 	} #while
       
   110 	exit;
       
   111 } #sub
       
   112 
       
   113 __DATA__
       
   114 
       
   115 #--------------------------------------------------------------#
       
   116 #-------------------------- USAGE -----------------------------#
       
   117 #--------------------------------------------------------------#
       
   118  Script name:	parse_build_warnings.pl
       
   119 
       
   120  Copyright (c) 2007-2008 Nokia. All rights reserved.
       
   121 
       
   122  Purpose:
       
   123 
       
   124 	To parse warning messages from s60 platform build log.
       
   125 
       
   126  Revision History:
       
   127 
       
   128 	v0.1.0 19.09.2007 Qvist Heikki 	Initial version.
       
   129 	v0.1.1 20.09.2007 Qvist Heikki 	Count warnings.
       
   130 	v0.1.2 10.10.2007 Qvist Heikki 	Count warnings per a component.
       
   131 	v0.2.0 10.01.2008 Qvist Heikki 	Clean useless output. Fix counters (0 -> 1).
       
   132 	v0.3.0 10.01.2008 Qvist Heikki 	Output to CSV-file for Excel reading.
       
   133     
       
   134     Commandline options:
       
   135     
       
   136         -h show this info.
       
   137         -l log file to parse out.
       
   138         -w output file contain warnings.
       
   139         	If not given, <logfile>.warnings.txt is generated.
       
   140 #--------------------------------------------------------------#