common/tools/brag/yarpToBRAG.pl
author Simon Howkins <simonh@symbian.org>
Wed, 07 Oct 2009 15:36:15 +0100
changeset 649 4468add5d834
child 650 b4c5f01c1ab7
permissions -rw-r--r--
Added post-processing of YARP analysis to feed into BRAG status.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
649
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     1
#!perl -w
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     2
#
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     8
#
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    11
#
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    12
# Contributors:
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    13
#
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    14
# Description:
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    15
# Generate the BRAG-compatible XML summary of the Raptor log from Yarp analysis
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    16
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    17
use strict;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    18
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    19
use Getopt::Long;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    20
use Text::CSV;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    21
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    22
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    23
if (!@ARGV)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    24
{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    25
	warn "Generate an XML summary of the Raptor build from a Yarp CSV file\n";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    26
	warn "Eg: yarpToBRAG.pl aYarpFile.csv [*_yarp.csv ...]\n";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    27
	exit(1);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    28
}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    29
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    30
# Start to build structure to be output as XML (same format as XML::Parser would create for us)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    31
my $xmlNewline = bless { Text => "\n" }, "Characters";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    32
my $buildPhase = bless { name => "Build", Kids => [ $xmlNewline ] }, "phase";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    33
my $buildStatus =
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    34
[
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    35
	bless
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    36
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    37
		Kids =>
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    38
		[
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    39
			$xmlNewline,
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    40
			$buildPhase,
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    41
			$xmlNewline,
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    42
		]
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    43
	}, "buildStatus"
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    44
];
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    45
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    46
@ARGV = map { glob $_ } @ARGV;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    47
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    48
foreach my $yarpCSV (@ARGV)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    49
{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    50
	# Read Yarp CSV File
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    51
	unless (open(CSV, $yarpCSV))
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    52
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    53
		warn "ERROR: Unable to open $yarpCSV to process. Skipping.\n";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    54
		next;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    55
	}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    56
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    57
	my $csv = Text::CSV->new();
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    58
	my @keys = ();
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    59
	while (my $line = <CSV>)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    60
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    61
		chomp $line;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    62
		
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    63
		unless ($csv->parse($line))
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    64
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    65
			my $err = $csv->error_input();
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    66
			warn "WARNING: Failed to parse $yarpCSV line $. as CSV '$line': $err  Skipping\n";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    67
			next;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    68
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    69
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    70
		if (!@keys)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    71
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    72
			@keys = $csv->fields();
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    73
			next;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    74
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    75
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    76
		my @values = $csv->fields();
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    77
		last unless $values[0];
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    78
		unless (scalar @values == scalar @keys)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    79
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    80
			warn "WARNING: line does not match expected format at $yarpCSV line $.. Skipping\n";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    81
			next;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    82
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    83
		# Populate the hash using a hash slice
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    84
		my $failure = {};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    85
		@{$failure}{@keys} = @values;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    86
		$failure->{platform} = lc $failure->{platform};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    87
		
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    88
		# Work out the package
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    89
		$failure->{package} = $failure->{bldinf};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    90
		$failure->{package} =~ s{[A-Z]:}{}i;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    91
		$failure->{package} =~ s{^(/sf/.*?/.*?)/.*}{$1}i;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    92
		
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    93
		# Create a more readable error message
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    94
		my %errorIdToDetail = (
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    95
			tem => {message => "Failed to process $failure->{source}", severity => "major"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    96
			msvctoolscompile => {message => "Failed to compile $failure->{source}", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    97
			compile => {message => "Failed to compile $failure->{source}", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    98
			compile2object => {message => "Failed to compile $failure->{source}", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    99
			win32compile2object => {message => "Failed to compile $failure->{source}", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   100
			tools2lib => {message => "Failed to build library $failure->{target}", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   101
			win32archive => {message => "Failed to build library $failure->{target}", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   102
			"link" => {message => "Failed to create symbols for $failure->{target}", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   103
			postlink => {message => "Failed to link $failure->{target}", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   104
			win32stageonelink => {message => "Failed to link $failure->{target} (stage 1)", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   105
			win32stagetwolink => {message => "Failed to link $failure->{target}", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   106
			win32simplelink => {message => "Failed to link $failure->{target}", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   107
			win32processexports => {message => "Failed to export $failure->{source} to $failure->{target}", severity => "minor"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   108
			tracecompile => {message => "Trace compile failure for $failure->{target}", severity => "unknown"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   109
			extension_makefile => {message => "Failed to process an extension makefile connected to $failure->{bldinf}", severity => "major"},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   110
		);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   111
#		die $failure->{name} unless exists $errorIdToDetail{$failure->{name}};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   112
		my $message = $errorIdToDetail{$failure->{name}}->{message} || "Unknown failure tag '$failure->{name}' ($failure->{source} -> $failure->{target})";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   113
		$failure->{severity} = $errorIdToDetail{$failure->{name}}->{severity} || "unknown";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   114
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   115
		# Look through the steps to see if we already have one to match this platform
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   116
		my $step;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   117
		foreach (@{$buildPhase->{Kids}})
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   118
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   119
			next unless ref $_ eq "step";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   120
			if ($_->{name} eq $failure->{platform})
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   121
			{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   122
				$step = $_;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   123
				last;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   124
			}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   125
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   126
		unless ($step)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   127
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   128
			# First item found for this platform - create step entry
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   129
			$step = bless { name => $failure->{platform}, Kids => [ $xmlNewline ] }, "step";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   130
			push @{$buildPhase->{Kids}}, $step, $xmlNewline;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   131
			# Also create empty <failures> tags with severities in a sensible order
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   132
			foreach my $severity (qw{critical major minor})
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   133
			{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   134
				my $failureSet = bless { level => $severity, Kids => [ $xmlNewline ] }, "failures";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   135
				push @{$step->{Kids}}, $failureSet, $xmlNewline;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   136
			}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   137
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   138
		
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   139
		# Look through the sets of failures in this step to see if we hve one which matches this severity
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   140
		my $failureSet;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   141
		foreach (@{$step->{Kids}})
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   142
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   143
			next unless ref $_ eq "failures";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   144
			if ($_->{level} eq $failure->{severity})
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   145
			{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   146
				$failureSet = $_;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   147
				last;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   148
			}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   149
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   150
		unless ($failureSet)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   151
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   152
			# First item found at this severity - create failures entry
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   153
			$failureSet = bless { level => $failure->{severity}, Kids => [ $xmlNewline ] }, "failures";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   154
			push @{$step->{Kids}}, $failureSet, $xmlNewline;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   155
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   156
		
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   157
		# Now create the failure itself, and add it to this failure set
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   158
		my $failureItem = bless {
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   159
#			href => "",
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   160
			"package" => $failure->{package},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   161
			Kids => [ bless { Text => $message }, "Characters" ],
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   162
		}, "failure";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   163
		push @{$failureSet->{Kids}}, $failureItem, $xmlNewline;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   164
	}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   165
	close(CSV);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   166
}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   167
# Print XML
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   168
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   169
print "<?xml-stylesheet type='text/xsl' href='brag.xsl'?>\n";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   170
printTree($buildStatus->[0]);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   171
print "\n";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   172
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   173
exit(0);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   174
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   175
sub printTree
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   176
{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   177
	my $tree = shift or die;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   178
	die unless ref $tree;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   179
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   180
	my $tagName = ref $tree;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   181
	$tagName =~ s{^main::}{};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   182
	if ($tagName eq "Characters")
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   183
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   184
		print $tree->{Text};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   185
		return;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   186
	}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   187
	
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   188
	print "<$tagName";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   189
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   190
	foreach my $attr (
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   191
		sort {
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   192
			my $order = "name level start stop href";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   193
			my $ixA = index $order, $a;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   194
			my $ixB = index $order, $b;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   195
			die "$a $b" if $ixA + $ixB == -2;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   196
			$ixA - $ixB;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   197
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   198
		grep {
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   199
			! ref $tree->{$_}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   200
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   201
		keys %$tree)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   202
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   203
		print " $attr=\"$tree->{$attr}\"";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   204
	}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   205
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   206
	my $children = $tree->{Kids} || [];
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   207
	if (scalar @$children)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   208
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   209
		print ">";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   210
		foreach my $child (@$children)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   211
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   212
			printTree($child);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   213
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   214
		print "</$tagName";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   215
	}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   216
	else
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   217
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   218
		print "/"
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   219
	}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   220
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   221
	print ">";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   222
}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   223