|
1 # Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 |
|
16 |
|
17 use FindBin; # for FindBin::Bin |
|
18 use Getopt::Long; |
|
19 |
|
20 my $PerlLibPath; # fully qualified pathname of the directory containing our Perl modules |
|
21 |
|
22 BEGIN { |
|
23 # check user has a version of perl that will cope |
|
24 require 5.005_03; |
|
25 # establish the path to the Perl libraries: currently the same directory as this script |
|
26 $PerlLibPath = $FindBin::Bin; # X:/epoc32/tools |
|
27 $PerlLibPath =~ s/\//\\/g; # X:\epoc32\tools |
|
28 $PerlLibPath .= "\\"; |
|
29 } |
|
30 |
|
31 use lib $PerlLibPath; |
|
32 use E32env; |
|
33 use CheckSource; |
|
34 use FCLoggerUTL; |
|
35 use featurevariantparser; |
|
36 |
|
37 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
38 |
|
39 $ENV{MAKE} = 'make' unless defined $ENV{MAKE}; |
|
40 } |
|
41 |
|
42 # command data structure |
|
43 my %Commands=( |
|
44 BUILD=>{ |
|
45 build=>1, |
|
46 program=>1, |
|
47 what=>1, |
|
48 function=>'Combines commands EXPORT,MAKEFILE,LIBRARY,RESOURCE,TARGET,FINAL', |
|
49 subcommands=>['EXPORT','MAKEFILE', 'LIBRARY', 'RESOURCE', 'TARGET', 'FINAL'], |
|
50 savespace=>1, |
|
51 instructionset=>1, |
|
52 debug=>1, |
|
53 no_debug=>1, |
|
54 logfc=>1, |
|
55 checksource=>1, |
|
56 wrap=>1, #To support Compiler wrapper option along with BUILD command |
|
57 }, |
|
58 CLEAN=>{ |
|
59 build=>1, |
|
60 program=>1, |
|
61 function=>'Removes everything built with ABLD TARGET', |
|
62 what=>1, |
|
63 }, |
|
64 CLEANALL=>{ |
|
65 program=>1, |
|
66 function=>'Removes everything built with ABLD TARGET', |
|
67 what=>1, |
|
68 }, |
|
69 CLEANEXPORT=>{ |
|
70 function=>'Removes files created by ABLD EXPORT', |
|
71 what=>1, |
|
72 noplatform=>1, |
|
73 }, |
|
74 CLEANMAKEFILE=>{ |
|
75 program=>1, |
|
76 function=>'Removes files generated by ABLD MAKEFILE', |
|
77 what=>1, |
|
78 hidden=>1, |
|
79 }, |
|
80 EXPORT=>{ |
|
81 noplatform=>1, |
|
82 what=>1, |
|
83 function=>'Copies the exported files to their destinations', |
|
84 }, |
|
85 FINAL=>{ |
|
86 build=>1, |
|
87 program=>1, |
|
88 function=>'Allows extension makefiles to execute final commands', |
|
89 }, |
|
90 FREEZE=>{ |
|
91 program=>1, |
|
92 remove=>1, |
|
93 function=>'Freezes exported functions in a .DEF file', |
|
94 }, |
|
95 HELP=>{ |
|
96 noplatform=>1, |
|
97 function=>'Displays commands, options or help about a particular command', |
|
98 notest=>1, |
|
99 }, |
|
100 LIBRARY=>{ |
|
101 program=>1, |
|
102 function=>'Creates import libraries from the frozen .DEF files', |
|
103 }, |
|
104 LISTING=>{ |
|
105 build=>1, |
|
106 program=>1, |
|
107 function=>'Creates assembler listing file for corresponding source file', |
|
108 source=>1, |
|
109 }, |
|
110 MAKEFILE=>{ |
|
111 program=>1, |
|
112 function=>'Creates makefiles or IDE workspaces', |
|
113 what=>1, |
|
114 savespace=>1, |
|
115 instructionset=>1, |
|
116 debug=>1, |
|
117 no_debug=>1, |
|
118 logfc=>1, |
|
119 wrap=>1, #To support Compiler wrapper option along with MAKEFILE command |
|
120 }, |
|
121 REALLYCLEAN=>{ |
|
122 build=>1, |
|
123 program=>1, |
|
124 function=>'As CLEAN, but also removes exported files and makefiles', |
|
125 what=>1, |
|
126 subcommands=>['CLEANEXPORT', 'CLEAN', 'CLEANALL'], |
|
127 }, |
|
128 RESOURCE=>{ |
|
129 build=>1, |
|
130 program=>1, |
|
131 function=>'Creates resource files, bitmaps and AIFs', |
|
132 }, |
|
133 # ROMFILE=>{ |
|
134 # function=>'Under development - syntax not finalised', |
|
135 # noverbose=>1, |
|
136 # nokeepgoing=>1, |
|
137 # hidden=>1, |
|
138 # }, |
|
139 ROMFILE=>{ |
|
140 noverbose=>1, |
|
141 build=>1, |
|
142 program=>1, |
|
143 function=>'generates an IBY file to include in a ROM' |
|
144 }, |
|
145 SAVESPACE=>{ |
|
146 build=>1, |
|
147 program=>1, |
|
148 what=>1, |
|
149 function=>'As TARGET, but deletes intermediate files on success', |
|
150 hidden=>1, # hidden because only used internally from savespace flag |
|
151 }, |
|
152 TARGET=>{ |
|
153 build=>1, |
|
154 program=>1, |
|
155 what=>1, |
|
156 function=>'Creates the main executable and also the resources', |
|
157 savespace=>1, |
|
158 checksource=>1, |
|
159 wrap=>1, #To support Compiler wrapper option along with TARGET command |
|
160 }, |
|
161 TIDY=>{ |
|
162 build=>1, |
|
163 program=>1, |
|
164 function=>'Removes executables which need not be released', |
|
165 } |
|
166 ); |
|
167 |
|
168 # get the path to the bldmake-generated files |
|
169 # we can perhaps work this out from the current working directory in later versions |
|
170 my $BldInfDir; |
|
171 my $PrjBldDir; |
|
172 BEGIN { |
|
173 $BldInfDir=shift @ARGV; |
|
174 $PrjBldDir=$E32env::Data{BldPath}; |
|
175 $PrjBldDir=~s-^(.*)\\-$1-o; |
|
176 $PrjBldDir.=$BldInfDir; |
|
177 $PrjBldDir=~m-(.*)\\-o; # remove backslash because some old versions of perl can't cope |
|
178 unless (-d $1) { |
|
179 die "ABLD ERROR: Project Bldmake directory \"$PrjBldDir\" does not exist\n"; |
|
180 } |
|
181 } |
|
182 |
|
183 # check the platform module exists and then load it |
|
184 BEGIN { |
|
185 unless (-e "${PrjBldDir}Platform.pm") { |
|
186 die "ABLD ERROR: \"${PrjBldDir}Platform.pm\" not yet created\n"; |
|
187 } |
|
188 } |
|
189 use lib $PrjBldDir; |
|
190 use Platform; |
|
191 |
|
192 # change directory to the BLD.INF directory - we might begin to do |
|
193 # things with relative paths in the future. |
|
194 chdir($BldInfDir) or die "ABLD ERROR: Can't CD to \"$BldInfDir\"\n"; |
|
195 |
|
196 # MAIN PROGRAM SECTION |
|
197 { |
|
198 |
|
199 # PROCESS THE COMMAND LINE |
|
200 my %Options=(); |
|
201 unless (@ARGV) { |
|
202 &Usage(); |
|
203 } |
|
204 |
|
205 # Process options and check that all are recognised |
|
206 # modified start: added functionality checkwhat |
|
207 unless (GetOptions(\%Options, 'checkwhat|cw','check|c', 'keepgoing|k', 'savespace|s', 'verbose|v', |
|
208 'what|w', 'remove|r', 'instructionset|i=s', |
|
209 'checksource|cs', 'debug','no_debug', 'logfc|fc','wrap:s')) { |
|
210 exit 1; |
|
211 } |
|
212 # modified end: added functionality checkwhat |
|
213 |
|
214 # check the option combinations |
|
215 # modified start: added functionality checkwhat |
|
216 if ($Options{checkwhat} ) { |
|
217 $Options{check}=1; |
|
218 } |
|
219 # modified end: added functionality checkwhat |
|
220 if (($Options{check} and $Options{what})) { |
|
221 &Options; |
|
222 } |
|
223 if (($Options{check} or $Options{what}) and ($Options{keepgoing} or $Options{savespace} or $Options{verbose})) { |
|
224 &Options(); |
|
225 } |
|
226 if ($Options{checksource} and $Options{what}) { |
|
227 &Options(); |
|
228 } |
|
229 |
|
230 |
|
231 # take the test parameter out of the command-line if it's there |
|
232 my $Test=''; |
|
233 if (@ARGV && $ARGV[0]=~/^test$/io) { |
|
234 $Test='test'; |
|
235 shift @ARGV; |
|
236 } |
|
237 |
|
238 # if there's only the test parameter there, display usage |
|
239 unless (@ARGV) { |
|
240 &Usage(); |
|
241 } |
|
242 |
|
243 # get the command parameter out of the command line |
|
244 my $Command=uc shift @ARGV; |
|
245 unless (defined $Commands{$Command}) { |
|
246 &Commands(); |
|
247 } |
|
248 my %CommandHash=%{$Commands{$Command}}; |
|
249 |
|
250 # check the test parameter is not specified where it shouldn't be |
|
251 if ($Test and $CommandHash{notest}) { |
|
252 &Help($Command); |
|
253 } |
|
254 |
|
255 # check the options are suitable for the commands |
|
256 # -verbose and -keepgoing have no effect in certain cases |
|
257 if ($Options{what} or $Options{check}) { |
|
258 unless ($CommandHash{what}) { |
|
259 &Help($Command); |
|
260 } |
|
261 } |
|
262 #Function Call Logger |
|
263 if ($Options{logfc}) { |
|
264 unless ($CommandHash{logfc}) { |
|
265 &Help($Command); |
|
266 } |
|
267 } |
|
268 if ($Options{savespace}) { |
|
269 unless ($CommandHash{savespace}) { |
|
270 &Help($Command); |
|
271 } |
|
272 } |
|
273 if ($Options{instructionset}) { |
|
274 unless ($CommandHash{instructionset}) { |
|
275 &Help($Command); |
|
276 } |
|
277 } |
|
278 if ($Options{debug}) { |
|
279 unless ($CommandHash{debug}) { |
|
280 &Help($Command); |
|
281 } |
|
282 } |
|
283 if ($Options{no_debug}) { |
|
284 unless ($CommandHash{no_debug}) { |
|
285 &Help($Command); |
|
286 } |
|
287 } |
|
288 |
|
289 if ($Options{keepgoing}) { |
|
290 if ($CommandHash{nokeepgoing}) { |
|
291 &Help($Command); |
|
292 } |
|
293 } |
|
294 if ($Options{verbose}) { |
|
295 if ($CommandHash{noverbose}) { |
|
296 &Help($Command); |
|
297 } |
|
298 } |
|
299 if ($Options{remove}) { |
|
300 unless ($CommandHash{remove}) { |
|
301 &Help($Command); |
|
302 } |
|
303 } |
|
304 if ($Options{checksource}) { |
|
305 unless ($CommandHash{checksource}) { |
|
306 &Help($Command); |
|
307 } |
|
308 } |
|
309 #Compiler Wrapper support |
|
310 if (exists $Options{wrap}) { |
|
311 unless ($CommandHash{wrap}) { |
|
312 &Help($Command); |
|
313 } |
|
314 } |
|
315 |
|
316 # process help command if necessary |
|
317 if ($Command eq 'HELP') { |
|
318 if (@ARGV) { |
|
319 my $Tmp=uc shift @ARGV; |
|
320 if (defined $Commands{$Tmp}) { |
|
321 &Help($Tmp); |
|
322 } |
|
323 elsif ($Tmp eq 'OPTIONS') { |
|
324 &Options(); |
|
325 } |
|
326 elsif ($Tmp eq 'COMMANDS') { |
|
327 &Commands(); |
|
328 } |
|
329 } |
|
330 &Usage(); |
|
331 } |
|
332 |
|
333 # process parameters |
|
334 my ($Plat, $Bld, $Program, $Source)=('','','',''); |
|
335 my %MakefileVariations; |
|
336 my $FeatureVariantArg; |
|
337 |
|
338 # platform parameter first |
|
339 unless ($CommandHash{noplatform}) { |
|
340 unless ($Plat=uc shift @ARGV) { |
|
341 $Plat='ALL'; # default |
|
342 } |
|
343 else { |
|
344 # Explicit feature variant platforms take the form <base platform>.<variant name> |
|
345 # e.g. armv5.variant1. |
|
346 # If valid, we actually create and invoke a distinct variation of the "base" makefile |
|
347 if ($Plat =~ /^(\S+)\.(\S+)$/) |
|
348 { |
|
349 $Plat = $1; |
|
350 $FeatureVariantArg = uc($2); |
|
351 |
|
352 if (!$Platform::FeatureVariantSupportingPlats{$Plat}) |
|
353 { |
|
354 die "This project does not support platform \"$Plat\.$FeatureVariantArg\"\n"; |
|
355 } |
|
356 else |
|
357 { |
|
358 $MakefileVariations{$Plat} = &GetMakefileVariations($Plat, $FeatureVariantArg); |
|
359 } |
|
360 } |
|
361 |
|
362 COMPARAM1 : { |
|
363 if (grep(/^$Plat$/, ('ALL', @Platform::Plats))) { |
|
364 last COMPARAM1; |
|
365 } |
|
366 if ($Plat =~ /(.*)EDG$/) { |
|
367 my $SubPlat = $1; |
|
368 if (grep(/^$SubPlat$/, ('ALL', @Platform::Plats))) { |
|
369 last COMPARAM1; |
|
370 } |
|
371 } |
|
372 # check whether the platform might in fact be a build, and |
|
373 # set the platform and build accordingly if it is |
|
374 if ($CommandHash{build}) { |
|
375 if ($Plat=~/^(UDEB|UREL|DEB|REL)$/o) { |
|
376 $Bld=$Plat; |
|
377 $Plat='ALL'; |
|
378 last COMPARAM1; |
|
379 } |
|
380 } |
|
381 # check whether the platform might in fact be a program, and |
|
382 # set the platform, build and program accordingly if it is |
|
383 if ($CommandHash{program}) { |
|
384 if (((not $Test) and grep /^$Plat$/, @{$Platform::Programs{ALL}}) |
|
385 or ($Test and grep /^$Plat$/, @{$Platform::TestPrograms{ALL}})) { |
|
386 $Program=$Plat; |
|
387 $Plat='ALL'; |
|
388 $Bld='ALL'; |
|
389 last COMPARAM1; |
|
390 } |
|
391 } |
|
392 # report the error |
|
393 if ($CommandHash{build} and $CommandHash{program}) { |
|
394 die "This project does not support platform, build or $Test program \"$Plat\"\n"; |
|
395 } |
|
396 if ($CommandHash{build} and not $CommandHash{program}) { |
|
397 die "This project does not support platform or build \"$Plat\"\n"; |
|
398 } |
|
399 if ($CommandHash{program} and not $CommandHash{build}) { |
|
400 die "This project does not support platform or $Test program \"$Plat\"\n"; |
|
401 } |
|
402 if (not ($CommandHash{build} or $CommandHash{program})) { |
|
403 die "This project does not support platform \"$Plat\"\n"; |
|
404 } |
|
405 } |
|
406 } |
|
407 } |
|
408 |
|
409 #Compiler Wrapper support |
|
410 my $CompilerWrapperFlagMacro = ""; |
|
411 if(exists $Options{wrap}) |
|
412 { |
|
413 my $error = "Environment variable 'ABLD_COMPWRAP' is not set\n"; |
|
414 # If tool name for wrapping compiler is set in environment variable |
|
415 if($ENV{ABLD_COMPWRAP}) |
|
416 { |
|
417 $CompilerWrapperFlagMacro =" ABLD_COMPWRAP_FLAG=-wrap" . ($Options{wrap} ? "=$Options{wrap}":""); |
|
418 } |
|
419 elsif($Options{keepgoing}) |
|
420 { |
|
421 # If Tool name is not set and keepgoing option is specified then ignore -wrap option and continue processing |
|
422 print $error; |
|
423 delete $Options{wrap}; |
|
424 } |
|
425 else |
|
426 { |
|
427 # Issue error and exit if neither keepgoing option nor tool name is specified |
|
428 die $error; |
|
429 } |
|
430 } |
|
431 |
|
432 # process the build parameter for those commands which require it |
|
433 if ($CommandHash{build}) { |
|
434 unless ($Bld) { |
|
435 unless ($Bld=uc shift @ARGV) { |
|
436 $Bld='ALL'; # default |
|
437 } |
|
438 else { |
|
439 COMPARAM2 : { |
|
440 if ($Bld=~/^(ALL|UDEB|UREL|DEB|REL)$/o) { |
|
441 # Change for TOOLS, TOOLS2 and VC6TOOLS platforms |
|
442 if ($Plat ne 'ALL') { |
|
443 if (($Plat!~/TOOLS2?$/o and $Bld=~/^(DEB|REL)$/o) or ($Plat=~/TOOLS2?$/o and $Bld=~/^(UDEB|UREL)$/o)) { |
|
444 die "Platform \"$Plat\" does not support build \"$Bld\"\n"; |
|
445 } |
|
446 } |
|
447 last COMPARAM2; |
|
448 } |
|
449 # check whether the build might in fact be a program, and |
|
450 # set the build and program if it is |
|
451 if ($CommandHash{program}) { |
|
452 if (((not $Test) and grep /^$Bld$/, @{$Platform::Programs{$Plat}}) |
|
453 or ($Test and grep /^$Bld$/, @{$Platform::TestPrograms{$Plat}})) { |
|
454 $Program=$Bld; |
|
455 $Bld='ALL'; |
|
456 last COMPARAM2; |
|
457 } |
|
458 my $Error="This project does not support build or $Test program \"$Bld\""; |
|
459 if ($Plat eq 'ALL') { |
|
460 $Error.=" for any platform\n"; |
|
461 } |
|
462 else { |
|
463 $Error.=" for platform \"$Plat\"\n"; |
|
464 } |
|
465 die $Error; |
|
466 } |
|
467 my $Error="This project does not support build \"$Bld\""; |
|
468 if ($Plat eq 'ALL') { |
|
469 $Error.=" for any platform\n"; |
|
470 } |
|
471 else { |
|
472 $Error.=" for platform \"$Plat\"\n"; |
|
473 } |
|
474 die $Error; |
|
475 } |
|
476 } |
|
477 } |
|
478 } |
|
479 |
|
480 # get the program parameter for those commands which require it |
|
481 if ($CommandHash{program}) { |
|
482 unless ($Program) { |
|
483 unless ($Program=uc shift @ARGV) { |
|
484 $Program=''; #default - means ALL |
|
485 } |
|
486 else { |
|
487 # check that the program is supported |
|
488 unless (((not $Test) and grep /^$Program$/, @{$Platform::Programs{$Plat}}) |
|
489 or ($Test and grep /^$Program$/, @{$Platform::TestPrograms{$Plat}})) { |
|
490 my $Error="This project does not support $Test program \"$Program\""; |
|
491 if ($Plat eq 'ALL') { |
|
492 $Error.=" for any platform\n"; |
|
493 } |
|
494 else { |
|
495 $Error.=" for platform \"$Plat\"\n"; |
|
496 } |
|
497 die $Error; |
|
498 } |
|
499 } |
|
500 } |
|
501 } |
|
502 |
|
503 # get the source file parameter for those commands which require it |
|
504 if ($CommandHash{source}) { |
|
505 unless ($Source=uc shift @ARGV) { |
|
506 $Source=''; #default - means ALL |
|
507 } |
|
508 else { |
|
509 $Source=" SOURCE=$Source"; |
|
510 } |
|
511 } |
|
512 |
|
513 # check for too many arguments |
|
514 if (@ARGV) { |
|
515 &Help($Command); |
|
516 } |
|
517 |
|
518 if ( $Options{instructionset} ) |
|
519 { # we have a -i option. |
|
520 if ($Plat eq 'ARMV5') |
|
521 { |
|
522 if ( !( ( uc( $Options{instructionset} ) eq "ARM") || ( uc( $Options{instructionset} ) eq "THUMB" ) ) ) { |
|
523 # Only ARM and THUMB options are valid. |
|
524 &Options(); |
|
525 } |
|
526 } |
|
527 else |
|
528 { # Can only use -i for armv5 builds. |
|
529 &Options(); |
|
530 } |
|
531 } |
|
532 |
|
533 # process CHECKSOURCE_OVERRIDE |
|
534 if ($ENV{CHECKSOURCE_OVERRIDE} && (($Plat =~ /^ARMV5/) || ($Plat eq 'WINSCW')) && ($Command eq 'TARGET') && !$Options{what}) |
|
535 { |
|
536 $Options{checksource} = 1; |
|
537 } |
|
538 |
|
539 my $checksourceMakeVariables = " "; |
|
540 if ($Options{checksource}) { |
|
541 $checksourceMakeVariables .= "CHECKSOURCE_VERBOSE=1 " if ($Options{verbose}); |
|
542 } |
|
543 |
|
544 # expand the platform list |
|
545 my @Plats; |
|
546 unless ($CommandHash{noplatform}) { |
|
547 if ($Plat eq 'ALL') { |
|
548 @Plats=@Platform::RealPlats; |
|
549 # Adjust the "ALL" list according to the availability of compilers |
|
550 @Plats=grep !/WINSCW$/o, @Plats unless (defined $ENV{MWSym2Libraries}); |
|
551 @Plats=grep !/WINS$/o, @Plats unless (defined $ENV{MSDevDir}); |
|
552 @Plats=grep !/X86$/o, @Plats unless (defined $ENV{MSDevDir}); |
|
553 @Plats=grep !/X86SMP$/o, @Plats unless (defined $ENV{MSDevDir}); |
|
554 @Plats=grep !/X86GCC$/o, @Plats unless (defined $ENV{MSDevDir}); |
|
555 @Plats=grep !/X86GMP$/o, @Plats unless (defined $ENV{MSDevDir}); |
|
556 if ($CommandHash{build}) { |
|
557 # remove unnecessary platforms if just building for tools, or building everything but tools |
|
558 # so that the makefiles for other platforms aren't created with abld build |
|
559 if ($Bld=~/^(UDEB|UREL)$/o) { |
|
560 @Plats=grep !/TOOLS2?$/o, @Plats; |
|
561 } |
|
562 elsif ($Bld=~/^(DEB|REL)$/o) { |
|
563 @Plats=grep /TOOLS2?$/o, @Plats; |
|
564 } |
|
565 } |
|
566 } |
|
567 else |
|
568 { |
|
569 @Plats=($Plat); |
|
570 } |
|
571 |
|
572 foreach $Plat (@Plats) |
|
573 { |
|
574 # Skip platforms resolved above |
|
575 next if $MakefileVariations{$Plat}; |
|
576 |
|
577 # Implicit feature variant platforms apply when a default feature variant exists and the platform supports it |
|
578 # If valid, we actually create and invoke a distinct variation of the "base" makefile |
|
579 if ($Platform::FeatureVariantSupportingPlats{$Plat} && featurevariantparser->DefaultExists()) |
|
580 { |
|
581 if($Command eq "REALLYCLEAN") |
|
582 { |
|
583 my @myfeature = featurevariantparser->GetBuildableFeatureVariants(); |
|
584 push @{$MakefileVariations{$Plat}}, ".".$_ foreach(@myfeature); |
|
585 } |
|
586 else |
|
587 { |
|
588 $MakefileVariations{$Plat} = &GetMakefileVariations($Plat, "DEFAULT"); |
|
589 } |
|
590 } |
|
591 else |
|
592 { |
|
593 # For non-feature variant platforms we always store a single makefile variation of nothing i.e. |
|
594 # we use the "normal" makefile generated for the platform |
|
595 $MakefileVariations{$Plat} = &GetMakefileVariations($Plat, ""); |
|
596 } |
|
597 |
|
598 } |
|
599 |
|
600 foreach $Plat (@Plats) { |
|
601 foreach my $makefileVariation (@{$MakefileVariations{$Plat}}) { |
|
602 unless (-e "$PrjBldDir$Plat$makefileVariation$Test.make") { |
|
603 die "ABLD ERROR: \"$PrjBldDir$Plat$makefileVariation$Test.make\" not yet created\n"; |
|
604 } |
|
605 } |
|
606 } |
|
607 undef $Plat; |
|
608 } |
|
609 |
|
610 # set up a list of commands where there are sub-commands |
|
611 my @Commands=($Command); |
|
612 if ($CommandHash{subcommands}) { |
|
613 @Commands=@{$CommandHash{subcommands}}; |
|
614 if ($Command eq 'BUILD') { # avoid makefile listings here |
|
615 if ($Options{what} or $Options{check}) { |
|
616 @Commands=grep !/^MAKEFILE$/o, @{$CommandHash{subcommands}}; |
|
617 } |
|
618 } |
|
619 } |
|
620 # implement savespace if necessary |
|
621 if ($Options{savespace}) { |
|
622 foreach $Command (@Commands) { |
|
623 if ($Command eq 'TARGET') { |
|
624 $Command='SAVESPACE'; |
|
625 } |
|
626 } |
|
627 } |
|
628 |
|
629 # set up makefile call flags and macros from the options |
|
630 my $KeepgoingFlag=''; |
|
631 my $KeepgoingMacro=''; |
|
632 my $NoDependencyMacro=''; |
|
633 my $VerboseMacro=' VERBOSE=-s'; |
|
634 if ($Options{keepgoing}) { |
|
635 $KeepgoingFlag=' -k'; |
|
636 $KeepgoingMacro=' KEEPGOING=-k'; |
|
637 } |
|
638 if ($Options{verbose}) { |
|
639 $VerboseMacro=''; |
|
640 } |
|
641 my $RemoveMacro=''; |
|
642 if ($Options{remove}) { |
|
643 $RemoveMacro=' EFREEZE_ALLOW_REMOVE=1'; |
|
644 } |
|
645 if ( ($Options{savespace}) and ($Options{keepgoing}) ){ |
|
646 $NoDependencyMacro=' NO_DEPENDENCIES=-nd'; |
|
647 } |
|
648 |
|
649 my $AbldFlagsMacro=""; |
|
650 $AbldFlagsMacro = "-iarm " if (uc $Options{instructionset} eq "ARM"); |
|
651 $AbldFlagsMacro = "-ithumb " if (uc $Options{instructionset} eq "THUMB"); |
|
652 |
|
653 if ($Options{debug}) { |
|
654 $AbldFlagsMacro .= "-debug "; |
|
655 } |
|
656 elsif($Options{no_debug}) { |
|
657 $AbldFlagsMacro .= "-no_debug "; |
|
658 } |
|
659 |
|
660 #Function call logging flag for makmake |
|
661 if ($Options{logfc}) { |
|
662 #Check the availability and version of logger |
|
663 if (&FCLoggerUTL::PMCheckFCLoggerVersion()) { |
|
664 $AbldFlagsMacro .= "-logfc "; |
|
665 } |
|
666 } |
|
667 |
|
668 if(!($AbldFlagsMacro eq "") ){ |
|
669 $AbldFlagsMacro =" ABLD_FLAGS=\"$AbldFlagsMacro\""; |
|
670 } |
|
671 |
|
672 # set up a list of make calls |
|
673 my @Calls; |
|
674 |
|
675 # handle the exports related calls first |
|
676 if (($Command)=grep /^(.*EXPORT)$/o, @Commands) { # EXPORT, CLEANEXPORT |
|
677 unless (-e "${PrjBldDir}EXPORT$Test.make") { |
|
678 die "ABLD ERROR: \"${PrjBldDir}EXPORT$Test.make\" not yet created\n"; |
|
679 } |
|
680 unless ($Options {checksource}) { |
|
681 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
682 unless ($Options{what} or $Options{check}) { |
|
683 push @Calls, "$ENV{MAKE} -r $KeepgoingFlag -f \"${PrjBldDir}EXPORT$Test.make\" $Command$VerboseMacro$KeepgoingMacro"; |
|
684 } |
|
685 else { |
|
686 push @Calls, "$ENV{MAKE} -r -f \"${PrjBldDir}EXPORT$Test.make\" WHAT"; |
|
687 } |
|
688 } |
|
689 else { |
|
690 |
|
691 unless ($Options{what} or $Options{check}) { |
|
692 push @Calls, "make -r $KeepgoingFlag -f \"${PrjBldDir}EXPORT$Test.make\" $Command$VerboseMacro$KeepgoingMacro"; |
|
693 } |
|
694 else { |
|
695 push @Calls, "make -r -f \"${PrjBldDir}EXPORT$Test.make\" WHAT"; |
|
696 } |
|
697 } |
|
698 } |
|
699 @Commands=grep !/EXPORT$/o, @Commands; |
|
700 } |
|
701 |
|
702 # then do the rest of the calls |
|
703 |
|
704 COMMAND: foreach $Command (@Commands) { |
|
705 |
|
706 if ($Options {checksource} && ($Command eq "TARGET" || $Command eq "SAVESPACE")) { |
|
707 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
708 push @Calls, "$ENV{MAKE} -r -f \"".$PrjBldDir."EXPORT.make\"".$checksourceMakeVariables."CHECKSOURCE"; |
|
709 } |
|
710 else { |
|
711 push @Calls, "make -r -f \"".$PrjBldDir."EXPORT.make\"".$checksourceMakeVariables."CHECKSOURCE"; |
|
712 } |
|
713 } |
|
714 |
|
715 my $Plat; |
|
716 PLATFORM: foreach $Plat (@Plats) { |
|
717 |
|
718 # set up a list of builds to carry out commands for if appropriate |
|
719 my @Blds=($Bld); |
|
720 if (${$Commands{$Command}}{build}) { |
|
721 if ($Bld eq 'ALL') { |
|
722 unless ($Plat=~/TOOLS2?$/o) { # change for platforms TOOLS, TOOLS2 and VC6TOOLS |
|
723 @Blds=('UDEB', 'UREL'); |
|
724 } |
|
725 else { |
|
726 @Blds=('DEB', 'REL'); |
|
727 } |
|
728 } |
|
729 else { |
|
730 # check the build is suitable for the platform - TOOLS, TOOLS2 and VC6TOOLS are annoyingly atypical |
|
731 unless (($Plat!~/TOOLS2?$/o and $Bld=~/^(UDEB|UREL)$/o) or ($Plat=~/TOOLS2?$/o and $Bld=~/^(DEB|REL)$/o)) { |
|
732 next; |
|
733 } |
|
734 } |
|
735 } |
|
736 else { |
|
737 @Blds=('IRRELEVANT'); |
|
738 } |
|
739 |
|
740 # You get CHECKSOURCE_GENERIC "for free" if no component is specified in the call |
|
741 if ($Options {checksource} && ($Command eq "TARGET" || $Command eq "SAVESPACE") && $Program) { |
|
742 foreach my $makefileVariation (@{$MakefileVariations{$Plat}}) { |
|
743 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
744 push @Calls, "$ENV{MAKE} -r -f \"$PrjBldDir$Plat$makefileVariation$Test.make\"".$checksourceMakeVariables."CHECKSOURCE_GENERIC"; |
|
745 } |
|
746 else { |
|
747 push @Calls, "make -r -f \"$PrjBldDir$Plat$makefileVariation$Test.make\"".$checksourceMakeVariables."CHECKSOURCE_GENERIC"; |
|
748 } |
|
749 } |
|
750 } |
|
751 |
|
752 my $LoopBld; |
|
753 foreach $LoopBld (@Blds) { |
|
754 my $CFG=''; |
|
755 if ($LoopBld ne 'IRRELEVANT') { |
|
756 $CFG=" CFG=$LoopBld"; |
|
757 } |
|
758 if ($Options {checksource}) { |
|
759 if ($Command eq "TARGET" || $Command eq "SAVESPACE") { |
|
760 foreach my $makefileVariation (@{$MakefileVariations{$Plat}}) { |
|
761 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
762 push @Calls, "$ENV{MAKE} -r -f \"$PrjBldDir$Plat$makefileVariation$Test.make\"".$checksourceMakeVariables."CHECKSOURCE$Program$CFG"; |
|
763 } |
|
764 else { |
|
765 push @Calls, "make -r -f \"$PrjBldDir$Plat$makefileVariation$Test.make\"".$checksourceMakeVariables."CHECKSOURCE$Program$CFG"; |
|
766 } |
|
767 } |
|
768 } |
|
769 next; |
|
770 } |
|
771 |
|
772 unless ($Options{what} or $Options{check}) { |
|
773 if ($Program) { # skip programs if they're not supported for a platform |
|
774 unless ($Test) { |
|
775 unless (grep /^$Program$/, @{$Platform::Programs{$Plat}}) { |
|
776 next PLATFORM; |
|
777 } |
|
778 } |
|
779 else { |
|
780 unless (grep /^$Program$/, @{$Platform::TestPrograms{$Plat}}) { |
|
781 next PLATFORM; |
|
782 } |
|
783 } |
|
784 } |
|
785 my $AbldFlagsMacroTmp=""; |
|
786 my $CompilerWrapperFlagMacroTemp=""; |
|
787 if ($Command eq "MAKEFILE") |
|
788 { # Only want ABLD_FLAGS for Makefile |
|
789 $AbldFlagsMacroTmp=$AbldFlagsMacro; |
|
790 if(exists ($Options{wrap})) |
|
791 { |
|
792 # Require ABLD_COMPWRAP_FLAG when --wrap option is specified |
|
793 $CompilerWrapperFlagMacroTemp = $CompilerWrapperFlagMacro; |
|
794 } |
|
795 } |
|
796 foreach my $makefileVariation (@{$MakefileVariations{$Plat}}) { |
|
797 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
798 |
|
799 if ( ($Command eq "TARGET") && (-e $PerlLibPath . "tracecompiler.pl") ) |
|
800 { |
|
801 not scalar grep(/tracecompiler\.pl $Plat/,@Calls) and push @Calls, "perl " . $PerlLibPath . "tracecompiler.pl $Plat $Program"; |
|
802 } |
|
803 push @Calls, "$ENV{MAKE} -r $KeepgoingFlag -f \"$PrjBldDir$Plat$makefileVariation$Test.make\"" |
|
804 ." $Command$Program$CFG$Source$VerboseMacro" . |
|
805 "$KeepgoingMacro$RemoveMacro$NoDependencyMacro" . |
|
806 "$AbldFlagsMacroTmp$CompilerWrapperFlagMacroTemp"; |
|
807 |
|
808 #Compiler Wrapper support |
|
809 if ( exists($Options{wrap}) && ($Options{wrap} eq "") && ($Command eq "TARGET") ) |
|
810 { |
|
811 my $CFGCOMPWRAP=''; |
|
812 if ($LoopBld ne 'IRRELEVANT') |
|
813 { |
|
814 $CFGCOMPWRAP =" CFG=COMPWRAP".$LoopBld; |
|
815 } |
|
816 push @Calls, "$ENV{MAKE} -r $KeepgoingFlag -f \"$PrjBldDir$Plat$makefileVariation$Test.make\""." TARGET$Program$CFGCOMPWRAP"; |
|
817 } |
|
818 } |
|
819 else { |
|
820 push @Calls, "make -r $KeepgoingFlag -f \"$PrjBldDir$Plat$makefileVariation$Test.make\"" |
|
821 ." $Command$Program$CFG$Source$VerboseMacro" . |
|
822 "$KeepgoingMacro$RemoveMacro$NoDependencyMacro" . |
|
823 "$AbldFlagsMacroTmp$CompilerWrapperFlagMacroTemp"; |
|
824 |
|
825 #Compiler Wrapper support |
|
826 if ( exists($Options{wrap}) && ($Options{wrap} eq "") && ($Command eq "TARGET") ) |
|
827 { |
|
828 my $CFGCOMPWRAP=''; |
|
829 if ($LoopBld ne 'IRRELEVANT') |
|
830 { |
|
831 $CFGCOMPWRAP =" CFG=COMPWRAP".$LoopBld; |
|
832 } |
|
833 push @Calls, "make -r $KeepgoingFlag -f \"$PrjBldDir$Plat$makefileVariation$Test.make\""." TARGET$Program$CFGCOMPWRAP"; |
|
834 } |
|
835 } |
|
836 } |
|
837 next; |
|
838 } |
|
839 |
|
840 unless (${$Commands{$Command}}{what}) { |
|
841 next COMMAND; |
|
842 } |
|
843 if ($Program) { # skip programs if they're not supported for a platform |
|
844 unless ($Test) { |
|
845 unless (grep /^$Program$/, @{$Platform::Programs{$Plat}}) { |
|
846 next PLATFORM; |
|
847 } |
|
848 } |
|
849 else { |
|
850 unless (grep /^$Program$/, @{$Platform::TestPrograms{$Plat}}) { |
|
851 next PLATFORM; |
|
852 } |
|
853 } |
|
854 } |
|
855 my $Makefile=''; |
|
856 if ($Command=~/MAKEFILE$/o) { |
|
857 $Makefile='MAKEFILE'; |
|
858 } |
|
859 |
|
860 foreach my $makefileVariation (@{$MakefileVariations{$Plat}}) { |
|
861 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
862 push @Calls, "$ENV{MAKE} -r -f \"$PrjBldDir$Plat$makefileVariation$Test.make\" WHAT$Makefile$Program $CFG"; |
|
863 } |
|
864 else { |
|
865 push @Calls, "make -r -f \"$PrjBldDir$Plat$makefileVariation$Test.make\" WHAT$Makefile$Program $CFG"; |
|
866 } |
|
867 } |
|
868 } |
|
869 } |
|
870 } |
|
871 |
|
872 |
|
873 # make the required calls |
|
874 |
|
875 my $Call; |
|
876 my %checkSourceUniqueOutput; |
|
877 unless ($Options{what} or $Options{check}) { |
|
878 foreach $Call (@Calls) { |
|
879 print " $Call\n" unless ($Options{checksource} && !$Options {verbose}); |
|
880 open PIPE, "$Call |"; |
|
881 $|=1; # bufferring is disabled |
|
882 while (<PIPE>) { |
|
883 if ($Options {checksource}) |
|
884 { |
|
885 if ($Options{verbose}) |
|
886 { |
|
887 print $_; |
|
888 } |
|
889 else |
|
890 { |
|
891 $checkSourceUniqueOutput{$_} = 1; |
|
892 } |
|
893 } |
|
894 else |
|
895 { |
|
896 print; |
|
897 } |
|
898 } |
|
899 close PIPE; |
|
900 } |
|
901 |
|
902 print $_ foreach (sort keys %checkSourceUniqueOutput); |
|
903 } |
|
904 else { |
|
905 my %WhatCheck; # check for duplicates |
|
906 foreach $Call (@Calls) { |
|
907 open PIPE, "$Call |"; |
|
908 while (<PIPE>) { |
|
909 next if (/(Nothing to be done for|Entering directory|Leaving directory) \S+\.?$/o); |
|
910 # releasables split on whitespace - quotes possible -stripped out |
|
911 while (/("([^"\t\n\r\f]+)"|([^ "\t\n\r\f]+))/go) { |
|
912 my $Releasable=($2 ? $2 : $3); |
|
913 $Releasable =~ s/\//\\/g; # convert forward slash into backslash |
|
914 unless ($WhatCheck{$Releasable}) { |
|
915 $WhatCheck{$Releasable}=1; |
|
916 if ($Options{what}) { |
|
917 print "$Releasable\n"; |
|
918 } |
|
919 else { |
|
920 if (!-e $Releasable) { |
|
921 print STDERR "MISSING: $Releasable\n"; |
|
922 } |
|
923 # modified start: added functionality checkwhat |
|
924 elsif ($Options{checkwhat}) { |
|
925 print "$Releasable\n"; |
|
926 } |
|
927 # modified end: added functionality checkwhat |
|
928 } |
|
929 } |
|
930 } |
|
931 } |
|
932 close PIPE; |
|
933 } |
|
934 } |
|
935 } |
|
936 |
|
937 sub Usage () { |
|
938 print <<ENDHERESTRING; |
|
939 Common usage : abld [test] command [options] [platform[.Feature Variant]] [build] [program] |
|
940 where command is build, target, etc. |
|
941 (type \"abld help commands\" for a list of commands) |
|
942 where options are -c, -k, etc. |
|
943 (type \"abld help options\" for a list of options) |
|
944 where parameters depend upon the command |
|
945 (type \"abld help <command>\" for command-specific help) |
|
946 where parameters default to 'ALL' if unspecified |
|
947 ENDHERESTRING |
|
948 |
|
949 print |
|
950 "project platforms:\n", |
|
951 " @Platform::Plats\n" |
|
952 ; |
|
953 |
|
954 if (%Platform::FeatureVariantSupportingPlats) |
|
955 { |
|
956 my @featureVariants; |
|
957 |
|
958 foreach my $featureVariantSupportingPlat (keys %Platform::FeatureVariantSupportingPlats) |
|
959 { |
|
960 push @featureVariants, $featureVariantSupportingPlat.".".$_ foreach (featurevariantparser->GetValidVariants()); |
|
961 } |
|
962 |
|
963 if (@featureVariants) |
|
964 { |
|
965 @featureVariants = map{uc($_)} @featureVariants; |
|
966 print |
|
967 "feature variant platforms:\n", |
|
968 " @featureVariants\n"; |
|
969 } |
|
970 } |
|
971 exit 1; |
|
972 } |
|
973 |
|
974 # modified start: added functionality checkwhat |
|
975 sub Options () { |
|
976 print <<ENDHERESTRING; |
|
977 Options (case-insensitive) : |
|
978 -c or -check check the releasables are present |
|
979 -cw or -checkwhat combined check and what |
|
980 -k or -keepgoing build unrelated targets on error |
|
981 -s or -savespace delete intermediate files on success |
|
982 -v or -verbose display tools calls as they happen |
|
983 -w or -what list the releasables |
|
984 -r or -remove allow FREEZE to remove exports |
|
985 -i thumb or -i arm override for build ARMV5 platform options |
|
986 -cs or -checksource checks source conformance to Symbian's filename policy |
|
987 -debug or -no_debug enable/disable generation of symbolic debug information for ARM ABI compliant platforms |
|
988 -fc or -logfc enable function call logging |
|
989 -wrap[=proxy] enable invocation of external wrapper tool |
|
990 |
|
991 possible combinations : |
|
992 (([-check]|[-what]|[-checkwhat])|([-k][-s][-v][-i [thumb|arm]][-cs][-debug|-no_debug][-fc][-wrap[=proxy]])) |
|
993 ENDHERESTRING |
|
994 |
|
995 exit; |
|
996 |
|
997 } |
|
998 # modified end: added functionality checkwhat |
|
999 |
|
1000 sub Help ($) { |
|
1001 my ($Command)=@_; |
|
1002 |
|
1003 my %CommandHash=%{$Commands{$Command}}; |
|
1004 |
|
1005 print 'ABLD'; |
|
1006 unless ($CommandHash{notest}) { |
|
1007 print ' [test]'; |
|
1008 } |
|
1009 print " $Command "; |
|
1010 if ($Command eq 'HELP') { |
|
1011 print '([OPTIONS|COMMANDS]|[<command>])'; |
|
1012 } |
|
1013 else { |
|
1014 if ($CommandHash{what}) { |
|
1015 print '(([-c]|[-w])|'; |
|
1016 } |
|
1017 if ($CommandHash{savespace}) { |
|
1018 print '[-s]'; |
|
1019 } |
|
1020 if ($CommandHash{instructionset}) { |
|
1021 print '[-i thumb|arm]'; |
|
1022 } |
|
1023 if ($CommandHash{remove}) { |
|
1024 print '[-r]'; |
|
1025 } |
|
1026 if ($CommandHash{checksource}) { |
|
1027 print '[-cs]'; |
|
1028 } |
|
1029 unless ($CommandHash{nokeepgoing}) { |
|
1030 print '[-k]'; |
|
1031 } |
|
1032 unless ($CommandHash{noverbose}) { |
|
1033 print '[-v]'; |
|
1034 } |
|
1035 if ($CommandHash{debug}) { |
|
1036 print '[-debug|-no_debug]'; |
|
1037 } |
|
1038 if ($CommandHash{logfc}) { |
|
1039 print '[-logfc]|[-fc]'; |
|
1040 } |
|
1041 if ($CommandHash{what}) { |
|
1042 print '))'; |
|
1043 } |
|
1044 unless ($CommandHash{noplatform}) { |
|
1045 print ' [<platform>]'; |
|
1046 } |
|
1047 if ($CommandHash{build}) { |
|
1048 print ' [<build>]'; |
|
1049 } |
|
1050 if ($CommandHash{program}) { |
|
1051 print ' [<program>]'; |
|
1052 } |
|
1053 if ($CommandHash{source}) { |
|
1054 print ' [<source>]'; |
|
1055 } |
|
1056 if ($CommandHash{wrap}) { |
|
1057 print '[-wrap[=proxy]]'; |
|
1058 } |
|
1059 } |
|
1060 |
|
1061 print |
|
1062 "\n", |
|
1063 "\n", |
|
1064 "$CommandHash{function}\n" |
|
1065 ; |
|
1066 exit; |
|
1067 } |
|
1068 |
|
1069 sub Commands () { |
|
1070 |
|
1071 print "Commands (case-insensitive):\n"; |
|
1072 foreach (sort keys %Commands) { |
|
1073 next if ${$Commands{$_}}{hidden}; |
|
1074 my $Tmp=$_; |
|
1075 while (length($Tmp) < 12) { |
|
1076 $Tmp.=' '; |
|
1077 } |
|
1078 print " $Tmp ${$Commands{$_}}{function}\n"; |
|
1079 } |
|
1080 |
|
1081 exit; |
|
1082 } |
|
1083 |
|
1084 sub GetMakefileVariations ($$) |
|
1085 { |
|
1086 my ($plat, $featureVariantArg) = @_; |
|
1087 my @variations = (); |
|
1088 |
|
1089 if (!$featureVariantArg) |
|
1090 { |
|
1091 push @variations, ""; |
|
1092 } |
|
1093 else |
|
1094 { |
|
1095 my @resolvedVariants = featurevariantparser->ResolveFeatureVariant($featureVariantArg); |
|
1096 # modified start: makefile improvement |
|
1097 my %temp_hash =("default" => ""); |
|
1098 foreach (@resolvedVariants){ |
|
1099 $temp_hash{$_}=""; |
|
1100 } |
|
1101 push @variations, ".".$_ foreach (keys %temp_hash); |
|
1102 } |
|
1103 # modified end: makefile improvement |
|
1104 return \@variations; |
|
1105 } |
|
1106 |
|
1107 |