common/tools/raptor/RaptorWarning.pm
changeset 270 48a6e55f691b
parent 242 51e429810aba
child 364 4dc3b5b1577c
equal deleted inserted replaced
269:cdf0b7c501d2 270:48a6e55f691b
       
     1 # Copyright (c) 2009 Symbian Foundation Ltd
       
     2 # This component and the accompanying materials are made available
       
     3 # under the terms of the License "Eclipse Public License v1.0"
       
     4 # which accompanies this distribution, and is available
       
     5 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     6 #
       
     7 # Initial Contributors:
       
     8 # Symbian Foundation Ltd - initial contribution.
       
     9 #
       
    10 # Contributors:
       
    11 #
       
    12 # Description:
       
    13 # Raptor parser module.
       
    14 # Extract, analyzes and dumps raptor warnings i.e. content of <warning> tags from a raptor log file
       
    15 
       
    16 package RaptorWarning;
       
    17 
       
    18 use strict;
       
    19 use RaptorCommon;
       
    20 
       
    21 our $reset_status = {};
       
    22 my $buildlog_status = {};
       
    23 my $buildlog_warning_status = {};
       
    24 
       
    25 $reset_status->{name} = 'reset_status';
       
    26 $reset_status->{next_status} = {buildlog=>$buildlog_status};
       
    27 
       
    28 $buildlog_status->{name} = 'buildlog_status';
       
    29 $buildlog_status->{next_status} = {warning=>$buildlog_warning_status};
       
    30 
       
    31 $buildlog_warning_status->{name} = 'buildlog_warning_status';
       
    32 $buildlog_warning_status->{next_status} = {};
       
    33 $buildlog_warning_status->{on_start} = 'RaptorWarning::on_start_buildlog_warning';
       
    34 $buildlog_warning_status->{on_end} = 'RaptorWarning::on_end_buildlog_warning';
       
    35 $buildlog_warning_status->{on_chars} = 'RaptorWarning::on_chars_buildlog_warning';
       
    36 
       
    37 my $characters = '';
       
    38 
       
    39 my $category = $RaptorCommon::CATEGORY_RAPTORWARNING;
       
    40 
       
    41 sub process
       
    42 {
       
    43 	my ($text) = @_;
       
    44 	
       
    45 	my $severity = $RaptorCommon::SEVERITY_UNKNOWN;
       
    46 	
       
    47 	if ($text =~ m,unmatchable,)
       
    48 	{
       
    49 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
       
    50 		
       
    51 		#dump_error($category, $severity, $text);
       
    52 		print "$category, $severity, $text\n";
       
    53 	}
       
    54 }
       
    55 
       
    56 sub on_start_buildlog_warning
       
    57 {
       
    58 	my $filename = "$::basedir/warnings.txt";
       
    59 	print "Writing warning file $filename\n" if (!-f$filename);
       
    60 	open(FILE, ">>$filename");
       
    61 }
       
    62 
       
    63 sub on_chars_buildlog_warning
       
    64 {
       
    65 	my ($ch) = @_;
       
    66 	
       
    67 	#print "on_chars_buildlog_warning\n";
       
    68 	
       
    69 	$characters .= $ch->{Data};
       
    70 	
       
    71 	#print "characters is now -->$characters<--\n";
       
    72 }
       
    73 
       
    74 sub on_end_buildlog_warning
       
    75 {
       
    76 	#print "on_end_buildlog_warning\n";
       
    77 	
       
    78 	process($characters);
       
    79 	
       
    80 	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
       
    81 	print FILE "\n" if ($characters !~ m,[\r\n]$, );
       
    82 	
       
    83 	$characters = '';
       
    84 	
       
    85 	close(FILE);
       
    86 }
       
    87 
       
    88 
       
    89 1;