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