author | Dario Sestito <darios@symbian.org> |
Thu, 04 Mar 2010 16:35:52 +0000 | |
changeset 183 | 20288e22722e |
parent 182 | d7b846505d9e |
child 185 | 978ef35b4e5f |
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 text in <buildlog> context which doesn't belong to any <recipe> tags |
|
15 |
||
16 |
package RaptorUnreciped; |
|
17 |
||
18 |
use strict; |
|
19 |
use RaptorCommon; |
|
20 |
||
21 |
our $reset_status = {}; |
|
22 |
my $buildlog_status = {}; |
|
23 |
my $buildlog_subtag_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} = {'?default?'=>$buildlog_subtag_status}; |
|
30 |
$buildlog_status->{on_start} = 'RaptorUnreciped::on_start_buildlog'; |
|
31 |
$buildlog_status->{on_end} = 'RaptorUnreciped::on_end_buildlog'; |
|
32 |
$buildlog_status->{on_chars} = 'RaptorUnreciped::on_chars_buildlog'; |
|
33 |
||
34 |
$buildlog_subtag_status->{name} = 'buildlog_subtag_status'; |
|
35 |
$buildlog_subtag_status->{next_status} = {}; |
|
36 |
$buildlog_subtag_status->{on_start} = 'RaptorUnreciped::on_start_buildlog_subtag'; |
|
37 |
$buildlog_subtag_status->{on_end} = 'RaptorUnreciped::on_end_buildlog_subtag'; |
|
38 |
||
39 |
my $filename = ''; |
|
40 |
my $failure_item = 0; |
|
41 |
||
42 |
my $characters = ''; |
|
43 |
my $store_chars = 1; |
|
44 |
||
45 |
my $CATEGORY_RAPTORUNRECIPED = 'raptor_unreciped'; |
|
46 |
my $CATEGORY_RAPTORUNRECIPED_NORULETOMAKETARGET = 'no_rule_to_make_target'; |
|
47 |
my $CATEGORY_RAPTORUNRECIPED_TARGETNOTREMADEFORERRORS = 'target_not_remade_for_errors'; |
|
48 |
my $CATEGORY_RAPTORUNRECIPED_IGNORINGOLDCOMMANDSFORTARGET = 'ignoring_old_commands_for_target'; |
|
49 |
my $CATEGORY_RAPTORUNRECIPED_OVERRIDINGCOMMANDSFORTARGET = 'overriding_commands_for_target'; |
|
182
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
50 |
my $CATEGORY_RAPTORUNRECIPED_MAKE_TARGETNOTREMADEBECAUSEOFERRORS = 'make_target_not_remade_because_of_errors'; |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
51 |
my $CATEGORY_RAPTORUNRECIPED_MAKE_ERROR1 = 'make_error_1'; |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
52 |
my $CATEGORY_RAPTORUNRECIPED_MAKE_NORULETOMAKETARGET = 'make_no_rule_to_make_target'; |
177 | 53 |
|
54 |
sub process |
|
55 |
{ |
|
56 |
my ($text, $logfile, $component, $mmp, $phase, $recipe, $file, $line) = @_; |
|
57 |
||
58 |
my $category = $CATEGORY_RAPTORUNRECIPED; |
|
59 |
my $severity = ''; |
|
60 |
my $subcategory = ''; |
|
61 |
||
62 |
if ($text =~ m,make\.exe: \*\*\* No rule to make target,) |
|
63 |
{ |
|
64 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
|
65 |
my $subcategory = $CATEGORY_RAPTORUNRECIPED_NORULETOMAKETARGET; |
|
66 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
67 |
} |
|
68 |
elsif ($text =~ m,make\.exe: Target .* not remade because of errors,) |
|
69 |
{ |
|
70 |
$severity = $RaptorCommon::SEVERITY_MINOR; |
|
71 |
my $subcategory = $CATEGORY_RAPTORUNRECIPED_TARGETNOTREMADEFORERRORS; |
|
72 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
73 |
} |
|
74 |
elsif ($text =~ m,: warning: ignoring old commands for target,) |
|
75 |
{ |
|
76 |
$severity = $RaptorCommon::SEVERITY_MINOR; |
|
77 |
my $subcategory = $CATEGORY_RAPTORUNRECIPED_IGNORINGOLDCOMMANDSFORTARGET; |
|
78 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
79 |
} |
|
80 |
elsif ($text =~ m,: warning: overriding commands for target,) |
|
81 |
{ |
|
82 |
$severity = $RaptorCommon::SEVERITY_MINOR; |
|
83 |
my $subcategory = $CATEGORY_RAPTORUNRECIPED_OVERRIDINGCOMMANDSFORTARGET; |
|
84 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
85 |
} |
|
182
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
86 |
elsif ($text =~ m,^make: Target .* not remade because of errors\.,) |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
87 |
{ |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
88 |
$severity = $RaptorCommon::SEVERITY_MINOR; |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
89 |
my $subcategory = $CATEGORY_RAPTORUNRECIPED_MAKE_TARGETNOTREMADEBECAUSEOFERRORS; |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
90 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
91 |
} |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
92 |
elsif ($text =~ m,^make: \*\*\* .* Error 1,) |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
93 |
{ |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
94 |
$severity = $RaptorCommon::SEVERITY_MINOR; |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
95 |
my $subcategory = $CATEGORY_RAPTORUNRECIPED_MAKE_ERROR1; |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
96 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
97 |
} |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
98 |
elsif ($text =~ m,^make: \*\*\* No rule to make target .*\ needed by .*,) |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
99 |
{ |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
100 |
$severity = $RaptorCommon::SEVERITY_MINOR; |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
101 |
my $subcategory = $CATEGORY_RAPTORUNRECIPED_MAKE_NORULETOMAKETARGET; |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
102 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
103 |
} |
d7b846505d9e
Add more categories for unreciped failures
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
104 |
elsif ($text =~ m,^make: Nothing to be done for .*,) |
177 | 105 |
{ |
106 |
# don't dump |
|
107 |
} |
|
108 |
elsif ($text =~ m,^(true|false)$,) |
|
109 |
{ |
|
110 |
# don't dump |
|
111 |
} |
|
112 |
else # log everything by default |
|
113 |
{ |
|
114 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
115 |
} |
|
116 |
} |
|
117 |
||
118 |
sub on_start_buildlog |
|
119 |
{ |
|
120 |
RaptorCommon::init(); |
|
121 |
||
122 |
$filename = "$::raptorbitsdir/raptor_unreciped.txt"; |
|
123 |
if (!-f$filename) |
|
124 |
{ |
|
125 |
print "Writing unreciped file $filename\n"; |
|
126 |
open(FILE, ">$filename"); |
|
127 |
close(FILE); |
|
128 |
} |
|
129 |
} |
|
130 |
||
131 |
sub on_chars_buildlog |
|
132 |
{ |
|
133 |
my ($ch) = @_; |
|
134 |
||
135 |
#print "on_chars_buildlog\n"; |
|
136 |
||
137 |
if ($store_chars) |
|
138 |
{ |
|
139 |
$characters .= $ch->{Data}; |
|
140 |
||
141 |
#print "characters is now -->$characters<--\n"; |
|
142 |
} |
|
143 |
} |
|
144 |
||
145 |
sub on_end_buildlog_subtag |
|
146 |
{ |
|
147 |
$store_chars = 1; |
|
148 |
} |
|
149 |
||
150 |
sub process_characters |
|
151 |
{ |
|
152 |
#print "process_characters\n"; |
|
153 |
||
154 |
$characters =~ s,^[\r\n]*,,; |
|
155 |
$characters =~ s,[\r\n]*$,,; |
|
156 |
||
157 |
#print "characters is -->$characters<--\n"; |
|
158 |
||
159 |
my @lines = split(/[\r\n]/, $characters); |
|
160 |
for my $line (@lines) |
|
161 |
{ |
|
162 |
if ($line =~ m,[^\s^\r^\n],) |
|
163 |
{ |
|
164 |
#print "dumping chars\n"; |
|
165 |
||
166 |
if ($failure_item == 0 and -f "$filename") |
|
167 |
{ |
|
168 |
open(FILE, "$filename"); |
|
169 |
{ |
|
170 |
local $/ = undef; |
|
171 |
my $filecontent = <FILE>; |
|
172 |
$failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s); |
|
173 |
} |
|
174 |
close(FILE); |
|
175 |
} |
|
176 |
||
177 |
$failure_item++; |
|
178 |
||
179 |
open(FILE, ">>$filename"); |
|
180 |
print FILE "---failure_item_$failure_item\---\n"; |
|
181 |
print FILE "$line\n\n"; |
|
182 |
close(FILE); |
|
183 |
||
184 |
process($line, $::current_log_file, '', '', '', '', "raptor_unreciped.txt", $failure_item); |
|
185 |
} |
|
186 |
} |
|
187 |
||
188 |
$characters = ''; |
|
189 |
$store_chars = 0; |
|
190 |
} |
|
191 |
||
192 |
sub on_start_buildlog_subtag |
|
193 |
{ |
|
194 |
#print "on_start_buildlog_subtag\n"; |
|
195 |
||
196 |
process_characters(); |
|
197 |
} |
|
198 |
||
199 |
sub on_end_buildlog |
|
200 |
{ |
|
201 |
process_characters(); |
|
202 |
} |
|
203 |
||
204 |
||
205 |
1; |