1 # |
|
2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of the License "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 #------------------------------------------------------------------------------ |
|
17 # Name : Localiser.pm |
|
18 # Use : Implementation of a new localisation process. |
|
19 |
|
20 # |
|
21 # Version History : |
|
22 # |
|
23 # v1.1.2 (30/01/2008) : Valliappan Ramanathan - ISIS |
|
24 # - Updated to build with EC build |
|
25 |
|
26 # |
|
27 # v1.1.1 (04/08/2006) : |
|
28 # - Update include management, now it uses cpp. |
|
29 # |
|
30 # v1.1.0 (12/05/2006) : |
|
31 # - Corrected include parsing, remove that fact that file must start with \ |
|
32 # - Added locales_xx.iby creation |
|
33 # |
|
34 # v1.0.1 (12/05/2006) : |
|
35 # - Corrected __MakeRlt function |
|
36 # |
|
37 # v1.0 (19/04/2006) : |
|
38 # - First version of the script. |
|
39 #------------------------------------------------------------------------------ |
|
40 |
|
41 ## @ file |
|
42 # |
|
43 |
|
44 #------------------------------------------------------------------------------ |
|
45 # Package __OUT |
|
46 #------------------------------------------------------------------------------ |
|
47 package __OUT; |
|
48 use strict; |
|
49 |
|
50 my $outputer = "__OUT"; |
|
51 |
|
52 sub SetLoggerPackage |
|
53 { |
|
54 my ($p) = shift; |
|
55 return unless($p); |
|
56 $outputer = $p; |
|
57 } |
|
58 |
|
59 sub AUTOLOAD |
|
60 { |
|
61 my ($method) = (our $AUTOLOAD); |
|
62 if ( $outputer eq "__OUT" ) |
|
63 { |
|
64 $method =~ s/^__OUT:://; |
|
65 if ($method =~ /print/i) |
|
66 { |
|
67 print ("@_"); |
|
68 } |
|
69 elsif ($method =~ /die/i) |
|
70 { |
|
71 die (@_); |
|
72 } |
|
73 else |
|
74 { |
|
75 print (uc($method).": @_"); |
|
76 } |
|
77 } |
|
78 elsif ( defined ($outputer) and defined($method) ) |
|
79 { |
|
80 print "@_\n" if ($method =~ /die/i); |
|
81 $method =~ s/^__OUT::/$outputer\::/; |
|
82 no strict 'refs'; |
|
83 &$method( @_ ); |
|
84 } |
|
85 } |
|
86 |
|
87 1; |
|
88 |
|
89 ## @class ZipUp |
|
90 # |
|
91 # |
|
92 # |
|
93 package ZipUp; |
|
94 use strict; |
|
95 use Archive::Zip; |
|
96 use File::Copy; |
|
97 |
|
98 sub new |
|
99 { |
|
100 my ( $class, $filename ) = @_; |
|
101 return undef unless ($filename); |
|
102 |
|
103 my $self = { |
|
104 __filename => $filename, |
|
105 }; |
|
106 |
|
107 return bless $self, $class; |
|
108 } |
|
109 |
|
110 sub AddFile |
|
111 { |
|
112 my ( $self, $filename ) = (shift,shift); |
|
113 &__OUT::Print ("Adding '\\$filename'\n"); |
|
114 my $cmd = "zip ".$self->{ __filename }." $filename\n"; |
|
115 &__OUT::Print (scalar(`$cmd`)); |
|
116 } |
|
117 |
|
118 sub AddFilesFromList |
|
119 { |
|
120 my ( $self, $listfilename ) = (shift,shift); |
|
121 if ( -e $listfilename ) |
|
122 { |
|
123 &__OUT::Print ("Adding files using '$listfilename'\n"); |
|
124 my $cmd = "more $listfilename | zip -9 ".$self->{ __filename }." -@"; |
|
125 &__OUT::Print ( $cmd."\n" ); |
|
126 &__OUT::Print ( scalar( `$cmd` ) ); |
|
127 } |
|
128 } |
|
129 1; |
|
130 |
|
131 |
|
132 ## @class Finder |
|
133 # |
|
134 # |
|
135 # |
|
136 package Finder; |
|
137 |
|
138 sub new |
|
139 { |
|
140 my ( $class, $regexp, $rootdir ) = @_; |
|
141 |
|
142 my $self = { |
|
143 __rootdir => $rootdir, |
|
144 __regexp => $regexp, |
|
145 }; |
|
146 |
|
147 return bless $self, $class; |
|
148 } |
|
149 |
|
150 sub Find |
|
151 { |
|
152 my ($self, $dir, $list) = @_; |
|
153 |
|
154 my @fake; |
|
155 $list = \@fake unless (defined ($list)); |
|
156 $dir = $self->{__rootdir} unless (defined($dir)); |
|
157 |
|
158 opendir (DIR, $dir); |
|
159 my @l = readdir(DIR); |
|
160 closedir(DIR); |
|
161 |
|
162 foreach my $name (@l) |
|
163 { |
|
164 next if ($name =~ /^\.+$/); |
|
165 my $filename = "$dir/$name"; |
|
166 |
|
167 if ( -d $filename ) |
|
168 { |
|
169 $self->Find($filename, $list); |
|
170 } |
|
171 elsif ( $filename =~ /$self->{__regexp}/i ) |
|
172 { |
|
173 push @$list, $filename; |
|
174 } |
|
175 } |
|
176 |
|
177 return $list; |
|
178 } |
|
179 |
|
180 1; |
|
181 |
|
182 |
|
183 ## @class Localiser |
|
184 # |
|
185 # |
|
186 package Localiser; |
|
187 use strict; |
|
188 use File::Path; |
|
189 #use ISIS::GenBuildTools; |
|
190 use IPC::Open3; |
|
191 use File::Spec; |
|
192 use File::Basename; |
|
193 |
|
194 my $DEFAULT_LOC_PATH = "\\s60\\S60LocFiles"; |
|
195 use constant DEFAULT_XML_PATH => ".xml"; |
|
196 use constant DEFAULT_WHATXML_PATH => "_what.xml"; |
|
197 use constant DEFAULT_CHECKXML_PATH => "_check.xml"; |
|
198 use constant DEFAULT_TPATH => "\\zips"; |
|
199 |
|
200 |
|
201 use constant DEFAULT_MAKE_PATH => ".make"; |
|
202 use constant DEFAULT_WHATMAKE_PATH => "whatMakefile"; |
|
203 use constant DEFAULT_CHECKMAKE_PATH => "checkMakefile"; |
|
204 |
|
205 sub new |
|
206 { |
|
207 my $class = shift; |
|
208 |
|
209 my $configfiles = shift; |
|
210 my $languagelist = shift; |
|
211 my $includepath = shift; |
|
212 my $bldfile = shift; |
|
213 my $tpath = shift || DEFAULT_TPATH; |
|
214 my @configuration; |
|
215 my %platform;# = ("armv5"); |
|
216 my $self = { |
|
217 __configfiles => $configfiles, |
|
218 __includepath => $includepath, |
|
219 __languagelist => $languagelist, |
|
220 __configuration => \@configuration, |
|
221 __platform => \%platform, |
|
222 __tpath => $tpath, |
|
223 __bldfile => $bldfile |
|
224 }; |
|
225 return bless $self, $class; |
|
226 } |
|
227 |
|
228 |
|
229 sub DefaultLocPath |
|
230 { |
|
231 my ($k) = @_; |
|
232 $DEFAULT_LOC_PATH = $k if (defined ($k)); |
|
233 return $DEFAULT_LOC_PATH; |
|
234 } |
|
235 |
|
236 sub Keepgoing |
|
237 { |
|
238 my ($self, $k) = @_; |
|
239 $self->{__keepgoing} = $k if (defined ($k)); |
|
240 return $self->{__keepgoing}; |
|
241 } |
|
242 |
|
243 sub SetLoggerPackage |
|
244 { |
|
245 my ($self, $outputer) = @_; |
|
246 return unless($outputer); |
|
247 &__OUT::SetLoggerPackage($outputer); |
|
248 } |
|
249 |
|
250 sub Initialise() |
|
251 { |
|
252 my $self = shift; |
|
253 my ($drive) = File::Spec->splitpath(File::Spec->rel2abs(File::Spec->curdir())); |
|
254 foreach my $filename ( @{ $self->{__configfiles} } ) |
|
255 { |
|
256 # adding path of the input file into the include path list |
|
257 my $includepath = ""; |
|
258 $includepath .= "-I ".File::Spec->rel2abs(dirname($filename)); |
|
259 foreach my $path ( @{ $self->{__includepath} } ) |
|
260 { |
|
261 $path = File::Spec->rel2abs($path); |
|
262 $path = "$drive$path" if ($path =~ /^\\/); |
|
263 $includepath .= " -I $path"; |
|
264 } |
|
265 |
|
266 # command line to execute |
|
267 my $cmd = "cpp -nostdinc -u $includepath ".File::Spec->rel2abs($filename); |
|
268 __OUT::Print( "$cmd\n"); |
|
269 |
|
270 # parsing using cpp... |
|
271 my $childpid = open3(\*WTRFH, \*RDRFH, \*ERRFH, $cmd); |
|
272 close(WTRFH); |
|
273 |
|
274 while (<RDRFH>) |
|
275 { |
|
276 if ( /^\s*<option (\w+)>/ ) |
|
277 { |
|
278 my $option = lc($1); |
|
279 $self->{ __platform }->{ $option } = $option; # if ($option =~ /^(armv5|winscw)$/i); |
|
280 } |
|
281 else |
|
282 { |
|
283 my $c = &__LocInfoData::CreateFromLine( $_ ); |
|
284 push ( @{ $self->{__configuration} }, $c ) if ($c); |
|
285 } |
|
286 } |
|
287 close(RDRFH); |
|
288 |
|
289 # Manage cpp errors |
|
290 my $err = ""; |
|
291 while(<ERRFH>) { $err .= "$_\n";} |
|
292 if (not ($err eq "")){ __OUT::Error ("$err"); } |
|
293 |
|
294 # Closing cleanly.... |
|
295 close(ERRFH); |
|
296 waitpid($childpid, 0); |
|
297 } |
|
298 |
|
299 |
|
300 # if not platform add default one: armv5 |
|
301 unless (scalar (keys (%{$self->{ __platform }}) )) |
|
302 { |
|
303 __OUT::Warning("No platform specified, using default (ARMV5)"); |
|
304 $self->{ __platform }->{ 'armv5' } = 'armv5'; |
|
305 } |
|
306 } |
|
307 |
|
308 sub CheckConfig |
|
309 { |
|
310 my $self = shift; |
|
311 my $result = 1; |
|
312 foreach my $c ( @{ $self->{__configuration} } ) |
|
313 { |
|
314 $result &&= $c->CheckBldInf(); |
|
315 $result &&= $c->CheckLocFiles(); |
|
316 } |
|
317 return $result; |
|
318 } |
|
319 |
|
320 sub PrepareLocalisation |
|
321 { |
|
322 my $self = shift; |
|
323 my $filename = shift; |
|
324 |
|
325 my $zip = new ZipUp($filename); |
|
326 |
|
327 __OUT::Print ("Preparing each component\n"); |
|
328 |
|
329 foreach my $c ( @{ $self->{__configuration} } ) |
|
330 { |
|
331 $c->ZipUpLocFiles( $zip ); |
|
332 } |
|
333 |
|
334 HandleEpoc32LocFiles( $self-> { __languagelist }, $zip ); |
|
335 |
|
336 my $time1; |
|
337 my $time2; |
|
338 |
|
339 $time1 = time(); |
|
340 foreach my $c ( @{ $self->{__configuration} } ) |
|
341 { |
|
342 $c->GenerateStubLocFiles( $self-> { __languagelist } ); |
|
343 $c->ChangeMMPsAndMKs( $self-> { __languagelist }, $zip ); |
|
344 $c->TouchRSS(); |
|
345 } |
|
346 $time2 = time(); |
|
347 my $time = $time2 - $time1; |
|
348 __OUT::Print ("time for loc file / mmp changes: $time\n"); |
|
349 |
|
350 } |
|
351 |
|
352 sub GenerateMakefiles |
|
353 { |
|
354 my $self = shift; |
|
355 my $time1; |
|
356 my $time2; |
|
357 $time1 = time(); |
|
358 __OUT::Print ("Generating Makefiles for EC\n"); |
|
359 $self->__GenerateECMakefile(); |
|
360 #$self->__GenerateWhatECMakefile(); |
|
361 #$self->__GenerateCheckECMakefile(); |
|
362 $time2 = time(); |
|
363 my $time = $time2 - $time1; |
|
364 __OUT::Print ("time for GenerateMakefiles: $time\n"); |
|
365 |
|
366 } |
|
367 |
|
368 sub GenerateXMLFiles |
|
369 { |
|
370 my $self = shift; |
|
371 __OUT::Print ("Generating XML for TBS\n"); |
|
372 $self->__GenerateTBSXML(); |
|
373 $self->__GenerateWhatTBSXML(); |
|
374 $self->__GenerateCheckTBSXML(); |
|
375 } |
|
376 |
|
377 sub __GenerateTBSXML |
|
378 { |
|
379 my $self = shift; |
|
380 my $xmlfile = $self->{ __bldfile }."".DEFAULT_XML_PATH; |
|
381 open (XML, ">$xmlfile") or __OUT::Die ("Cannot open '$xmlfile':$!"); |
|
382 print XML "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
|
383 print XML "<Product Name=\"$xmlfile\">\n"; |
|
384 print XML "\t<Commands>\n"; |
|
385 my $id = 1; |
|
386 my $stage = 1; |
|
387 |
|
388 print XML "\t\t<SetEnv Order = \"1\" Name = \"EPOCROOT\" Value = \"\\\"/>\n"; |
|
389 print XML "\t\t<SetEnv Order = \"2\" Name = \"PATH\" Value = \"\\epoc32\\gcc\\bin;\\epoc32\\tools;%PATH%\"/>\n"; |
|
390 |
|
391 |
|
392 # bldmake bldfiles |
|
393 foreach my $c ( @{ $self->{__configuration} } ) |
|
394 { |
|
395 #<Execute CommandLine="call bldmake bldfiles -k" Component="\s60\icons" Cwd="\s60\icons\group" ID="2" Stage="1" /> |
|
396 print XML " <Execute CommandLine=\"call bldmake bldfiles -k\" Component=\"".$c->GetPath()."\" Cwd=\"".$c->GetPath()."\\".$c->GetGroup()."\" ID=\"".$id++."\" Stage=\"$stage\" />\n"; |
|
397 } |
|
398 $stage++; |
|
399 |
|
400 # abld makefile |
|
401 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
402 { |
|
403 foreach my $c ( @{ $self->{__configuration} } ) |
|
404 { |
|
405 foreach my $mmp ( @{$c->GetMMPs()} ) |
|
406 { |
|
407 print XML " <Execute CommandLine=\"call abld makefile $p ".$mmp." -k\" Component=\"".$c->GetPath()."\" Cwd=\"".$c->GetPath()."\\".$c->GetGroup()."\" ID=\"".$id++."\" Stage=\"$stage\" />\n"; |
|
408 } |
|
409 } |
|
410 # Next platform |
|
411 $stage++; |
|
412 } |
|
413 |
|
414 # abld resource |
|
415 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
416 { |
|
417 foreach my $c ( @{ $self->{__configuration} } ) |
|
418 { |
|
419 foreach my $mmp ( @{ $c->GetMMPs() } ) |
|
420 { |
|
421 if ( $c->GetMMPType($mmp) eq 'mmp') |
|
422 { |
|
423 print XML " <Execute CommandLine=\"call abld resource $p ".$mmp." -k\" Component=\"".$c->GetPath()."\" Cwd=\"".$c->GetPath()."\\".$c->GetGroup()."\" ID=\"".$id++."\" Stage=\"$stage\" />\n"; |
|
424 } |
|
425 } |
|
426 } |
|
427 # Next platform |
|
428 $stage++; |
|
429 } |
|
430 |
|
431 # |
|
432 # Mk are treated by languages |
|
433 # |
|
434 foreach my $lang ( @{ $self-> { __languagelist } } ) |
|
435 { |
|
436 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
437 { |
|
438 foreach my $c ( @{ $self->{__configuration} } ) |
|
439 { |
|
440 foreach my $mmp ( @{ $c->GetMMPs() } ) |
|
441 { |
|
442 if ( $c->GetMMPType($mmp) eq 'mk') |
|
443 { |
|
444 print XML " <Execute CommandLine=\"set LANGUAGE=$lang && call abld resource $p ".$mmp." -k\" Component=\"".$c->GetPath()."\" Cwd=\"".$c->GetPath()."\\".$c->GetGroup()."\" ID=\"".$id++."\" Stage=\"$stage\" />\n"; |
|
445 } |
|
446 } |
|
447 } |
|
448 # Next platform... |
|
449 $stage++; |
|
450 } |
|
451 } |
|
452 |
|
453 |
|
454 |
|
455 print XML " </Commands>\n"; |
|
456 print XML "</Product>\n"; |
|
457 close(XML); |
|
458 } |
|
459 |
|
460 sub __GenerateWhatTBSXML |
|
461 { |
|
462 my $self = shift; |
|
463 my $xmlfile = $self->{ __bldfile }."".DEFAULT_WHATXML_PATH; |
|
464 open (XML, ">$xmlfile") or __OUT::Die ("Cannot open '$xmlfile':$!"); |
|
465 print XML "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
|
466 print XML "<Product Name=\"$xmlfile\">\n"; |
|
467 print XML "\t<Commands>\n"; |
|
468 my $id = 1; |
|
469 my $stage = 1; |
|
470 |
|
471 print XML "\t\t<SetEnv Order = \"1\" Name = \"EPOCROOT\" Value = \"\\\"/>\n"; |
|
472 print XML "\t\t<SetEnv Order = \"2\" Name = \"PATH\" Value = \"\\epoc32\\gcc\\bin;\\epoc32\\tools;%PATH%\"/>\n"; |
|
473 |
|
474 # abld resource |
|
475 foreach my $c ( @{ $self->{__configuration} } ) |
|
476 { |
|
477 foreach my $mmp ( @{$c->GetMMPs()} ) |
|
478 { |
|
479 if ( $c->GetMMPType($mmp) eq 'mk') |
|
480 { |
|
481 foreach my $lang ( @{ $self-> { __languagelist } } ) |
|
482 { |
|
483 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
484 { |
|
485 print XML " <Execute CommandLine=\"set LANGUAGE=$lang && call abld build $p ".$mmp." -w\" Component=\"".$c->GetPath()."\" Cwd=\"".$c->GetPath()."\\".$c->GetGroup()."\" ID=\"".$id++."\" Stage=\"$stage\" />\n"; |
|
486 } |
|
487 } |
|
488 } |
|
489 else |
|
490 { |
|
491 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
492 { |
|
493 print XML " <Execute CommandLine=\"call abld build $p ".$mmp." -w\" Component=\"".$c->GetPath()."\" Cwd=\"".$c->GetPath()."\\".$c->GetGroup()."\" ID=\"".$id++."\" Stage=\"$stage\" />\n"; |
|
494 } |
|
495 } |
|
496 } |
|
497 } |
|
498 $stage++; |
|
499 print XML " </Commands>\n"; |
|
500 print XML "</Product>\n"; |
|
501 close(XML); |
|
502 } |
|
503 |
|
504 sub __GenerateCheckTBSXML |
|
505 { |
|
506 my $self = shift; |
|
507 my $xmlfile = $self->{ __bldfile }."".DEFAULT_CHECKXML_PATH; |
|
508 open (XML, ">$xmlfile") or __OUT::Die ("Cannot open '$xmlfile':$!"); |
|
509 print XML "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
|
510 print XML "<Product Name=\"$xmlfile\">\n"; |
|
511 print XML "\t<Commands>\n"; |
|
512 my $id = 1; |
|
513 my $stage = 1; |
|
514 |
|
515 print XML "\t\t<SetEnv Order = \"1\" Name = \"EPOCROOT\" Value = \"\\\"/>\n"; |
|
516 print XML "\t\t<SetEnv Order = \"2\" Name = \"PATH\" Value = \"\\epoc32\\gcc\\bin;\\epoc32\\tools;%PATH%\"/>\n"; |
|
517 |
|
518 # abld resource |
|
519 foreach my $c ( @{ $self->{__configuration} } ) |
|
520 { |
|
521 foreach my $mmp ( @{$c->GetMMPs()} ) |
|
522 { |
|
523 if ( $c->GetMMPType($mmp) eq 'mk') |
|
524 { |
|
525 foreach my $lang ( @{ $self-> { __languagelist } } ) |
|
526 { |
|
527 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
528 { |
|
529 print XML " <Execute CommandLine=\"set LANGUAGE=$lang && call abld build $p ".$mmp." -c\" Component=\"".$c->GetPath()."\" Cwd=\"".$c->GetPath()."\\".$c->GetGroup()."\" ID=\"".$id++."\" Stage=\"$stage\" />\n"; |
|
530 } |
|
531 } |
|
532 } |
|
533 else |
|
534 { |
|
535 foreach my $p ( keys ( %{ $self->{ __platform } } ) ) |
|
536 { |
|
537 print XML " <Execute CommandLine=\"call abld build $p ".$mmp." -c\" Component=\"".$c->GetPath()."\" Cwd=\"".$c->GetPath()."\\".$c->GetGroup()."\" ID=\"".$id++."\" Stage=\"$stage\" />\n"; |
|
538 } |
|
539 } |
|
540 } |
|
541 } |
|
542 $stage++; |
|
543 print XML " </Commands>\n"; |
|
544 print XML "</Product>\n"; |
|
545 close(XML); |
|
546 } |
|
547 |
|
548 |
|
549 |
|
550 sub HandleEpoc32LocFiles |
|
551 { |
|
552 my ($langlist, $zip) = (shift, shift); |
|
553 |
|
554 open (LST,">>\\cleanupfiles.lst"); |
|
555 foreach my $locfile (@{GetEpoc32LocFiles()}) |
|
556 { |
|
557 $zip->AddFile($locfile); |
|
558 print LST $locfile."\n"; |
|
559 __OUT::Print ("=== updating '$locfile' ===\n"); |
|
560 my ($path, $group, @mmps, @locfiles, @tlocfiles); |
|
561 push(@locfiles, $locfile); |
|
562 my $lid = new __LocInfoData($path, $group, \@mmps, \@locfiles, \@tlocfiles); |
|
563 $lid = __LocInfoData::CreateFromLine(",,\"\",\"$locfile\""); |
|
564 $lid->GenerateStubLocFile($locfile, $langlist); |
|
565 } |
|
566 close(LST); |
|
567 } |
|
568 |
|
569 sub GetEpoc32LocFiles |
|
570 { |
|
571 my @array; |
|
572 my (@locs) = `dir /s/b \\epoc32\\include\\*.loc`; |
|
573 foreach my $loc (@locs) |
|
574 { |
|
575 if ($loc =~ /^[A-Z]:(.*)\\(.*?)$/i) |
|
576 { |
|
577 print "Found $loc ($1, $2).\n"; |
|
578 push(@array, $1."\\".$2); |
|
579 } |
|
580 } |
|
581 return \@array; |
|
582 } |
|
583 |
|
584 sub __GenerateECMakefile |
|
585 { |
|
586 my $self = shift; |
|
587 my $makefile =$self->{ __bldfile }."".DEFAULT_MAKE_PATH; |
|
588 open (XML, ">$makefile") or __OUT::Die ("Cannot open '$makefile':$!"); |
|
589 print XML "".$self->{ __bldfile }.":bldmake_bldfiles_all \\\n"; |
|
590 print XML "\t abld_makefile_all \\\n"; |
|
591 print XML "\t abld_resource_all \n\n"; |
|
592 |
|
593 print XML "".$self->{ __bldfile }."_what: what_all\n\n"; |
|
594 print XML "".$self->{ __bldfile }."_check: check_all\n\n"; |
|
595 |
|
596 #print XML "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
|
597 #print XML "<Product Name=\"$xmlfile\">\n"; |
|
598 #print XML "\t<Commands>\n"; |
|
599 my $id = 1; |
|
600 my $stage = 1; |
|
601 my %componentHash; |
|
602 my $component=""; |
|
603 #print XML "\t\t<SetEnv Order = \"1\" Name = \"EPOCROOT\" Value = \"\\\"/>\n"; |
|
604 #print XML "\t\t<SetEnv Order = \"2\" Name = \"PATH\" Value = \"\\epoc32\\gcc\\bin;\\epoc32\\tools;%PATH%\"/>\n"; |
|
605 |
|
606 |
|
607 # bldmake bldfiles |
|
608 #my $concatStages = "bldmake_bldfiles_all:"; |
|
609 #my $componontID = 1; |
|
610 |
|
611 my $makeUnitList = "bldmake-UNITS:="; |
|
612 |
|
613 |
|
614 foreach my $c ( @{ $self->{__configuration} } ) |
|
615 { |
|
616 $component = $c->GetPath()."\\".$c->GetGroup(); |
|
617 if ( ! exists($componentHash{$component})){ |
|
618 $componentHash{$component} = $component; |
|
619 #$concatStages .= "\t\\\n"; |
|
620 #<Execute CommandLine="call bldmake bldfiles -k" Component="\s60\icons" Cwd="\s60\icons\group" ID="2" Stage="1" /> |
|
621 #print XML "bldmake_bldfiles-$componontID:\n"; |
|
622 $makeUnitList .="\t\\\n\t".$c->GetPath()."\\".$c->GetGroup(); |
|
623 #print XML " <Execute CommandLine=\"call bldmake bldfiles -k\" Component=\"".$c->GetPath()."\" Cwd=\"".$c->GetPath()."\\".$c->GetGroup()."\" ID=\"".$id++."\" Stage=\"$stage\" />\n"; |
|
624 #$concatStages .= "\t bldmake_bldfiles-$componontID"; |
|
625 #$componontID++; |
|
626 } |
|
627 } |
|
628 $makeUnitList .="\n\n"; |
|
629 print XML $makeUnitList; |
|
630 print XML "bldmake_bldfiles_all: \$(addsuffix -bldmake_bldfiles-k,\$(bldmake-UNITS))\n\n"; |
|
631 print XML "%-bldmake_bldfiles-k:\n"; |
|
632 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
633 print XML "\t\@echo === bldmake \$*\n"; |
|
634 print XML "\tcd \$* && bldmake bldfiles -k\n"; |
|
635 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
636 |
|
637 #$stage++; |
|
638 print XML "\n\n"; |
|
639 #print XML "".$concatStages."\n\n"; |
|
640 |
|
641 #$concatStages = "abld_makefile_all: "; |
|
642 #$componontID = 1; |
|
643 |
|
644 $makeUnitList = "abld-UNITS:= \$(abld-mmp-UNITS) \$(abld-mk-UNITS)"; |
|
645 |
|
646 my $abldMMPUnitList = "abld-mmp-UNITS:="; |
|
647 my $abldMKUnitList = "abld-mk-UNITS:="; |
|
648 my $isAbldUnitAdded = 0; |
|
649 # abld makefile |
|
650 my $mmptype; |
|
651 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
652 { |
|
653 foreach my $c ( @{ $self->{__configuration} } ) |
|
654 { |
|
655 foreach my $mmp ( @{$c->GetMMPs()} ) |
|
656 { |
|
657 #$concatStages .= "\t\\\n"; |
|
658 #print XML "abld_makefile-$componontID: bldmake_bldfiles_all \n"; |
|
659 #print XML "\t\@echo ===-------------------------------------------------\n"; |
|
660 #print XML "\t\@echo === abld_makefile\n"; |
|
661 #print XML "\t\@echo === ".$c->GetPath()."\\".$c->GetGroup()."\n"; |
|
662 #print XML "\t\@echo ===-------------------------------------------------\n"; |
|
663 #print XML "\t cd ".$c->GetPath()."\\".$c->GetGroup()." && abld makefile $p ".$mmp." -k \n\n"; |
|
664 $mmptype = $c->GetMMPType($mmp); |
|
665 print "mmptype:...$mmptype\n"; |
|
666 print "getgroup:...".$c->GetGroup()."\n"; |
|
667 print "getpath:...".$c->GetPath()."\n"; |
|
668 print "mmp:...".$mmp."\n"; |
|
669 print "length of getgroup string:....".(length($c->GetGroup()))."\n"; |
|
670 my $strlength = length($c->GetGroup()); |
|
671 if($isAbldUnitAdded == 0){ |
|
672 if($mmptype eq 'mmp'){ |
|
673 if($strlength != 0){ |
|
674 $abldMMPUnitList .="\t\\\n\t".$c->GetPath()."\\".$c->GetGroup()."\\".$mmp; |
|
675 }else { |
|
676 $abldMMPUnitList .="\t\\\n\t".$c->GetPath()."\\".$mmp; |
|
677 } |
|
678 }else { |
|
679 if($strlength != 0){ |
|
680 $abldMKUnitList .="\t\\\n\t".$c->GetPath()."\\".$c->GetGroup()."\\".$mmp; |
|
681 }else { |
|
682 $abldMKUnitList .="\t\\\n\t".$c->GetPath()."\\".$mmp; |
|
683 } |
|
684 } |
|
685 } |
|
686 #print XML " <Execute CommandLine=\"call abld makefile $p ".$mmp." -k\" Component=\"".$c->GetPath()."\" Cwd=\"".$c->GetPath()."\\".$c->GetGroup()."\" ID=\"".$id++."\" Stage=\"$stage\" />\n"; |
|
687 #$concatStages .= "\t abld_makefile-$componontID"; |
|
688 #$componontID++; |
|
689 } |
|
690 } |
|
691 $isAbldUnitAdded = 1; |
|
692 # Next platform |
|
693 $stage++; |
|
694 } |
|
695 $makeUnitList .="\n\n"; |
|
696 $abldMMPUnitList .="\n\n"; |
|
697 $abldMKUnitList .="\n\n"; |
|
698 print XML $abldMMPUnitList; |
|
699 print XML $abldMKUnitList; |
|
700 print XML $makeUnitList; |
|
701 |
|
702 my $abldDepRule = "abld_makefile_all: "; |
|
703 |
|
704 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
705 { |
|
706 print XML "abld_makefile_$p: \$(addsuffix -abld_makefile_$p-k,\$(abld-UNITS))\n\n"; |
|
707 print XML "%-abld_makefile_$p-k:bldmake_bldfiles_all\n"; |
|
708 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
709 print XML "\t\@echo === abld makefile \$*\n"; |
|
710 print XML "\tcd \$(*D) && abld makefile $p \$(*F) -k\n"; |
|
711 print XML "\t\@echo ===-------------------------------------------------\n\n"; |
|
712 $abldDepRule.="\t\\\n\tabld_makefile_$p"; |
|
713 } |
|
714 $abldDepRule.="\n\n"; |
|
715 print XML $abldDepRule; |
|
716 |
|
717 print XML "\n\n"; |
|
718 |
|
719 #print XML "".$concatStages."\n\n"; |
|
720 #$concatStages = "abld_resource_all:"; |
|
721 #$componontID = 1; |
|
722 |
|
723 $abldDepRule = "abld_resource_mmp: "; |
|
724 # abld resource |
|
725 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
726 { |
|
727 print XML "abld_resource_mmp_$p: \$(addsuffix -abld_resource_mmp_$p-k,\$(abld-mmp-UNITS))\n\n"; |
|
728 print XML "%-abld_resource_mmp_$p-k:abld_makefile_all\n"; |
|
729 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
730 print XML "\t\@echo === abld resource $p \$*\n"; |
|
731 print XML "\tcd \$(*D) && abld resource $p \$(*F) -k\n"; |
|
732 print XML "\t\@echo ===-------------------------------------------------\n\n"; |
|
733 $abldDepRule.="\t\\\n\tabld_resource_mmp_$p"; |
|
734 } |
|
735 $abldDepRule.="\n\n"; |
|
736 print XML $abldDepRule; |
|
737 |
|
738 print XML "\n\n"; |
|
739 |
|
740 $abldDepRule = "abld_resource_mk: "; |
|
741 foreach my $lang ( @{ $self-> { __languagelist } } ) |
|
742 { |
|
743 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
744 { |
|
745 print XML "abld_resource_mk_".$p."_".$lang.": \$(addsuffix -abld_resource_mk_".$p."_".$lang."-k,\$(abld-mk-UNITS))\n\n"; |
|
746 print XML "%-abld_resource_mk_".$p."_".$lang."-k:abld_resource_mmp\n"; |
|
747 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
748 print XML "\t\@echo === abld resource $p \$*\n"; |
|
749 print XML "\tSET LANGUAGE=".$lang." && cd \$(*D) && abld resource $p \$(*F) -k\n"; |
|
750 print XML "\t\@echo ===-------------------------------------------------\n\n"; |
|
751 $abldDepRule.="\t\\\n\tabld_resource_mk_".$p."_".$lang; |
|
752 } |
|
753 } |
|
754 $abldDepRule.="\n\n"; |
|
755 print XML $abldDepRule; |
|
756 print XML "\n\n"; |
|
757 |
|
758 print XML "abld_resource_all: abld_resource_mmp abld_resource_mk\n\n"; |
|
759 |
|
760 $abldDepRule = "abld_what_mmp: "; |
|
761 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
762 { |
|
763 print XML "abld_what_mmp_$p: \$(addsuffix -abld_what_mmp_$p,\$(abld-mmp-UNITS))\n\n"; |
|
764 print XML "%-abld_what_mmp_$p:\n"; |
|
765 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
766 print XML "\t\@echo === abld what $p \$*\n"; |
|
767 print XML "\tcd \$(*D) && abld build $p \$(*F) -w\n"; |
|
768 print XML "\t\@echo ===-------------------------------------------------\n\n"; |
|
769 $abldDepRule.="\t\\\n\tabld_what_mmp_$p"; |
|
770 } |
|
771 $abldDepRule.="\n\n"; |
|
772 print XML $abldDepRule; |
|
773 |
|
774 $abldDepRule = "abld_what_mk: "; |
|
775 foreach my $lang ( @{ $self-> { __languagelist } } ) |
|
776 { |
|
777 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
778 { |
|
779 print XML "abld_what_mk_".$p."_".$lang.": \$(addsuffix -abld_what_mk_".$p."_".$lang.",\$(abld-mk-UNITS))\n\n"; |
|
780 print XML "%-abld_what_mk_".$p."_".$lang." : abld_what_mmp\n"; |
|
781 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
782 print XML "\t\@echo === abld what $p \$*\n"; |
|
783 print XML "\tSET LANGUAGE=".$lang." && cd \$(*D) && abld build $p \$(*F) -w\n"; |
|
784 print XML "\t\@echo ===-------------------------------------------------\n\n"; |
|
785 $abldDepRule.="\t\\\n\tabld_what_mk_".$p."_".$lang; |
|
786 } |
|
787 } |
|
788 $abldDepRule.="\n\n"; |
|
789 print XML $abldDepRule; |
|
790 |
|
791 print XML "what_all: abld_what_mmp abld_what_mk\n\n"; |
|
792 |
|
793 $abldDepRule = "abld_check_mmp: "; |
|
794 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
795 { |
|
796 print XML "abld_check_mmp_$p: \$(addsuffix -abld_check_mmp_$p,\$(abld-mmp-UNITS))\n\n"; |
|
797 print XML "%-abld_check_mmp_$p:\n"; |
|
798 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
799 print XML "\t\@echo === abld check $p \$*\n"; |
|
800 print XML "\tcd \$(*D) && abld build $p \$(*F) -c\n"; |
|
801 print XML "\t\@echo ===-------------------------------------------------\n\n"; |
|
802 $abldDepRule.="\t\\\n\tabld_check_mmp_$p"; |
|
803 } |
|
804 $abldDepRule.="\n\n"; |
|
805 print XML $abldDepRule; |
|
806 |
|
807 $abldDepRule = "abld_check_mk: "; |
|
808 foreach my $lang ( @{ $self-> { __languagelist } } ) |
|
809 { |
|
810 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
811 { |
|
812 print XML "abld_check_mk_".$p."_".$lang.": \$(addsuffix -abld_check_mk_".$p."_".$lang.",\$(abld-mk-UNITS))\n\n"; |
|
813 print XML "%-abld_check_mk_".$p."_".$lang." : abld_check_mmp\n"; |
|
814 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
815 print XML "\t\@echo === abld check $p \$*\n"; |
|
816 print XML "\tSET LANGUAGE=".$lang." && cd \$(*D) && abld build $p \$(*F) -c\n"; |
|
817 print XML "\t\@echo ===-------------------------------------------------\n\n"; |
|
818 $abldDepRule.="\t\\\n\tabld_check_mk_".$p."_".$lang; |
|
819 } |
|
820 } |
|
821 $abldDepRule.="\n\n"; |
|
822 print XML $abldDepRule; |
|
823 |
|
824 print XML "check_all: abld_check_mmp abld_check_mk\n\n"; |
|
825 close(XML); |
|
826 } |
|
827 |
|
828 sub __GenerateWhatECMakefile |
|
829 { |
|
830 my $self = shift; |
|
831 my $makefile =$self->{ __bldfile }."_".DEFAULT_WHATMAKE_PATH; |
|
832 open (XML, ">$makefile") or __OUT::Die ("Cannot open '$makefile':$!"); |
|
833 #print XML "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
|
834 #print XML "<Product Name=\"$xmlfile\">\n"; |
|
835 #print XML "\t<Commands>\n"; |
|
836 my $id = 1; |
|
837 my $stage = 1; |
|
838 |
|
839 print XML "all: abld_resource_all \\\n"; |
|
840 print XML "\t abld_mk_all \n\n"; |
|
841 |
|
842 |
|
843 my $concatStages = "abld_resource_all:"; |
|
844 my $componontID = 1; |
|
845 |
|
846 |
|
847 #print XML "\t\t<SetEnv Order = \"1\" Name = \"EPOCROOT\" Value = \"\\\"/>\n"; |
|
848 #print XML "\t\t<SetEnv Order = \"2\" Name = \"PATH\" Value = \"\\epoc32\\gcc\\bin;\\epoc32\\tools;%PATH%\"/>\n"; |
|
849 |
|
850 # abld resource |
|
851 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
852 { |
|
853 foreach my $c ( @{ $self->{__configuration} } ) |
|
854 { |
|
855 foreach my $mmp ( @{ $c->GetMMPs() } ) |
|
856 { |
|
857 if ( $c->GetMMPType($mmp) eq 'mmp') |
|
858 { |
|
859 $concatStages .= "\t\\\n"; |
|
860 print XML "abld_resource-$componontID: \n"; |
|
861 print XML "\t cd ".$c->GetPath()."\\".$c->GetGroup()." && abld build $p ".$mmp." -w \n\n"; |
|
862 $concatStages .= "\t abld_resource-$componontID"; |
|
863 $componontID++; |
|
864 } |
|
865 } |
|
866 } |
|
867 # Next platform |
|
868 $stage++; |
|
869 } |
|
870 print XML "\n\n"; |
|
871 print XML "".$concatStages."\n\n"; |
|
872 |
|
873 |
|
874 $concatStages = "abld_mk_all: "; |
|
875 $componontID = 1; |
|
876 |
|
877 # |
|
878 # Mk are treated by languages |
|
879 # |
|
880 foreach my $lang ( @{ $self-> { __languagelist } } ) |
|
881 { |
|
882 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
883 { |
|
884 foreach my $c ( @{ $self->{__configuration} } ) |
|
885 { |
|
886 foreach my $mmp ( @{ $c->GetMMPs() } ) |
|
887 { |
|
888 if ( $c->GetMMPType($mmp) eq 'mk') |
|
889 { |
|
890 $concatStages .= "\t\\\n"; |
|
891 if($componontID eq 1){ |
|
892 print XML "abld_mk-$componontID: abld_resource_all \n"; |
|
893 }else { |
|
894 print XML "abld_mk-$componontID: abld_mk-".($componontID-1)." \n"; |
|
895 } |
|
896 print XML "\t SET LANGUAGE=".$lang." && cd ".$c->GetPath()."\\".$c->GetGroup()." && abld build $p ".$mmp." -w\n\n"; |
|
897 $concatStages .= "\t abld_mk-$componontID"; |
|
898 $componontID++; |
|
899 } |
|
900 } |
|
901 } |
|
902 # Next platform... |
|
903 $stage++; |
|
904 } |
|
905 } |
|
906 print XML "\n"; |
|
907 print XML "".$concatStages."\n\n"; |
|
908 |
|
909 #print XML " </Commands>\n"; |
|
910 #print XML "</Product>\n"; |
|
911 close(XML); |
|
912 } |
|
913 |
|
914 sub __GenerateCheckECMakefile |
|
915 { |
|
916 my $self = shift; |
|
917 my $makefile =$self->{ __bldfile }."_".DEFAULT_CHECKMAKE_PATH; |
|
918 open (XML, ">$makefile") or __OUT::Die ("Cannot open '$makefile':$!"); |
|
919 #print XML "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
|
920 #print XML "<Product Name=\"$xmlfile\">\n"; |
|
921 #print XML "\t<Commands>\n"; |
|
922 my $id = 1; |
|
923 my $stage = 1; |
|
924 |
|
925 print XML "all: abld_resource_all \\\n"; |
|
926 print XML "\t abld_mk_all \n\n"; |
|
927 |
|
928 |
|
929 my $concatStages = "abld_resource_all:"; |
|
930 my $componontID = 1; |
|
931 |
|
932 |
|
933 #print XML "\t\t<SetEnv Order = \"1\" Name = \"EPOCROOT\" Value = \"\\\"/>\n"; |
|
934 #print XML "\t\t<SetEnv Order = \"2\" Name = \"PATH\" Value = \"\\epoc32\\gcc\\bin;\\epoc32\\tools;%PATH%\"/>\n"; |
|
935 |
|
936 # abld resource |
|
937 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
938 { |
|
939 foreach my $c ( @{ $self->{__configuration} } ) |
|
940 { |
|
941 foreach my $mmp ( @{ $c->GetMMPs() } ) |
|
942 { |
|
943 if ( $c->GetMMPType($mmp) eq 'mmp') |
|
944 { |
|
945 $concatStages .= "\t\\\n"; |
|
946 print XML "abld_resource-$componontID: \n"; |
|
947 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
948 print XML "\t\@echo === abld_resource-$componontID\n"; |
|
949 print XML "\t\@echo === ".$c->GetPath()."\\".$c->GetGroup()."\n"; |
|
950 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
951 print XML "\t cd ".$c->GetPath()."\\".$c->GetGroup()." && abld build $p ".$mmp." -c \n\n"; |
|
952 $concatStages .= "\t abld_resource-$componontID"; |
|
953 $componontID++; |
|
954 } |
|
955 } |
|
956 } |
|
957 # Next platform |
|
958 $stage++; |
|
959 } |
|
960 print XML "\n\n"; |
|
961 print XML "".$concatStages."\n\n"; |
|
962 |
|
963 |
|
964 $concatStages = "abld_mk_all: "; |
|
965 $componontID = 1; |
|
966 |
|
967 # |
|
968 # Mk are treated by languages |
|
969 # |
|
970 foreach my $lang ( @{ $self-> { __languagelist } } ) |
|
971 { |
|
972 foreach my $p ( keys (%{ $self->{ __platform } }) ) |
|
973 { |
|
974 foreach my $c ( @{ $self->{__configuration} } ) |
|
975 { |
|
976 foreach my $mmp ( @{ $c->GetMMPs() } ) |
|
977 { |
|
978 if ( $c->GetMMPType($mmp) eq 'mk') |
|
979 { |
|
980 $concatStages .= "\t\\\n"; |
|
981 if($componontID eq 1){ |
|
982 print XML "abld_mk-$componontID: abld_resource_all \n"; |
|
983 }else { |
|
984 print XML "abld_mk-$componontID: abld_mk-".($componontID-1)." \n"; |
|
985 } |
|
986 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
987 print XML "\t\@echo === abld_mk-$componontID\n"; |
|
988 print XML "\t\@echo === ".$c->GetPath()."\\".$c->GetGroup()."\n"; |
|
989 print XML "\t\@echo ===-------------------------------------------------\n"; |
|
990 print XML "\t SET LANGUAGE=".$lang." && cd ".$c->GetPath()."\\".$c->GetGroup()." && abld build $p ".$mmp." -c\n\n"; |
|
991 $concatStages .= "\t abld_mk-$componontID"; |
|
992 $componontID++; |
|
993 } |
|
994 } |
|
995 } |
|
996 # Next platform... |
|
997 $stage++; |
|
998 } |
|
999 } |
|
1000 print XML "\n"; |
|
1001 print XML "".$concatStages."\n\n"; |
|
1002 close(XML); |
|
1003 } |
|
1004 |
|
1005 sub DeleteOriginalLocFiles{ |
|
1006 my $line; |
|
1007 if( -e "\\cleanupfiles.lst"){ |
|
1008 open (LST,"<\\cleanupfiles.lst"); |
|
1009 while ($line = <LST>) |
|
1010 { |
|
1011 chomp($line); |
|
1012 if( -e "$line.isis.orig"){ |
|
1013 unlink ( "$line.isis.orig" ) or __OUT::Warning(" Failed to delete stubbed loc file $line.isis.orig --- \n"); |
|
1014 }else { |
|
1015 if( -e "$line.orig"){ |
|
1016 unlink ( "$line.orig" ) or __OUT::Warning(" Failed to delete stubbed mk file $line.orig --- \n"); |
|
1017 } |
|
1018 } |
|
1019 if( -e "$line.isis.trace"){ |
|
1020 unlink ( "$line.isis.trace" ) or __OUT::Warning(" Failed to delete stubbed loc file $line.isis.trace --- \n"); |
|
1021 } |
|
1022 |
|
1023 } |
|
1024 close(LST); |
|
1025 unlink( "\\cleanupfiles.lst" ) or __OUT::Warning(" Failed to delete cleanupfiles.lst \n"); |
|
1026 } |
|
1027 } |
|
1028 |
|
1029 sub SaveGeneratedResources |
|
1030 { |
|
1031 my $tpath = shift; |
|
1032 my $bldfile = shift; |
|
1033 my $time1; |
|
1034 my $time2; |
|
1035 |
|
1036 $time1 = time(); |
|
1037 __SaveGeneratedResource($tpath, $bldfile); |
|
1038 $time2 = time(); |
|
1039 __OUT::Print ("Total Time SaveGeneratedResources:" .($time2-$time1)."\n"); |
|
1040 } |
|
1041 sub __SaveGeneratedResource |
|
1042 { |
|
1043 my $tpath = shift; |
|
1044 my $bldfile = shift; |
|
1045 my %hlist; |
|
1046 |
|
1047 # |
|
1048 # Saving localised resources |
|
1049 # |
|
1050 __OUT::Print ("<b>Zipping generated resources</b>\n"); |
|
1051 __OUT::Print ("<b>bldfile ---- $bldfile"."_what_compile.log"."</b>\n"); |
|
1052 open (LOG, "$bldfile"."_what_compile.log") or __OUT::Die ("Cannot open"."$bldfile"."_what_compile.log:$!"); |
|
1053 foreach my $line ( <LOG> ) |
|
1054 { |
|
1055 chomp ($line); |
|
1056 if ( $line =~ /^\\/ and $line =~ /\.r(\d+)$/i) |
|
1057 { |
|
1058 push @{ $hlist{$1} }, $line; |
|
1059 } |
|
1060 } |
|
1061 close (LOG); |
|
1062 |
|
1063 #my $tpath = $self->{__tpath}; |
|
1064 mkpath ( "$tpath\\LocPackages" ) unless ( -e "$tpath\\LocPackages" ); |
|
1065 foreach my $lid ( sort keys %hlist ) |
|
1066 { |
|
1067 __OUT::Print ("<b>Zipping resources of language $lid</b>\n"); |
|
1068 |
|
1069 unlink ("\\resourcelist_${lid}.lst") if ( -e "\\resourcelist_${lid}.lst" ); |
|
1070 open (LST,">\\resourcelist_${lid}.lst"); |
|
1071 foreach ( sort @{ $hlist{$lid} } ) |
|
1072 { |
|
1073 print LST "$_\n"; |
|
1074 } |
|
1075 close (LST); |
|
1076 my $zip = new ZipUp( "$tpath\\LocPackages\\package_${lid}.zip" ); |
|
1077 $zip->AddFilesFromList ( "\\resourcelist_${lid}.lst" ); |
|
1078 } |
|
1079 } |
|
1080 |
|
1081 sub Cleanup |
|
1082 { |
|
1083 my $self = shift; |
|
1084 my @ll = ("sc"); |
|
1085 foreach my $c ( @{ $self->{__configuration} } ) |
|
1086 { |
|
1087 #$c->RestoreOrigLocFiles(); |
|
1088 #$c->ChangeMMPsAndMKs( \@ll ); |
|
1089 } |
|
1090 } |
|
1091 1; |
|
1092 |
|
1093 |
|
1094 ## @class LocaliseTBS |
|
1095 # This is an internal class. It is a modelisation of the locinfo data line. |
|
1096 # |
|
1097 # |
|
1098 package LocaliseTBS; |
|
1099 use strict; |
|
1100 use File::Path; |
|
1101 use ISIS::GenBuildTools; |
|
1102 use IPC::Open3; |
|
1103 use File::Spec; |
|
1104 use File::Basename; |
|
1105 |
|
1106 use constant DEFAULT_XML_PATH => ".xml"; |
|
1107 use constant DEFAULT_WHATXML_PATH => "_what.xml"; |
|
1108 use constant DEFAULT_CHECKXML_PATH => "_check.xml"; |
|
1109 use constant DEFAULT_TPATH => "\\zips"; |
|
1110 |
|
1111 sub Localise |
|
1112 { |
|
1113 my $time1 = time(); |
|
1114 my $bldfile = shift; |
|
1115 __OUT::Print ("Localisation starting - ".localtime()."\n"); |
|
1116 __OUT::Print ("Localisation $bldfile -\n"); |
|
1117 GenBuildTools::BuildTBS( "$bldfile".DEFAULT_XML_PATH ); |
|
1118 GenBuildTools::BuildTBS( "$bldfile".DEFAULT_WHATXML_PATH ); |
|
1119 GenBuildTools::BuildTBS( "$bldfile".DEFAULT_CHECKXML_PATH ); |
|
1120 __OUT::Print ("Localisation ending - ".localtime()."\n"); |
|
1121 my $time2 = time(); |
|
1122 __OUT::Print ("Total Time:" .($time2-$time1)."\n"); |
|
1123 } |
|
1124 |
|
1125 1; |
|
1126 |
|
1127 |
|
1128 |
|
1129 ## @class __LocInfoData |
|
1130 # This is an internal class. It is a modelisation of the locinfo data line. |
|
1131 # |
|
1132 # |
|
1133 package __LocInfoData; |
|
1134 use strict; |
|
1135 use File::Copy; |
|
1136 |
|
1137 sub CreateFromLine |
|
1138 { |
|
1139 my ( $line ) = shift; |
|
1140 |
|
1141 # managing comments and empty lines |
|
1142 return undef if ( $line =~ /^\s*((#|\/\/).*)*$/ ); |
|
1143 my @atoms = split( /,/, $line ); |
|
1144 |
|
1145 if (scalar(@atoms)==3 or scalar(@atoms)==4 or scalar(@atoms)==5) |
|
1146 { |
|
1147 my @locfiles; |
|
1148 my @mmps; |
|
1149 #path,path_to_bld_inf,"list of mmp",["path/to.loc"[,"/path/to/delivery"]] |
|
1150 if ($atoms[2] =~ s/\"([^\"]*)\"/$1/) |
|
1151 { |
|
1152 @mmps = split(/\s+/, $atoms[2]); |
|
1153 } |
|
1154 else |
|
1155 { |
|
1156 __OUT::Die("Malformed3 input file at line: '$line'\n"); |
|
1157 } |
|
1158 if (scalar(@atoms)>3) |
|
1159 { |
|
1160 if ($atoms[3] =~ s/\"([^\"]*)\"/$1/) |
|
1161 { |
|
1162 @locfiles = split(/\s+/, $atoms[3]) |
|
1163 } |
|
1164 else |
|
1165 { |
|
1166 __OUT::Die("Malformed4 input file at line: '$line'\n"); |
|
1167 } |
|
1168 |
|
1169 } |
|
1170 |
|
1171 if (scalar(@atoms)==5) |
|
1172 { |
|
1173 if ($atoms[4] =~ s/\"([^\"]*)\"/$1/) |
|
1174 { |
|
1175 my @tlocfiles = split(/\s+/, $atoms[4]); |
|
1176 push @tlocfiles, &Localiser::DefaultLocPath(); |
|
1177 return new __LocInfoData($atoms[0], $atoms[1], \@mmps, \@locfiles, \@tlocfiles); |
|
1178 } |
|
1179 else |
|
1180 { |
|
1181 __OUT::Die("Malformed5 input file at line: '$line'\n"); |
|
1182 } |
|
1183 } |
|
1184 elsif (scalar(@atoms)==4) |
|
1185 { |
|
1186 my @tlocfiles; |
|
1187 push @tlocfiles, &Localiser::DefaultLocPath(); |
|
1188 return new __LocInfoData($atoms[0], $atoms[1], \@mmps, \@locfiles, \@tlocfiles); |
|
1189 } |
|
1190 elsif (scalar(@atoms)==3) |
|
1191 { |
|
1192 my @tlocfiles; |
|
1193 push @tlocfiles, &Localiser::DefaultLocPath(); |
|
1194 return new __LocInfoData($atoms[0], $atoms[1], \@mmps, \@locfiles, \@tlocfiles); |
|
1195 } |
|
1196 } |
|
1197 return undef; |
|
1198 } |
|
1199 |
|
1200 sub new |
|
1201 { |
|
1202 my $class = shift; |
|
1203 my ($path, $group, $mmps, $locfiles, $tlocfiles) = @_; |
|
1204 my $self = { |
|
1205 __path => $path, |
|
1206 __group => $group, |
|
1207 __mmps => $mmps, |
|
1208 __mmpstype => undef, |
|
1209 __locfiles => $locfiles, |
|
1210 __tlocfiles => $tlocfiles |
|
1211 }; |
|
1212 return bless $self, $class; |
|
1213 } |
|
1214 |
|
1215 |
|
1216 sub GetPath |
|
1217 { |
|
1218 my $self = shift; |
|
1219 return $self->{__path}; |
|
1220 } |
|
1221 |
|
1222 sub GetGroup |
|
1223 { |
|
1224 my $self = shift; |
|
1225 return $self->{__group}; |
|
1226 } |
|
1227 |
|
1228 sub GetMMPs |
|
1229 { |
|
1230 my $self = shift; |
|
1231 return $self->{__mmps}; |
|
1232 } |
|
1233 |
|
1234 sub GetMMPType |
|
1235 { |
|
1236 my ($self, $mmp) = (shift, shift); |
|
1237 return $self->{__mmpstype}->{$mmp}->{type}; |
|
1238 } |
|
1239 |
|
1240 sub GetLocFiles |
|
1241 { |
|
1242 my $self = shift; |
|
1243 return $self->{__locfiles}; |
|
1244 } |
|
1245 |
|
1246 sub GetTranslatedLocFiles |
|
1247 { |
|
1248 my $self = shift; |
|
1249 return $self->{__tlocfiles}; |
|
1250 } |
|
1251 |
|
1252 sub CheckBldInf |
|
1253 { |
|
1254 my $self = shift; |
|
1255 my $bldinf = $self->GetPath()."/".$self->GetGroup()."/bld.inf"; |
|
1256 unless ( -e $bldinf ) |
|
1257 { |
|
1258 __OUT::Error ("Cannot find bld.inf in '$bldinf' directory\n"); |
|
1259 |
|
1260 return 0; |
|
1261 } |
|
1262 return 1; |
|
1263 } |
|
1264 |
|
1265 sub CheckLocFiles |
|
1266 { |
|
1267 my $self = shift; |
|
1268 my $result = 1; |
|
1269 |
|
1270 foreach ( @{ $self->{__locfiles} } ) |
|
1271 { |
|
1272 my $loc = $self->GetPath()."/$_"; |
|
1273 |
|
1274 unless ( -e $loc ) |
|
1275 { |
|
1276 __OUT::Error ("Cannot find '$loc'\n"); |
|
1277 } |
|
1278 } |
|
1279 return $result; |
|
1280 } |
|
1281 |
|
1282 sub ZipUpLocFiles |
|
1283 { |
|
1284 my ( $self, $zip ) = (shift, shift); |
|
1285 foreach ( @{ $self->{__locfiles} } ) |
|
1286 { |
|
1287 my $loc = $self->GetPath()."/$_"; |
|
1288 $zip->AddFile( $loc ); |
|
1289 } |
|
1290 } |
|
1291 |
|
1292 |
|
1293 sub GenerateStubLocFiles |
|
1294 { |
|
1295 my ($self, $langlist) = (shift, shift); |
|
1296 |
|
1297 open (LST,">>\\cleanupfiles.lst"); |
|
1298 |
|
1299 foreach ( @{ $self->{__locfiles} } ) |
|
1300 { |
|
1301 my $loc = $self->GetPath()."/$_"; |
|
1302 |
|
1303 print LST $loc."\n"; |
|
1304 |
|
1305 $self->GenerateStubLocFile( $loc, $langlist ); |
|
1306 } |
|
1307 close (LST); |
|
1308 } |
|
1309 |
|
1310 sub RestoreOrigLocFiles |
|
1311 { |
|
1312 my ($self, $langlist) = (shift, shift); |
|
1313 foreach ( @{ $self->{__locfiles} } ) |
|
1314 { |
|
1315 |
|
1316 |
|
1317 my $loc = $self->GetPath()."/$_"; |
|
1318 |
|
1319 if ( -e "$loc.isis.orig" ) |
|
1320 { |
|
1321 unlink ( $loc ) or __OUT::Warning(" Failed to delete stubbed loc file $loc \n"); |
|
1322 copy ( "$loc.isis.orig", $loc) or __OUT::Warning(" Failed to restore loc file from $loc.isis.orig to $loc \n"); |
|
1323 unlink ( "$loc.isis.orig" ) or __OUT::Warning(" Failed to delete original backup loc file $loc \n"); |
|
1324 } |
|
1325 |
|
1326 if ( -e "$loc.isis.trace" ) |
|
1327 { |
|
1328 unlink ( "$loc.isis.trace" ) or __OUT::Warning(" Failed to delete $loc.isis.trace \n"); |
|
1329 unlink ( "$loc" ) or __OUT::Warning(" Failed to delete original backup loc file $loc \n"); |
|
1330 } |
|
1331 |
|
1332 |
|
1333 } |
|
1334 } |
|
1335 |
|
1336 sub GenerateStubLocFile |
|
1337 { |
|
1338 my ($self, $locfile, $langlist) = (shift, shift, shift); |
|
1339 |
|
1340 my $sav = $locfile.".isis.orig"; |
|
1341 my $trace = $locfile.".isis.trace"; |
|
1342 |
|
1343 __OUT::Print (" Backuping $locfile as $sav \n"); |
|
1344 |
|
1345 if ( -e "$trace" ) |
|
1346 { |
|
1347 unlink ( $trace ) or __OUT::Warning(" Failed to delete $trace \n"); |
|
1348 } |
|
1349 |
|
1350 if ( -e "$sav" ) |
|
1351 { |
|
1352 unlink ( $sav ) or __OUT::Warning(" Failed to delete stubbed loc file $sav \n"); |
|
1353 } |
|
1354 copy ($locfile, $sav) or __OUT::Error ("Cannot sav '$locfile'"); |
|
1355 |
|
1356 unless ( -e "$locfile" ) |
|
1357 { |
|
1358 open (TRACE, ">$trace") or __OUT::Error ("Cannot create trace file '$trace':$!"); |
|
1359 print TRACE "// File generated by Localiser.pm for tracing missing loc file - DO NOT EDIT!\n\n"; |
|
1360 close (TRACE); |
|
1361 } |
|
1362 |
|
1363 __OUT::Print ("=== Stubbing '$locfile' ===\n"); |
|
1364 |
|
1365 open (LOC, ">$locfile") or __OUT::Die ("Cannot open/create '$locfile':$!"); |
|
1366 print LOC "// File generated by Localiser.pm - DO NOT EDIT!\n\n"; |
|
1367 |
|
1368 my $first = 1; |
|
1369 my $name = $locfile; |
|
1370 $name =~ /(\w+\.loc)$/;$name=$1; |
|
1371 foreach my $lid ( @$langlist ) |
|
1372 { |
|
1373 if ($first) |
|
1374 { |
|
1375 $first = 0; |
|
1376 print LOC "#if defined(LANGUAGE_$lid)\n"; |
|
1377 } |
|
1378 else |
|
1379 { |
|
1380 print LOC "#elif defined(LANGUAGE_$lid)\n"; |
|
1381 } |
|
1382 my $f = $self->FindLocFor($name, $lid); |
|
1383 if ($f) |
|
1384 { |
|
1385 print LOC "\t#include \"".&__MakeRlt($locfile, $f)."\"\n"; |
|
1386 } |
|
1387 else |
|
1388 { |
|
1389 __OUT::Warning ("no translation to $lid for $locfile\n"); |
|
1390 print LOC "\t#warning no translation to $lid for $locfile\n"; |
|
1391 if ( -e "$sav" ) |
|
1392 { |
|
1393 $sav =~ /(\w+\.loc.isis.orig)$/; |
|
1394 print LOC "\t#include \"$1\"\n"; |
|
1395 } |
|
1396 } |
|
1397 } |
|
1398 if ( -e "$sav" ) |
|
1399 { |
|
1400 print LOC "#else\n"; |
|
1401 print LOC "// fallback to EE by default\n"; |
|
1402 $sav =~ /(\w+\.loc.isis.orig)$/; |
|
1403 print LOC "#include \"$1\"\n"; |
|
1404 } |
|
1405 print LOC "#endif\n"; |
|
1406 print LOC "// END OF FILE\n"; |
|
1407 close (LOC); |
|
1408 } |
|
1409 |
|
1410 sub __MakeRlt |
|
1411 { |
|
1412 my ($spath, $dpath) = @_; |
|
1413 #print "__MakeRlt($spath, $dpath)\n"; |
|
1414 # only backslahes |
|
1415 $spath =~ s/\//\\/g; |
|
1416 $dpath =~ s/\//\\/g; |
|
1417 $spath =~ s/^.:\\/\\/; |
|
1418 $dpath =~ s/^.:\\/\\/; |
|
1419 # remove filename |
|
1420 $spath =~ s/(\\|\/)\w+\.loc$/$1/; |
|
1421 # remove transform abs to rel path |
|
1422 $spath =~ s/\\[^\\]+/..\\/g; |
|
1423 |
|
1424 # clean up |
|
1425 # no trailing, no double \\ |
|
1426 $dpath =~ s/^\\+//; |
|
1427 $spath =~ s/\\+$//; |
|
1428 $dpath =~ s/\\\\/\\/g; |
|
1429 $spath =~ s/\\\\/\\/g; |
|
1430 return $spath."\\".$dpath; |
|
1431 } |
|
1432 |
|
1433 sub FindLocFor |
|
1434 { |
|
1435 my ($self, $locfile, $lid) = (shift, shift, shift); |
|
1436 |
|
1437 my $target = $locfile; |
|
1438 $target =~ s/\.loc$/_$lid.loc/i; |
|
1439 |
|
1440 foreach my $dir ( @{ $self->GetTranslatedLocFiles() } ) |
|
1441 { |
|
1442 opendir(DIR, "$dir/$lid"); |
|
1443 my @files = readdir(DIR); |
|
1444 close (DIR); |
|
1445 |
|
1446 foreach my $f ( @files ) |
|
1447 { |
|
1448 if ( $f =~ /^$target$/i ) |
|
1449 { |
|
1450 return "$dir/$lid/$target"; |
|
1451 } |
|
1452 } |
|
1453 } |
|
1454 return undef; |
|
1455 } |
|
1456 |
|
1457 |
|
1458 sub TouchRSS |
|
1459 { |
|
1460 my $self = shift; |
|
1461 my $component = $self->GetPath(); |
|
1462 $component =~ s/\//\\/g; |
|
1463 foreach ( `dir /s/b $component\\*.rss 2>&1` ) |
|
1464 { |
|
1465 chomp($_); |
|
1466 `attrib -r $_ 2>&1`; |
|
1467 `etouch $_ 2>&1`; |
|
1468 } |
|
1469 } |
|
1470 |
|
1471 sub ChangeMMPsAndMKs |
|
1472 { |
|
1473 my ($self, $langlist,$zip) = @_; |
|
1474 my $finder = new Finder( "\\.(mmp|mk)\$", $self->GetPath() ); |
|
1475 my $dmmps = $finder->Find(); |
|
1476 |
|
1477 foreach my $mmp ( @{ $self->{__mmps} } ) |
|
1478 { |
|
1479 __OUT::Print ("=== $mmp changing Language to [".join(' ',@$langlist)."]\n"); |
|
1480 my $dir = $self->GetPath()."/".$self->GetGroup(); |
|
1481 |
|
1482 $self->{__mmpstype}->{$mmp}->{type} = 'notfound'; |
|
1483 foreach my $f ( @$dmmps ) |
|
1484 { |
|
1485 my $uf = $f; |
|
1486 $uf =~ s/\.(mmp|mk)$//i; |
|
1487 if ( $uf =~ m/$mmp$/i ) |
|
1488 { |
|
1489 __OUT::Print (" + Found '$mmp' match => '$f'\n"); |
|
1490 $self->{__mmpstype}->{$mmp}->{path} = $f; |
|
1491 if ( $f =~ /^.*\.mmp$/i ) |
|
1492 { |
|
1493 $zip->AddFile($f); |
|
1494 $self->{__mmpstype}->{$mmp}->{type} = 'mmp'; |
|
1495 $self->__AlterLanguage( $langlist, "$f" ); |
|
1496 } |
|
1497 elsif ( $f =~ /^.*\.mk$/i ) |
|
1498 { |
|
1499 $zip->AddFile($f); |
|
1500 $self->{__mmpstype}->{$mmp}->{type} = 'mk'; |
|
1501 $self->__PatchMakefile( $langlist, "$f" ) if ( $f =~ /^.*\.mk$/i ); |
|
1502 } |
|
1503 __OUT::Print (" - Path: ".$self->{__mmpstype}->{$mmp}->{path}."\n"); |
|
1504 __OUT::Print (" - Type: ".$self->{__mmpstype}->{$mmp}->{type}."\n"); |
|
1505 } |
|
1506 } |
|
1507 if ( $self->{__mmpstype}->{$mmp}->{type} eq 'notfound' ) |
|
1508 { |
|
1509 __OUT::Error("Cannot find an mmp or mk file for this configuration definition: '$mmp'\n"); |
|
1510 } |
|
1511 } |
|
1512 } |
|
1513 |
|
1514 sub __PatchMakefile |
|
1515 { |
|
1516 my ( $self, $langlist, $mkfilepath ) = @_; |
|
1517 print " - $mkfilepath\n"; |
|
1518 |
|
1519 # Restoring if required. |
|
1520 if( -e $mkfilepath.'.orig' ) |
|
1521 { |
|
1522 print " restoring orig file"; |
|
1523 unlink($mkfilepath); |
|
1524 move ( $mkfilepath.'.orig', $mkfilepath ); |
|
1525 return 1 if (((scalar(@$langlist))==1) and (@{$langlist}[0] =~ /\s*sc\s*/)); |
|
1526 } |
|
1527 |
|
1528 # saving orig file to .orig |
|
1529 copy ($mkfilepath, $mkfilepath.'.orig') unless ( -e $mkfilepath.'.orig' ); |
|
1530 |
|
1531 if ( open (MK, "$mkfilepath.orig") ) |
|
1532 { |
|
1533 return 0 unless ( open (MKO, ">$mkfilepath") ); |
|
1534 print MKO "# DO NOT EDIT FILE PATCHED BY ISIS LOCALISER\n"; |
|
1535 foreach my $line ( <MK> ) |
|
1536 { |
|
1537 if ($line =~ /^\s*LANGUAGE\s*=/i) |
|
1538 { |
|
1539 print MKO "#ISISLOCALISERFIX $line"; |
|
1540 } |
|
1541 elsif ( $line =~ /epocrc\.bat/i ) |
|
1542 { |
|
1543 chomp($line); |
|
1544 print MKO "$line -DLANGUAGE_\$(LANGUAGE)\n"; |
|
1545 } |
|
1546 else |
|
1547 { |
|
1548 print MKO $line; |
|
1549 } |
|
1550 } |
|
1551 close(MK); |
|
1552 close (MKO); |
|
1553 open (LST,">>\\cleanupfiles.lst"); |
|
1554 print LST "$mkfilepath\n"; |
|
1555 close(LST); |
|
1556 return 1; |
|
1557 } |
|
1558 return 0; |
|
1559 } |
|
1560 |
|
1561 |
|
1562 sub __AlterLanguage |
|
1563 { |
|
1564 my ($self, $langlist, $file) = @_; |
|
1565 my ($type,$subst,$open_comment,$rss); |
|
1566 if ($file =~ /\.mmp$/i) { |
|
1567 $type="mmp"; |
|
1568 } |
|
1569 elsif ($file =~ /\.mmpi$/i){ |
|
1570 $type="mmp"; |
|
1571 } |
|
1572 else { |
|
1573 print STDERR "Unknown file $file\n"; |
|
1574 return; |
|
1575 } |
|
1576 print " - $file\n"; |
|
1577 open(IN, $file); |
|
1578 my @lines=<IN>; |
|
1579 close (IN); |
|
1580 |
|
1581 foreach (@lines){ |
|
1582 if (m!^\s*/\*!){ |
|
1583 $open_comment=1; |
|
1584 if (m!\*/!) { |
|
1585 $open_comment=0; |
|
1586 } |
|
1587 next; |
|
1588 } |
|
1589 if (m!\*/!) { |
|
1590 $open_comment=0; |
|
1591 next; |
|
1592 } |
|
1593 next if ($open_comment); |
|
1594 next if (m!^\s*//!); |
|
1595 if ((/^\s*lang\s+\w+\s*/i) and ($type eq "mmp")) |
|
1596 { |
|
1597 $_ = "LANG\t".join(' ', @$langlist)."\n"; |
|
1598 $subst=1; |
|
1599 } |
|
1600 if (/\.rss/i) |
|
1601 { |
|
1602 $rss=1; |
|
1603 } |
|
1604 } |
|
1605 if ($subst) { |
|
1606 __OUT::Print (scalar(`attrib -r $file`)); |
|
1607 open (OUT,">$file") or __OUT::Die ("Cannot open $file for overwriting"); |
|
1608 print OUT @lines; |
|
1609 close OUT; |
|
1610 } |
|
1611 elsif ($rss) |
|
1612 { |
|
1613 __OUT::Warning ("$file has no LANGUAGE or LANG definition in MMP,MK file\n"); |
|
1614 } |
|
1615 |
|
1616 } |
|
1617 |
|
1618 1; |
|
1619 |
|
1620 ## @package HelpManagement |
|
1621 # |
|
1622 # |
|
1623 package HelpManagement; |
|
1624 use strict; |
|
1625 use File::Copy; |
|
1626 |
|
1627 sub Copy |
|
1628 { |
|
1629 my ($languages, $path, $tpath) = @_; |
|
1630 $tpath = $tpath || Localiser::DEFAULT_TPATH; |
|
1631 |
|
1632 my @help_destination_path=qw(\epoc32\data\z\resource\Help\ \epoc32\winscw\c\resource\Help\ ); |
|
1633 my $locfiledir="\\S60\\S60Helps\\Data"; # Default path to locfiles (can be changed by $locfile_path option) |
|
1634 |
|
1635 foreach my $lid (@$languages) |
|
1636 { |
|
1637 if (opendir (DIR, $path."/$lid" )) |
|
1638 { |
|
1639 |
|
1640 my $zip = new ZipUp( File::Spec->catfile($tpath,"LocPackages","package_${lid}.zip" ) ); |
|
1641 |
|
1642 foreach my $file ( readdir(DIR)) |
|
1643 { |
|
1644 if ($file =~ /(\w+\.h)lp$/i) |
|
1645 { |
|
1646 my $realname=lc($1).$lid; |
|
1647 foreach my $dpath (@help_destination_path) |
|
1648 { |
|
1649 __OUT::Print ("Exporting '$path/$lid/$file' to '$dpath\\$realname'\n"); |
|
1650 copy ("$path/$lid/$file", "$dpath\\$realname"); |
|
1651 $zip->AddFile( "$dpath\\$realname" ); |
|
1652 } |
|
1653 } |
|
1654 } |
|
1655 closedir(DIR); |
|
1656 } |
|
1657 } |
|
1658 } |
|
1659 |
|
1660 1; |
|
1661 |
|
1662 package DTDHandler; |
|
1663 use strict; |
|
1664 use File::Copy; |
|
1665 use File::Path; |
|
1666 use File::Find; # for finding |
|
1667 use File::Basename; # for fileparse |
|
1668 |
|
1669 my (@dtdfiles,@GeneratedFiles); |
|
1670 #----------------------------------------------------------------------------------------- |
|
1671 # DTDHandler::find_dtdfiles() |
|
1672 # |
|
1673 # Finds the input DTD files in supplied directory. This is call back function |
|
1674 # |
|
1675 # Parameters: |
|
1676 #----------------------------------------------------------------------------------------- |
|
1677 |
|
1678 sub find_dtdfiles |
|
1679 { |
|
1680 my $dtd_name = $File::Find::name; |
|
1681 $dtd_name =~ s/\//\\/g; #Change / marks to \ |
|
1682 my($n, $d, $ext) = fileparse($dtd_name, '\..*'); |
|
1683 if( $ext =~ /\.dtd/i) |
|
1684 { |
|
1685 push @dtdfiles, $dtd_name; |
|
1686 } |
|
1687 } |
|
1688 |
|
1689 sub HandleDTD |
|
1690 { |
|
1691 my ($locFilesPath,$dtdTarget) = (shift,shift); |
|
1692 $dtdTarget .= "package_dtd.zip"; |
|
1693 |
|
1694 my $dtd_path = "\\epoc32\\winscw\\c\\Nokia\\Installs\\MyThemes\\"; |
|
1695 my %original_dtd; |
|
1696 @dtdfiles = (); |
|
1697 @GeneratedFiles = (); |
|
1698 |
|
1699 # get components that include DTD files |
|
1700 opendir(SDIR, ${dtd_path}) or __OUT::Die("can not read ${dtd_path}\n"); |
|
1701 my @folders = grep !/^\.\.?$/ && -d (${dtd_path}.$_), readdir SDIR; |
|
1702 closedir(SDIR); |
|
1703 |
|
1704 foreach my $dtd_folder(@folders) { |
|
1705 -d "${dtd_path}${dtd_folder}\\loc" || mkpath ("${dtd_path}${dtd_folder}\\loc",0,0x755); |
|
1706 } |
|
1707 |
|
1708 #search for in dtd input files in loc files directory |
|
1709 find( \&find_dtdfiles, "$locFilesPath" ); |
|
1710 |
|
1711 #copy all dtd files to dtd handler input directory |
|
1712 foreach (@dtdfiles) |
|
1713 { |
|
1714 foreach my $dtd_folder (@folders) { |
|
1715 if ($_ =~ m/$dtd_folder/i) { |
|
1716 xcopy ($_,"${dtd_path}${dtd_folder}\\loc"); |
|
1717 } |
|
1718 } |
|
1719 } |
|
1720 |
|
1721 __OUT::Print("==== DTD generation ====\n"); |
|
1722 #create Dtd files |
|
1723 foreach my $dtd_folder (@folders) { |
|
1724 __OUT::Print(`\\epoc32\\RELEASE\\WINSCW\\UREL\\XnThemeInstallerCons.exe c:\\Nokia\\installs\\MyThemes\\${dtd_folder}\\loc\\ 2&>1`); |
|
1725 rmtree( "\\epoc32\\WINSCW\\C\\private\\10207254\\themes\\sources" ); |
|
1726 # this kind of xcopy call MUST be replaced by a Perl command |
|
1727 __OUT::Print(`call xcopy \\epoc32\\WINSCW\\C\\private\\10207254\\themes\\* \\epoc32\\data\\z\\private\\10207254\\themes\\ \/E \/I \/Y \/R`); |
|
1728 __OUT::Print(`call xcopy \\epoc32\\WINSCW\\C\\private\\10207254\\themes\\* \\epoc32\\release\\winscw\\udeb\\z\\private\\10207254\\themes\\ \/E \/I \/Y \/R`); |
|
1729 __OUT::Print(`call xcopy \\epoc32\\WINSCW\\C\\private\\10207254\\themes\\* \\epoc32\\release\\winscw\\urel\\z\\private\\10207254\\themes\\ \/E \/I \/Y \/R`); |
|
1730 } |
|
1731 |
|
1732 __OUT::Print("==== DTD Language packaging ====\n"); |
|
1733 |
|
1734 system ("zip -r -q ${dtdTarget} \\epoc32\\data\\z\\private\\10207254\\themes\\* \\epoc32\\release\\winscw\\udeb\\z\\private\\10207254\\themes\\* \\epoc32\\release\\winscw\\urel\\z\\private\\10207254\\themes\\*"); |
|
1735 |
|
1736 __OUT::Print("==== Done DTD ====\n"); |
|
1737 } |
|
1738 |
|
1739 #----------------------------------------------------------------------------------------- |
|
1740 # DTDHandler::CopyDTDFiles($lid, $s60locpath) |
|
1741 # |
|
1742 # Copy the DTD files |
|
1743 # |
|
1744 # Parameters: |
|
1745 #----------------------------------------------------------------------------------------- |
|
1746 sub CopyDTDFiles |
|
1747 { |
|
1748 my ($language,$locFilesPath) = (shift, shift); |
|
1749 my @list = (); |
|
1750 @dtdfiles = (); |
|
1751 |
|
1752 #search for in dtd input files in loc files directory |
|
1753 find( \&find_dtdfiles, "$locFilesPath" ); |
|
1754 |
|
1755 |
|
1756 my $file_found_flag = 0; |
|
1757 foreach my $file (@dtdfiles) |
|
1758 { |
|
1759 my($n, $d, $ext) = fileparse($file, '\..*'); |
|
1760 |
|
1761 # find if file name without extention ends with language id. |
|
1762 if ($n =~ /\_$language$/i) |
|
1763 { |
|
1764 $file_found_flag = 1; |
|
1765 |
|
1766 #remove language id from the file name |
|
1767 $n =~ s/\_$language$//i; |
|
1768 |
|
1769 #copy dtd file to \epoc32\data\Z\private\101F4CD2\Content\<language> directory |
|
1770 my $dist = "\\epoc32\\data\\Z\\private\\101F4CD2\\Content\\$language\\$n$ext"; |
|
1771 |
|
1772 __OUT::Print("Copy '$file' to '$dist'\n"); |
|
1773 xcopy($file,$dist); |
|
1774 push (@list,$dist); |
|
1775 |
|
1776 #copy dtd file to \epoc32\release\winscw\udeb\Z\private\101F4CD2\Content\<language> directory |
|
1777 $dist =~ s/data/RELEASE\\WINSCW\\UDEB/i; |
|
1778 __OUT::Print("Copy '$file' to '$dist'\n"); |
|
1779 xcopy($file,$dist); |
|
1780 push (@list,$dist); |
|
1781 |
|
1782 #copy dtd file to \epoc32\release\winscw\urel\Z\private\101F4CD2\Content\<language> directory |
|
1783 $dist =~ s/UDEB/UREL/i; |
|
1784 __OUT::Print("Copy '$file' to '$dist'\n"); |
|
1785 xcopy($file,$dist); |
|
1786 push (@list,$dist); |
|
1787 } |
|
1788 } |
|
1789 |
|
1790 __OUT::Print("Error: Dtd files for $language not found!!!") if (! $file_found_flag); |
|
1791 |
|
1792 return @list; |
|
1793 } |
|
1794 |
|
1795 #----------------------------------------------------------------------------------------- |
|
1796 # DTDHandler::xcopy() |
|
1797 # |
|
1798 # copies file from source path to destination path. |
|
1799 # |
|
1800 # Parameters: |
|
1801 # Source file with path |
|
1802 # Destination file with path |
|
1803 #----------------------------------------------------------------------------------------- |
|
1804 |
|
1805 sub xcopy |
|
1806 { |
|
1807 my $source = shift; |
|
1808 my $dist = shift; |
|
1809 |
|
1810 # if distination file exist then clear read flag |
|
1811 if (-f $dist) |
|
1812 { |
|
1813 chmod ($dist , 0755); |
|
1814 } |
|
1815 else |
|
1816 { |
|
1817 my($n, $d, $ext) = fileparse($dist, '\..*'); |
|
1818 # check weather distination directory exist or not. If directory doesn't exist then create it. |
|
1819 -d $d || mkpath($d, 0, 0x755); |
|
1820 } |
|
1821 |
|
1822 # copy source to distination |
|
1823 copy($source,$dist); |
|
1824 } |
|
1825 |
|
1826 1; |
|
1827 |
|
1828 ## @package Locales |
|
1829 # |
|
1830 # |
|
1831 package Locales; |
|
1832 use File::Spec; |
|
1833 |
|
1834 sub CreatesLocales |
|
1835 { |
|
1836 my ($languages, $product, $flags, $ddir) = @_; |
|
1837 |
|
1838 $ddir = $ddir || Localiser::DEFAULT_TPATH; |
|
1839 |
|
1840 foreach my $lid (@$languages) |
|
1841 { |
|
1842 my $zip = new ZipUp( File::Spec->catfile($ddir,"LocPackages","package_${lid}.zip") ); |
|
1843 $zip->AddFile( __GenerateLocalesIBY((defined($product))?"${product}_":'', $lid, $flags) ); |
|
1844 } |
|
1845 } |
|
1846 |
|
1847 use IPC::Open3; |
|
1848 sub __GenerateLocalesIBY($$$) |
|
1849 { |
|
1850 my ($prefix, $langcode, $flags) = @_; |
|
1851 return if ($langcode =~ /sc/); |
|
1852 return if ($langcode !~ /\d+/); |
|
1853 |
|
1854 my $output = File::Spec->catfile("/epoc32/rom/include","${prefix}locales_$langcode.iby"); |
|
1855 |
|
1856 __OUT::Print ("Generating $output...\n"); |
|
1857 |
|
1858 open (OUT, ">$output"); |
|
1859 print OUT "#ifndef __LOCALES_".$langcode."_IBY__\n"; |
|
1860 print OUT "#define __LOCALES_".$langcode."_IBY__\n"; |
|
1861 |
|
1862 |
|
1863 my $arg = "-I ..\\include\\oem -I .\\include -I.\\Variant "; |
|
1864 foreach (@$flags) { $arg .= " -D$_ "; } |
|
1865 |
|
1866 |
|
1867 # use open3 to manage the error stream |
|
1868 chdir ("\\epoc32\\rom"); |
|
1869 local (*WTRFH, *RDRFH, *ERRFH); |
|
1870 my $cmd = "cpp -nostdinc -u $arg include\\locales_sc.iby -include .\\include\\header.iby"; |
|
1871 __OUT::Print ("Calling $cmd\n"); |
|
1872 my $childpid = open3(\*WTRFH, \*RDRFH, \*ERRFH, $cmd); |
|
1873 close(WTRFH); |
|
1874 while(<RDRFH>) |
|
1875 { |
|
1876 if (/^\s*data\s*=\s*MULTI_LINGUIFY/) |
|
1877 { |
|
1878 /MULTI_LINGUIFY\s*\(\s*(\S+)\s+(\S+)\s+(\S+)\s*\)/; |
|
1879 my $ext = $1; |
|
1880 my $w1 = $2; |
|
1881 my $w2 = $3; |
|
1882 if ( $ext=~ /^RSC$/i ) |
|
1883 { |
|
1884 $ext =~ s/RSC/r$langcode/i; |
|
1885 print OUT "data=$w1.$ext $w2.$ext\n"; |
|
1886 } |
|
1887 else |
|
1888 { |
|
1889 __OUT::Warning ("Cannot extract '$_'"); |
|
1890 } |
|
1891 } |
|
1892 elsif (/\.rsc/i) |
|
1893 { |
|
1894 s/\.rsc/\.r$langcode/ogi; |
|
1895 print OUT $_; |
|
1896 } |
|
1897 elsif (/\.dbz/i) |
|
1898 { |
|
1899 s/\.dbz/\.d$langcode/ogi; |
|
1900 print OUT $_; |
|
1901 } |
|
1902 elsif (/\.hlp/i) |
|
1903 { |
|
1904 s/\.hlp/\.h$langcode/ogi; |
|
1905 print OUT $_; |
|
1906 } |
|
1907 elsif ( /\\elocl\.dll/i ) |
|
1908 { |
|
1909 s/elocl\.dll/elocl\.$langcode/ogi; |
|
1910 s/elocl\.loc/elocl\.$langcode/ogi; |
|
1911 print OUT $_; |
|
1912 } |
|
1913 #rename Content\01 to Content\xx (where xx is language id). This is for handlng DTD files |
|
1914 elsif (/Content\\01/) |
|
1915 { |
|
1916 s/Content\\01/Content\\$langcode/ogi; |
|
1917 print OUT $_; |
|
1918 } |
|
1919 #rename .o0001 to .0xx (where xx is language id). This is for handlng DTD files |
|
1920 elsif (/\.o0001/i) |
|
1921 { |
|
1922 my $line = $_; |
|
1923 my $lang = $langcode; |
|
1924 #round up language id to 4 digis |
|
1925 while (length($lang) < 4) |
|
1926 { |
|
1927 $lang = "0".$lang; |
|
1928 } |
|
1929 |
|
1930 $line =~ s/\.o0001/\.o$lang/ogi; |
|
1931 print OUT $line; |
|
1932 } |
|
1933 elsif ( /^\s*(data|file)=/ ) |
|
1934 { |
|
1935 __OUT::Warning ("This should not be included in resource.iby '$_'\nThis file should be included using an 'applicationnameVariant.iby' file.\n"); |
|
1936 } |
|
1937 } |
|
1938 print OUT "#endif\n"; |
|
1939 close(OUT); |
|
1940 # Closing cleanly.... |
|
1941 close(RDRFH); |
|
1942 |
|
1943 # Manage cpp errors |
|
1944 my $err = ""; |
|
1945 while(<ERRFH>) { $err .= "$_\n";} |
|
1946 if (not ($err eq "")){ __OUT::Error ("$err"); } |
|
1947 |
|
1948 # Closing cleanly.... |
|
1949 close(ERRFH); |
|
1950 waitpid($childpid, 0); |
|
1951 |
|
1952 chdir("\\"); |
|
1953 return $output; |
|
1954 } |
|
1955 |
|
1956 1; |
|
1957 # End of File |
|