common/tools/raptor/RaptorWarning.pm
author Simon Howkins <simonh@symbian.org>
Mon, 24 Aug 2009 11:17:40 +0100
changeset 372 ea854a4b723d
parent 364 4dc3b5b1577c
child 383 52675b624b66
permissions -rw-r--r--
Bug 289 Issue in populatezip.pl when doing Platform build in step preprocess-zip-config
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
#
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
#
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
# Contributors:
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    11
#
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
# Description:
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# Raptor parser module.
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    14
# Extract, analyzes and dumps raptor warnings i.e. content of <warning> tags from a raptor log file
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    16
package RaptorWarning;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    17
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    18
use strict;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    19
use RaptorCommon;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    20
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    21
our $reset_status = {};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    22
my $buildlog_status = {};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    23
my $buildlog_warning_status = {};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    25
$reset_status->{name} = 'reset_status';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
$reset_status->{next_status} = {buildlog=>$buildlog_status};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    27
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    28
$buildlog_status->{name} = 'buildlog_status';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    29
$buildlog_status->{next_status} = {warning=>$buildlog_warning_status};
364
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    30
$buildlog_status->{on_start} = 'RaptorWarning::on_start_buildlog';
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
$buildlog_warning_status->{name} = 'buildlog_warning_status';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
$buildlog_warning_status->{next_status} = {};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
$buildlog_warning_status->{on_start} = 'RaptorWarning::on_start_buildlog_warning';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
$buildlog_warning_status->{on_end} = 'RaptorWarning::on_end_buildlog_warning';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
$buildlog_warning_status->{on_chars} = 'RaptorWarning::on_chars_buildlog_warning';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    37
364
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    38
my $filename = '';
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    39
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
my $characters = '';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
my $category = $RaptorCommon::CATEGORY_RAPTORWARNING;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
sub process
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    45
{
364
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    46
	my ($text, $component, $phase, $recipe, $file, $line) = @_;
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    48
	my $severity = $RaptorCommon::SEVERITY_UNKNOWN;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    49
	
364
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    50
	if ($text =~ m,missing flag ENABLE_ABIV2_MODE,)
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    51
	{
364
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    52
		$severity = $RaptorCommon::SEVERITY_NORMAL;
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    53
		my $subcategory = $RaptorCommon::CATEGORY_RAPTORWARNING_MISSINGFLAGABIV2;
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    54
		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    55
	}
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    56
	else # log everything by default
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    57
	{
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    58
		$severity = $RaptorCommon::SEVERITY_NORMAL;
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    59
		my $subcategory = '';
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    60
		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    61
	}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    62
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    63
364
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    64
sub on_start_buildlog
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    65
{
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    66
	RaptorCommon::init();
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    67
	
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    68
	$filename = "$::basedir/warnings.txt";
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    69
	if (!-f$filename)
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    70
	{
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    71
		print "Writing warnings file $filename\n";
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    72
		open(FILE, ">$filename");
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    73
		close(FILE);
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    74
	}
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    75
}
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    76
sub on_start_buildlog_warning
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    77
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    78
	open(FILE, ">>$filename");
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    81
sub on_chars_buildlog_warning
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    82
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
	my ($ch) = @_;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    84
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    85
	#print "on_chars_buildlog_warning\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    86
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
	$characters .= $ch->{Data};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    88
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
	#print "characters is now -->$characters<--\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    90
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    91
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    92
sub on_end_buildlog_warning
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    93
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    94
	#print "on_end_buildlog_warning\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    95
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    96
	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    97
	print FILE "\n" if ($characters !~ m,[\r\n]$, );
364
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    98
	close(FILE);
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    99
	
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
   100
	# get the line number - not really optimized
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
   101
	my $linecount = 0;
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
   102
	open(FILE, "$filename");
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
   103
	for ($linecount = 0; <FILE>; $linecount++) { }
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
   104
	close(FILE);
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
   105
	
4dc3b5b1577c Enable analysis of Raptor warnings. Publish to Diamonds
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
   106
	process($characters, '', '', '', "warnings.txt", $linecount);
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   107
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   108
	$characters = '';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   109
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   110
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   111
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   112
1;