author | Dario Sestito <darios@symbian.org> |
Tue, 09 Mar 2010 12:36:24 +0000 | |
changeset 188 | dbf40764ca6a |
parent 186 | b76adfbc6648 |
child 228 | ba90e30c0f3c |
permissions | -rw-r--r-- |
177 | 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 |
# Raptor parser module. |
|
14 |
# Extract, analyzes and dumps raptor errors i.e. content of <error> tags from a raptor log file |
|
15 |
||
16 |
package RaptorError; |
|
17 |
||
18 |
use strict; |
|
19 |
use RaptorCommon; |
|
20 |
||
21 |
our $reset_status = {}; |
|
22 |
my $buildlog_status = {}; |
|
23 |
my $buildlog_error_status = {}; |
|
24 |
||
25 |
$reset_status->{name} = 'reset_status'; |
|
26 |
$reset_status->{next_status} = {buildlog=>$buildlog_status}; |
|
27 |
||
28 |
$buildlog_status->{name} = 'buildlog_status'; |
|
29 |
$buildlog_status->{next_status} = {error=>$buildlog_error_status}; |
|
30 |
$buildlog_status->{on_start} = 'RaptorError::on_start_buildlog'; |
|
31 |
||
32 |
$buildlog_error_status->{name} = 'buildlog_error_status'; |
|
33 |
$buildlog_error_status->{next_status} = {}; |
|
34 |
$buildlog_error_status->{on_start} = 'RaptorError::on_start_buildlog_error'; |
|
35 |
$buildlog_error_status->{on_end} = 'RaptorError::on_end_buildlog_error'; |
|
36 |
$buildlog_error_status->{on_chars} = 'RaptorError::on_chars_buildlog_error'; |
|
37 |
||
38 |
my $filename = ''; |
|
39 |
||
40 |
my $characters = ''; |
|
41 |
||
42 |
my $CATEGORY_RAPTORERROR = 'raptor_error'; |
|
43 |
my $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION = 'cannot_process_schema_version'; |
|
44 |
my $CATEGORY_RAPTORERROR_NOBLDINFFOUND = 'no_bld_inf_found'; |
|
45 |
my $CATEGORY_RAPTORERROR_CANTFINDMMPFILE = 'cant_find_mmp_file'; |
|
46 |
my $CATEGORY_RAPTORERROR_MAKEEXITEDWITHERRORS = 'make_exited_with_errors'; |
|
47 |
my $CATEGORY_RAPTORERROR_TOOLDIDNOTRETURNVERSION = 'tool_didnot_return_version'; |
|
48 |
my $CATEGORY_RAPTORERROR_UNKNOWNBUILDCONFIG = 'unknown_build_config'; |
|
49 |
my $CATEGORY_RAPTORERROR_NOBUILDCONFIGSGIVEN = 'no_build_configs_given'; |
|
185
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
50 |
my $CATEGORY_RAPTORERROR_COULDNOTEXPORT = 'missing_source_file'; |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
51 |
my $CATEGORY_RAPTORERROR_MISSINGBLDINFFILE = 'missing_bld_inf_file'; |
177 | 52 |
|
53 |
sub process |
|
54 |
{ |
|
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
55 |
my ($text, $logfile, $component, $mmp, $phase, $recipe, $file) = @_; |
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
56 |
|
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
57 |
my $dumped = 1; |
177 | 58 |
|
59 |
my $category = $CATEGORY_RAPTORERROR; |
|
60 |
my $severity = ''; |
|
61 |
my $subcategory = ''; |
|
62 |
||
63 |
if ($text =~ m,Cannot process schema version .* of file,) |
|
64 |
{ |
|
65 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
|
66 |
$subcategory = $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION; |
|
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
67 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file); |
177 | 68 |
} |
69 |
elsif ($text =~ m,No bld\.inf found at,) |
|
70 |
{ |
|
71 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
|
72 |
$subcategory = $CATEGORY_RAPTORERROR_NOBLDINFFOUND; |
|
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
73 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file); |
177 | 74 |
} |
75 |
elsif ($text =~ m,Can't find mmp file,) |
|
76 |
{ |
|
181
314156ec7d7c
Can't find mmp file should be severity Major
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
77 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
177 | 78 |
$subcategory = $CATEGORY_RAPTORERROR_CANTFINDMMPFILE; |
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
79 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file); |
177 | 80 |
} |
81 |
elsif ($text =~ m,The make-engine exited with errors,) |
|
82 |
{ |
|
83 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
|
84 |
$subcategory = $CATEGORY_RAPTORERROR_MAKEEXITEDWITHERRORS; |
|
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
85 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file); |
177 | 86 |
} |
87 |
elsif ($text =~ m,tool .* from config .* did not return version .* as required,) |
|
88 |
{ |
|
89 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
|
90 |
$subcategory = $CATEGORY_RAPTORERROR_TOOLDIDNOTRETURNVERSION; |
|
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
91 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file); |
177 | 92 |
} |
93 |
elsif ($text =~ m,Unknown build configuration '.*',) |
|
94 |
{ |
|
95 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
|
96 |
$subcategory = $CATEGORY_RAPTORERROR_UNKNOWNBUILDCONFIG; |
|
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
97 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file); |
177 | 98 |
} |
99 |
elsif ($text =~ m,No build configurations given,) |
|
100 |
{ |
|
101 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
|
102 |
$subcategory = $CATEGORY_RAPTORERROR_NOBUILDCONFIGSGIVEN; |
|
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
103 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file); |
177 | 104 |
} |
185
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
105 |
elsif ($text =~ m,Could not export .* to .* : \[Errno 2\] No such file or directory: .*,) |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
106 |
{ |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
107 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
108 |
$subcategory = $CATEGORY_RAPTORERROR_COULDNOTEXPORT; |
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
109 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file); |
185
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
110 |
} |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
111 |
elsif ($text =~ m,win32/mingw/bin/cpp\.exe: .*bld\.inf:.*bld\.inf: No such file or directory,) |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
112 |
{ |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
113 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
114 |
$subcategory = $CATEGORY_RAPTORERROR_MISSINGBLDINFFILE; |
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
115 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file); |
185
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
116 |
} |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
117 |
elsif ($text =~ m,^Preprocessor exception: ''Errors in .*bld\.inf'' : in command,) |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
118 |
{ |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
119 |
# don't dump |
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
120 |
$dumped = 0; |
185
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
121 |
} |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
122 |
elsif ($text =~ m,Source of export does not exist: .*,) |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
123 |
{ |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
124 |
# don't dump |
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
125 |
$dumped = 0; |
185
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
126 |
} |
177 | 127 |
else # log everything by default |
128 |
{ |
|
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
129 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file); |
177 | 130 |
} |
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
131 |
|
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
132 |
return $dumped; |
177 | 133 |
} |
134 |
||
135 |
sub on_start_buildlog |
|
136 |
{ |
|
137 |
RaptorCommon::init(); |
|
138 |
||
139 |
$filename = "$::raptorbitsdir/raptor_error.txt"; |
|
140 |
if (!-f$filename) |
|
141 |
{ |
|
142 |
print "Writing errors file $filename\n"; |
|
143 |
open(FILE, ">$filename"); |
|
144 |
close(FILE); |
|
145 |
} |
|
146 |
} |
|
147 |
||
148 |
sub on_start_buildlog_error |
|
149 |
{ |
|
150 |
} |
|
151 |
||
152 |
sub on_chars_buildlog_error |
|
153 |
{ |
|
154 |
my ($ch) = @_; |
|
155 |
||
156 |
#print "on_chars_buildlog_error\n"; |
|
157 |
||
158 |
$characters .= $ch->{Data}; |
|
159 |
||
160 |
#print "characters is now -->$characters<--\n"; |
|
161 |
} |
|
162 |
||
163 |
sub on_end_buildlog_error |
|
164 |
{ |
|
165 |
#print "on_end_buildlog_error\n"; |
|
166 |
||
167 |
$characters =~ s,^[\r\n]*,,; |
|
168 |
$characters =~ s,[\r\n]*$,,; |
|
169 |
||
170 |
if ($characters =~ m,[^\s^\r^\n],) |
|
171 |
{ |
|
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
172 |
my $dumped = process($characters, $::current_log_file, '', '', '', '', "raptor_error.txt"); |
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
173 |
|
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
174 |
if ($dumped) |
177 | 175 |
{ |
186
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
176 |
open(FILE, ">>$filename"); |
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
177 |
print FILE "---failure_item_$::failure_item_number\---\n"; |
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
185
diff
changeset
|
178 |
print FILE "$characters\n\n"; |
177 | 179 |
close(FILE); |
180 |
} |
|
181 |
} |
|
182 |
||
183 |
$characters = ''; |
|
184 |
} |
|
185 |
||
186 |
||
187 |
1; |