|
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'; |
|
50 |
|
51 sub process |
|
52 { |
|
53 my ($text, $logfile, $component, $mmp, $phase, $recipe, $file, $line) = @_; |
|
54 |
|
55 my $category = $CATEGORY_RAPTORUNRECIPED; |
|
56 my $severity = ''; |
|
57 my $subcategory = ''; |
|
58 |
|
59 if ($text =~ m,make\.exe: \*\*\* No rule to make target,) |
|
60 { |
|
61 $severity = $RaptorCommon::SEVERITY_MAJOR; |
|
62 my $subcategory = $CATEGORY_RAPTORUNRECIPED_NORULETOMAKETARGET; |
|
63 RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
64 } |
|
65 elsif ($text =~ m,make\.exe: Target .* not remade because of errors,) |
|
66 { |
|
67 $severity = $RaptorCommon::SEVERITY_MINOR; |
|
68 my $subcategory = $CATEGORY_RAPTORUNRECIPED_TARGETNOTREMADEFORERRORS; |
|
69 RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
70 } |
|
71 elsif ($text =~ m,: warning: ignoring old commands for target,) |
|
72 { |
|
73 $severity = $RaptorCommon::SEVERITY_MINOR; |
|
74 my $subcategory = $CATEGORY_RAPTORUNRECIPED_IGNORINGOLDCOMMANDSFORTARGET; |
|
75 RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
76 } |
|
77 elsif ($text =~ m,: warning: overriding commands for target,) |
|
78 { |
|
79 $severity = $RaptorCommon::SEVERITY_MINOR; |
|
80 my $subcategory = $CATEGORY_RAPTORUNRECIPED_OVERRIDINGCOMMANDSFORTARGET; |
|
81 RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
82 } |
|
83 elsif ($text =~ m,make\.exe: Nothing to be done for .*,) |
|
84 { |
|
85 # don't dump |
|
86 } |
|
87 elsif ($text =~ m,^(true|false)$,) |
|
88 { |
|
89 # don't dump |
|
90 } |
|
91 else # log everything by default |
|
92 { |
|
93 RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line); |
|
94 } |
|
95 } |
|
96 |
|
97 sub on_start_buildlog |
|
98 { |
|
99 RaptorCommon::init(); |
|
100 |
|
101 $filename = "$::raptorbitsdir/raptor_unreciped.txt"; |
|
102 if (!-f$filename) |
|
103 { |
|
104 print "Writing unreciped file $filename\n"; |
|
105 open(FILE, ">$filename"); |
|
106 close(FILE); |
|
107 } |
|
108 } |
|
109 |
|
110 sub on_chars_buildlog |
|
111 { |
|
112 my ($ch) = @_; |
|
113 |
|
114 #print "on_chars_buildlog\n"; |
|
115 |
|
116 if ($store_chars) |
|
117 { |
|
118 $characters .= $ch->{Data}; |
|
119 |
|
120 #print "characters is now -->$characters<--\n"; |
|
121 } |
|
122 } |
|
123 |
|
124 sub on_end_buildlog_subtag |
|
125 { |
|
126 $store_chars = 1; |
|
127 } |
|
128 |
|
129 sub process_characters |
|
130 { |
|
131 #print "process_characters\n"; |
|
132 |
|
133 $characters =~ s,^[\r\n]*,,; |
|
134 $characters =~ s,[\r\n]*$,,; |
|
135 |
|
136 #print "characters is -->$characters<--\n"; |
|
137 |
|
138 my @lines = split(/[\r\n]/, $characters); |
|
139 for my $line (@lines) |
|
140 { |
|
141 if ($line =~ m,[^\s^\r^\n],) |
|
142 { |
|
143 #print "dumping chars\n"; |
|
144 |
|
145 if ($failure_item == 0 and -f "$filename") |
|
146 { |
|
147 open(FILE, "$filename"); |
|
148 { |
|
149 local $/ = undef; |
|
150 my $filecontent = <FILE>; |
|
151 $failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s); |
|
152 } |
|
153 close(FILE); |
|
154 } |
|
155 |
|
156 $failure_item++; |
|
157 |
|
158 open(FILE, ">>$filename"); |
|
159 print FILE "---failure_item_$failure_item\---\n"; |
|
160 print FILE "$line\n\n"; |
|
161 close(FILE); |
|
162 |
|
163 process($line, $::current_log_file, '', '', '', '', "raptor_unreciped.txt", $failure_item); |
|
164 } |
|
165 } |
|
166 |
|
167 $characters = ''; |
|
168 $store_chars = 0; |
|
169 } |
|
170 |
|
171 sub on_start_buildlog_subtag |
|
172 { |
|
173 #print "on_start_buildlog_subtag\n"; |
|
174 |
|
175 process_characters(); |
|
176 } |
|
177 |
|
178 sub on_end_buildlog |
|
179 { |
|
180 process_characters(); |
|
181 } |
|
182 |
|
183 |
|
184 1; |