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