|
1 # Copyright (c) 2004-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 # Cl_gccxml; |
|
15 # |
|
16 # |
|
17 |
|
18 package Cl_gccxml; |
|
19 |
|
20 require Exporter; |
|
21 @ISA=qw(Exporter); |
|
22 @EXPORT=qw( |
|
23 PMHelp_Mmp |
|
24 PMStartBldList |
|
25 PMBld |
|
26 PMStartSrcList |
|
27 PMStartSrc |
|
28 PMSrcDepend |
|
29 PMSrcBldDepend |
|
30 PMEndSrcBld |
|
31 PMEndSrc |
|
32 PMEndSrcList |
|
33 PMBitMapBld |
|
34 PMResrcBld |
|
35 |
|
36 ); |
|
37 use strict; |
|
38 use cl_generic; |
|
39 use Genutl; |
|
40 use File::Path; |
|
41 use Cwd; |
|
42 use Pathutl; |
|
43 |
|
44 sub PMHelp_Mmp { |
|
45 print "// No additional keywords for this platform\n"; |
|
46 } |
|
47 |
|
48 # takes an 'expression' to evaluate with $_ bound to each of the |
|
49 # remaining args |
|
50 sub PrintList |
|
51 { |
|
52 my $expr = shift @_; |
|
53 foreach (@_) { |
|
54 my $str = eval($expr); |
|
55 &main::Output($str); |
|
56 } |
|
57 } |
|
58 |
|
59 my $epocroot = $ENV{EPOCROOT}; |
|
60 $epocroot=~ s-\\$--; # chop trailing \\ |
|
61 my $Makecmd; |
|
62 sub PMStartBldList($) { |
|
63 ($Makecmd) = @_; |
|
64 my $BasicTrgType=&main::BasicTrgType; |
|
65 my @BldList=&main::BldList; |
|
66 my @ChopSysIncPaths=&main::Path_Chop(&main::SysIncPaths); |
|
67 my @ChopUserIncPaths=&main::Path_Chop(&main::UserIncPaths); |
|
68 my $RelPath="$epocroot\\EPOC32\\RELEASE"; |
|
69 my @MacroList=&main::MacroList(); |
|
70 my $VariantFile=&main::VariantFile(); |
|
71 my $Trg=&main::Trg; |
|
72 my $DPath = &main::Path_RltToWork($epocroot); |
|
73 my $DefFile = &main::DefFile; |
|
74 my $EABIDefFile = &main::EABIDef; |
|
75 my $ExtCompileOption = &main::CompilerOption("GCCXML"); |
|
76 |
|
77 &Generic_Header(0,$Makecmd); # define standard things using absolute paths |
|
78 |
|
79 $DefFile="" if(!(-e $DefFile)); |
|
80 &main::Output( |
|
81 "GXPTRGUDEB = $RelPath\\GCCXML\\UDEB\n", |
|
82 "GXPTRGUREL = $RelPath\\GCCXML\\UREL\n\n", |
|
83 "DEFFILE = $DefFile\n\n", |
|
84 "EABIDEFFILE = $EABIDefFile\n\n" |
|
85 ); |
|
86 |
|
87 &main::Output( |
|
88 "INCDIR =" |
|
89 ); |
|
90 |
|
91 foreach (@ChopUserIncPaths) { |
|
92 &main::Output( |
|
93 " -I \"$_\"" |
|
94 ); |
|
95 } |
|
96 |
|
97 &main::Output( |
|
98 " -I- " |
|
99 ); |
|
100 |
|
101 foreach (@ChopSysIncPaths) { |
|
102 &main::Output( |
|
103 " -I \"$_\"" |
|
104 ); |
|
105 } |
|
106 if($VariantFile){ |
|
107 &main::Output("\\\n -include \"$VariantFile\""); |
|
108 } |
|
109 &main::Output( |
|
110 "\n", |
|
111 "\n" |
|
112 ); |
|
113 |
|
114 &main::Output( |
|
115 "GCCFLAGS= -nostdinc -Wall -Wno-ctor-dtor-privacy -Wno-unknown-pragmas -UWIN32 -fshort-wchar -quiet -w $ExtCompileOption\n", # -fsyntax-only |
|
116 "\n" |
|
117 ); |
|
118 |
|
119 &main::Output( |
|
120 "GCCDEFS = -D __EABI__ -D __SUPPORT_CPP_EXCEPTIONS__" |
|
121 ); |
|
122 foreach(@MacroList) { |
|
123 &main::Output( |
|
124 " -D$_" |
|
125 ); |
|
126 } |
|
127 &main::Output( |
|
128 " \$(USERDEFS)\n", |
|
129 "\n" |
|
130 ); |
|
131 |
|
132 foreach (@BldList) { |
|
133 &main::Output( |
|
134 "GCC$_ = gccxml_cc1plus -bi" |
|
135 ); |
|
136 if (/REL$/o) { |
|
137 &main::Output( |
|
138 ' -fomit-frame-pointer ' |
|
139 ); |
|
140 } |
|
141 elsif (/DEB$/o) { |
|
142 &main::Output( |
|
143 ' -g' |
|
144 ); |
|
145 } |
|
146 &main::Output( |
|
147 ' $(GCCFLAGS)' |
|
148 ); |
|
149 foreach (&main::MacroList($_)) { |
|
150 &main::Output( |
|
151 " -D$_" |
|
152 ); |
|
153 } |
|
154 |
|
155 &main::Output( |
|
156 " \$(GCCDEFS)\n" |
|
157 ); |
|
158 } |
|
159 &main::Output( |
|
160 "\n", |
|
161 "\n" |
|
162 ); |
|
163 |
|
164 &main::Output( |
|
165 "LIBRARY:\n", |
|
166 "\t\@echo Nothing to do\n" |
|
167 ); |
|
168 |
|
169 # Resource building is done entirely via cl_generic.pm |
|
170 PrintList("\"\nRESOURCE\$_ : MAKEWORK\$_\"", @BldList) |
|
171 &main::Output( |
|
172 "\n", |
|
173 "\n", |
|
174 ); |
|
175 |
|
176 foreach (@BldList) { |
|
177 &main::Output( |
|
178 "$_ :" |
|
179 ); |
|
180 |
|
181 if ($BasicTrgType !~ /IMPLIB/io) { |
|
182 my $TrgBase = &main::Path_Split('base',$Trg); |
|
183 &main::Output ( |
|
184 " \\\n\t", |
|
185 &Generic_Quote("\$(GXPTRG$_)\\$TrgBase$BasicTrgType.gxp") |
|
186 ); |
|
187 } |
|
188 &main::Output( |
|
189 "\n", |
|
190 "\n" |
|
191 ); |
|
192 } |
|
193 } |
|
194 |
|
195 # DumpToFile |
|
196 sub DumpMMPToFile |
|
197 { |
|
198 my $rfiFileList; |
|
199 my @rfiFiles; |
|
200 if(scalar @_) # if an argument has been passed then it is a reference to the list of .RFI files. |
|
201 { |
|
202 ($rfiFileList) = @_; |
|
203 @rfiFiles = @$rfiFileList; |
|
204 } |
|
205 |
|
206 my $BldPath=&main::BldPath; |
|
207 my $Target = &main::Trg; |
|
208 my $TargetBase = &main::Path_Split('Base', $Target); |
|
209 my $Gxpurel="$epocroot\\epoc32\\release\\gccxml\\urel"; |
|
210 my $Gxpudeb="$epocroot\\epoc32\\release\\gccxml\\udeb"; |
|
211 unless (-d $BldPath) { |
|
212 mkpath([$BldPath]); |
|
213 } |
|
214 unless (-d $Gxpurel) { |
|
215 mkpath([$Gxpurel]); |
|
216 } |
|
217 unless (-d $Gxpudeb) { |
|
218 mkpath([$Gxpudeb]); |
|
219 } |
|
220 $BldPath = (&main::Path_StepDirs($BldPath))[-2]; |
|
221 use File::Basename; |
|
222 my $FileName = basename(&main::MmpFile()); |
|
223 $FileName = $BldPath.$FileName.".xml"; |
|
224 open FILE,"> $FileName" or die "Cannot open mmp info dump file $FileName: $!"; |
|
225 print FILE "<?xml version=\"1.0\"?>\n<mmpInfo>\n"; |
|
226 |
|
227 my $Path = &main::RelPath(); |
|
228 my $MmpFile = &main::MmpFile(); |
|
229 my $TrgType = &main::TrgType(); |
|
230 my $TrgPath = &main::TrgPath(); |
|
231 print FILE "\t<mmp path=\"$MmpFile\"/>\n"; |
|
232 print FILE "\t<target name=\"$Target\" type=\"$TrgType\" "; |
|
233 |
|
234 if(not $TrgPath eq '') |
|
235 { |
|
236 print FILE "path=\"$TrgPath\""; |
|
237 } |
|
238 print FILE "/>\n"; |
|
239 # insert current working directory |
|
240 my $WorkPath = &main::Path_WorkPath(); |
|
241 print FILE "\t<cwd path=\"$WorkPath\"/>\n"; |
|
242 |
|
243 my $ABI = &main::ABI; |
|
244 print FILE "\t<abi type=\"$ABI\"/>\n"; |
|
245 my $LinkAs = &main::LinkAs; |
|
246 print FILE "\t<linkAs name=\"$LinkAs\"/>\n"; |
|
247 my $LinkAsBase = &main::LinkAsBase; |
|
248 print FILE "\t<linkAsBase name=\"$LinkAsBase\"/>\n"; |
|
249 |
|
250 # Uids |
|
251 my @UidList=&main::UidList; |
|
252 my $count = 0; |
|
253 print FILE "\t<uids"; |
|
254 foreach my $uid(@UidList) |
|
255 { |
|
256 print FILE " u$count=\"$uid\"" ; |
|
257 $count++; |
|
258 } |
|
259 print FILE "/>\n"; |
|
260 |
|
261 # Versioning |
|
262 my %Version = &main::Version; |
|
263 print FILE "\t<version"; |
|
264 foreach my $var (sort keys %Version) |
|
265 { |
|
266 print FILE " $var=\"$Version{$var}\""; |
|
267 } |
|
268 print FILE "/>\n"; |
|
269 |
|
270 # Capabilities |
|
271 my $Capability = &main::Capability; |
|
272 print FILE "\t<capability id=\"$Capability\"/>\n"; |
|
273 |
|
274 # DefFile |
|
275 my $DefFile = &main::DefFile; |
|
276 $DefFile="" if(!(-e $DefFile)); |
|
277 print FILE "\t<defFile path=\"$DefFile\" type=\"GCC\"/>\n"; |
|
278 |
|
279 # EABIDefFile |
|
280 my $EABIDefFile = &main::EABIDef; |
|
281 print FILE "\t<defFile path=\"$EABIDefFile\" type=\"EABI\"/>\n"; |
|
282 |
|
283 # Handle All types of libraries |
|
284 my $FirstLib = &main::FirstLib; |
|
285 my @LibList = &main::LibList; |
|
286 my @ASSPLibList = &main::ASSPLibList; |
|
287 my @StatLibList = &main::StatLibList;; |
|
288 print FILE "\t<libs>\n"; |
|
289 |
|
290 #first |
|
291 print FILE "\t\t<lib name=\"$FirstLib\" type=\"First\"/>\n"; |
|
292 |
|
293 # normal |
|
294 foreach my $lib (@LibList) |
|
295 { |
|
296 print FILE "\t\t<lib name=\"$lib\"/>\n"; |
|
297 } |
|
298 # ASSP Specific |
|
299 foreach my $lib (@ASSPLibList) |
|
300 { |
|
301 print FILE "\t\t<lib name=\"$lib\" type=\"ASSP\"/>\n"; |
|
302 } |
|
303 |
|
304 # Static Libraries |
|
305 foreach my $lib (@StatLibList) |
|
306 { |
|
307 print FILE "\t\t<lib name=\"$lib\" type=\"Static\"/>\n"; |
|
308 } |
|
309 print FILE "\t</libs>\n"; |
|
310 |
|
311 # Resources |
|
312 print FILE "\t<resources>\n"; |
|
313 my $rfiFile; |
|
314 foreach $rfiFile (@rfiFiles) |
|
315 { |
|
316 print FILE "\t\t<resource name=\"$rfiFile\"/>\n"; |
|
317 } |
|
318 print FILE "\t</resources>\n"; |
|
319 |
|
320 close FILE; |
|
321 } |
|
322 |
|
323 sub PMBld { |
|
324 my @ASSPLibList=&main::ASSPLibList; |
|
325 my @SrcList=&main::SrcList; |
|
326 my $BaseTrg=&main::BaseTrg; |
|
327 my $Bld=&main::Bld; |
|
328 my $ChopBldPath=&main::Path_Chop(&main::BldPath); |
|
329 my $EPOCIncPath=&main::EPOCIncPath; |
|
330 my $BasicTrgType=&main::BasicTrgType; |
|
331 my $ChopRelPath=&main::Path_Chop(&main::RelPath); |
|
332 my $RelPath=&main::RelPath; |
|
333 my $Trg=&main::Trg; |
|
334 my $TrgType=&main::TrgType; |
|
335 my @UidList=&main::UidList; |
|
336 # DefFile |
|
337 my $DefFile = &main::DefFile; |
|
338 # EABIDefFile |
|
339 my $EABIDefFile = &main::EABIDef; |
|
340 |
|
341 my $rfiList = GatherResourceInformation(); |
|
342 my @RfiFiles = @$rfiList; |
|
343 |
|
344 |
|
345 |
|
346 DumpMMPToFile(\@RfiFiles); |
|
347 |
|
348 # REAL TARGETS |
|
349 #------------- |
|
350 &main::Output( |
|
351 "# REAL TARGET - BUILD VARIANT $Bld\n", |
|
352 "\n" |
|
353 ); |
|
354 |
|
355 &main::Output( |
|
356 "WHAT$Bld : WHATGENERIC\n", |
|
357 "\n", |
|
358 "CLEAN$Bld : CLEANBUILD$Bld CLEANRELEASE$Bld\n", |
|
359 "\n", |
|
360 "CLEANBUILD$Bld : \n", |
|
361 "\t\@perl -S ermdir.pl \"\$(EPOCBLD$Bld)\"\n", |
|
362 "\n", |
|
363 "CLEANRELEASE$Bld : CLEANGENERIC\n", |
|
364 "\n" |
|
365 ); |
|
366 my @releaseables; |
|
367 &Generic_WhatCleanTargets($Bld, "WHAT$Bld", "CLEANRELEASE$Bld", @releaseables); |
|
368 &Generic_MakeWorkDir("MAKEWORK$Bld",$ChopBldPath); |
|
369 &Generic_MakeWorkDir("MAKEWORK$Bld",$ChopRelPath); |
|
370 &Generic_Releaseables; |
|
371 |
|
372 &main::Output( |
|
373 "\n", |
|
374 "\n" |
|
375 ); |
|
376 |
|
377 # XML Stuff |
|
378 &main::Output( |
|
379 &Generic_Quote("\$(GXPTRG$Bld)\\$BaseTrg$BasicTrgType.gxp"), " : ", |
|
380 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseTrg$BasicTrgType.gxp"), |
|
381 "\n\tcopy \"\$(EPOCBLD$Bld)\\$BaseTrg$BasicTrgType.gxp\" \"\$@\"" |
|
382 ); |
|
383 |
|
384 &main::Output( |
|
385 "\n", |
|
386 "\n" |
|
387 ); |
|
388 |
|
389 # TARGET *.GXP |
|
390 #------------ |
|
391 if (scalar @SrcList >150) { |
|
392 # deal with very long lists by splitting them into 150 file pieces, which allows |
|
393 # about 200 bytes per filename if the underlying max size is 32K |
|
394 # |
|
395 |
|
396 my $counter1=150; # i.e. trigger new variable immediately |
|
397 my $counter2=0; |
|
398 my @objvarlist=(); |
|
399 foreach (@SrcList) { |
|
400 if ($counter1==150) { |
|
401 $counter1=0; |
|
402 $counter2++; |
|
403 my $objvar = "OBJECTS$Bld$counter2"; |
|
404 push @objvarlist, " \$($objvar)"; |
|
405 &main::Output( |
|
406 "\n", |
|
407 "$objvar=" |
|
408 ); |
|
409 } |
|
410 my $BaseSrc = &main::Path_Split('Base', $_); |
|
411 my $Ext = &main::Path_Split('Ext', $_); |
|
412 $BaseSrc.='_' if (lc($Ext) eq '.cia'); |
|
413 &main::Output( |
|
414 " \\\n\t", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.xml") |
|
415 ); |
|
416 $counter1++; |
|
417 } |
|
418 use File::Basename; |
|
419 my $FileName = basename(&main::MmpFile()).".xml"; |
|
420 &main::Output( |
|
421 " \\\n\t\$(EPOCBLD)\\$FileName", |
|
422 "\n", |
|
423 "\n", |
|
424 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseTrg$BasicTrgType.gxp"), " : ", @objvarlist,"\n", |
|
425 "\tif exist \"\$\@\" del \"\$\@\"\n" |
|
426 ); |
|
427 foreach (@objvarlist) { |
|
428 &main::Output( |
|
429 "\tzip -j \$\@$_\n" |
|
430 ); |
|
431 } |
|
432 &main::Output( |
|
433 "\tif exist \$(EABIDEFFILE) zip -j \$\@ \$(EABIDEFFILE)\n", |
|
434 "\n\n" |
|
435 ); |
|
436 } else { |
|
437 # shorter lists remain unchanged |
|
438 # |
|
439 &main::Output( |
|
440 "OBJECTS$Bld=" |
|
441 ); |
|
442 use File::Basename; |
|
443 my $FileName = basename(&main::MmpFile()).".xml"; |
|
444 |
|
445 &main::Output("\$(EPOCBLD)\\$FileName"); |
|
446 foreach (@SrcList) { |
|
447 my $BaseSource = &main::Path_Split('Base', $_); |
|
448 my $Ext = &main::Path_Split('Ext', $_); |
|
449 $BaseSource.='_' if (lc($Ext) eq '.cia'); |
|
450 &main::Output( |
|
451 " \\\n\t", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSource.xml") |
|
452 ); |
|
453 } |
|
454 |
|
455 &main::Output( |
|
456 "\n", |
|
457 "\n" |
|
458 ); |
|
459 |
|
460 &main::Output("RESOURCEINFO$Bld="); |
|
461 foreach (@RfiFiles) |
|
462 { |
|
463 &main::Output(" \\\n\t\$(EPOCBLD)\\$_"); |
|
464 } |
|
465 &main::Output("\n\n"); |
|
466 |
|
467 &main::Output( |
|
468 |
|
469 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseTrg$BasicTrgType.gxp"), " : \$(OBJECTS$Bld) \$(EABIDEFFILE) \$(RESOURCEINFO$Bld)\n", |
|
470 |
|
471 "\tif exist \"\$\@\" del \"\$\@\"\n", |
|
472 "\tzip -j \$\@ \$^ \$(EABIDEFFILE) \$(RESOURCEINFO$Bld)\n", |
|
473 "\n\n" |
|
474 ); |
|
475 } |
|
476 } |
|
477 |
|
478 |
|
479 sub PMStartSrcList { |
|
480 |
|
481 &main::Output( |
|
482 "# SOURCES\n", |
|
483 "\n" |
|
484 ); |
|
485 } |
|
486 |
|
487 sub PMBitMapBld { |
|
488 &Generic_BitMapBld; |
|
489 } |
|
490 |
|
491 sub PMResrcBld { |
|
492 &Generic_ResrcBld; |
|
493 } |
|
494 |
|
495 sub PMStartSrc { |
|
496 my $Src=&main::Src; |
|
497 |
|
498 &main::Output( |
|
499 "# Source $Src\n", |
|
500 "\n" |
|
501 ); |
|
502 } |
|
503 |
|
504 sub PMSrcDepend { |
|
505 my @BldList=&main::BldList; |
|
506 my @DepList=&main::DepList; |
|
507 my $BaseSrc=&main::BaseSrc; |
|
508 my $ExtSrc=&main::ExtSrc; |
|
509 my $cia = (lc($ExtSrc) eq '.cia') ? "_" : ""; |
|
510 |
|
511 return if (@DepList == 0); |
|
512 |
|
513 foreach (@BldList) { |
|
514 &main::Output( |
|
515 &Generic_Quote("\$(EPOCBLD$_)\\$BaseSrc$cia.lis"), " ", |
|
516 &Generic_Quote("\$(EPOCBLD$_)\\$BaseSrc$cia.xml"), " \\\n", |
|
517 ); |
|
518 } |
|
519 &main::Output( |
|
520 ":" |
|
521 ); |
|
522 foreach (@DepList) { |
|
523 &main::Output( |
|
524 " \\\n\t", &Generic_Quote($_) |
|
525 ); |
|
526 } |
|
527 &main::Output( |
|
528 "\n", |
|
529 "\n" |
|
530 ); |
|
531 } |
|
532 |
|
533 sub PMSrcBldDepend { |
|
534 my $Bld=&main::Bld; |
|
535 my @DepList=&main::DepList; |
|
536 my $BaseSrc=&main::BaseSrc; |
|
537 my $ExtSrc=&main::ExtSrc; |
|
538 my $cia = (lc($ExtSrc) eq '.cia') ? "_" : ""; |
|
539 |
|
540 return if (@DepList == 0); |
|
541 |
|
542 &main::Output( |
|
543 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc$cia.lis"), " ", |
|
544 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc$cia.xml"), " :", |
|
545 ); |
|
546 foreach (@DepList) { |
|
547 &main::Output( |
|
548 " \\\n\t", &Generic_Quote($_) |
|
549 ); |
|
550 } |
|
551 &main::Output( |
|
552 "\n", |
|
553 "\n" |
|
554 ); |
|
555 } |
|
556 |
|
557 my %sources; |
|
558 |
|
559 sub PMEndSrcBld { |
|
560 my $ABI=&main::ABI; |
|
561 my $BaseSrc=&main::BaseSrc; |
|
562 my $Bld=&main::Bld; |
|
563 my $Src=ucfirst lc &main::Src; |
|
564 my $SrcPath=&main::SrcPath; |
|
565 my $Ext = &main::Path_Split('Ext', $Src); |
|
566 my $Cia = (lc($Ext) eq '.cia') ? 1 : 0; |
|
567 |
|
568 my $ChopSrcPath=&main::Path_Chop($SrcPath); |
|
569 |
|
570 # add source path, source file and build type to hashmap. |
|
571 $sources{$SrcPath}{$Src}{$Bld}=1; |
|
572 |
|
573 # Use GCC trick to get assembler source files preprocessed with CPP |
|
574 $Src =~ s/\.s$/.S/i; |
|
575 |
|
576 if ($Cia) { |
|
577 &main::Output( |
|
578 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc\_.xml"), " : ", |
|
579 &Generic_Quote("$SrcPath$Src"), "\n", |
|
580 "\t\$(GCC$Bld) -D__CIA__ -I \"$ChopSrcPath\" \$(INCDIR) -fxml=\$\@ -o nul \"$ChopSrcPath\\$Src\"\n", |
|
581 "\n", |
|
582 ); |
|
583 } else { |
|
584 &main::Output( |
|
585 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.xml"), " : ", |
|
586 &Generic_Quote("$SrcPath$Src"), "\n", |
|
587 "\t\$(GCC$Bld) -I \"$ChopSrcPath\" \$(INCDIR) -fxml=\$\@ -o nul \"$ChopSrcPath\\$Src\"\n", |
|
588 "\n", |
|
589 ); |
|
590 } |
|
591 |
|
592 #Keep the staus of the dependency-generation-flag was enabled or disabled. |
|
593 my $Deps_Stat = &main::Deps_GetNoDependencies(); |
|
594 if($Deps_Stat){ |
|
595 #If the no-dependency-generation-flag turned on, turn it off temporarily, so that we can get |
|
596 #the dependencies. |
|
597 &main::Deps_SetNoDependenciesStatus(0); |
|
598 } |
|
599 # Code to print the log file includeheaders.txt |
|
600 my $IncFileName = "$epocroot\\epoc32\\release\\gccxml\\includeheaders.txt"; |
|
601 open INC_FILE,">> $IncFileName" or die "Cannot open file $IncFileName"; |
|
602 |
|
603 #Get the dependencies for the current source file. |
|
604 my @DepList=&main::Deps_GenDependsL("$SrcPath$Src"); |
|
605 foreach(@DepList) { |
|
606 print INC_FILE "$_\n"; |
|
607 } |
|
608 close INC_FILE; |
|
609 |
|
610 #Set the dependency-generation-flag to its original state so that, it doesn't affect the other target |
|
611 #builds. |
|
612 &main::Deps_SetNoDependenciesStatus($Deps_Stat); |
|
613 |
|
614 # Code to print the existance of the file in logs |
|
615 my $neededfile="$epocroot\\epoc32\\release\\gccxml\\includeheaders.txt"; |
|
616 if (!-e $neededfile) |
|
617 { |
|
618 print "!!! File $epocroot\\epoc32\\release\\gccxml\\includeheaders.txt does not exist\n"; |
|
619 } |
|
620 } |
|
621 |
|
622 sub PMEndSrc { |
|
623 &main::Output( |
|
624 "\n", |
|
625 "\n" |
|
626 ); |
|
627 } |
|
628 |
|
629 sub PMEndSrcList { |
|
630 my $BldPath=&main::BldPath; |
|
631 my $Target = &main::Trg; |
|
632 my $TargetBase = &main::Path_Split('Base', $Target); |
|
633 use File::Basename; |
|
634 my $FileName = basename(&main::MmpFile()); |
|
635 $FileName = $BldPath.$FileName.".xml"; |
|
636 open FILE,">> $FileName" or die "Cannot open mmp info dump file $FileName: $!"; |
|
637 my $path; |
|
638 foreach $path (keys %sources) |
|
639 { |
|
640 my %thing = %{$sources{$path}}; # {"UREL"}; |
|
641 my $file; |
|
642 foreach $file (keys %thing) |
|
643 { |
|
644 if( defined $thing{$file}{"UREL"}) |
|
645 { |
|
646 if( defined $thing{$file}{"UDEB"} ) |
|
647 { |
|
648 print FILE "\t<sourceFile name=\"$file\" path=\"$path\"/>\n"; |
|
649 } |
|
650 else |
|
651 { |
|
652 print FILE "\t<sourceFile name=\"$file\" path=\"$path\" type=\"UREL\"/>\n"; |
|
653 } |
|
654 } |
|
655 else |
|
656 { |
|
657 if(defined $thing{$file}{"UDEB"}) |
|
658 { |
|
659 print FILE "\t<sourceFile name=\"$file\" path=\"$path\" type=\"UDEB\"/>\n"; |
|
660 } |
|
661 else |
|
662 { |
|
663 die "Should Never Get HERE!"; |
|
664 } |
|
665 } |
|
666 |
|
667 } |
|
668 } |
|
669 |
|
670 |
|
671 |
|
672 my $BldInfDir=&Path_WorkPath; |
|
673 my $PrjBldDir=$E32env::Data{BldPath}; |
|
674 $PrjBldDir=~s-^(.*)\\-$1-o; |
|
675 $PrjBldDir.=$BldInfDir; |
|
676 $PrjBldDir=~m-(.*)\\-o; # remove backslash because some old versions of perl can't cope |
|
677 |
|
678 |
|
679 ### the export call is like this |
|
680 my $lCmd = "make -r -f \"${PrjBldDir}EXPORT.make\" WHAT"; |
|
681 my @lExportDump = split(/\n/,`$lCmd`); |
|
682 foreach my $lLine (@lExportDump) { |
|
683 $lLine =~ s/"//g; |
|
684 chomp($lLine); |
|
685 if($lLine =~ /.*\.h/i) { |
|
686 print FILE "\t<export name=\"$lLine\"/>\n"; |
|
687 } |
|
688 } |
|
689 |
|
690 print FILE "</mmpInfo>\n\n"; |
|
691 close FILE; |
|
692 |
|
693 |
|
694 |
|
695 &Generic_End; |
|
696 } |
|
697 |
|
698 |
|
699 sub GetRelDir |
|
700 { |
|
701 my ($fileName) = @_; |
|
702 $fileName = CleanPath($fileName); # make sure that /'s are use rather than \ or \\ |
|
703 if($fileName!~m-\/-) # no directory, just a file name, so return ./ |
|
704 { |
|
705 return "./"; |
|
706 } |
|
707 elsif($fileName=~m-^(.*\/)[^\/]+$-) # return directory |
|
708 { |
|
709 return $1; |
|
710 } |
|
711 else # don't know how could get here |
|
712 { |
|
713 return "./"; |
|
714 } |
|
715 } |
|
716 |
|
717 |
|
718 sub SearchMmpFile |
|
719 { |
|
720 my @rfiFiles; |
|
721 my @SystemIncludes = &main::SysIncPaths; |
|
722 my @UserIncludes = &main::UserIncPaths; |
|
723 my $ResourceStruct = &main::ResourceStructRef; |
|
724 |
|
725 foreach my $ResourceStructure (@$ResourceStruct) |
|
726 { |
|
727 push @rfiFiles, AnalyseResourceFile($$ResourceStructure{Source}, \@SystemIncludes, \@UserIncludes); |
|
728 } |
|
729 return \@rfiFiles; |
|
730 } |
|
731 |
|
732 sub AnalyseResourceFile |
|
733 { # when get to here $rssFile should be fully qualified relative to mmp file location (i.e. base: .../name.rss) |
|
734 my ($rssFile, $systemIncludeList, $userIncludeList) = @_; |
|
735 my @resourceRelatedFiles = ($rssFile); |
|
736 my $baseFile = 0; #flag to indicate whether this is the base file which the rfi file is named after |
|
737 my $rssItem; |
|
738 my $containerFile; |
|
739 foreach $rssItem (@resourceRelatedFiles) #@resourceRelatedFiles is added to during this foreach loop as included files are found |
|
740 { |
|
741 $rssItem = CleanPath($rssItem); |
|
742 if( ! ($baseFile) ) |
|
743 { |
|
744 $baseFile = 1; # set to non-zero so that setting up the rfi file is only done once |
|
745 if($rssItem =~m-\/-) |
|
746 { |
|
747 if($rssItem =~m-^\S*\/([^\/]+)$-) # just extracts file name |
|
748 { |
|
749 $containerFile = $1 . ".rfi"; |
|
750 } |
|
751 } |
|
752 else |
|
753 { |
|
754 $containerFile = $rssItem . ".rfi"; |
|
755 } |
|
756 open CONTAINER, ">$containerFile"; |
|
757 } |
|
758 OutputHeader($rssItem); |
|
759 my $resourceFiles = ReadFile($rssItem, \@resourceRelatedFiles, $systemIncludeList, $userIncludeList); |
|
760 @resourceRelatedFiles = @$resourceFiles; |
|
761 } |
|
762 close CONTAINER; |
|
763 return $containerFile; |
|
764 } |
|
765 |
|
766 sub CheckForInclude |
|
767 { # check whether the passed line from the resource type file is a #include line, if it is then store it to be added to the rfi file |
|
768 my ($line, $dir, $resourceFiles, $systemIncludeList, $userIncludeList) = @_; |
|
769 my @resourceFiles = @$resourceFiles; |
|
770 if($line =~ /^\s*\#include\s+([\<\"])(\S+)([\>\"])(\s+\/\/.*)?/) |
|
771 { |
|
772 if( ($1 eq "\"") and ($3 eq "\"") ) |
|
773 { |
|
774 my $possibleAddition = SearchDirectories($2, "quoted", $dir, $systemIncludeList, $userIncludeList); |
|
775 if($possibleAddition ne "") |
|
776 { |
|
777 push @resourceFiles, $possibleAddition; |
|
778 } |
|
779 } |
|
780 elsif( ($1 eq "\<") and ($3 eq "\>") ) |
|
781 { |
|
782 my $possibleAddition = SearchDirectories($2, "angle", $dir, $systemIncludeList, $userIncludeList); |
|
783 if($possibleAddition ne "") |
|
784 { |
|
785 push @resourceFiles, $possibleAddition; |
|
786 } |
|
787 } |
|
788 } |
|
789 return \@resourceFiles; |
|
790 } |
|
791 |
|
792 sub ReadFile |
|
793 { # copy the passed file into the rfi file and check it for included files |
|
794 my ($fileName, $resourceFiles, $systemIncludeList, $userIncludeList) = @_; |
|
795 my $dir = GetRelDir($fileName); |
|
796 |
|
797 open RESOURCE, $fileName or die "Can't open file $fileName from " . cwd() . "\n"; |
|
798 my $line; |
|
799 foreach $line (<RESOURCE>) |
|
800 { |
|
801 print CONTAINER $line; |
|
802 $resourceFiles = CheckForInclude($line, $dir, $resourceFiles, $systemIncludeList, $userIncludeList); |
|
803 } |
|
804 close RESOURCE; |
|
805 return $resourceFiles; |
|
806 } |
|
807 |
|
808 sub OutputHeader |
|
809 { |
|
810 my ($fileName) = @_; |
|
811 print CONTAINER "\n\n/* GXP ***********************\n"; |
|
812 if($fileName =~m-\/-) |
|
813 { # remove path as only want to store file name |
|
814 if($fileName =~m-^\S*\/([^\/]+)$-) |
|
815 { |
|
816 print CONTAINER " * $1\n"; |
|
817 } |
|
818 } |
|
819 else |
|
820 { |
|
821 print CONTAINER " * $fileName\n"; |
|
822 } |
|
823 print CONTAINER " ****************************/\n\n"; |
|
824 } |
|
825 |
|
826 |
|
827 sub RecordSystemIncludes |
|
828 { |
|
829 my ($line) = @_; |
|
830 my @terms = split(/ /, $line); |
|
831 my $term; |
|
832 my @systemIncludes = (); |
|
833 foreach $term (@terms) |
|
834 { |
|
835 if($term!~m/\/\//) # if term is not the start of a c++ style comment |
|
836 { |
|
837 push @systemIncludes, $term; |
|
838 } |
|
839 else |
|
840 { |
|
841 last; |
|
842 } |
|
843 } |
|
844 return \@systemIncludes; |
|
845 } |
|
846 |
|
847 sub RecordUserIncludes |
|
848 { |
|
849 my ($line) = @_; |
|
850 my @terms = split(/ /, $line); |
|
851 my $term; |
|
852 my @userIncludes = (); |
|
853 foreach $term (@terms) |
|
854 { |
|
855 if($term!~m/\/\//) # if term is not the start of a c++ style comment |
|
856 { |
|
857 push @userIncludes, $term; |
|
858 } |
|
859 else |
|
860 { |
|
861 last; |
|
862 } |
|
863 } |
|
864 return \@userIncludes; |
|
865 } |
|
866 |
|
867 sub CleanPath # change \ and \\ in path to / |
|
868 { |
|
869 my ($fileName) = @_; |
|
870 $fileName =~ s-\\\\-\/-og; |
|
871 $fileName =~ s-\\-\/-og; |
|
872 return $fileName; |
|
873 } |
|
874 |
|
875 sub RecordSourcePath |
|
876 { |
|
877 my ($line) = @_; |
|
878 my $sourcePath; |
|
879 if($line=~/^(\S+)/) # in case of comments at end of line |
|
880 { |
|
881 $sourcePath = $1; |
|
882 $sourcePath = CleanPath($sourcePath); |
|
883 if($sourcePath !~ m/\/$/) |
|
884 { |
|
885 $sourcePath .= "\/"; |
|
886 } |
|
887 } |
|
888 return $sourcePath; |
|
889 } |
|
890 |
|
891 sub SearchDirectories |
|
892 { |
|
893 my ($fileName, $includeType, $base, $systemIncludeList, $userIncludeList) = @_; |
|
894 my @systemIncludes = @$systemIncludeList; |
|
895 my @userIncludes = @$userIncludeList; |
|
896 |
|
897 $fileName = CleanPath($fileName); |
|
898 |
|
899 if(-e $base.$fileName) |
|
900 { |
|
901 return $base.$fileName; |
|
902 } |
|
903 if($includeType eq "quoted") |
|
904 { |
|
905 # search through the user includes and return dir + file name if found |
|
906 my $directory; |
|
907 foreach $directory (@userIncludes) |
|
908 { |
|
909 my $qualifiedFileName = $directory . "/" . $fileName; |
|
910 if(-e $qualifiedFileName) |
|
911 { |
|
912 return $qualifiedFileName; |
|
913 } |
|
914 } |
|
915 } |
|
916 |
|
917 # search through the system includes |
|
918 my $directory; |
|
919 foreach $directory (@systemIncludes) |
|
920 { |
|
921 my $qualifiedFileName = $directory . "/" . $fileName; |
|
922 if(-e $qualifiedFileName) |
|
923 { |
|
924 return $qualifiedFileName; |
|
925 } |
|
926 } |
|
927 return ""; |
|
928 } |
|
929 |
|
930 |
|
931 sub GatherResourceInformation |
|
932 { |
|
933 my $BldPath=&main::BldPath; |
|
934 unless (-d $BldPath) { |
|
935 mkpath([$BldPath]); |
|
936 } |
|
937 $BldPath = (&main::Path_StepDirs($BldPath))[-2]; |
|
938 my $bldInfDirectory = cwd(); # store current directory so can return to it later |
|
939 my $MmpFile = &main::MmpFile(); |
|
940 $MmpFile = CleanPath($MmpFile); |
|
941 my $MmpFileDir = "./"; |
|
942 my $MmpFileName = $MmpFile; |
|
943 if($MmpFile=~m-\/-) |
|
944 { |
|
945 if($MmpFile=~m-^(.*)\/([^\/]*)$-) |
|
946 { |
|
947 $MmpFileDir = $1; |
|
948 $MmpFileName = $2; |
|
949 } |
|
950 } |
|
951 chdir($MmpFileDir) or die "Error: Could not change to MMP file directory: $MmpFileDir\n"; |
|
952 |
|
953 my $rfiFileList = &SearchMmpFile; # analyse the mmp file for resource files |
|
954 |
|
955 my @RfiFiles = @$rfiFileList; |
|
956 foreach (@RfiFiles) # copy the rfi files to the BldPath and delete them from temporary locations |
|
957 { |
|
958 system("copy \"$_\" \"$BldPath$_\""); |
|
959 unlink $_; |
|
960 } |
|
961 chdir($bldInfDirectory); # return to the orignial directory |
|
962 |
|
963 return \@RfiFiles; # return list of rfi files to be added to .mmp.xml file |
|
964 } |
|
965 1; |