| author | Dario Sestito <darios@symbian.org> |
| Mon, 12 Apr 2010 14:47:03 +0100 | |
| changeset 236 | 8a3d46cfe8b5 |
| parent 223 | 604012c39141 |
| child 258 | 08436a227940 |
| 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 releaseable (whatlog) information |
|
15 |
||
16 |
package releaseables; |
|
17 |
||
18 |
use strict; |
|
19 |
||
20 |
our $reset_status = {};
|
|
21 |
my $buildlog_status = {};
|
|
22 |
my $whatlog_status = {};
|
|
23 |
my $bitmap_status = {};
|
|
24 |
my $resource_status = {};
|
|
25 |
my $build_status = {};
|
|
26 |
my $export_status = {};
|
|
27 |
my $stringtable_status = {};
|
|
28 |
my $archive_status = {};
|
|
29 |
my $archive_member_status = {};
|
|
30 |
my $whatlog_default_status = {};
|
|
31 |
||
32 |
$reset_status->{name} = 'reset_status';
|
|
33 |
$reset_status->{next_status} = {buildlog=>$buildlog_status};
|
|
34 |
||
35 |
$buildlog_status->{name} = 'buildlog_status';
|
|
36 |
$buildlog_status->{next_status} = {whatlog=>$whatlog_status};
|
|
37 |
$buildlog_status->{on_start} = 'releaseables::on_start_buildlog';
|
|
38 |
||
39 |
$whatlog_status->{name} = 'whatlog_status';
|
|
40 |
$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};
|
|
41 |
$whatlog_status->{on_start} = 'releaseables::on_start_whatlog';
|
|
42 |
$whatlog_status->{on_end} = 'releaseables::on_end_whatlog';
|
|
43 |
||
44 |
$bitmap_status->{name} = 'bitmap_status';
|
|
45 |
$bitmap_status->{next_status} = {};
|
|
46 |
$bitmap_status->{on_start} = 'releaseables::on_start_bitmap';
|
|
47 |
$bitmap_status->{on_end} = 'releaseables::on_end_whatlog_subtag';
|
|
48 |
$bitmap_status->{on_chars} = 'releaseables::on_chars_whatlog_subtag';
|
|
49 |
||
50 |
$resource_status->{name} = 'resource_status';
|
|
51 |
$resource_status->{next_status} = {};
|
|
52 |
$resource_status->{on_start} = 'releaseables::on_start_resource';
|
|
53 |
$resource_status->{on_end} = 'releaseables::on_end_whatlog_subtag';
|
|
54 |
$resource_status->{on_chars} = 'releaseables::on_chars_whatlog_subtag';
|
|
55 |
||
56 |
$build_status->{name} = 'build_status';
|
|
57 |
$build_status->{next_status} = {};
|
|
58 |
$build_status->{on_start} = 'releaseables::on_start_build';
|
|
59 |
$build_status->{on_end} = 'releaseables::on_end_whatlog_subtag';
|
|
60 |
$build_status->{on_chars} = 'releaseables::on_chars_whatlog_subtag';
|
|
61 |
||
62 |
$stringtable_status->{name} = 'stringtable_status';
|
|
63 |
$stringtable_status->{next_status} = {};
|
|
64 |
$stringtable_status->{on_start} = 'releaseables::on_start_stringtable';
|
|
65 |
$stringtable_status->{on_end} = 'releaseables::on_end_whatlog_subtag';
|
|
66 |
$stringtable_status->{on_chars} = 'releaseables::on_chars_whatlog_subtag';
|
|
67 |
||
68 |
$archive_status->{name} = 'archive_status';
|
|
69 |
$archive_status->{next_status} = {member=>$archive_member_status};
|
|
70 |
||
71 |
$archive_member_status->{name} = 'archive_member_status';
|
|
72 |
$archive_member_status->{next_status} = {};
|
|
73 |
$archive_member_status->{on_start} = 'releaseables::on_start_archive_member';
|
|
74 |
$archive_member_status->{on_end} = 'releaseables::on_end_whatlog_subtag';
|
|
75 |
$archive_member_status->{on_chars} = 'releaseables::on_chars_whatlog_subtag';
|
|
76 |
||
77 |
$export_status->{name} = 'export_status';
|
|
78 |
$export_status->{next_status} = {};
|
|
79 |
$export_status->{on_start} = 'releaseables::on_start_export';
|
|
80 |
||
81 |
$whatlog_default_status->{name} = 'whatlog_default_status';
|
|
82 |
$whatlog_default_status->{next_status} = {};
|
|
83 |
$whatlog_default_status->{on_start} = 'releaseables::on_start_whatlog_default';
|
|
84 |
||
85 |
my $whatlog_info = {};
|
|
86 |
my $curbldinf = 'unknown'; |
|
87 |
my $curconfig = 'unknown'; |
|
88 |
my $curfiletype = 'unknown'; |
|
89 |
my $characters = ''; |
|
90 |
||
91 |
sub on_start_buildlog |
|
92 |
{
|
|
93 |
||
94 |
} |
|
95 |
||
96 |
sub on_start_whatlog |
|
97 |
{
|
|
98 |
my ($el) = @_; |
|
99 |
||
100 |
$whatlog_info = {};
|
|
101 |
||
102 |
my $bldinf = ''; |
|
103 |
my $config = ''; |
|
104 |
my $attributes = $el->{Attributes};
|
|
105 |
for (keys %{$attributes})
|
|
106 |
{
|
|
107 |
#print "reading attribute $_\n"; |
|
108 |
if ($attributes->{$_}->{'LocalName'} eq 'bldinf')
|
|
109 |
{
|
|
110 |
$bldinf = $attributes->{$_}->{'Value'};
|
|
111 |
#print "bldinf=$bldinf\n"; |
|
112 |
} |
|
113 |
elsif ($attributes->{$_}->{'LocalName'} eq 'config')
|
|
114 |
{
|
|
115 |
$config = $attributes->{$_}->{'Value'};
|
|
116 |
$config =~ s,\.whatlog$,,; |
|
117 |
} |
|
118 |
} |
|
119 |
||
120 |
if ($bldinf eq '') |
|
121 |
{
|
|
122 |
print "WARNING: whatlog tag with no bldinf attribute. Skipping\n"; |
|
123 |
return; |
|
124 |
} |
|
125 |
||
126 |
$curbldinf = $bldinf; |
|
127 |
$curconfig = $config; |
|
128 |
$whatlog_info->{$curbldinf} = {} if (!defined $whatlog_info->{$curbldinf});
|
|
129 |
$whatlog_info->{$curbldinf}->{$curconfig} = {} if (!defined $whatlog_info->{$curbldinf}->{$curconfig});
|
|
130 |
} |
|
131 |
||
132 |
sub on_start_whatlog_subtag |
|
133 |
{
|
|
134 |
my ($ft) = @_; |
|
135 |
||
136 |
$curfiletype = $ft; |
|
137 |
$characters = ''; |
|
138 |
$whatlog_info->{$curbldinf}->{$curconfig}->{$curfiletype} = [] if (! defined $whatlog_info->{$curbldinf}->{$curconfig}->{$curfiletype});
|
|
139 |
} |
|
140 |
||
141 |
sub on_chars_whatlog_subtag |
|
142 |
{
|
|
143 |
my ($ch) = @_; |
|
144 |
||
145 |
$characters .= $ch->{Data};
|
|
146 |
||
147 |
#print "characters is now -->$characters<--\n"; |
|
148 |
} |
|
149 |
||
150 |
sub on_end_whatlog_subtag |
|
151 |
{
|
|
152 |
$characters = normalize_filepath($characters); |
|
153 |
||
154 |
push(@{$whatlog_info->{$curbldinf}->{$curconfig}->{$curfiletype}}, $characters);
|
|
155 |
||
156 |
$curfiletype = 'unknown'; |
|
157 |
$characters = ''; |
|
158 |
} |
|
159 |
||
160 |
sub on_start_bitmap |
|
161 |
{
|
|
162 |
on_start_whatlog_subtag('bitmap');
|
|
163 |
} |
|
164 |
||
165 |
sub on_start_resource |
|
166 |
{
|
|
167 |
on_start_whatlog_subtag('resource');
|
|
168 |
} |
|
169 |
||
170 |
sub on_start_build |
|
171 |
{
|
|
172 |
on_start_whatlog_subtag('build');
|
|
173 |
} |
|
174 |
||
175 |
sub on_start_stringtable |
|
176 |
{
|
|
177 |
on_start_whatlog_subtag('stringtable');
|
|
178 |
} |
|
179 |
||
180 |
sub on_start_archive_member |
|
181 |
{
|
|
182 |
on_start_whatlog_subtag('export');
|
|
183 |
} |
|
184 |
||
185 |
sub on_start_export |
|
186 |
{
|
|
187 |
my ($el) = @_; |
|
188 |
||
189 |
$whatlog_info->{$curbldinf}->{$curconfig}->{export} = [] if (! defined $whatlog_info->{$curbldinf}->{$curconfig}->{export});
|
|
190 |
||
191 |
my $destination = ''; |
|
192 |
my $attributes = $el->{Attributes};
|
|
193 |
for (keys %{$attributes})
|
|
194 |
{
|
|
195 |
#print "reading attribute $_\n"; |
|
196 |
if ($attributes->{$_}->{'LocalName'} eq 'destination')
|
|
197 |
{
|
|
198 |
$destination = $attributes->{$_}->{'Value'};
|
|
199 |
#print "destination=$destination\n"; |
|
200 |
last; |
|
201 |
} |
|
202 |
} |
|
203 |
||
204 |
if ($destination eq '') |
|
205 |
{
|
|
206 |
print "WARNING: export tag with no destination attribute. Skipping\n"; |
|
207 |
return; |
|
208 |
} |
|
209 |
||
210 |
$destination = normalize_filepath($destination); |
|
211 |
||
212 |
push(@{$whatlog_info->{$curbldinf}->{$curconfig}->{export}}, $destination);
|
|
213 |
} |
|
214 |
||
215 |
sub on_end_whatlog |
|
216 |
{
|
|
217 |
my $unknown_counter = 0; |
|
218 |
||
219 |
for my $bldinf (keys %{$whatlog_info})
|
|
220 |
{
|
|
221 |
for my $config (keys %{$whatlog_info->{$bldinf}})
|
|
222 |
{
|
|
223 |
my $normalized = lc($bldinf); |
|
224 |
$normalized =~ s,^[A-Za-z]:,,; |
|
225 |
$normalized =~ s,[\\],/,g; |
|
226 |
||
227 |
$normalized =~ m,^/sf/([^/]+)/([^/]+)/,; |
|
228 |
my $layer = $1; |
|
229 |
my $package = $2; |
|
230 |
||
|
216
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
231 |
mkdir("$::releaseablesdir/$layer");
|
|
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
232 |
mkdir("$::releaseablesdir/$layer/$package");
|
| 177 | 233 |
|
|
216
2c2dbe93b84b
Uh parser to report on list of missing releaseables
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
234 |
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
|
235 |
my $filenamemissing = "$::raptorbitsdir/$layer\_$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; |