author | Dario Sestito <darios@symbian.org> |
Wed, 16 Jun 2010 11:44:46 +0100 | |
changeset 287 | 598059d917c3 |
parent 260 | 09b83ca8e0cf |
child 298 | 27d2c4249a97 |
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: |
|
258
08436a227940
Add author information. Reviewed descriptions
Dario Sestito <darios@symbian.org>
parents:
223
diff
changeset
|
11 |
# Dario Sestito <darios@symbian.org> |
177 | 12 |
# |
13 |
# Description: |
|
14 |
# Raptor parser module. |
|
15 |
# Extract releaseable (whatlog) information |
|
16 |
||
17 |
package releaseables; |
|
18 |
||
19 |
use strict; |
|
20 |
||
21 |
our $reset_status = {}; |
|
22 |
my $buildlog_status = {}; |
|
23 |
my $whatlog_status = {}; |
|
24 |
my $bitmap_status = {}; |
|
25 |
my $resource_status = {}; |
|
26 |
my $build_status = {}; |
|
27 |
my $export_status = {}; |
|
28 |
my $stringtable_status = {}; |
|
29 |
my $archive_status = {}; |
|
30 |
my $archive_member_status = {}; |
|
31 |
my $whatlog_default_status = {}; |
|
32 |
||
33 |
$reset_status->{name} = 'reset_status'; |
|
34 |
$reset_status->{next_status} = {buildlog=>$buildlog_status}; |
|
35 |
||
36 |
$buildlog_status->{name} = 'buildlog_status'; |
|
37 |
$buildlog_status->{next_status} = {whatlog=>$whatlog_status}; |
|
38 |
$buildlog_status->{on_start} = 'releaseables::on_start_buildlog'; |
|
39 |
||
40 |
$whatlog_status->{name} = 'whatlog_status'; |
|
41 |
$whatlog_status->{next_status} = {bitmap=>$bitmap_status, resource=>$resource_status, build=>$build_status, export=>$export_status, stringtable=>$stringtable_status, archive=>$archive_status, '?default?'=>$whatlog_default_status}; |
|
42 |
$whatlog_status->{on_start} = 'releaseables::on_start_whatlog'; |
|
43 |
$whatlog_status->{on_end} = 'releaseables::on_end_whatlog'; |
|
44 |
||
45 |
$bitmap_status->{name} = 'bitmap_status'; |
|
46 |
$bitmap_status->{next_status} = {}; |
|
47 |
$bitmap_status->{on_start} = 'releaseables::on_start_bitmap'; |
|
48 |
$bitmap_status->{on_end} = 'releaseables::on_end_whatlog_subtag'; |
|
49 |
$bitmap_status->{on_chars} = 'releaseables::on_chars_whatlog_subtag'; |
|
50 |
||
51 |
$resource_status->{name} = 'resource_status'; |
|
52 |
$resource_status->{next_status} = {}; |
|
53 |
$resource_status->{on_start} = 'releaseables::on_start_resource'; |
|
54 |
$resource_status->{on_end} = 'releaseables::on_end_whatlog_subtag'; |
|
55 |
$resource_status->{on_chars} = 'releaseables::on_chars_whatlog_subtag'; |
|
56 |
||
57 |
$build_status->{name} = 'build_status'; |
|
58 |
$build_status->{next_status} = {}; |
|
59 |
$build_status->{on_start} = 'releaseables::on_start_build'; |
|
60 |
$build_status->{on_end} = 'releaseables::on_end_whatlog_subtag'; |
|
61 |
$build_status->{on_chars} = 'releaseables::on_chars_whatlog_subtag'; |
|
62 |
||
63 |
$stringtable_status->{name} = 'stringtable_status'; |
|
64 |
$stringtable_status->{next_status} = {}; |
|
65 |
$stringtable_status->{on_start} = 'releaseables::on_start_stringtable'; |
|
66 |
$stringtable_status->{on_end} = 'releaseables::on_end_whatlog_subtag'; |
|
67 |
$stringtable_status->{on_chars} = 'releaseables::on_chars_whatlog_subtag'; |
|
68 |
||
69 |
$archive_status->{name} = 'archive_status'; |
|
70 |
$archive_status->{next_status} = {member=>$archive_member_status}; |
|
71 |
||
72 |
$archive_member_status->{name} = 'archive_member_status'; |
|
73 |
$archive_member_status->{next_status} = {}; |
|
74 |
$archive_member_status->{on_start} = 'releaseables::on_start_archive_member'; |
|
75 |
$archive_member_status->{on_end} = 'releaseables::on_end_whatlog_subtag'; |
|
76 |
$archive_member_status->{on_chars} = 'releaseables::on_chars_whatlog_subtag'; |
|
77 |
||
78 |
$export_status->{name} = 'export_status'; |
|
79 |
$export_status->{next_status} = {}; |
|
80 |
$export_status->{on_start} = 'releaseables::on_start_export'; |
|
81 |
||
82 |
$whatlog_default_status->{name} = 'whatlog_default_status'; |
|
83 |
$whatlog_default_status->{next_status} = {}; |
|
84 |
$whatlog_default_status->{on_start} = 'releaseables::on_start_whatlog_default'; |
|
85 |
||
86 |
my $whatlog_info = {}; |
|
87 |
my $curbldinf = 'unknown'; |
|
88 |
my $curconfig = 'unknown'; |
|
89 |
my $curfiletype = 'unknown'; |
|
90 |
my $characters = ''; |
|
91 |
||
92 |
sub on_start_buildlog |
|
93 |
{ |
|
94 |
||
95 |
} |
|
96 |
||
97 |
sub on_start_whatlog |
|
98 |
{ |
|
99 |
my ($el) = @_; |
|
100 |
||
101 |
$whatlog_info = {}; |
|
102 |
||
103 |
my $bldinf = ''; |
|
104 |
my $config = ''; |
|
105 |
my $attributes = $el->{Attributes}; |
|
106 |
for (keys %{$attributes}) |
|
107 |
{ |
|
108 |
#print "reading attribute $_\n"; |
|
109 |
if ($attributes->{$_}->{'LocalName'} eq 'bldinf') |
|
110 |
{ |
|
111 |
$bldinf = $attributes->{$_}->{'Value'}; |
|
112 |
#print "bldinf=$bldinf\n"; |
|
113 |
} |
|
114 |
elsif ($attributes->{$_}->{'LocalName'} eq 'config') |
|
115 |
{ |
|
116 |
$config = $attributes->{$_}->{'Value'}; |
|
117 |
$config =~ s,\.whatlog$,,; |
|
118 |
} |
|
119 |
} |
|
120 |
||
121 |
if ($bldinf eq '') |
|
122 |
{ |
|
123 |
print "WARNING: whatlog tag with no bldinf attribute. Skipping\n"; |
|
124 |
return; |
|
125 |
} |
|
126 |
||
127 |
$curbldinf = $bldinf; |
|
128 |
$curconfig = $config; |
|
129 |
$whatlog_info->{$curbldinf} = {} if (!defined $whatlog_info->{$curbldinf}); |
|
130 |
$whatlog_info->{$curbldinf}->{$curconfig} = {} if (!defined $whatlog_info->{$curbldinf}->{$curconfig}); |
|
131 |
} |
|
132 |
||
133 |
sub on_start_whatlog_subtag |
|
134 |
{ |
|
135 |
my ($ft) = @_; |
|
136 |
||
137 |
$curfiletype = $ft; |
|
138 |
$characters = ''; |
|
139 |
$whatlog_info->{$curbldinf}->{$curconfig}->{$curfiletype} = [] if (! defined $whatlog_info->{$curbldinf}->{$curconfig}->{$curfiletype}); |
|
140 |
} |
|
141 |
||
142 |
sub on_chars_whatlog_subtag |
|
143 |
{ |
|
144 |
my ($ch) = @_; |
|
145 |
||
146 |
$characters .= $ch->{Data}; |
|
147 |
||
148 |
#print "characters is now -->$characters<--\n"; |
|
149 |
} |
|
150 |
||
151 |
sub on_end_whatlog_subtag |
|
152 |
{ |
|
153 |
$characters = normalize_filepath($characters); |
|
154 |
||
155 |
push(@{$whatlog_info->{$curbldinf}->{$curconfig}->{$curfiletype}}, $characters); |
|
156 |
||
157 |
$curfiletype = 'unknown'; |
|
158 |
$characters = ''; |
|
159 |
} |
|
160 |
||
161 |
sub on_start_bitmap |
|
162 |
{ |
|
163 |
on_start_whatlog_subtag('bitmap'); |
|
164 |
} |
|
165 |
||
166 |
sub on_start_resource |
|
167 |
{ |
|
168 |
on_start_whatlog_subtag('resource'); |
|
169 |
} |
|
170 |
||
171 |
sub on_start_build |
|
172 |
{ |
|
173 |
on_start_whatlog_subtag('build'); |
|
174 |
} |
|
175 |
||
176 |
sub on_start_stringtable |
|
177 |
{ |
|
178 |
on_start_whatlog_subtag('stringtable'); |
|
179 |
} |
|
180 |
||
181 |
sub on_start_archive_member |
|
182 |
{ |
|
183 |
on_start_whatlog_subtag('export'); |
|
184 |
} |
|
185 |
||
186 |
sub on_start_export |
|
187 |
{ |
|
188 |
my ($el) = @_; |
|
189 |
||
190 |
$whatlog_info->{$curbldinf}->{$curconfig}->{export} = [] if (! defined $whatlog_info->{$curbldinf}->{$curconfig}->{export}); |
|
191 |
||
192 |
my $destination = ''; |
|
193 |
my $attributes = $el->{Attributes}; |
|
194 |
for (keys %{$attributes}) |
|
195 |
{ |
|
196 |
#print "reading attribute $_\n"; |
|
197 |
if ($attributes->{$_}->{'LocalName'} eq 'destination') |
|
198 |
{ |
|
199 |
$destination = $attributes->{$_}->{'Value'}; |
|
200 |
#print "destination=$destination\n"; |
|
201 |
last; |
|
202 |
} |
|
203 |
} |
|
204 |
||
205 |
if ($destination eq '') |
|
206 |
{ |
|
207 |
print "WARNING: export tag with no destination attribute. Skipping\n"; |
|
208 |
return; |
|
209 |
} |
|
210 |
||
211 |
$destination = normalize_filepath($destination); |
|
212 |
||
213 |
push(@{$whatlog_info->{$curbldinf}->{$curconfig}->{export}}, $destination); |
|
214 |
} |
|
215 |
||
216 |
sub on_end_whatlog |
|
217 |
{ |
|
218 |
my $unknown_counter = 0; |
|
219 |
||
220 |
for my $bldinf (keys %{$whatlog_info}) |
|
221 |
{ |
|
222 |
for my $config (keys %{$whatlog_info->{$bldinf}}) |
|
223 |
{ |
|
224 |
my $normalized = lc($bldinf); |
|
225 |
$normalized =~ s,^[A-Za-z]:,,; |
|
226 |
$normalized =~ s,[\\],/,g; |
|
227 |
||
260
09b83ca8e0cf
Revert to version 236 as 237 breaks the parser
Dario Sestito <darios@symbian.org>
parents:
259
diff
changeset
|
228 |
$normalized =~ m,^/sf/([^/]+)/([^/]+)/,; |
177 | 229 |
my $layer = $1; |
230 |
my $package = $2; |
|
231 |
||
216
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
232 |
mkdir("$::releaseablesdir/$layer"); |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
233 |
mkdir("$::releaseablesdir/$layer/$package"); |
177 | 234 |
|
216
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
235 |
my $filename = "$::releaseablesdir/$layer/$package/info.tsv"; |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
236 |
my $filenamemissing = "$::raptorbitsdir/$layer\_$package\_missing.txt" if ($::missing); |
177 | 237 |
|
238 |
print "Writing info file $filename\n" if (!-f$filename); |
|
239 |
open(FILE, ">>$filename"); |
|
240 |
||
241 |
for my $filetype (keys %{$whatlog_info->{$bldinf}->{$config}}) |
|
242 |
{ |
|
243 |
for (sort(@{$whatlog_info->{$bldinf}->{$config}->{$filetype}})) |
|
244 |
{ |
|
245 |
print FILE "$_\t$filetype\t$config\n"; |
|
216
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
246 |
my $file = $_; |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
247 |
|
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
248 |
if($::missing && !-f $file) |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
249 |
{ |
223
604012c39141
Minor adjustments to UH parser
Dario Sestito <darios@symbian.org>
parents:
216
diff
changeset
|
250 |
open(MISSING, ">>$filenamemissing"); |
604012c39141
Minor adjustments to UH parser
Dario Sestito <darios@symbian.org>
parents:
216
diff
changeset
|
251 |
print MISSING $file."\n"; |
604012c39141
Minor adjustments to UH parser
Dario Sestito <darios@symbian.org>
parents:
216
diff
changeset
|
252 |
close(MISSING); |
604012c39141
Minor adjustments to UH parser
Dario Sestito <darios@symbian.org>
parents:
216
diff
changeset
|
253 |
} |
177 | 254 |
} |
255 |
} |
|
223
604012c39141
Minor adjustments to UH parser
Dario Sestito <darios@symbian.org>
parents:
216
diff
changeset
|
256 |
close(FILE); |
177 | 257 |
} |
258 |
} |
|
259 |
} |
|
216
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
260 |
sub remove_missing_duplicates |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
261 |
{ |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
262 |
opendir(DIR, $::raptorbitsdir); |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
263 |
my @files = grep((-f "$::raptorbitsdir/$_" && $_ !~ /^\.\.?$/ && $_ =~ /_missing\.txt$/), readdir(DIR)); |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
264 |
close(DIR); |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
265 |
|
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
266 |
for my $file (@files) |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
267 |
{ |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
268 |
open(FILE, "+<$::raptorbitsdir/$file"); |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
269 |
print "working on $file\n"; |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
270 |
|
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
271 |
# Read it |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
272 |
my @content = <FILE>; |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
273 |
|
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
274 |
# Sort it, and grep to remove duplicates |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
275 |
my $previous = "\n\n"; |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
276 |
@content = grep {$_ ne $previous && ($previous = $_, 1) } sort @content; |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
277 |
|
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
278 |
# Write it |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
279 |
seek(FILE, 0, 0); |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
280 |
print FILE @content; |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
281 |
truncate(FILE,tell(FILE)); |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
282 |
|
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
283 |
close(FILE); |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
284 |
} |
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
285 |
} |
177 | 286 |
|
287 |
sub normalize_filepath |
|
288 |
{ |
|
289 |
my ($filepath) = @_; |
|
290 |
||
291 |
if ($filepath =~ m,[^\s^\r^\n]+(.*)[\r\n]+(.*)[^\s^\r^\n]+,) |
|
292 |
{ |
|
293 |
print "WARNING: file path string extends over multiple line: $filepath. Removing all NL's and CR's\n"; |
|
294 |
} |
|
295 |
||
296 |
# strip all CR's and NL's |
|
297 |
$filepath =~ s,[\r\n],,g; |
|
298 |
||
299 |
# strip all whitespaces at string start/end |
|
300 |
$filepath =~ s,^\s+,,g; |
|
301 |
$filepath =~ s,\s+$,,g; |
|
302 |
||
303 |
# remove drive letter and colon from the beginning of the string |
|
304 |
$filepath =~ s,^[A-Za-z]:,,; |
|
305 |
||
306 |
# normalize slashes |
|
307 |
$filepath =~ s,\\,/,g; |
|
308 |
$filepath =~ s,//,/,g; |
|
309 |
||
310 |
if ($filepath !~ m,^/epoc32/,i) |
|
311 |
{ |
|
312 |
print "WARNING: file '$filepath' doesn't seem valid. Writing to info file anyway\n"; |
|
313 |
} |
|
314 |
||
315 |
return $filepath; |
|
316 |
} |
|
317 |
||
318 |
sub on_start_whatlog_default |
|
319 |
{ |
|
320 |
my ($el) = @_; |
|
321 |
||
322 |
my $tagname = $el->{LocalName}; |
|
323 |
||
324 |
print "WARNING: unsupported tag '$tagname' in <whatlog> context\n"; |
|
325 |
} |
|
326 |
||
327 |
1; |