common/tools/brag/yarpToBRAG.pl
author Louis Henry Nayegon <louisn@symbian.org>
Thu, 15 Oct 2009 15:59:58 +0100
changeset 675 92fa86ed31d8
parent 654 b64b5a0f8662
child 752 1f07674ec99f
permissions -rw-r--r--
Merge
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
654
b64b5a0f8662 Added lib dir to pick up Text::CSV when it's not included with the installed perl distribution.
Simon Howkins <simonh@symbian.org>
parents: 650
diff changeset
    19
use FindBin;
b64b5a0f8662 Added lib dir to pick up Text::CSV when it's not included with the installed perl distribution.
Simon Howkins <simonh@symbian.org>
parents: 650
diff changeset
    20
use lib "$FindBin::Bin/../lib";
b64b5a0f8662 Added lib dir to pick up Text::CSV when it's not included with the installed perl distribution.
Simon Howkins <simonh@symbian.org>
parents: 650
diff changeset
    21
649
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    22
use Getopt::Long;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    23
use Text::CSV;
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
if (!@ARGV)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    26
{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    27
	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
    28
	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
    29
	exit(1);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    30
}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    31
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
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)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    33
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
    34
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
    35
my $buildStatus =
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
	bless
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
		Kids =>
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    40
		[
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
			$buildPhase,
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    43
			$xmlNewline,
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
	}, "buildStatus"
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    46
];
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
@ARGV = map { glob $_ } @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
foreach my $yarpCSV (@ARGV)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    51
{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    52
	# Read Yarp CSV File
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    53
	unless (open(CSV, $yarpCSV))
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    54
	{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    55
		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
    56
		next;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    57
	}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    58
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    59
	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
    60
	my @keys = ();
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    61
	while (my $line = <CSV>)
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
		chomp $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
		unless ($csv->parse($line))
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    66
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    67
			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
    68
			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
    69
			next;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    70
		}
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
		if (!@keys)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    73
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    74
			@keys = $csv->fields();
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    75
			next;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    76
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    77
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    78
		my @values = $csv->fields();
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    79
		last unless $values[0];
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    80
		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
    81
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    82
			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
    83
			next;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    84
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    85
		# 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
    86
		my $failure = {};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    87
		@{$failure}{@keys} = @values;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    88
		$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
    89
		
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    90
		# Work out the package
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    91
		$failure->{package} = $failure->{bldinf};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    92
		$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
    93
		$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
    94
		
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    95
		# 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
    96
		my %errorIdToDetail = (
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    97
			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
    98
			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
    99
			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
   100
			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
   101
			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
   102
			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
   103
			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
   104
			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
   105
			"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
   106
			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
   107
			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
   108
			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
   109
			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
   110
			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
   111
			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
   112
			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
   113
		);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   114
#		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
   115
		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
   116
		$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
   117
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   118
		# 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
   119
		my $step;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   120
		foreach (@{$buildPhase->{Kids}})
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
			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
   123
			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
   124
			{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   125
				$step = $_;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   126
				last;
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
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   129
		unless ($step)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   130
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   131
			# 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
   132
			$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
   133
			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
   134
			# 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
   135
			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
   136
			{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   137
				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
   138
				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
   139
			}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   140
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   141
		
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   142
		# 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
   143
		my $failureSet;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   144
		foreach (@{$step->{Kids}})
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
			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
   147
			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
   148
			{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   149
				$failureSet = $_;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   150
				last;
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
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   153
		unless ($failureSet)
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   154
		{
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   155
			# 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
   156
			$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
   157
			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
   158
		}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   159
		
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   160
		# 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
   161
		my $failureItem = bless {
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   162
#			href => "",
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   163
			"package" => $failure->{package},
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   164
			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
   165
		}, "failure";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   166
		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
   167
	}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   168
	close(CSV);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   169
}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   170
# Print XML
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   171
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
   172
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
   173
printTree($buildStatus->[0]);
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   174
print "\n";
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
exit(0);
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
sub printTree
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 $tree = shift or die;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   181
	die unless ref $tree;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   182
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   183
	my $tagName = ref $tree;
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   184
	$tagName =~ s{^main::}{};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   185
	if ($tagName eq "Characters")
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
		print $tree->{Text};
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   188
		return;
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
	
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   191
	print "<$tagName";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   192
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   193
	foreach my $attr (
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   194
		sort {
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   195
			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
   196
			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
   197
			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
   198
			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
   199
			$ixA - $ixB;
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
		grep {
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   202
			! ref $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
		keys %$tree)
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
		print " $attr=\"$tree->{$attr}\"";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   207
	}
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
	my $children = $tree->{Kids} || [];
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   210
	if (scalar @$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
		print ">";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   213
		foreach my $child (@$children)
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
			printTree($child);
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
		print "</$tagName";
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
	else
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
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   224
	print ">";
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   225
}
4468add5d834 Added post-processing of YARP analysis to feed into BRAG status.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   226