common/tools/brag/raptorToBRAG.pl
author MattD <mattd@symbian.org>
Thu, 12 Nov 2009 16:06:26 +0000
changeset 750 debbafbce638
parent 665 ddca63d8e13c
child 752 1f07674ec99f
permissions -rw-r--r--
Added tag PDK_3.0.c for changeset 12815724a053
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     1
#!perl -w
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     2
#
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     8
#
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    11
#
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    12
# Contributors:
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    13
#
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    14
# Description:
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    15
# Generate the BRAG-compatible XML summary of the Raptor log from the CSV output of the raptor parser
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    16
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    17
use strict;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    18
665
ddca63d8e13c Add use lib statement to look for Text-CSV in local lib folder
Dario Sestito <darios@symbian.org>
parents: 605
diff changeset
    19
use FindBin;
ddca63d8e13c Add use lib statement to look for Text-CSV in local lib folder
Dario Sestito <darios@symbian.org>
parents: 605
diff changeset
    20
use lib "$FindBin::Bin/../lib";
ddca63d8e13c Add use lib statement to look for Text-CSV in local lib folder
Dario Sestito <darios@symbian.org>
parents: 605
diff changeset
    21
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    22
use Getopt::Long;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    23
use Text::CSV;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    24
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    25
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    26
my $raptorSummary;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    27
my $help = 0;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    28
GetOptions((
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    29
	'raptorsummary=s' => \$raptorSummary,
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    30
	'help!' => \$help
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    31
));
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    32
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    33
$help = 1 if (!$raptorSummary);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    34
if ($help)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    35
{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    36
	print "Generate an XML summary of the Raptor build from a summary.csv file\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    37
	print "Usage: perl summarize.pl --raptorsummary=CSV\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    38
	exit(0);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    39
}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    40
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    41
# Start to build structure to be output as XML (same format as XML::Parser would create for us)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    42
my $xmlNewline = bless { Text => "\n" }, "Characters";
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    43
my $buildStatus =
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    44
[
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    45
	bless
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    46
	{
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    47
		Kids =>
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    48
		[
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    49
			$xmlNewline,
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    50
			bless
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    51
			{
605
2907b286c72a Adjusted capitalisation to make the final output more aesthetically pleasing.
Simon Howkins <simonh@symbian.org>
parents: 569
diff changeset
    52
				name => "Build",
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    53
				Kids => [ $xmlNewline ]
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    54
			}, "phase",
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    55
		]
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    56
	}, "buildStatus"
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    57
];
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    58
# Get a shortcut reference to the bit we will use a lot
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    59
my $buildPhase = $buildStatus->[0]->{Kids}->[-1];
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    60
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    61
# READ SUMMARY.CSV FILE
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    62
open(CSV, $raptorSummary);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    63
my $csv = Text::CSV->new();
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    64
while (my $line = <CSV>)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    65
{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    66
	chomp $line;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    67
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    68
	unless ($csv->parse($line))
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    69
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    70
		my $err = $csv->error_input();
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    71
		warn "Failed to parse $raptorSummary line line $. as CSV '$line': $err  Skipping\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    72
		next;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    73
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    74
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    75
	my @keys = qw{category subcategory severity config component phase recipe file linenum};
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    76
	my @values = $csv->fields();
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    77
	unless (scalar @keys == scalar @keys)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    78
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    79
		warn "WARNING: line does not match expected format at $raptorSummary line $.. Skipping\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    80
		next;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    81
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    82
	
556
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
    83
	# Populate the hash using a hash slice
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    84
	my $failure = {};
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    85
	@{$failure}{@keys} = @values;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    86
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    87
	if (!$failure->{category})
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    88
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    89
		warn "WARNING: summary line without a category at $raptorSummary line $.. Skipping\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    90
		next;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    91
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    92
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    93
	if ($failure->{category} =~ m{^recipe_failure$}i and !$failure->{component})
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    94
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    95
		warn "WARNING: recipe_failure with component field empty at $raptorSummary line $.. Skipping\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    96
		next;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    97
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    98
	$failure->{subcategory} ||= 'uncategorized';
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    99
	$failure->{severity} ||= 'unknown';
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   100
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   101
	# Look through the steps to see if we already have one to match this config
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   102
	my $step;
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
   103
	foreach (@{$buildPhase->{Kids}})
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   104
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   105
		next unless ref $_ eq "step";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   106
		if ($_->{name} eq $failure->{config})
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   107
		{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   108
			$step = $_;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   109
			last;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   110
		}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   111
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   112
	unless ($step)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   113
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   114
		# First item found in this step - create step entry
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   115
		$step = bless { name => $failure->{config}, Kids => [ $xmlNewline ] }, "step";
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
   116
		push @{$buildPhase->{Kids}}, $step, $xmlNewline;
556
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   117
		# Also create empty <failures> tags with severities in a sensible order
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   118
		foreach my $severity (qw{critical major minor})
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   119
		{
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   120
			my $failureSet = bless { level => $severity, Kids => [ $xmlNewline ] }, "failures";
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   121
			push @{$step->{Kids}}, $failureSet, $xmlNewline;
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   122
		}
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   123
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   124
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   125
	# Look through the sets of failures in this step to see if we hve one which matches this severity
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   126
	my $failureSet;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   127
	foreach (@{$step->{Kids}})
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   128
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   129
		next unless ref $_ eq "failures";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   130
		if ($_->{level} eq $failure->{severity})
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   131
		{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   132
			$failureSet = $_;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   133
			last;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   134
		}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   135
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   136
	unless ($failureSet)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   137
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   138
		# First item found at this severity - create failures entry
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   139
		$failureSet = bless { level => $failure->{severity}, Kids => [ $xmlNewline ] }, "failures";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   140
		push @{$step->{Kids}}, $failureSet, $xmlNewline;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   141
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   142
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   143
	# Now create the failure itself, and add it to this failure set
556
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   144
	my $failureItem = bless {
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   145
#		href => "",
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   146
		Kids => [ bless { Text => $failure->{subcategory} }, "Characters" ]
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   147
	}, "failure";
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   148
	if ($failure->{component})
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   149
	{
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   150
		$failure->{component} =~ s{^(/sf/.*?/.*?)/.*$}{$1};
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   151
		$failureItem->{package} = $failure->{component};
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   152
	}
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   153
	push @{$failureSet->{Kids}}, $failureItem, $xmlNewline;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   154
}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   155
close(CSV);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   156
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   157
# Print XML
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   158
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   159
print "<?xml-stylesheet type='text/xsl' href='brag.xsl'?>\n";
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
   160
