common/tools/raptor/parse.pl
author Dario Sestito <darios@symbian.org>
Wed, 26 Aug 2009 12:30:59 +0100
changeset 383 52675b624b66
parent 242 51e429810aba
child 720 44dd64cfb32b
permissions -rw-r--r--
Add raptor build html summary computation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
#
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
#
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
# Contributors:
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    11
#
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
# Description:
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# Run the raptor parsers
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    14
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
use strict;
383
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    16
use FindBin;
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    17
use lib $FindBin::Bin;
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    18
use RaptorReleaseable;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    19
use RaptorError;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    20
use RaptorWarning;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    21
use RaptorInfo;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    22
use RaptorUnreciped;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    23
use RaptorRecipe;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    25
use XML::SAX;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
use RaptorSAXHandler;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    27
use Getopt::Long;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    28
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    29
my @logfiles;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    30
my $releaseable_module = 0;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
my $error_module = 0;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
my $warning_module = 0;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
my $info_module = 0;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
my $unreciped_module = 0;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
my $recipe_module = 0;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
our $basedir = '';
383
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    37
our $raptor_config = '';
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    38
my $append = 0;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    39
my $help = 0;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
GetOptions((
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
	'log:s' => \@logfiles,
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
	'releaseable!' => \$releaseable_module,
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
	'error!' => \$error_module,
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
	'warning!' => \$warning_module,
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    45
	'info!' => \$info_module,
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    46
	'unreciped!' => \$unreciped_module,
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
	'recipe!' => \$recipe_module,
383
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    48
	'basedir=s' => \$basedir,
52675b624b66 Add raptor build html summary computation
Dario Sestito <darios@symbian.org>
parents: 242
diff changeset
    49
	'config=s' => \$raptor_config,
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    50
	'append!' => \$append,
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    51
	'help!' => \$help
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    52
));
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    53
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    54
$help = 1 if (!@logfiles);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    55
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    56
if ($help)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    57
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    58
	print "Run the raptor parsers\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    59
	print "Usage: perl parse.pl [MODULES] --log=FILE1 --log=FILE2 ... [OPTIONS]\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    60
	print "where MODULES are:\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    61
	print "\t--releaseable Extract releaseable (whatlog) information\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    62
	print "\t--error Extracts raptor errors, i.e. content of <error> tags\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    63
	print "\t--warning Extracts raptor warnings, i.e. content of <warning> tags\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    64
	print "\t--info Extracts raptor info text i.e. content of <info> tags from a raptor log file\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    65
	print "\t--unreciped Extracts output text in <buildlog> context which doesn't belong to any <recipe> tags\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
	print "\t--recipe Extract, analyzes and dumps raptor recipes i.e. content of <recipe> tags from a raptor log file\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    67
	print "where OPTIONS are:\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
	print "\t--basedir=DIR Generate output file under DIR\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
	print "\t--append Do not stop if basedir exists but append newly extracted info to already existing.\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    70
	exit(0);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    71
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    72
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    73
if (!$basedir)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    74
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    75
	$basedir = time;
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    76
	
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    77
	print "Using $basedir as basedir.\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    78
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
if (-d $basedir)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    81
	if ($append)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    82
	{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
		print "Directory $basedir exists. Appending new info to it.\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    84
	}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    85
	else
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    86
	{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
		print "Directory $basedir exists. Quitting.\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    88
		exit(1);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
	}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    90
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    91
mkdir($basedir);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    92
#print "Created dir $basedir.\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    93
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    94
my $saxhandler = RaptorSAXHandler->new();
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    95
if ($releaseable_module)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    96
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    97
	print "Adding RaptorReleaseable module to the observers\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    98
	$saxhandler->add_observer('RaptorReleaseable', $RaptorReleaseable::reset_status);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    99
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   100
if ($error_module)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   101
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   102
	print "Adding RaptorError module to the observers\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   103
	$saxhandler->add_observer('RaptorError', $RaptorError::reset_status);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   104
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   105
if ($warning_module)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   106
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   107
	print "Adding RaptorWarning module to the observers\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   108
	$saxhandler->add_observer('RaptorWarning', $RaptorWarning::reset_status);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   109
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   110
if ($info_module)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   111
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   112
	print "Adding RaptorInfo module to the observers\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   113
	$saxhandler->add_observer('RaptorInfo', $RaptorInfo::reset_status);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   114
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   115
if ($unreciped_module)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   116
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   117
	print "Adding RaptorUnreciped module to the observers\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   118
	$saxhandler->add_observer('RaptorUnreciped', $RaptorUnreciped::reset_status);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   119
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   120
if ($recipe_module)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   121
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   122
	print "Adding RaptorRecipe module to the observers\n";
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   123
	$saxhandler->add_observer('RaptorRecipe', $RaptorRecipe::reset_status);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   124
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   125
my $parser = XML::SAX::ParserFactory->parser(Handler=>$saxhandler);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   126
for (@logfiles)
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   127
{
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   128
	$parser->parse_uri($_);
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   129
}
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   130