242
|
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 recipes i.e. content of <recipe> tags from a raptor log file
|
|
15 |
|
|
16 |
package RaptorRecipe;
|
|
17 |
|
|
18 |
use strict;
|
|
19 |
use RaptorCommon;
|
|
20 |
|
|
21 |
our $reset_status = {};
|
|
22 |
my $buildlog_status = {};
|
|
23 |
my $buildlog_recipe_status = {};
|
383
|
24 |
my $buildlog_recipe_status_status = {};
|
242
|
25 |
|
|
26 |
$reset_status->{name} = 'reset_status';
|
|
27 |
$reset_status->{next_status} = {buildlog=>$buildlog_status};
|
|
28 |
|
|
29 |
$buildlog_status->{name} = 'buildlog_status';
|
|
30 |
$buildlog_status->{next_status} = {recipe=>$buildlog_recipe_status};
|
383
|
31 |
$buildlog_status->{on_start} = 'RaptorRecipe::on_start_buildlog';
|
|
32 |
$buildlog_status->{on_end} = 'RaptorRecipe::on_end_buildlog';
|
242
|
33 |
|
|
34 |
$buildlog_recipe_status->{name} = 'buildlog_recipe_status';
|
383
|
35 |
$buildlog_recipe_status->{next_status} = {status=>$buildlog_recipe_status_status};
|
242
|
36 |
$buildlog_recipe_status->{on_start} = 'RaptorRecipe::on_start_buildlog_recipe';
|
|
37 |
$buildlog_recipe_status->{on_end} = 'RaptorRecipe::on_end_buildlog_recipe';
|
|
38 |
$buildlog_recipe_status->{on_chars} = 'RaptorRecipe::on_chars_buildlog_recipe';
|
|
39 |
|
383
|
40 |
$buildlog_recipe_status_status->{name} = 'buildlog_recipe_status_status';
|
|
41 |
$buildlog_recipe_status_status->{next_status} = {};
|
|
42 |
$buildlog_recipe_status_status->{on_start} = 'RaptorRecipe::on_start_buildlog_recipe_status';
|
|
43 |
|
|
44 |
|
|
45 |
my $filename = '';
|
|
46 |
my $failure_item = 0;
|
|
47 |
|
242
|
48 |
my $recipe_info = {};
|
|
49 |
|
383
|
50 |
my $characters = '';
|
|
51 |
|
|
52 |
my $CATEGORY_RECIPEFAILURE = 'recipe_failure';
|
|
53 |
my $CATEGORY_RECIPEFAILURE_ARMCC_CANNOTOPENSOURCEINPUTFILE = 'armcc_cannot_open_source_input_file';
|
|
54 |
my $CATEGORY_RECIPEFAILURE_ARMLINK_COULDNOTOPENFILE = 'armlink_could_not_open_file';
|
|
55 |
my $CATEGORY_RECIPEFAILURE_ELF2E32_COULDNOTOPENFILE = 'elf2e32_could_not_open_file';
|
715
|
56 |
my $CATEGORY_RECIPEFAILURE_ARMAR_FILEDOESNOTEXIST = 'armar_file_does_not_exist';
|
242
|
57 |
|
|
58 |
sub process
|
|
59 |
{
|
383
|
60 |
my ($text, $component, $phase, $recipe, $file, $line) = @_;
|
|
61 |
|
|
62 |
my $category = $CATEGORY_RECIPEFAILURE;
|
|
63 |
my $severity = '';
|
|
64 |
my $subcategory = '';
|
242
|
65 |
|
383
|
66 |
if ($text =~ m,Error: #5: cannot open source input file .*: No such file or directory,)
|
|
67 |
{
|
|
68 |
$severity = $RaptorCommon::SEVERITY_MAJOR;
|
|
69 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMCC_CANNOTOPENSOURCEINPUTFILE;
|
|
70 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
|
|
71 |
}
|
|
72 |
elsif ($text =~ m,Fatal error: L6002U: Could not open file .*: No such file or directory,)
|
242
|
73 |
{
|
383
|
74 |
$severity = $RaptorCommon::SEVERITY_MAJOR;
|
|
75 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMLINK_COULDNOTOPENFILE;
|
|
76 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
|
|
77 |
}
|
|
78 |
elsif ($text =~ m,elf2e32 : Error: E1001: Could not open file : .*.,)
|
|
79 |
{
|
|
80 |
$severity = $RaptorCommon::SEVERITY_MAJOR;
|
|
81 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ELF2E32_COULDNOTOPENFILE;
|
|
82 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
|
242
|
83 |
}
|
715
|
84 |
elsif ($text =~ m,Error: L6833E: File '.*' does not exist,)
|
|
85 |
{
|
|
86 |
$severity = $RaptorCommon::SEVERITY_MAJOR;
|
|
87 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMAR_FILEDOESNOTEXIST;
|
|
88 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
|
|
89 |
}
|
383
|
90 |
else # log everything by default
|
|
91 |
{
|
|
92 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
|
|
93 |
}
|
|
94 |
}
|
|
95 |
|
|
96 |
sub on_start_buildlog
|
|
97 |
{
|
|
98 |
#print FILE "line,layer,component,name,armlicence,platform,phase,code,bldinf,mmp,target,source,\n";
|
|
99 |
|
|
100 |
RaptorCommon::init();
|
242
|
101 |
}
|
|
102 |
|
|
103 |
sub on_start_buildlog_recipe
|
|
104 |
{
|
|
105 |
my ($el) = @_;
|
|
106 |
|
383
|
107 |
#print "on_start_buildlog_recipe\n";
|
242
|
108 |
|
383
|
109 |
$recipe_info = {};
|
242
|
110 |
|
|
111 |
my $attributes = $el->{Attributes};
|
|
112 |
for (keys %{$attributes})
|
|
113 |
{
|
383
|
114 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'};
|
|
115 |
#print "$_ -> $attributes->{$_}->{'Value'}\n";
|
242
|
116 |
}
|
|
117 |
}
|
|
118 |
|
|
119 |
sub on_chars_buildlog_recipe
|
|
120 |
{
|
|
121 |
my ($ch) = @_;
|
|
122 |
|
|
123 |
#print "on_chars_buildlog_recipe\n";
|
|
124 |
|
|
125 |
$characters .= $ch->{Data};
|
|
126 |
|
|
127 |
#print "characters is now -->$characters<--\n";
|
|
128 |
}
|
|
129 |
|
383
|
130 |
sub on_start_buildlog_recipe_status
|
|
131 |
{
|
|
132 |
my ($el) = @_;
|
|
133 |
|
|
134 |
my $attributes = $el->{Attributes};
|
|
135 |
for (keys %{$attributes})
|
|
136 |
{
|
|
137 |
if ($attributes->{$_}->{'LocalName'} eq 'code')
|
|
138 |
{
|
|
139 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'};
|
|
140 |
}
|
|
141 |
elsif ($attributes->{$_}->{'LocalName'} eq 'exit')
|
|
142 |
{
|
|
143 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'};
|
|
144 |
}
|
|
145 |
elsif ($attributes->{$_}->{'LocalName'} eq 'attempt')
|
|
146 |
{
|
|
147 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'};
|
|
148 |
}
|
|
149 |
}
|
|
150 |
}
|
|
151 |
|
242
|
152 |
sub on_end_buildlog_recipe
|
|
153 |
{
|
383
|
154 |
if ($recipe_info->{exit} =~ /failed/)
|
|
155 |
{
|
|
156 |
# normalize bldinf path
|
|
157 |
$recipe_info->{bldinf} = lc($recipe_info->{bldinf});
|
|
158 |
$recipe_info->{bldinf} =~ s,^[A-Za-z]:,,;
|
|
159 |
$recipe_info->{bldinf} =~ s,[\\],/,g;
|
|
160 |
|
|
161 |
my $package = '';
|
|
162 |
if ($recipe_info->{bldinf} =~ m,/((os|mw|app|tools|ostools|adaptation)/[^/]*),)
|
|
163 |
{
|
|
164 |
$package = $1;
|
|
165 |
$package =~ s,/,_,;
|
|
166 |
}
|
|
167 |
else
|
|
168 |
{
|
|
169 |
print "WARNING: can't understand bldinf attribute of recipe: $recipe_info->{bldinf}. Won't dump to failed recipes file.\n";
|
|
170 |
}
|
|
171 |
|
|
172 |
$characters =~ s,^[\r\n]*,,;
|
|
173 |
$characters =~ s,[\r\n]*$,,;
|
|
174 |
|
|
175 |
if ($package)
|
|
176 |
{
|
|
177 |
$filename = "$::basedir/$package.txt";
|
|
178 |
if (!-f$filename)
|
|
179 |
{
|
|
180 |
print "Writing recipe file $filename\n";
|
|
181 |
open(FILE, ">$filename");
|
|
182 |
close(FILE);
|
|
183 |
}
|
|
184 |
|
|
185 |
if ($failure_item == 0 and -f "$filename")
|
|
186 |
{
|
|
187 |
open(FILE, "$filename");
|
|
188 |
{
|
|
189 |
local $/ = undef;
|
|
190 |
my $filecontent = <FILE>;
|
|
191 |
$failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s);
|
|
192 |
}
|
|
193 |
close(FILE);
|
|
194 |
}
|
|
195 |
|
|
196 |
$failure_item++;
|
|
197 |
|
|
198 |
open(FILE, ">>$filename");
|
|
199 |
print FILE "---failure_item_$failure_item\---\n";
|
|
200 |
print FILE "$characters\n\n";
|
|
201 |
close(FILE);
|
|
202 |
}
|
|
203 |
|
|
204 |
process($characters, $recipe_info->{bldinf}, $recipe_info->{phase}, $recipe_info->{name}, "$package.txt", $failure_item);
|
|
205 |
}
|
|
206 |
|
|
207 |
$characters = '';
|
|
208 |
}
|
|
209 |
|
|
210 |
sub on_end_buildlog
|
|
211 |
{
|
242
|
212 |
}
|
|
213 |
|
|
214 |
|
|
215 |
1; |