printTree($buildStatus->[0]);
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   161
print "\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   162
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   163
exit(0);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   164
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   165
sub printTree
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   166
{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   167
	my $tree = shift or die;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   168
	die unless ref $tree;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   169
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   170
	my $tagName = ref $tree;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   171
	$tagName =~ s{^main::}{};
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   172
	if ($tagName eq "Characters")
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   173
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   174
		print $tree->{Text};
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   175
		return;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   176
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   177
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   178
	print "<$tagName";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   179
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   180
	foreach my $attr (
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   181
		sort {
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   182
			my $order = "name level start stop href";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   183
			my $ixA = index $order, $a;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   184
			my $ixB = index $order, $b;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   185
			die "$a $b" if $ixA + $ixB == -2;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   186
			$ixA - $ixB;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   187
		}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   188
		grep {
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   189
			! ref $tree->{$_}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   190
		}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   191
		keys %$tree)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   192
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   193
		print " $attr=\"$tree->{$attr}\"";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   194
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   195
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   196
	my $children = $tree->{Kids} || [];
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   197
	if (scalar @$children)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   198
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   199
		print ">";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   200
		foreach my $child (@$children)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   201
		{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   202
			printTree($child);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   203
		}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   204
		print "</$tagName";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   205
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   206
	else
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   207
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   208
		print "/"
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   209
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   210
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   211
	print ">";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   212
}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   213