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