common/tools/uh2diamonds.pl
author Dario Sestito <darios@symbian.org>
Thu, 27 May 2010 13:55:39 +0100 (2010-05-27)
changeset 1051 044ab1b95cae
parent 1050 34dcbee2af5e
child 1181 4bdc287cd2c7
permissions -rw-r--r--
Reverse order of Diamonds summary info
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1050
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
#
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
#
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
# Contributors:
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    11
#
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
# Description:
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# Translates uh report (index.html) to a Diamonds file
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    14
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
use strict;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    16
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    17
use Getopt::Long;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    18
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    19
my $input = "\\output\\logs\\html\\index.html";
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    20
my $output = "\\output\\logs\\diamonds_uh.xml";
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    21
my $help = 0;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    22
GetOptions((
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    23
	'in=s' => \$input,
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
	'out=s' => \$output,
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    25
	'help!' => \$help
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
));
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    27
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    28
if ($help)
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    29
{
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    30
	print "Translates uh report (index.html) to a Diamonds file\n";
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
	print "Usage: perl uh2diamonds.pl [--in=UHINDEX] [--out=XMLFILE]\n";
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
	print "\n";
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
	print "UHINDEX is optional, its default is \\output\\logs\\html\\index.html\n";
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
	print "XMLFILE is optional, its default is \\output\\logs\\diamonds_uh.xml\n";
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
	exit(0);
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
}
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    37
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    38
my $critical = 0;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    39
my $major = 0;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
my $minor = 0;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
my $unknown = 0;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
my $missing = 0;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
open(INDEX, $input) or die "Can't open $input for reading";
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    45
while (<INDEX>)
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    46
{
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
	my $line = $_;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    48
	if ($line =~ m,<tr><td><a href='.*'>\w+</a></td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td></tr>,)
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    49
	{
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    50
		$critical += $1;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    51
		$major += $2;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    52
		$minor += $3;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    53
		$unknown += $4;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    54
	}
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    55
	elsif($line =~ m,<tr><td><a href='.+'>.+</a></td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td></tr>,)
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    56
	{
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    57
		$critical += $1;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    58
		$major += $2;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    59
		$minor += $3;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    60
		$unknown += $4;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    61
		$missing += $5;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    62
	}
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    63
}
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    64
close(INDEX);
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    65
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
my $xml_content = <<_EOX;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    67
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
<?xml version=\"1.0\" encoding=\"utf-8\"?>
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
<diamonds-build>
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    70
  <schema>14</schema>
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    71
  <faults>
1051
044ab1b95cae Reverse order of Diamonds summary info
Dario Sestito <darios@symbian.org>
parents: 1050
diff changeset
    72
    <total severity=\"Missing Artifacts\">$missing</total>
044ab1b95cae Reverse order of Diamonds summary info
Dario Sestito <darios@symbian.org>
parents: 1050
diff changeset
    73
    <total severity=\"Raptor Build Unknown\">$unknown</total>
1050
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    74
    <total severity=\"Raptor Build Minor\">$minor</total>
1051
044ab1b95cae Reverse order of Diamonds summary info
Dario Sestito <darios@symbian.org>
parents: 1050
diff changeset
    75
    <total severity=\"Raptor Build Major\">$major</total>
044ab1b95cae Reverse order of Diamonds summary info
Dario Sestito <darios@symbian.org>
parents: 1050
diff changeset
    76
    <total severity=\"Raptor Build Critical\">$critical</total>
1050
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    77
  </faults>
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    78
</diamonds-build>
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
_EOX
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    81
if (open(XML, ">$output"))
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    82
{
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
	print XML $xml_content;
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    84
	close(XML);
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    85
	print "Wrote Diamonds file: $output\n";
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    86
}
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
else
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    88
{
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
	warn "Could not write to file: $output\n";
34dcbee2af5e Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    90
}