common/tools/raptor/RaptorWarning.pm
author tathagatar
Mon, 03 Aug 2009 12:03:08 +0100
changeset 297 a0d00364d458
parent 242 51e429810aba
child 364 4dc3b5b1577c
permissions -rw-r--r--
Making device property file
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};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    30
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
$buildlog_warning_status->{name} = 'buildlog_warning_status';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
$buildlog_warning_status->{next_status} = {};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
$buildlog_warning_status->{on_start} = 'RaptorWarning::on_start_buildlog_warning';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
$buildlog_warning_status->{on_end} = 'RaptorWarning::on_end_buildlog_warning';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
$buildlog_warning_status->{on_chars} = 'RaptorWarning::on_chars_buildlog_warning';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    37
my $characters = '';
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    38
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    39
my $category = $RaptorCommon::CATEGORY_RAPTORWARNING;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
sub process
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
	my ($text) = @_;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    45
	my $severity = $RaptorCommon::SEVERITY_UNKNOWN;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    46
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
	if ($text =~ m,unmatchable,)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    48
	{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    49
		$severity = $RaptorCommon::SEVERITY_CRITICAL;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    50
		
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    51
		#dump_error($category, $severity, $text);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    52
		print "$category, $severity, $text\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    53
	}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    54
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    55
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    56
sub on_start_buildlog_warning
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    57
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    58
	my $filename = "$::basedir/warnings.txt";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    59
	print "Writing warning file $filename\n" if (!-f$filename);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    60
	open(FILE, ">>$filename");
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
sub on_chars_buildlog_warning
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    64
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    65
	my ($ch) = @_;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    67
	#print "on_chars_buildlog_warning\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
	$characters .= $ch->{Data};
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    70
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    71
	#print "characters is now -->$characters<--\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    72
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    73
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    74
sub on_end_buildlog_warning
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    75
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    76
	#print "on_end_buildlog_warning\n";
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
	process($characters);
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
	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    81
	print FILE "\n" if ($characters !~ m,[\r\n]$, );
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
	$characters = '';
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
	close(FILE);
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
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
1;