author | Dario Sestito <darios@symbian.org> |
Mon, 08 Mar 2010 17:19:08 +0000 | |
changeset 185 | 978ef35b4e5f |
parent 181 | 314156ec7d7c |
child 186 | b76adfbc6648 |
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 |
my $failure_item = 0; |
|
40 |
||
41 |
my $characters = ''; |
|
42 |
||
43 |
my $CATEGORY_RAPTORERROR = 'raptor_error'; |
|
44 |
my $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION = 'cannot_process_schema_version'; |
|
45 |
my $CATEGORY_RAPTORERROR_NOBLDINFFOUND = 'no_bld_inf_found'; |
|
46 |
my $CATEGORY_RAPTORERROR_CANTFINDMMPFILE = 'cant_find_mmp_file'; |
|
47 |
my $CATEGORY_RAPTORERROR_MAKEEXITEDWITHERRORS = 'make_exited_with_errors'; |
|
48 |
my $CATEGORY_RAPTORERROR_TOOLDIDNOTRETURNVERSION = 'tool_didnot_return_version'; |
|
49 |
my $CATEGORY_RAPTORERROR_UNKNOWNBUILDCONFIG = 'unknown_build_config'; |
|
50 |
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
|
51 |
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
|
52 |
my $CATEGORY_RAPTORERROR_MISSINGBLDINFFILE = 'missing_bld_inf_file'; |
177 | 53 |
|
54 |
sub process |
|
55 |
{ |
|
56 |
my ($text, $logfile, $component, $mmp, $phase, $recipe, $file, $line) = @_; |
|
57 |
||
58 |
my $category = $CATEGORY_RAPTORERROR; |
|
59 |
my $severity = ''; |
|
60 |
my $subcategory = ''; |
|
61 |
||
62 |
if ($text =~ m,Cannot process schema version .* of file,) |
|
63 |
{ |
|
64 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
|
65 |
$subcategory = $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION; |
|
66 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
67 |
} |
|
68 |
elsif ($text =~ m,No bld\.inf found at,) |
|
69 |
{ |
|
70 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
|
71 |
$subcategory = $CATEGORY_RAPTORERROR_NOBLDINFFOUND; |
|
72 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
73 |
} |
|
74 |
elsif ($text =~ m,Can't find mmp file,) |
|
75 |
{ |
|
181
314156ec7d7c
Can't find mmp file should be severity Major
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
76 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
177 | 77 |
$subcategory = $CATEGORY_RAPTORERROR_CANTFINDMMPFILE; |
78 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
79 |
} |
|
80 |
elsif ($text =~ m,The make-engine exited with errors,) |
|
81 |
{ |
|
82 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
|
83 |
$subcategory = $CATEGORY_RAPTORERROR_MAKEEXITEDWITHERRORS; |
|
84 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
85 |
} |
|
86 |
elsif ($text =~ m,tool .* from config .* did not return version .* as required,) |
|
87 |
{ |
|
88 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
|
89 |
$subcategory = $CATEGORY_RAPTORERROR_TOOLDIDNOTRETURNVERSION; |
|
90 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
91 |
} |
|
92 |
elsif ($text =~ m,Unknown build configuration '.*',) |
|
93 |
{ |
|
94 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
|
95 |
$subcategory = $CATEGORY_RAPTORERROR_UNKNOWNBUILDCONFIG; |
|
96 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
97 |
} |
|
98 |
elsif ($text =~ m,No build configurations given,) |
|
99 |
{ |
|
100 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
|
101 |
$subcategory = $CATEGORY_RAPTORERROR_NOBUILDCONFIGSGIVEN; |
|
102 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
103 |
} |
|
185
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
104 |
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
|
105 |
{ |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
106 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
107 |
$subcategory = $CATEGORY_RAPTORERROR_COULDNOTEXPORT; |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
108 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
109 |
} |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
110 |
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
|
111 |
{ |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
112 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
113 |
$subcategory = $CATEGORY_RAPTORERROR_MISSINGBLDINFFILE; |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
114 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
115 |
} |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
116 |
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
|
117 |
{ |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
118 |
# don't dump |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
119 |
} |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
120 |
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
|
121 |
{ |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
122 |
# don't dump |
978ef35b4e5f
Add more categories for unreciped and raptor error failures
Dario Sestito <darios@symbian.org>
parents:
181
diff
changeset
|
123 |
} |
177 | 124 |
else # log everything by default |
125 |
{ |
|
126 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
127 |
} |
|
128 |
} |
|
129 |
||
130 |
sub on_start_buildlog |
|
131 |
{ |
|
132 |
RaptorCommon::init(); |
|
133 |
||
134 |
$filename = "$::raptorbitsdir/raptor_error.txt"; |
|
135 |
if (!-f$filename) |
|
136 |
{ |
|
137 |
print "Writing errors file $filename\n"; |
|
138 |
open(FILE, ">$filename"); |
|
139 |
close(FILE); |
|
140 |
} |
|
141 |
} |
|
142 |
||
143 |
sub on_start_buildlog_error |
|
144 |
{ |
|
145 |
} |
|
146 |
||
147 |
sub on_chars_buildlog_error |
|
148 |
{ |
|
149 |
my ($ch) = @_; |
|
150 |
||
151 |
#print "on_chars_buildlog_error\n"; |
|
152 |
||
153 |
$characters .= $ch->{Data}; |
|
154 |
||
155 |
#print "characters is now -->$characters<--\n"; |
|
156 |
} |
|
157 |
||
158 |
sub on_end_buildlog_error |
|
159 |
{ |
|
160 |
#print "on_end_buildlog_error\n"; |
|
161 |
||
162 |
$characters =~ s,^[\r\n]*,,; |
|
163 |
$characters =~ s,[\r\n]*$,,; |
|
164 |
||
165 |
if ($characters =~ m,[^\s^\r^\n],) |
|
166 |
{ |
|
167 |
if ($failure_item == 0 and -f "$filename") |
|
168 |
{ |
|
169 |
open(FILE, "$filename"); |
|
170 |
{ |
|
171 |
local $/ = undef; |
|
172 |
my $filecontent = <FILE>; |
|
173 |
$failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s); |
|
174 |
} |
|
175 |
close(FILE); |
|
176 |
} |
|
177 |
||
178 |
$failure_item++; |
|
179 |
||
180 |
open(FILE, ">>$filename"); |
|
181 |
print FILE "---failure_item_$failure_item\---\n"; |
|
182 |
print FILE "$characters\n\n"; |
|
183 |
close(FILE); |
|
184 |
||
185 |
process($characters, $::current_log_file, '', '', '', '', "raptor_error.txt", $failure_item); |
|
186 |
} |
|
187 |
||
188 |
$characters = ''; |
|
189 |
} |
|
190 |
||
191 |
||
192 |
1; |