|
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 RaptorReleaseable; |
|
17 use RaptorError; |
|
18 use RaptorWarning; |
|
19 use RaptorInfo; |
|
20 use RaptorUnreciped; |
|
21 use RaptorRecipe; |
|
22 |
|
23 use XML::SAX; |
|
24 use RaptorSAXHandler; |
|
25 use Getopt::Long; |
|
26 |
|
27 my @logfiles; |
|
28 my $releaseable_module = 0; |
|
29 my $error_module = 0; |
|
30 my $warning_module = 0; |
|
31 my $info_module = 0; |
|
32 my $unreciped_module = 0; |
|
33 my $recipe_module = 0; |
|
34 our $basedir = ''; |
|
35 my $append = 0; |
|
36 my $help = 0; |
|
37 GetOptions(( |
|
38 'log:s' => \@logfiles, |
|
39 'releaseable!' => \$releaseable_module, |
|
40 'error!' => \$error_module, |
|
41 'warning!' => \$warning_module, |
|
42 'info!' => \$info_module, |
|
43 'unreciped!' => \$unreciped_module, |
|
44 'recipe!' => \$recipe_module, |
|
45 'basedir:s' => \$basedir, |
|
46 'append!' => \$append, |
|
47 'help!' => \$help |
|
48 )); |
|
49 |
|
50 $help = 1 if (!@logfiles); |
|
51 |
|
52 if ($help) |
|
53 { |
|
54 print "Run the raptor parsers\n"; |
|
55 print "Usage: perl parse.pl [MODULES] --log=FILE1 --log=FILE2 ... [OPTIONS]\n"; |
|
56 print "where MODULES are:\n"; |
|
57 print "\t--releaseable Extract releaseable (whatlog) information\n"; |
|
58 print "\t--error Extracts raptor errors, i.e. content of <error> tags\n"; |
|
59 print "\t--warning Extracts raptor warnings, i.e. content of <warning> tags\n"; |
|
60 print "\t--info Extracts raptor info text i.e. content of <info> tags from a raptor log file\n"; |
|
61 print "\t--unreciped Extracts output text in <buildlog> context which doesn't belong to any <recipe> tags\n"; |
|
62 print "\t--recipe Extract, analyzes and dumps raptor recipes i.e. content of <recipe> tags from a raptor log file\n"; |
|
63 print "where OPTIONS are:\n"; |
|
64 print "\t--basedir=DIR Generate output file under DIR\n"; |
|
65 print "\t--append Do not stop if basedir exists but append newly extracted info to already existing.\n"; |
|
66 exit(0); |
|
67 } |
|
68 |
|
69 if (!$basedir) |
|
70 { |
|
71 $basedir = time; |
|
72 |
|
73 print "Using $basedir as basedir.\n"; |
|
74 } |
|
75 if (-d $basedir) |
|
76 { |
|
77 if ($append) |
|
78 { |
|
79 print "Directory $basedir exists. Appending new info to it.\n"; |
|
80 } |
|
81 else |
|
82 { |
|
83 print "Directory $basedir exists. Quitting.\n"; |
|
84 exit(1); |
|
85 } |
|
86 } |
|
87 mkdir($basedir); |
|
88 #print "Created dir $basedir.\n"; |
|
89 |
|
90 my $saxhandler = RaptorSAXHandler->new(); |
|
91 if ($releaseable_module) |
|
92 { |
|
93 print "Adding RaptorReleaseable module to the observers\n"; |
|
94 $saxhandler->add_observer('RaptorReleaseable', $RaptorReleaseable::reset_status); |
|
95 } |
|
96 if ($error_module) |
|
97 { |
|
98 print "Adding RaptorError module to the observers\n"; |
|
99 $saxhandler->add_observer('RaptorError', $RaptorError::reset_status); |
|
100 } |
|
101 if ($warning_module) |
|
102 { |
|
103 print "Adding RaptorWarning module to the observers\n"; |
|
104 $saxhandler->add_observer('RaptorWarning', $RaptorWarning::reset_status); |
|
105 } |
|
106 if ($info_module) |
|
107 { |
|
108 print "Adding RaptorInfo module to the observers\n"; |
|
109 $saxhandler->add_observer('RaptorInfo', $RaptorInfo::reset_status); |
|
110 } |
|
111 if ($unreciped_module) |
|
112 { |
|
113 print "Adding RaptorUnreciped module to the observers\n"; |
|
114 $saxhandler->add_observer('RaptorUnreciped', $RaptorUnreciped::reset_status); |
|
115 } |
|
116 if ($recipe_module) |
|
117 { |
|
118 print "Adding RaptorRecipe module to the observers\n"; |
|
119 $saxhandler->add_observer('RaptorRecipe', $RaptorRecipe::reset_status); |
|
120 } |
|
121 my $parser = XML::SAX::ParserFactory->parser(Handler=>$saxhandler); |
|
122 for (@logfiles) |
|
123 { |
|
124 $parser->parse_uri($_); |
|
125 } |
|
126 |