|
1 # Copyright (c) 2001-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 # this package contains generic routines to handle bits of makefiles which are |
|
15 # common to all of the platforms. Currently it deals with AIF, MBM amd RSC files. |
|
16 # |
|
17 # |
|
18 |
|
19 package cl_generic; |
|
20 |
|
21 require Exporter; |
|
22 @ISA=qw(Exporter); |
|
23 @EXPORT=qw( |
|
24 Generic_Define |
|
25 Generic_Definition |
|
26 Generic_MakeWorkDir |
|
27 Generic_MakeWorkFile |
|
28 Generic_Quote |
|
29 Generic_Header |
|
30 Generic_Releaseables |
|
31 Generic_BitMapBld |
|
32 Generic_ResrcBld |
|
33 Generic_AifBld |
|
34 Generic_End |
|
35 Generic_CopyAction |
|
36 Generic_WhatCleanTargets |
|
37 Generic_WhatTargets |
|
38 Generic_CleanTargets |
|
39 ); |
|
40 |
|
41 use strict; |
|
42 use File::Basename; |
|
43 use lockit_info; |
|
44 use CheckSource; |
|
45 use E32Variant; |
|
46 |
|
47 my $SavedBldPath; |
|
48 my $MakefileType=0; # 0=NMAKE, 1=MAKE |
|
49 my %CheckSourceResourceIncludes; |
|
50 |
|
51 sub Generic_Header ($$;$) { |
|
52 my ($UseRltPaths, $makefileType, $supportAbsPathConversion) = @_; |
|
53 |
|
54 $MakefileType=($makefileType eq "nmake")? 0:1; |
|
55 |
|
56 my $LibSubDir="UDEB"; |
|
57 if (&main::PlatOS eq 'EPOC32') { |
|
58 $LibSubDir="UREL"; |
|
59 } |
|
60 elsif (&main::PlatOS eq 'TOOLS2') { |
|
61 $LibSubDir="LIB"; |
|
62 } |
|
63 |
|
64 my $BldPath=&main::BldPath; |
|
65 |
|
66 if ( LocalBuildPathExists() ) { |
|
67 $BldPath = ConvertToLocalBuild($BldPath); |
|
68 } |
|
69 |
|
70 # Get the information regarding supporting Compiler Wrapper option |
|
71 my $IsCompilerWrapperOption=&main::CompilerWrapperOption(); |
|
72 my $RelPath=&main::RelPath; |
|
73 my $LibPath=&main::LibPath; |
|
74 my $LinkPath=&main::LinkPath; |
|
75 my $StatLinkPath=&main::StatLinkPath; |
|
76 my $ASSPLinkPath=&main::ASSPLinkPath; |
|
77 |
|
78 $SavedBldPath=&main::Path_Chop($BldPath); |
|
79 |
|
80 if ($UseRltPaths) { |
|
81 |
|
82 if ( ! LocalBuildPathExists() ) { |
|
83 # Local build does not exists so keep relative path. |
|
84 $BldPath =&main::Path_RltToWork($BldPath); |
|
85 } |
|
86 |
|
87 $RelPath =&main::Path_RltToWork($RelPath); |
|
88 $LibPath =&main::Path_RltToWork($LibPath); |
|
89 $LinkPath =&main::Path_RltToWork($LinkPath); |
|
90 $StatLinkPath=&main::Path_RltToWork($StatLinkPath); |
|
91 $ASSPLinkPath=&main::Path_RltToWork($ASSPLinkPath); |
|
92 } |
|
93 |
|
94 $BldPath=&main::Path_Chop($BldPath); |
|
95 $RelPath=&main::Path_Chop($RelPath); |
|
96 $LibPath=&main::Path_Chop($LibPath); |
|
97 $LinkPath=&main::Path_Chop($LinkPath); |
|
98 $StatLinkPath=&main::Path_Chop($StatLinkPath); |
|
99 $ASSPLinkPath=&main::Path_Chop($ASSPLinkPath); |
|
100 |
|
101 my $EPOCDataPath=&main::Path_Chop(&main::EPOCDataPath); |
|
102 my $EPOCIncPath=&main::Path_Chop(&main::EPOCIncPath); |
|
103 my $DataPath=&main::Path_Chop(&main::DataPath); |
|
104 my $TrgPath=&main::Path_Chop(&main::TrgPath); |
|
105 |
|
106 my $erasedefn = "\@erase"; |
|
107 $erasedefn = "\@erase 2>>nul" if ($ENV{OS} eq "Windows_NT"); |
|
108 |
|
109 &main::Output( |
|
110 "\n", |
|
111 '# CWD ', &main::Path_WorkPath, "\n", |
|
112 '# MMPFile ', &main::MmpFile, "\n", |
|
113 '# Target ', &main::Trg, "\n", |
|
114 '# TargetType ', &main::TrgType, "\n", |
|
115 '# BasicTargetType ', &main::BasicTrgType, "\n", |
|
116 '# MakefileType ', ($MakefileType==1)? "GNU":"NMAKE", "\n" |
|
117 ); |
|
118 |
|
119 my @BldList=&main::BldList; |
|
120 my %featureVariantInfo = &main::FeatureVariantInfo; |
|
121 |
|
122 if (%featureVariantInfo) |
|
123 { |
|
124 &main::Output("# FeatureVariantName ", $featureVariantInfo{NAME}, "\n"); |
|
125 |
|
126 foreach (@BldList) |
|
127 { |
|
128 &main::Output("# FeatureVariant".$_."Label ", $featureVariantInfo{$_."_LABEL"}, "\n"); |
|
129 } |
|
130 } |
|
131 |
|
132 &main::Output( |
|
133 "\n", |
|
134 "ERASE = $erasedefn\n", |
|
135 "\n" |
|
136 ); |
|
137 |
|
138 # Include function to perform optional DOS to Unix slash conversion |
|
139 # on absolute paths if requested from backend. |
|
140 if ($supportAbsPathConversion) { |
|
141 &main::Output( |
|
142 "ifeq \"\$(UNIX_SLASH_FOR_CC_ABS_PATHS)\" \"1\"\n", |
|
143 "define absolutePaths\n", |
|
144 "\$(subst \\,\/,\$1)\n", |
|
145 "endef\n", |
|
146 "else\n", |
|
147 "define absolutePaths\n", |
|
148 "\$1\n", |
|
149 "endef\n", |
|
150 "endif\n", |
|
151 "\n" |
|
152 ); |
|
153 } |
|
154 |
|
155 &main::Output( |
|
156 "# EPOC DEFINITIONS\n", |
|
157 "\n" |
|
158 ); |
|
159 |
|
160 Generic_Define("EPOCBLD", $BldPath); |
|
161 if (defined $ENV{PBUILDPID}) { |
|
162 my $BldPathP = $BldPath . '$(PBUILDPID)'; |
|
163 Generic_Define("EPOCBLDP", $BldPathP); |
|
164 } else { |
|
165 Generic_Define("EPOCBLDP", $BldPath); |
|
166 } |
|
167 Generic_Define("EPOCTRG", $RelPath); |
|
168 Generic_Define("EPOCLIB", $LibPath); |
|
169 Generic_Define("EPOCLINK", $LinkPath); |
|
170 Generic_Define("EPOCSTATLINK", $StatLinkPath); |
|
171 Generic_Define("EPOCBSFSTATLINK", $RelPath); |
|
172 Generic_Define("EPOCASSPLINK", $ASSPLinkPath); |
|
173 |
|
174 Generic_Define("EPOCDATA", $EPOCDataPath); |
|
175 Generic_Define("EPOCINC", $EPOCIncPath); |
|
176 Generic_Define("TRGDIR", $TrgPath); |
|
177 Generic_Define("DATADIR", $DataPath); |
|
178 |
|
179 |
|
180 foreach (@BldList) { |
|
181 &main::Output("\n"); |
|
182 |
|
183 my $bldOffset = ""; |
|
184 $bldOffset .= $featureVariantInfo{$_."_LABEL"}."\\" if (%featureVariantInfo && !$featureVariantInfo{INVARIANT}); |
|
185 |
|
186 Generic_Define("EPOCBLD$_", "\$(EPOCBLD)\\".$bldOffset.lc($_)); |
|
187 if (defined $ENV{PBUILDPID}) { |
|
188 Generic_Define("EPOCBLDP$_", "\$(EPOCBLDP)\\".$bldOffset.lc($_)); |
|
189 } else { |
|
190 Generic_Define("EPOCBLDP$_", "\$(EPOCBLD)\\".$bldOffset.lc($_)); |
|
191 } |
|
192 Generic_Define("EPOCTRG$_", "\$(EPOCTRG)\\".lc($_)); |
|
193 Generic_Define("EPOCLIB$_", "\$(EPOCLIB)\\".lc($LibSubDir)); |
|
194 Generic_Define("EPOCLINK$_", "\$(EPOCLINK)\\".lc($LibSubDir)); |
|
195 Generic_Define("EPOCSTATLINK$_", "\$(EPOCSTATLINK)\\".lc($_)); |
|
196 Generic_Define("EPOCBSFSTATLINK$_","\$(EPOCBSFSTATLINK)\\".lc($_)); |
|
197 Generic_Define("EPOCASSPLINK$_", "\$(EPOCASSPLINK)\\".lc($LibSubDir)); |
|
198 } |
|
199 |
|
200 # Compiler Wrapper option support |
|
201 # Generate the information Compiler Wrapper options in second level make file. |
|
202 if($IsCompilerWrapperOption) |
|
203 { |
|
204 &main::Output( |
|
205 "\n\n", |
|
206 "#COMPILER WRAPPER OPTION DEFINITIONS\n", |
|
207 "COMPWRAP = ", |
|
208 "$ENV{ABLD_COMPWRAP}", # Extract the tool name from environment variable |
|
209 "\n\n" |
|
210 ); |
|
211 } |
|
212 # Compiler Wrapper option |
|
213 |
|
214 my $gccxml; |
|
215 if (&main::Plat =~ /gccxml/i){ |
|
216 $gccxml = &main::Plat; |
|
217 } |
|
218 |
|
219 my $edg; |
|
220 if (&main::Plat =~ /edg/i){ |
|
221 $edg = &main::Plat; |
|
222 } |
|
223 |
|
224 &main::Output( |
|
225 "\n", |
|
226 "# EPOC PSEUDOTARGETS\n", |
|
227 "\n" |
|
228 ); |
|
229 |
|
230 foreach (@BldList) { |
|
231 if(!$edg){ |
|
232 &main::Output( |
|
233 "$_ : MAKEWORK$_ RESOURCE$_\n\n" |
|
234 ); |
|
235 } |
|
236 else { |
|
237 &main::Output( |
|
238 "$_ : MAKEWORK$_ \n\n" |
|
239 ); |
|
240 } |
|
241 } |
|
242 |
|
243 &main::Output( # ALL comes after DEB: because first target in makefile is the default |
|
244 "ALL :" |
|
245 ); |
|
246 foreach (@BldList) { |
|
247 &main::Output( |
|
248 " $_" |
|
249 ); |
|
250 } |
|
251 # # Compiler Wrapper option support |
|
252 if($IsCompilerWrapperOption) |
|
253 { |
|
254 &main::Output( # ALL comes after DEB: because first target in makefile is the default |
|
255 "\n\nCOMPWRAPALL : COMPWRAPUREL COMPWRAPUDEB" |
|
256 ); |
|
257 |
|
258 } |
|
259 |
|
260 &main::Output( |
|
261 "\n", |
|
262 "\n", |
|
263 "CLEAN CLEANALL : CLEANBUILD CLEANRELEASE CLEANLIBRARY\n", |
|
264 "\n" |
|
265 ); |
|
266 my $pseudoTarget; |
|
267 foreach $pseudoTarget ("WHAT", "RESOURCE", "CLEANBUILD", "CLEANRELEASE", |
|
268 "MAKEWORK", "LISTING") |
|
269 { |
|
270 if(($gccxml && $pseudoTarget eq "RESOURCE") || |
|
271 !($gccxml || $edg)){ |
|
272 |
|
273 &main::Output( |
|
274 "\n", |
|
275 "\n", |
|
276 "$pseudoTarget $pseudoTarget","ALL :" |
|
277 ); |
|
278 foreach (@BldList) { |
|
279 &main::Output( |
|
280 " $pseudoTarget$_" |
|
281 ); |
|
282 } |
|
283 } |
|
284 } |
|
285 if($gccxml){ |
|
286 &main::Output( |
|
287 "\n", |
|
288 "\n", |
|
289 ); |
|
290 } |
|
291 |
|
292 if(!($gccxml || $edg)){ |
|
293 &main::Output( |
|
294 "\n", |
|
295 "\n", |
|
296 "MAKEWORK : MAKEWORKLIBRARY\n", |
|
297 "\n" |
|
298 ); |
|
299 } |
|
300 if(!$edg){ |
|
301 foreach (@BldList) { |
|
302 &main::Output( |
|
303 "RESOURCE$_ " |
|
304 ); |
|
305 } |
|
306 &main::Output( |
|
307 ": GENERIC_RESOURCE\n", |
|
308 "\n" |
|
309 ); |
|
310 } |
|
311 } |
|
312 |
|
313 # Quote name if necessary, according to the type of Makefile |
|
314 |
|
315 sub Generic_Quote ($) { |
|
316 my ($name)=@_; |
|
317 if ($MakefileType==1) { |
|
318 # GNU make wants backslash before each space |
|
319 $name =~ s/ /\\ /go; |
|
320 } else { |
|
321 # NMAKE prefers quotes around all filenames |
|
322 $name = "\"$name\""; |
|
323 } |
|
324 return $name; |
|
325 } |
|
326 |
|
327 # Generic file copying action, which uses built-in variables quoted appropriately |
|
328 # |
|
329 # GNU make variables may contain spaces, but perl.exe will be executed directly |
|
330 # and so doesn't need any quotes. |
|
331 |
|
332 sub Generic_CopyAction($) { |
|
333 my ($target) = @_; |
|
334 my $source = '$?'; |
|
335 $target = '$@' if (!defined $target); |
|
336 return "perl -w -S ecopyfile.pl $source $target\n"; |
|
337 } |
|
338 |
|
339 # Record necessary directories, for eventual emkdir.pl rules |
|
340 # Also need to record related defines, to eliminate duplicates |
|
341 |
|
342 my %DirDefines; |
|
343 sub expandDefines ($) { |
|
344 my ($value)=@_; |
|
345 while ($value =~ /^(.*?)\$\((\w+)\)(.*)$/) { |
|
346 last if ($2 eq 'PBUILDPID'); |
|
347 $value="$1$DirDefines{$2}$3"; |
|
348 } |
|
349 return $value; |
|
350 } |
|
351 sub Generic_Define ($$;$) { |
|
352 my ($name, $value, $trailer)=@_; |
|
353 $trailer="" if (! defined $trailer); |
|
354 &main::Output( |
|
355 "$name = $value$trailer\n" |
|
356 ); |
|
357 $DirDefines{$name}=expandDefines($value); |
|
358 } |
|
359 sub Generic_Definition ($) { |
|
360 return $DirDefines{$_[0]}; |
|
361 } |
|
362 |
|
363 my %MkDirs; |
|
364 sub Generic_MkDir ($) { |
|
365 my $dir=&main::Path_Chop(&expandDefines($_[0])); |
|
366 $dir = lc $dir; |
|
367 $dir =~ s/\$\(pbuildpid\)/\$\(PBUILDPID\)/g; |
|
368 $MkDirs{$dir}=1; |
|
369 return $dir; |
|
370 } |
|
371 |
|
372 # Accumulate MAKEWORK targets and lists of directories, |
|
373 # automatically filling in the rest of the details. |
|
374 # |
|
375 my %MakeWork; |
|
376 sub Generic_MakeWorkDir($$) { |
|
377 my ($work, $dir) = @_; |
|
378 |
|
379 if ( LocalBuildPathExists() ) { |
|
380 $dir = ConvertToLocalBuild($dir); |
|
381 } |
|
382 |
|
383 my $workhash; |
|
384 if (defined $MakeWork{$work}) { |
|
385 $workhash=$MakeWork{$work}; |
|
386 } else { |
|
387 my %newhash; |
|
388 $workhash=\%newhash; |
|
389 $MakeWork{$work}=$workhash; |
|
390 } |
|
391 my $normdir=lc &main::Path_Chop(&expandDefines($dir)); |
|
392 $normdir =~ s/\$\(pbuildpid\)/\$\(PBUILDPID\)/g; |
|
393 $$workhash{$normdir} ||= &Generic_MkDir($dir); |
|
394 } |
|
395 |
|
396 sub Generic_MakeWorkFile($$) { |
|
397 my ($work, $file) = @_; |
|
398 my $dir=&main::Path_Split('Path',&expandDefines($file)); |
|
399 &Generic_MakeWorkDir($work,$dir); |
|
400 } |
|
401 |
|
402 |
|
403 sub Generic_WhatTargets($$@) |
|
404 { |
|
405 my ($prefix, $whattarget, @files)=@_; |
|
406 |
|
407 if ((scalar @files) == 0) { |
|
408 &main::Output( |
|
409 "\n", |
|
410 "\n$whattarget :\n", |
|
411 "\t\@rem none\n" |
|
412 ); |
|
413 } else { |
|
414 # emit list of releasables in batches to avoid overflowing the 2048 character |
|
415 # batch file line limit doing echo or erase... |
|
416 |
|
417 my $count=1; |
|
418 my $length=0; |
|
419 &main::Output( |
|
420 "\n", |
|
421 "${prefix}_RELEASEABLES$count=" |
|
422 ); |
|
423 |
|
424 my $File; |
|
425 |
|
426 foreach $File (sort @files) { |
|
427 my $name = &Generic_Quote($File); |
|
428 my $namelen = length($name)+3; # for space, newline and tab |
|
429 if ($length+$namelen > 1700) { # very conservative limit |
|
430 $count++; |
|
431 $length=0; |
|
432 &main::Output( |
|
433 "\n", |
|
434 "${prefix}_RELEASEABLES$count=" |
|
435 ); |
|
436 } |
|
437 &main::Output( |
|
438 " \\\n\t", $name |
|
439 ); |
|
440 $length += $namelen; |
|
441 } |
|
442 &main::Output( |
|
443 "\n", |
|
444 "\n", |
|
445 "$whattarget:\n" |
|
446 ); |
|
447 my $filecount=1; |
|
448 while ($filecount<=$count) { |
|
449 &main::Output( |
|
450 "\t\@echo \$(${prefix}_RELEASEABLES$filecount)\n" |
|
451 ); |
|
452 $filecount++; |
|
453 } |
|
454 } |
|
455 |
|
456 &main::Output( |
|
457 "\n", |
|
458 ); |
|
459 } |
|
460 |
|
461 sub Generic_CleanTargets($$@) { |
|
462 my ($prefix, $cleantarget, @files)=@_; |
|
463 |
|
464 if ((scalar @files) == 0) { |
|
465 &main::Output( |
|
466 "\n", |
|
467 "\n$cleantarget :\n", |
|
468 "\t\@rem none\n" |
|
469 ); |
|
470 } else { |
|
471 # emit list of releasables in batches to avoid overflowing the 2048 character |
|
472 # batch file line limit doing echo or erase... |
|
473 |
|
474 my $count=1; |
|
475 my $length=0; |
|
476 &main::Output( |
|
477 "\n", |
|
478 "${prefix}_CLEANTARGETS$count=" |
|
479 ); |
|
480 |
|
481 my $File; |
|
482 |
|
483 foreach $File (sort @files) { |
|
484 my $name = &Generic_Quote($File); |
|
485 my $namelen = length($name)+3; # for space, newline and tab |
|
486 if ($length+$namelen > 1700) { # very conservative limit |
|
487 $count++; |
|
488 $length=0; |
|
489 &main::Output( |
|
490 "\n", |
|
491 "${prefix}_CLEANTARGETS$count=" |
|
492 ); |
|
493 } |
|
494 if (!main::NoExportLibrary || ($name !~ /.dso$/i && $name !~ /.lib$/i)) |
|
495 { |
|
496 &main::Output( |
|
497 " \\\n\t", $name |
|
498 ); |
|
499 $length += $namelen; |
|
500 } |
|
501 } |
|
502 &main::Output( |
|
503 "\n", |
|
504 "\n", |
|
505 "$cleantarget:\n", |
|
506 ); |
|
507 my $filecount=1; |
|
508 while ($filecount<=$count) { |
|
509 &main::Output( |
|
510 "\t-\$(ERASE) \$(${prefix}_CLEANTARGETS$filecount)\n" |
|
511 ); |
|
512 $filecount++; |
|
513 } |
|
514 } |
|
515 |
|
516 &main::Output( |
|
517 "\n", |
|
518 ); |
|
519 } |
|
520 |
|
521 sub Generic_WhatCleanTargets($$$@) { |
|
522 my ($prefix, $whattarget, $cleantarget, @files)=@_; |
|
523 |
|
524 if ((scalar @files) == 0) { |
|
525 &main::Output( |
|
526 "\n", |
|
527 "\n$whattarget $cleantarget :\n", |
|
528 "\t\@rem none\n" |
|
529 ); |
|
530 } else { |
|
531 # emit list of releasables in batches to avoid overflowing the 2048 character |
|
532 # batch file line limit doing echo or erase... |
|
533 |
|
534 my $count=1; |
|
535 my $length=0; |
|
536 &main::Output( |
|
537 "\n", |
|
538 "${prefix}_RELEASEABLES$count=" |
|
539 ); |
|
540 |
|
541 my $File; |
|
542 |
|
543 foreach $File (sort @files) { |
|
544 my $name = &Generic_Quote($File); |
|
545 my $namelen = length($name)+3; # for space, newline and tab |
|
546 if ($length+$namelen > 1700) { # very conservative limit |
|
547 $count++; |
|
548 $length=0; |
|
549 &main::Output( |
|
550 "\n", |
|
551 "${prefix}_RELEASEABLES$count=" |
|
552 ); |
|
553 } |
|
554 &main::Output( |
|
555 " \\\n\t", $name |
|
556 ); |
|
557 $length += $namelen; |
|
558 } |
|
559 &main::Output( |
|
560 "\n", |
|
561 "\n", |
|
562 "$whattarget:\n" |
|
563 ); |
|
564 my $filecount=1; |
|
565 while ($filecount<=$count) { |
|
566 &main::Output( |
|
567 "\t\@echo \$(${prefix}_RELEASEABLES$filecount)\n" |
|
568 ); |
|
569 $filecount++; |
|
570 } |
|
571 &main::Output( |
|
572 "\n", |
|
573 "$cleantarget:\n", |
|
574 ); |
|
575 $filecount=1; |
|
576 while ($filecount<=$count) { |
|
577 &main::Output( |
|
578 "\t-\$(ERASE) \$(${prefix}_RELEASEABLES$filecount)\n" |
|
579 ); |
|
580 $filecount++; |
|
581 } |
|
582 } |
|
583 |
|
584 &main::Output( |
|
585 "\n", |
|
586 ); |
|
587 } |
|
588 |
|
589 # accumulated list of generic releasables |
|
590 my %Files; |
|
591 sub Generic_End { |
|
592 &Generic_WhatCleanTargets("GENERIC","WHATGENERIC","CLEANGENERIC", keys %Files); |
|
593 |
|
594 &main::Output( |
|
595 "# Rules to create all necessary directories\n", |
|
596 ); |
|
597 |
|
598 foreach (sort keys %MakeWork) { |
|
599 my $workhash = $MakeWork{$_}; |
|
600 &main::Output( |
|
601 "\n$_ :", |
|
602 ); |
|
603 foreach (sort keys %$workhash) { |
|
604 my $withcase=$$workhash{$_}; |
|
605 if ($withcase =~ /\$\(PBUILDPID\)\\/) { |
|
606 &main::Output( |
|
607 " \\\n", |
|
608 "\t\$(if \$(PBUILDPID),", &Generic_Quote($withcase), ")" |
|
609 ); |
|
610 } else { |
|
611 &main::Output( |
|
612 " \\\n", |
|
613 "\t", &Generic_Quote($withcase) |
|
614 ); |
|
615 } |
|
616 } |
|
617 &main::Output( |
|
618 "\n" |
|
619 ); |
|
620 } |
|
621 &main::Output( |
|
622 "\n", |
|
623 "\n" |
|
624 ); |
|
625 |
|
626 my $dir; |
|
627 foreach $dir (sort keys %MkDirs) { |
|
628 if ($dir =~ /\$\(PBUILDPID\)\\/) { |
|
629 &main::Output( |
|
630 "\$(if \$(PBUILDPID),", &Generic_Quote($dir),") \\\n", |
|
631 ); |
|
632 } else { |
|
633 &main::Output( |
|
634 &Generic_Quote($dir)," \\\n", |
|
635 ); |
|
636 } |
|
637 } |
|
638 &main::Output( |
|
639 ":\n", |
|
640 "\tperl -w -S emkdir.pl \$\@\n", |
|
641 "\n" |
|
642 ); |
|
643 |
|
644 &main::Output( |
|
645 "CHECKSOURCE :\n", |
|
646 ); |
|
647 |
|
648 &main::Output (CheckSource_MakefileOutput(&main::CheckSourceMMPIncludes)); |
|
649 &main::Output (CheckSource_MakefileOutput(%CheckSourceResourceIncludes)); |
|
650 &main::Output (CheckSource_MakefileOutput(&main::CheckSourceMMPMetaData)); |
|
651 |
|
652 my $cs_targetprefix = ""; |
|
653 $cs_targetprefix = "U" unless (&main::Plat =~ /tools/i); |
|
654 |
|
655 &main::Output( |
|
656 "\nCHECKSOURCE".$cs_targetprefix."REL :\n", |
|
657 ); |
|
658 |
|
659 &main::Output (CheckSource_MakefileOutput(&main::CheckSourceURELIncludes)); |
|
660 |
|
661 &main::Output( |
|
662 "\nCHECKSOURCE".$cs_targetprefix."DEB :\n", |
|
663 ); |
|
664 |
|
665 &main::Output (CheckSource_MakefileOutput(&main::CheckSourceUDEBIncludes)); |
|
666 |
|
667 } |
|
668 |
|
669 sub Generic_Releaseables { |
|
670 |
|
671 my $ResrcPath=&main::TrgPath; |
|
672 my $dir; |
|
673 my $EPOCIncPath=&main::EPOCIncPath; |
|
674 |
|
675 &Generic_MakeWorkDir('GENERIC_MAKEWORK',$SavedBldPath); # used for temp directory in epocrc.pl |
|
676 |
|
677 my $AifStructRef=&main::AifStructRef; |
|
678 my $AifRef; |
|
679 foreach $AifRef (@$AifStructRef) { |
|
680 # regression change - workaround lack of AIF directory |
|
681 $$AifRef{TrgFile}=&main::Path_Split('File',$$AifRef{Trg}); # record for later |
|
682 my $path=&main::Path_Split('Path',"$ResrcPath$$AifRef{Trg}"); |
|
683 my $file="\$(EPOCDATA)\\$ResrcPath$$AifRef{Trg}"; |
|
684 my $xip="_xip"; |
|
685 my $base=&main::Path_Split('Base',"$file"); |
|
686 my $root=&main::Path_Split('Path',"$file"); |
|
687 my $ext=&main::Path_Split('Ext',"$file"); |
|
688 my $file_xip="$root"."$base$xip$ext"; # since XIP AIF format is generated |
|
689 if ($path eq "") { |
|
690 # no target path for the AIF file, so not a releasable |
|
691 $file="$SavedBldPath\\$$AifRef{Trg}"; |
|
692 } else { |
|
693 $Files{$file}=1; |
|
694 $Files{$file_xip}=1; |
|
695 } |
|
696 $$AifRef{GenericTrg}=$file; # record for later |
|
697 &Generic_MakeWorkFile('GENERIC_MAKEWORK',$file); |
|
698 } |
|
699 |
|
700 my $BitMapStructRef=&main::BitMapStructRef; |
|
701 my $BitMapRef; |
|
702 foreach $BitMapRef (@$BitMapStructRef) { |
|
703 my $path=$$BitMapRef{TrgPath}; |
|
704 my $file="\$(EPOCDATA)\\$path$$BitMapRef{Trg}"; |
|
705 $$BitMapRef{GenericTrg}=$file; # record for later |
|
706 $Files{$file}=1; |
|
707 &Generic_MakeWorkFile('GENERIC_MAKEWORK',$file); |
|
708 if ($$BitMapRef{Hdr}) { |
|
709 my $mbg=&main::Path_Split('Base', $$BitMapRef{Trg}); |
|
710 $mbg="\$(EPOCINC)\\$mbg.mbg"; |
|
711 &Generic_MakeWorkDir('GENERIC_MAKEWORK',$EPOCIncPath); |
|
712 $Files{$mbg}=1; |
|
713 } |
|
714 } |
|
715 |
|
716 my $ResourceStructRef=&main::ResourceStructRef; |
|
717 my $ResourceRef; |
|
718 foreach $ResourceRef (@$ResourceStructRef) { |
|
719 if(defined $$ResourceRef{Hdronly}) |
|
720 { |
|
721 my $rsg="\$(EPOCINC)\\$$ResourceRef{BaseTrg}.rsg"; |
|
722 $$ResourceRef{GenericTrg}=$rsg; # record for later |
|
723 |
|
724 &Generic_MakeWorkDir('GENERIC_MAKEWORK',$EPOCIncPath); |
|
725 $Files{$rsg}=1; |
|
726 } |
|
727 else |
|
728 { |
|
729 my $file="\$(EPOCDATA)\\$$ResourceRef{Trg}"; |
|
730 $$ResourceRef{GenericTrg}=$file; # record for later |
|
731 $Files{$file}=1; |
|
732 &Generic_MakeWorkFile('GENERIC_MAKEWORK',$file); |
|
733 if ($$ResourceRef{Hdr}) { |
|
734 my $rsg="\$(EPOCINC)\\$$ResourceRef{BaseTrg}.rsg"; |
|
735 &Generic_MakeWorkDir('GENERIC_MAKEWORK',$EPOCIncPath); |
|
736 $Files{$rsg}=1; |
|
737 } |
|
738 } |
|
739 } |
|
740 |
|
741 # Do StringTable 'export' |
|
742 my @stringTables = &main::StringTables(); |
|
743 foreach my $stringtable (@stringTables) |
|
744 { |
|
745 if(defined $stringtable->{ExportPath}) |
|
746 { |
|
747 $Files{$stringtable->{ExportPath}."\\".$stringtable->{BaseTrg}.".h"} = 1; |
|
748 } |
|
749 } |
|
750 |
|
751 |
|
752 &main::Output( |
|
753 "GENERIC_RESOURCE : GENERIC_MAKEWORK\n", |
|
754 "\n" |
|
755 ); |
|
756 |
|
757 } |
|
758 |
|
759 sub Generic_BitMapBld { |
|
760 |
|
761 my $BitMapRef=&main::BitMapRef; |
|
762 my $quotedTrg=&Generic_Quote($$BitMapRef{GenericTrg}); |
|
763 my $WorkPath = &main::Path_Chop(&main::Path_WorkPath); ## required for Lockit |
|
764 |
|
765 &main::Output( |
|
766 "# BitMap $$BitMapRef{Trg}\n", |
|
767 "\n", |
|
768 "GENERIC_RESOURCE : $quotedTrg\n", |
|
769 "\n", |
|
770 "$quotedTrg :" |
|
771 ); |
|
772 |
|
773 # must lower-case header here since bmconv generates a header with case-sensitive enums accordingly |
|
774 my $BitMapHdr=join('', &main::EPOCIncPath, &main::Path_Split('Base', $$BitMapRef{Trg}), '.mbg'); |
|
775 my $TmpBitMapHdr=join('', &main::BldPath, &main::Path_Split('Base', $$BitMapRef{Trg}), '.mbg'); |
|
776 |
|
777 my $SrcRef; |
|
778 foreach $SrcRef (@{$$BitMapRef{Source}}) { |
|
779 |
|
780 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
781 %Files = &Lockit_Releasables($WorkPath, $$BitMapRef{Trg}, \%Files, basename($$SrcRef{Src}),"",""); |
|
782 } |
|
783 else { |
|
784 %Files = &Lockit_Releasables($WorkPath, $$BitMapRef{Trg}, \%Files, basename($$SrcRef{Src})); |
|
785 } |
|
786 &main::Output( |
|
787 " \\\n ", &Generic_Quote($$SrcRef{Src}) |
|
788 ); |
|
789 } |
|
790 &main::Output( |
|
791 "\n", |
|
792 "\tperl -w -S epocmbm.pl -h\"$TmpBitMapHdr\"", |
|
793 "\t-o\"$$BitMapRef{GenericTrg}\"", |
|
794 "\t-l\"\\$$BitMapRef{TrgPath}:$WorkPath\"", |
|
795 "\\\n\t\t" |
|
796 ); |
|
797 &main::Output( |
|
798 " -b\"" |
|
799 ); |
|
800 foreach $SrcRef (@{$$BitMapRef{Source}}) { |
|
801 &main::Output( |
|
802 "\\\n\t\t/$$SrcRef{ClDepth}$$SrcRef{Src}" |
|
803 ); |
|
804 } |
|
805 |
|
806 |
|
807 &main::Output( |
|
808 "\" \\\n\t\t" |
|
809 ); |
|
810 |
|
811 &main::Output( |
|
812 " -l\"\\$$BitMapRef{TrgPath}:$WorkPath\"\n" |
|
813 ); |
|
814 |
|
815 if ($$BitMapRef{Hdr}) { |
|
816 &main::Output( |
|
817 "\tperl -w -S ecopyfile.pl \"$TmpBitMapHdr\" \"$BitMapHdr\"\n", |
|
818 ); |
|
819 } |
|
820 &main::Output( |
|
821 "\n" |
|
822 ); |
|
823 } |
|
824 |
|
825 sub Generic_ResrcBld { |
|
826 my $ResourceRef=&main::ResourceRef; |
|
827 my $WorkPath = &main::Path_Chop(&main::Path_WorkPath); # required for Lockit |
|
828 my @RcompMacro=&main::MmpMacros; |
|
829 |
|
830 &main::Output( |
|
831 "# Resource $$ResourceRef{Trg}\n", |
|
832 "\n" |
|
833 ); |
|
834 my @DepList=&main::DepList; |
|
835 |
|
836 &main::Output( |
|
837 "DEPEND=" |
|
838 ); |
|
839 foreach (@DepList) { |
|
840 &main::Output( |
|
841 " \\\n", |
|
842 "\t", &Generic_Quote($_) |
|
843 ); |
|
844 } |
|
845 &main::Output( |
|
846 "\n", |
|
847 "\n" |
|
848 ); |
|
849 |
|
850 my $BaseResrc= $$ResourceRef{BaseTrg}; |
|
851 my $SrcPath=&main::Path_Split('Path', $$ResourceRef{Source}); |
|
852 |
|
853 my $AbsSrc; |
|
854 my $AbsSrcPath; |
|
855 |
|
856 my $ResrcHdr=join '', &main::EPOCIncPath(), $BaseResrc, '.rsg'; |
|
857 my $AbsResrcHdr; |
|
858 my $PlatName=&main::PlatName; |
|
859 |
|
860 my @ChopAbsSysIncPaths; |
|
861 my @ChopAbsUserIncPaths; |
|
862 |
|
863 @ChopAbsSysIncPaths=&main::Path_Chop(&main::Path_AbsToWork(&main::ResourceSysIncPaths)); |
|
864 @ChopAbsUserIncPaths=&main::Path_Chop(&main::Path_AbsToWork(&main::UserIncPaths)); |
|
865 |
|
866 $AbsSrc=&main::Path_AbsToWork($$ResourceRef{Source}); |
|
867 $AbsSrcPath=&main::Path_AbsToWork($SrcPath); |
|
868 $AbsResrcHdr=&main::Path_AbsToWork($ResrcHdr); |
|
869 |
|
870 my $ChopAbsSrcPath=&main::Path_Chop($AbsSrcPath); |
|
871 |
|
872 my $EPOCDataDir = &main::Path_Chop($$ResourceRef{TrgPath}); |
|
873 |
|
874 my $RscOption= ""; |
|
875 my $HeaderOption = ""; |
|
876 my $HeaderCopyCmd = ""; |
|
877 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
878 if ($$ResourceRef{Hdr} || $$ResourceRef{Hdronly}) { |
|
879 $HeaderOption = " -h\"$SavedBldPath\\$BaseResrc$$ResourceRef{Lang}.rsg\""; |
|
880 $HeaderCopyCmd = "\tperl -w -S ecopyfile.pl \"$SavedBldPath\\$BaseResrc$$ResourceRef{Lang}.rsg\" \"$ResrcHdr\"\n"; |
|
881 } |
|
882 |
|
883 } |
|
884 else { |
|
885 if ($$ResourceRef{Hdr} || $$ResourceRef{Hdronly}) { |
|
886 $HeaderOption = " -h\"$SavedBldPath\\$BaseResrc.rsg\""; |
|
887 $HeaderCopyCmd = "\tperl -w -S ecopyfile.pl \"$SavedBldPath\\$BaseResrc.rsg\" \"$ResrcHdr\"\n"; |
|
888 } |
|
889 } |
|
890 if (! $$ResourceRef{Hdronly}) { |
|
891 $RscOption = " -o\$\@ "; |
|
892 } |
|
893 |
|
894 my $Uidsref=$$ResourceRef{Uids}; |
|
895 my @Uids=(); |
|
896 @Uids = @{$Uidsref} if (defined($Uidsref)); |
|
897 my $Uidsarg=""; |
|
898 if ($#Uids>0) { |
|
899 $Uidsarg="-uid2 $Uids[0] -uid3 $Uids[1]"; |
|
900 } |
|
901 elsif ($#Uids==0) { |
|
902 $Uidsarg="-uid2 $Uids[0] "; |
|
903 } |
|
904 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
905 %Files = &Lockit_Releasables($WorkPath, $$ResourceRef{Source}, \%Files, "", $$ResourceRef{Lang}) unless $$ResourceRef{Hdronly}; |
|
906 } |
|
907 else { |
|
908 %Files = &Lockit_Releasables($WorkPath,$$ResourceRef{Source}, \%Files, "") unless $$ResourceRef{Hdronly}; |
|
909 } |
|
910 my $quotedTrg=&Generic_Quote($$ResourceRef{GenericTrg}); |
|
911 &main::Output( |
|
912 "GENERIC_RESOURCE : $quotedTrg\n", |
|
913 "\n", |
|
914 "$quotedTrg : ", &Generic_Quote($AbsSrc), " \$(DEPEND)\n", |
|
915 "\tperl -w -S epocrc.pl -m045,046,047 -I \"$ChopAbsSrcPath\"" |
|
916 ); |
|
917 foreach (@ChopAbsUserIncPaths) { |
|
918 &main::Output( |
|
919 " -I \"$_\"" |
|
920 ); |
|
921 } |
|
922 &main::Output( |
|
923 " -I-" |
|
924 ); |
|
925 foreach (@ChopAbsSysIncPaths) { |
|
926 &main::Output( |
|
927 " -I \"$_\"" |
|
928 ); |
|
929 } |
|
930 foreach(@RcompMacro) { |
|
931 &main::Output( |
|
932 " -D$_ " |
|
933 ); |
|
934 } |
|
935 &main::Output( |
|
936 " -DLANGUAGE_$$ResourceRef{Lang} -u \"$AbsSrc\" ", |
|
937 " $Uidsarg ", |
|
938 "$RscOption $HeaderOption -t\"$SavedBldPath\"" |
|
939 ); |
|
940 |
|
941 if (!$$ResourceRef{Hdronly}) { |
|
942 &main::Output( |
|
943 " -l\"$EPOCDataDir:$WorkPath\"" |
|
944 ); |
|
945 } |
|
946 |
|
947 if (&main::ResourceVariantFile()) { |
|
948 &main::Output( |
|
949 " -preinclude\"".&main::ResourceVariantFile()."\"" |
|
950 ); |
|
951 } |
|
952 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
953 if ((lc $$ResourceRef{Lang}) eq "sc") { |
|
954 |
|
955 &main::Output( |
|
956 "\n", |
|
957 $HeaderCopyCmd, |
|
958 ); |
|
959 } |
|
960 &main::Output( |
|
961 "\n" |
|
962 ); |
|
963 |
|
964 } |
|
965 else { |
|
966 &main::Output( |
|
967 "\n", |
|
968 $HeaderCopyCmd, |
|
969 "\n" |
|
970 ); |
|
971 } |
|
972 |
|
973 my @macros; |
|
974 push @macros, "LANGUAGE_$$ResourceRef{Lang}", "_UNICODE"; |
|
975 my @userIncludes = &main::Path_Chop(&main::Path_AbsToWork(&main::UserIncPaths)); |
|
976 unshift (@userIncludes, $AbsSrcPath); |
|
977 my @systemIncludes = &main::Path_Chop(&main::Path_AbsToWork(&main::ResourceSysIncPaths)); |
|
978 |
|
979 CheckSource_Includes($AbsSrc, %CheckSourceResourceIncludes, &Variant_GetMacroHRHFile(), @macros, @userIncludes, @systemIncludes); |
|
980 } |
|
981 |
|
982 sub Generic_AifBld { |
|
983 |
|
984 my $AifRef=&main::AifRef; |
|
985 my $ResrcPath=&main::TrgPath; |
|
986 |
|
987 &main::Output( |
|
988 "# Aif $$AifRef{Trg}\n", |
|
989 "\n" |
|
990 ); |
|
991 my @DepList=&main::DepList; |
|
992 |
|
993 &main::Output( |
|
994 "DEPEND=" |
|
995 ); |
|
996 foreach (@DepList) { |
|
997 &main::Output( |
|
998 " \\\n", |
|
999 "\t", &Generic_Quote($_) |
|
1000 ); |
|
1001 } |
|
1002 &main::Output( |
|
1003 "\n", |
|
1004 "\n" |
|
1005 ); |
|
1006 |
|
1007 my @ChopRTWSysIncPaths=&main::Path_Chop(&main::Path_RltToWork(&main::ResourceSysIncPaths)); |
|
1008 my @ChopRTWUserIncPaths=&main::Path_Chop(&main::Path_RltToWork(&main::UserIncPaths)); |
|
1009 my $BaseResrc=&main::Path_Split('Base',$$AifRef{Source}); |
|
1010 |
|
1011 my $WorkPath = &main::Path_Chop(&main::Path_WorkPath); # required for Lockit |
|
1012 my $quotedTrg=&Generic_Quote($$AifRef{GenericTrg}); |
|
1013 &main::Output( |
|
1014 "GENERIC_RESOURCE : $quotedTrg\n", |
|
1015 "\n", |
|
1016 "$quotedTrg : ", &Generic_Quote("$$AifRef{Source}"), " \$(DEPEND)" |
|
1017 ); |
|
1018 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
1019 %Files = &Lockit_Releasables($WorkPath, $$AifRef{TrgFile}, \%Files, "", ""); |
|
1020 } |
|
1021 else |
|
1022 { |
|
1023 %Files = &Lockit_Releasables($WorkPath, $$AifRef{TrgFile}, \%Files, ""); |
|
1024 } |
|
1025 my $bitmapArg = ""; |
|
1026 if ($$AifRef{BitMaps}) { # bitmaps aren't essential |
|
1027 $bitmapArg = "\\\n\t\t-b\""; |
|
1028 foreach my $BitMapRef (@{$$AifRef{BitMaps}}) { |
|
1029 my $BitMap = &main::Path_Split('File', $$BitMapRef{Src}); |
|
1030 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
1031 %Files = &Lockit_Releasables($WorkPath, $$AifRef{TrgFile}, \%Files, $BitMap, ""); |
|
1032 } |
|
1033 else |
|
1034 { |
|
1035 %Files = &Lockit_Releasables($WorkPath, $$AifRef{TrgFile}, \%Files, $BitMap); |
|
1036 } |
|
1037 &main::Output( |
|
1038 " ", &Generic_Quote("$$BitMapRef{Src}") |
|
1039 ); |
|
1040 $bitmapArg .= "\\\n\t\t/$$BitMapRef{ClDepth}$$BitMapRef{Src}"; |
|
1041 } |
|
1042 $bitmapArg .= "\" "; |
|
1043 } |
|
1044 &main::Output( |
|
1045 "\n", |
|
1046 "\tperl -w -S epocaif.pl -o\$\@ ", |
|
1047 "\"$$AifRef{Source}\" ", |
|
1048 "\\\n\t\t", |
|
1049 "-t\"$SavedBldPath\" ", |
|
1050 " -l\"\$(TRGDIR):$WorkPath\"", |
|
1051 $bitmapArg, |
|
1052 "\\\n\t\t" |
|
1053 ); |
|
1054 foreach (@ChopRTWUserIncPaths) { |
|
1055 &main::Output( |
|
1056 " -I \"$_\"" |
|
1057 ); |
|
1058 } |
|
1059 &main::Output( |
|
1060 " -I-" |
|
1061 ); |
|
1062 foreach (@ChopRTWSysIncPaths) { |
|
1063 &main::Output( |
|
1064 " -I \"$_\"" |
|
1065 ); |
|
1066 } |
|
1067 &main::Output( |
|
1068 "\n", |
|
1069 "\n" |
|
1070 ); |
|
1071 } |
|
1072 |
|
1073 |
|
1074 |
|
1075 # |
|
1076 # Check to see that LOCAL_BUILD_PATH exists. |
|
1077 # |
|
1078 |
|
1079 sub LocalBuildPathExists() |
|
1080 { |
|
1081 if ( defined( $ENV{LOCAL_BUILD_PATH} ) ) { |
|
1082 return 1; |
|
1083 } |
|
1084 else { |
|
1085 return 0; |
|
1086 } |
|
1087 } |
|
1088 |
|
1089 |
|
1090 # |
|
1091 # Take the build path and ensure that it is now local. |
|
1092 # |
|
1093 |
|
1094 |
|
1095 sub ConvertToLocalBuild($) |
|
1096 { |
|
1097 my ($BldPath)=@_; |
|
1098 |
|
1099 my $sub_replacement = $ENV{"LOCAL_BUILD_PATH"}; |
|
1100 if ( !ValidBuildPath($sub_replacement) ) { |
|
1101 &FatalError(" Invalid Local Build Path : LOCAL_BUILD_PATH = \"$BldPath\" must be in format drive:dir_name1 " ); |
|
1102 } |
|
1103 else |
|
1104 { |
|
1105 # Replace the \epoc32\build with local setting |
|
1106 my $epocroot=$ENV{"EPOCROOT"}; |
|
1107 |
|
1108 my $sub_match = "\Q${epocroot}\EEPOC32\\\\BUILD"; |
|
1109 $BldPath =~ s/${sub_match}/${sub_replacement}/; |
|
1110 } |
|
1111 |
|
1112 return $BldPath |
|
1113 } |
|
1114 |
|
1115 |
|
1116 |
|
1117 # |
|
1118 # Checks that the path is at least of the form drive:path_name |
|
1119 # If no drive: then the makefiles will be produced but not work. |
|
1120 # |
|
1121 |
|
1122 |
|
1123 sub ValidBuildPath($) |
|
1124 { |
|
1125 my ($BldPath)=@_; |
|
1126 |
|
1127 if ( $BldPath =~/^[a-zA-z]{1}:{1}.*$/) { |
|
1128 # Must have at least d: |
|
1129 return 1; |
|
1130 } |
|
1131 else { |
|
1132 return 0; |
|
1133 } |
|
1134 |
|
1135 } |
|
1136 |
|
1137 1; |
|
1138 |