common/tools/raptor/unreciped_text.pl
author Shabe Razvi <shaber@symbian.org>
Thu, 09 Jul 2009 15:27:24 +0100
changeset 231 c75afb49c4d3
parent 222 1d9c60a4e308
permissions -rw-r--r--
Add branch and changeset support for getting source. BOM sources.csv can now be reused directly.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
#
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
#
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
# Contributors:
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    11
#
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
# Description:
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# Extracts output text in <buildlog> context which doesn't belong to <recipe>'s
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    14
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
use strict;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    16
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    17
use XML::SAX;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    18
use RaptorSAXHandler;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    19
use Getopt::Long;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    20
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    21
my @logfiles;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    22
my $basedir = '';
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    23
my $help = 0;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
GetOptions((
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    25
	'log:s' => \@logfiles,
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
	'basedir:s' => \$basedir,
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    27
	'help!' => \$help
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    28
));
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    29
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    30
$help = 1 if (!@logfiles);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
if ($help)
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
	print "Extracts text which doesn't belong to recipes from a raptor log file\n";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
	print "Usage: perl unreciped_text.pl --log=FILE1 --log=FILE2 [OPTIONS]\n";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
	print "where OPTIONS are:\n";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    37
	print "\t--basedir=DIR Generate output file under DIR\n";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    38
	exit(0);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    39
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
my $reset_status = {};
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
my $buildlog_status = {};
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
my $buildlog_subtag_status = {};
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    45
$reset_status->{name} = 'reset_status';
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    46
$reset_status->{next_status} = {buildlog=>$buildlog_status};
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    48
$buildlog_status->{name} = 'buildlog_status';
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    49
$buildlog_status->{next_status} = {'?default?'=>$buildlog_subtag_status};
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    50
$buildlog_status->{on_start} = 'main::on_start_buildlog';
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    51
$buildlog_status->{on_end} = 'main::on_end_buildlog';
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    52
$buildlog_status->{on_chars} = 'main::on_chars_buildlog';
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    53
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    54
$buildlog_subtag_status->{name} = 'buildlog_subtag_status';
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    55
$buildlog_subtag_status->{next_status} = {};
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    56
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    57
my $characters = '';
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    58
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    59
if (!$basedir)
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    60
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    61
	$basedir = time;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    62
	
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    63
	print "Using $basedir as basedir.\n";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    64
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    65
if (-d $basedir)
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    67
	print "Directory $basedir exists. Quitting.\n";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
	exit(1);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    70
mkdir($basedir);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    71
#print "Created dir $basedir.\n";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    72
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    73
my $saxhandler = RaptorSAXHandler->new();
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    74
$saxhandler->set_init_status($reset_status);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    75
my $parser = XML::SAX::ParserFactory->parser(Handler=>$saxhandler);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    76
for (@logfiles)
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    77
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    78
	$parser->parse_uri($_);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    81
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    82
sub on_start_buildlog
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    84
	my $filename = "$basedir/unreciped.txt";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    85
	print "Writing unreciped file $filename\n" if (!-f$filename);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    86
	open(FILE, ">>$filename");
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    88
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
sub on_chars_buildlog
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    90
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    91
	my ($ch) = @_;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    92
	
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    93
	my $characters = $ch->{Data};
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    94
	
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    95
	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    96
	
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    97
	#print "characters is now -->$characters<--\n";
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    98
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    99
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   100
sub on_end_buildlog
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   101
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   102
	close(FILE);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   103
}