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