common/tools/brag/sbsToBrag.pl
author Simon Howkins <simonh@symbian.org>
Fri, 04 Dec 2009 11:00:13 +0000
changeset 806 d6151ad46381
parent 798 db3cbddc6f4a
child 815 3ae590eac695
permissions -rw-r--r--
Updated framework for packaging SDK headers so the contents to zip can be set by a project property (or it can zip everything together if it's not set).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     1
#!perl -w
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     2
#
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     8
#
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    11
#
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    12
# Contributors:
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    13
#
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    14
# Description:
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    15
# Generate the BRAG-compatible XML summary of the Raptor log from the CSV output of the raptor parser
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    16
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    17
use strict;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    18
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    19
use FindBin;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    20
use lib "$FindBin::Bin";
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    21
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    22
use XML::Parser;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    23
#use Getopt::Long;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    24
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    25
use ToBrag;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    26
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    27
my $raptorLogGlob = shift or die "First argument must be raptor XML log to read\n";
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    28
shift and die "Only one argument please\n";
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    29
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    30
@ARGV = glob $raptorLogGlob;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    31
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    32
# Start to build structure to be output as XML (same format as XML::Parser would create for us)
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    33
my ($doc, $buildStatus) = ToBrag::createDocumentAndRoot("buildStatus");
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    34
# Obtain a phase object
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    35
my $buildPhase = ToBrag::ensureChild($buildStatus, "phase", "name", "Build");
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    36
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    37
# Parse the Raptor logs
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    38
# (Use XML::Parser in "Stream" mode so we don't have to hold all the data in memory at the same time)
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    39
my $xml = XML::Parser->new(Style => "Stream", Pkg => "main");
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    40
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    41
foreach my $log (@ARGV)
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    42
{
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    43
	$xml->parsefile($log);
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    44
}
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    45
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    46
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    47
print "<?xml-stylesheet type='text/xsl' href='brag.xsl'?>\n";
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    48
ToBrag::printTree($doc->[0]);
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    49
print "\n";
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    50
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    51
exit (0);
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    52
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    53
my $recipeContext;
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    54
my $errorContext;
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    55
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    56
sub StartTag
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    57
{
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    58
	my $expat = shift;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    59
	my $tagName = shift;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    60
	my %attrib = %_;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    61
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    62
	if ($tagName eq "recipe")
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    63
	{
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    64
		$recipeContext = {%attrib};
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    65
	}
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    66
	elsif ($tagName eq "status")
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    67
	{
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    68
		$recipeContext->{"exit"} = $attrib{"exit"};
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    69
	}
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    70
	elsif ($tagName eq "error")
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    71
	{
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    72
		$errorContext = {%attrib};
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    73
	}
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    74
}
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    75
sub EndTag
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    76
{
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    77
	my $expat = shift;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    78
	my $tagName = shift;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    79
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    80
	if ($tagName eq "recipe")
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    81
	{
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    82
		die unless $recipeContext;
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    83
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    84
		if ($recipeContext->{"exit"} ne "ok")
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    85
		{
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    86
			# Create a more readable error message
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    87
			my %errorIdToDetail = (
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    88
				tem => {message => "Failed to execute '$recipeContext->{source}' invoked via $recipeContext->{bldinf}", severity => "major"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    89
				msvctoolscompile => {message => "Failed to compile $recipeContext->{source}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    90
				compile => {message => "Failed to compile $recipeContext->{source}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    91
				compile2object => {message => "Failed to compile $recipeContext->{source}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    92
				win32compile2object => {message => "Failed to compile $recipeContext->{source}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    93
				tools2lib => {message => "Failed to build library $recipeContext->{target}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    94
				ar => {message => "Failed to build library $recipeContext->{target}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    95
				win32archive => {message => "Failed to build library $recipeContext->{target}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    96
				win32def2lib => {message => "Failed to build DLL entry point library $recipeContext->{target}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    97
				"link" => {message => "Failed to create symbols for $recipeContext->{target}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    98
				postlink => {message => "Failed to link $recipeContext->{target}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
    99
				win32stageonelink => {message => "Failed to link $recipeContext->{target} (stage 1)", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   100
				win32stagetwolink => {message => "Failed to link $recipeContext->{target}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   101
				win32simplelink => {message => "Failed to link $recipeContext->{target}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   102
				win32processexports => {message => "Failed to export $recipeContext->{source} to $recipeContext->{target}", severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   103
				tracecompile => {message => "Trace compile failure for $recipeContext->{target}", severity => "unknown"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   104
				extension_makefile => {message => "Failed within an extension makefile connected to $recipeContext->{bldinf}", severity => "major"},
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   105
			);
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   106
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   107
			my $message = $errorIdToDetail{$recipeContext->{name}}->{message} || "Unknown failure tag '$recipeContext->{name}' ($recipeContext->{source} -> $recipeContext->{target})";
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   108
			$recipeContext->{severity} = $errorIdToDetail{$recipeContext->{name}}->{severity} || "unknown";
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   109
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   110
			# Obtain a step object
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   111
			my $step = ToBrag::ensureStep($buildPhase, $recipeContext->{config});
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   112
			# Also create empty <failures> tags with severities in a sensible order
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   113
			ToBrag::ensureFailureSet($step, "critical");
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   114
			ToBrag::ensureFailureSet($step, "major");
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   115
			ToBrag::ensureFailureSet($step, "minor");
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   116
			# Obtain a failures object
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   117
			my $failureSet = ToBrag::ensureFailureSet($step, $recipeContext->{severity});
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   118
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   119
			# Now create the failure itself, and add it to this failure set
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   120
			my $failureItem = bless {
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   121
				Kids => [ bless { Kids => [ bless { Text => $message }, "Characters" ]}, "effect" ],
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   122
			}, "failure";
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   123
			if ($recipeContext->{component})
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   124
			{
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   125
				$recipeContext->{bldinf} =~ s{^\w:(/sf/.*?/.*?)/.*$}{$1};
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   126
				$failureItem->{package} = $recipeContext->{bldinf};
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   127
			}
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   128
			my @causes = grep { $_ && ! m/^\+ / } split("\n", $recipeContext->{Chars});
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   129
			@causes = map { "  $_" } @causes;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   130
			if (@causes)
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   131
			{
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   132
				my @reportedCauses = @causes[0 .. min($#causes, 49)];
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   133
				my $causesItem = bless {
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   134
					Kids => [ bless { Text => join "\n", @reportedCauses }, "Characters" ]
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   135
				}, "causes";
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   136
				push @{$failureItem->{Kids}}, $causesItem;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   137
				my $unreportedCauses = scalar @causes - scalar @reportedCauses;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   138
				$failureItem->{unreported_causes} = $unreportedCauses;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   139
			}
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   140
			push @{$failureSet->{Kids}}, $failureItem, $ToBrag::xmlNewline;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   141
		}
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   142
		
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   143
		$recipeContext = undef;
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   144
	}
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   145
	elsif ($tagName eq "error")
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   146
	{
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   147
		die unless $errorContext;
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   148
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   149
		# Add error to output tree
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   150
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   151
		my $severity = "unknown";
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   152
		my @messageInterpretation = (
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   153
			{regexp => qr{Cannot process schema version .* of file}, severity => "critical"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   154
			{regexp => qr{No bld\.inf found at}, severity => "major"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   155
			{regexp => qr{^Preprocessor exception}, severity => "major"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   156
			{regexp => qr{No such file or directory$}, severity => "major"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   157
			{regexp => qr{Can't find mmp file}, severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   158
			{regexp => qr{The make-engine exited with errors}, severity => "critical"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   159
			{regexp => qr{tool '.+?' from config '.*' did not return version '.*' as required\.}, severity => "critical"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   160
			{regexp => qr{Unknown build configuration '.*'}, severity => "critical"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   161
			{regexp => qr{No build configurations given}, severity => "critical"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   162
			{regexp => qr{Source of export does not exist:}, severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   163
			{regexp => qr{Could not export}, severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   164
			{regexp => qr{Could not export}, severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   165
			{regexp => qr{Source zip for export does not exist:}, severity => "minor"},
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   166
		);
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   167
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   168
		foreach (@messageInterpretation)
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   169
		{
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   170
			if ($errorContext->{Chars} =~ $_->{regexp})
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   171
			{
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   172
				$severity = $_->{severity};
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   173
				last;
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   174
			}
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   175
		}
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   176
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   177
		# Obtain a step object
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   178
		my $step = ToBrag::ensureStep($buildPhase, "Raptor Initialisation");
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   179
		# Also create empty <failures> tags with severities in a sensible order
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   180
		ToBrag::ensureFailureSet($step, "critical");
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   181
		ToBrag::ensureFailureSet($step, "major");
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   182
		ToBrag::ensureFailureSet($step, "minor");
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   183
		# Obtain a failures object
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   184
		my $failureSet = ToBrag::ensureFailureSet($step, $severity);
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   185
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   186
		# Now create the failure itself, and add it to this failure set
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   187
		my $failureItem = bless {
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   188
			Kids => [ bless { Kids => [ bless { Text => $errorContext->{Chars} }, "Characters" ]}, "effect" ],
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   189
		}, "failure";
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   190
		push @{$failureSet->{Kids}}, $failureItem, $ToBrag::xmlNewline;
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   191
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   192
		$errorContext = undef;
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   193
	}
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   194
}
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   195
sub Text
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   196
{
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   197
	s/^\n*//;
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   198
	if ($recipeContext)
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   199
	{
798
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   200
		$recipeContext->{Chars} .= $_;
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   201
	}
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   202
	elsif ($errorContext)
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   203
	{
db3cbddc6f4a Added processing of error tags.
Simon Howkins <simonh@symbian.org>
parents: 766
diff changeset
   204
		$errorContext->{Chars} .= $_;
753
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   205
	}
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   206
}
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   207
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   208
sub min
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   209
{
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   210
	return ($_[0] < $_[1]) ? $_[0] : $_[1] ;
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   211
}
5069de517698 New script which parses raptor logs directly to produce a BRAG summary.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   212