diff -r 3f8d2ea13886 -r 1d9c60a4e308 common/tools/raptor/unreciped_text.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/raptor/unreciped_text.pl Tue Jun 30 13:58:29 2009 +0100 @@ -0,0 +1,103 @@ +# Copyright (c) 2009 Symbian Foundation Ltd +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Symbian Foundation Ltd - initial contribution. +# +# Contributors: +# +# Description: +# Extracts output text in context which doesn't belong to 's + +use strict; + +use XML::SAX; +use RaptorSAXHandler; +use Getopt::Long; + +my @logfiles; +my $basedir = ''; +my $help = 0; +GetOptions(( + 'log:s' => \@logfiles, + 'basedir:s' => \$basedir, + 'help!' => \$help +)); + +$help = 1 if (!@logfiles); + +if ($help) +{ + print "Extracts text which doesn't belong to recipes from a raptor log file\n"; + print "Usage: perl unreciped_text.pl --log=FILE1 --log=FILE2 [OPTIONS]\n"; + print "where OPTIONS are:\n"; + print "\t--basedir=DIR Generate output file under DIR\n"; + exit(0); +} + +my $reset_status = {}; +my $buildlog_status = {}; +my $buildlog_subtag_status = {}; + +$reset_status->{name} = 'reset_status'; +$reset_status->{next_status} = {buildlog=>$buildlog_status}; + +$buildlog_status->{name} = 'buildlog_status'; +$buildlog_status->{next_status} = {'?default?'=>$buildlog_subtag_status}; +$buildlog_status->{on_start} = 'main::on_start_buildlog'; +$buildlog_status->{on_end} = 'main::on_end_buildlog'; +$buildlog_status->{on_chars} = 'main::on_chars_buildlog'; + +$buildlog_subtag_status->{name} = 'buildlog_subtag_status'; +$buildlog_subtag_status->{next_status} = {}; + +my $characters = ''; + +if (!$basedir) +{ + $basedir = time; + + print "Using $basedir as basedir.\n"; +} +if (-d $basedir) +{ + print "Directory $basedir exists. Quitting.\n"; + exit(1); +} +mkdir($basedir); +#print "Created dir $basedir.\n"; + +my $saxhandler = RaptorSAXHandler->new(); +$saxhandler->set_init_status($reset_status); +my $parser = XML::SAX::ParserFactory->parser(Handler=>$saxhandler); +for (@logfiles) +{ + $parser->parse_uri($_); +} + + +sub on_start_buildlog +{ + my $filename = "$basedir/unreciped.txt"; + print "Writing unreciped file $filename\n" if (!-f$filename); + open(FILE, ">>$filename"); +} + +sub on_chars_buildlog +{ + my ($ch) = @_; + + my $characters = $ch->{Data}; + + print FILE $characters if ($characters =~ m,[^\s^\r^\n],); + + #print "characters is now -->$characters<--\n"; +} + +sub on_end_buildlog +{ + close(FILE); +} \ No newline at end of file