common/tools/brag/yarpToBRAG.pl
author Simon Howkins <simonh@symbian.org>
Fri, 09 Oct 2009 14:28:02 +0100
changeset 650 b4c5f01c1ab7
parent 649 4468add5d834
child 654 b64b5a0f8662
permissions -rw-r--r--
Added understanding of the "ar" failure.
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"},
650
b4c5f01c1ab7 Added understanding of the "ar" failure.
Simon Howkins <simonh@symbian.org>
parents: 649
diff changeset
   101
			ar => {message => "Failed to build library $failure->{target}", severity => "minor"},
649
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   102
			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
   103
			"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
   104
			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
   105
			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
   106
			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
   107
			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
   108
			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
   109
			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
   110
			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
   111
		);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   112
#		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
   113
		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
   114
		$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
   115
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   116
		# 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
   117
		my $step;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   118
		foreach (@{$buildPhase->{Kids}})
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   119
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   120
			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
   121
			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
   122
			{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   123
				$step = $_;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   124
				last;
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
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   127
		unless ($step)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   128
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   129
			# 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
   130
			$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
   131
			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
   132
			# 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
   133
			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
   134
			{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   135
				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
   136
				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
   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
		
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   140
		# 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
   141
		my $failureSet;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   142
		foreach (@{$step->{Kids}})
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   143
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   144
			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
   145
			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
   146
			{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   147
				$failureSet = $_;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   148
				last;
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
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   151
		unless ($failureSet)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   152
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   153
			# 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
   154
			$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
   155
			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
   156
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   157
		
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   158
		# 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
   159
		my $failureItem = bless {
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   160
#			href => "",
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   161
			"package" => $failure->{package},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   162
			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
   163
		}, "failure";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   164
		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
   165
	}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   166
	close(CSV);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   167
}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   168
# Print XML
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   169
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
   170
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
   171
printTree($buildStatus->[0]);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   172
print "\n";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   173
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   174
exit(0);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   175
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   176
sub printTree
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   177
{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   178
	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
   179
	die unless ref $tree;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   180
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   181
	my $tagName = ref $tree;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   182
	$tagName =~ s{^main::}{};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   183
	if ($tagName eq "Characters")
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   184
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   185
		print $tree->{Text};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   186
		return;
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
	
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   189
	print "<$tagName";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   190
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   191
	foreach my $attr (
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   192
		sort {
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   193
			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
   194
			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
   195
			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
   196
			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
   197
			$ixA - $ixB;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   198
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   199
		grep {
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   200
			! ref $tree->{$_}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   201
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   202
		keys %$tree)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   203
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   204
		print " $attr=\"$tree->{$attr}\"";
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
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   207
	my $children = $tree->{Kids} || [];
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   208
	if (scalar @$children)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   209
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   210
		print ">";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   211
		foreach my $child (@$children)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   212
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   213
			printTree($child);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   214
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   215
		print "</$tagName";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   216
	}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   217
	else
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   218
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   219
		print "/"
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
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   222
	print ">";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   223
}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   224