|
1 # Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 |
|
16 package Cl_tools; |
|
17 |
|
18 # declare variables global for module |
|
19 my @Win32LibList=(); |
|
20 my $BaseAddressFlag; |
|
21 my $Win32Resrc; |
|
22 |
|
23 my $MWCC; |
|
24 my $MWLD; |
|
25 |
|
26 require Exporter; |
|
27 @ISA=qw(Exporter); |
|
28 @EXPORT=qw( |
|
29 PMHelp_Mmp |
|
30 PMCheckPlatformL |
|
31 PMPlatProcessMmp |
|
32 PMStartBldList |
|
33 PMBld |
|
34 PMStartSrcList |
|
35 PMStartSrc |
|
36 PMSrcDepend |
|
37 PMSrcBldDepend |
|
38 PMEndSrcBld |
|
39 PMEndSrc |
|
40 PMEndSrcList |
|
41 ); |
|
42 |
|
43 use Winutl; |
|
44 use cl_generic; |
|
45 |
|
46 sub PMHelp_Mmp { |
|
47 &Winutl_Help_Mmp; |
|
48 } |
|
49 |
|
50 sub PMCheckPlatformL { |
|
51 if ((&main::Plat eq 'TOOLS') and (&main::BasicTrgType ne 'EXE') and (&main::BasicTrgType ne 'LIB')) { |
|
52 die "Can't specify anything but EXE or LIB targettypes for this platform\n"; |
|
53 } |
|
54 } |
|
55 |
|
56 sub PMPlatProcessMmp (@) { |
|
57 &Winutl_DoMmp(\@_, $ENV{MWCSym2Includes}); |
|
58 $BaseAddressFlag=&Winutl_BaseAddress; |
|
59 if ($BaseAddressFlag ne "") { |
|
60 $BaseAddressFlag=" -imagebase \"$BaseAddressFlag\""; |
|
61 } |
|
62 @Win32LibList=&Winutl_Win32LibList; |
|
63 $Win32Resrc=&Winutl_Win32Resrc; |
|
64 } |
|
65 |
|
66 sub PMStartBldList($) { |
|
67 my ($makecmd) = @_; |
|
68 my $BaseTrg=&main::BaseTrg; |
|
69 my @BldList=&main::BldList; |
|
70 my @ChopSysIncPaths=&main::Path_Chop(&main::SysIncPaths); |
|
71 my @ChopUserIncPaths=&main::Path_Chop(&main::UserIncPaths); |
|
72 my $DefFile=&main::DefFile; |
|
73 my $BasicTrgType=&main::BasicTrgType; |
|
74 my $LibPath=&main::LibPath; |
|
75 my @MacroList=&main::MacroList(); |
|
76 my $VariantFile=&main::VariantFile(); |
|
77 my $Plat=&main::Plat; |
|
78 my $Trg=&main::Trg; |
|
79 my $TrgType=&main::TrgType; |
|
80 my $WarningLevel=&main::CompilerOption("CW"); |
|
81 |
|
82 # check version of CodeWarrior for Symbian OS |
|
83 if (defined($ENV{MWSym2Libraries})) { |
|
84 my $allthere=1; |
|
85 foreach (split/;/,$ENV{MWSym2Libraries}) { |
|
86 s/^\+//; # remove leading "+", if any |
|
87 if (!-d $_) { |
|
88 $allthere=0; |
|
89 last; |
|
90 } |
|
91 } |
|
92 if ($allthere) { |
|
93 $MWCC = "mwccsym2.exe"; |
|
94 $MWLD = "mwldsym2.exe"; |
|
95 print "Detected CodeWarrior for Symbian OS, version 2.0\n"; |
|
96 } |
|
97 } |
|
98 if (!defined($MWCC)) { |
|
99 if (defined($ENV{CWFolder}) && -d $ENV{CWFolder}) { |
|
100 $MWCC = "mwcc.exe"; |
|
101 $MWLD = "mwld.exe"; |
|
102 print "Detected CodeWarrior for Symbian OS, version 1.0\n"; |
|
103 die "ERROR: This version of CodeWarrior is not suitable for Symbian OS version 8\n"; |
|
104 } |
|
105 else { |
|
106 die "ERROR: Unable to identify a valid CodeWarrior for Symbian OS installation\n"; |
|
107 } |
|
108 } |
|
109 |
|
110 Generic_Header(0,$makecmd); # define standard things using absolute paths |
|
111 |
|
112 my $TrgDir=""; |
|
113 if (&Generic_Definition("TRGDIR") ne "") { |
|
114 $TrgDir="\$(TRGDIR)\\"; |
|
115 } |
|
116 |
|
117 # Change - winutl.pm checks MWCWinx86Includes, but mwccsym2.exe seems to use MWCIncludes |
|
118 if ($MWCC eq "mwccsym2.exe" && !defined($ENV{MWCIncludes})) { |
|
119 &main::Output( |
|
120 "\n", |
|
121 "MWCIncludes:=\$(MWCSym2Includes)\n", |
|
122 "export MWCIncludes\n", |
|
123 "\n" |
|
124 ); |
|
125 } |
|
126 |
|
127 &main::Output( |
|
128 "# EPOC DEFINITIONS\n", |
|
129 "\n", |
|
130 "INCDIR = -cwd source -i-" |
|
131 ); |
|
132 foreach (@ChopUserIncPaths,@ChopSysIncPaths) { |
|
133 &main::Output( |
|
134 " \\\n -i \"$_\"" |
|
135 ); |
|
136 } |
|
137 use Pathutl; |
|
138 if($VariantFile){ |
|
139 my $variantFilePath = Path_Split('Path',$VariantFile); |
|
140 $VariantFile = Path_Split('FILE',$VariantFile); |
|
141 # workaround for codewarrior defect: |
|
142 # codewarrior at the moment doesn't accept an absolute path with the |
|
143 # the -include option unless it contains a drive letter, this is solved |
|
144 # by including the directory and the file separately |
|
145 &main::Output("\\\n -i \"$variantFilePath\" -include \"$VariantFile\""); |
|
146 } |
|
147 &main::Output( |
|
148 "\n", |
|
149 "\n" |
|
150 ); |
|
151 |
|
152 &main::Output( |
|
153 "CWFLAGS =", |
|
154 " -wchar_t off", # do not treat wchar_t as a predefined type |
|
155 " -align 4", # long alignment |
|
156 " -warnings on", # selection of warnings |
|
157 " -w nohidevirtual", # turn off "hides inherited virtual function" warning |
|
158 ",nounusedexpr", # turn off "expression has no side effect" warning |
|
159 " -msgstyle gcc", # use GCC-style message format |
|
160 # " -strict on", # strict ANSI/ISO C++ checking |
|
161 " -enum int", # use int for enumeration types |
|
162 " -str pool", # pool strings into a single data object |
|
163 " $WarningLevel" |
|
164 |
|
165 ); |
|
166 |
|
167 &main::Output( |
|
168 " -stdinc" # insist because mwccsym2 has -nostdinc as the default(?) |
|
169 ); |
|
170 |
|
171 &main::Output( |
|
172 "\n", |
|
173 "\n" |
|
174 ); |
|
175 |
|
176 &main::Output( |
|
177 "CWDEFS = " |
|
178 ); |
|
179 foreach(@MacroList) { |
|
180 &main::Output( |
|
181 " -d \"$_\"" |
|
182 ); |
|
183 } |
|
184 &main::Output( |
|
185 " \$(USERDEFS)\n", |
|
186 "\n" |
|
187 ); |
|
188 |
|
189 foreach (@BldList) { |
|
190 &main::Output( |
|
191 "CW$_ = $MWCC" |
|
192 ); |
|
193 if (/DEB$/o) { |
|
194 &main::Output( |
|
195 ' -g -O0' # debug information, no optimisation |
|
196 ); |
|
197 } |
|
198 elsif (/REL$/o) { |
|
199 &main::Output( |
|
200 ' -O4,s' # highest level of optimisation, optimise for space |
|
201 ); |
|
202 } |
|
203 &main::Output( |
|
204 ' $(CWFLAGS)' |
|
205 ); |
|
206 foreach (&main::MacroList($_)) { |
|
207 &main::Output( |
|
208 " -d $_" |
|
209 ); |
|
210 } |
|
211 &main::Output( |
|
212 " \$(CWDEFS) \$(INCDIR)\n" |
|
213 ); |
|
214 } |
|
215 &main::Output( |
|
216 "\n", |
|
217 "\n" |
|
218 ); |
|
219 |
|
220 foreach (@BldList) { |
|
221 &main::Output( |
|
222 "$_ :" |
|
223 ); |
|
224 |
|
225 &main::Output ( |
|
226 " \\\n", |
|
227 "\t", &Generic_Quote("\$(EPOCTRG$_)\\$TrgDir$Trg") |
|
228 ); |
|
229 |
|
230 |
|
231 # lib has to come after the main target so that a .DEF file will be generated if the project is not frozen |
|
232 if ($DefFile and not &main::ExportUnfrozen) { |
|
233 &main::Output( |
|
234 " \\\n", |
|
235 "\tLIBRARY\n" |
|
236 ); |
|
237 } |
|
238 &main::Output( |
|
239 "\n", |
|
240 "\n" |
|
241 ); |
|
242 } |
|
243 |
|
244 &main::Output( |
|
245 "LIBRARY : MAKEWORKLIBRARY", |
|
246 "\n" |
|
247 ); |
|
248 &main::Output( |
|
249 "\n", |
|
250 "FREEZE :\n" |
|
251 ); |
|
252 &main::Output( |
|
253 "\n", |
|
254 "CLEANLIBRARY :\n" |
|
255 ); |
|
256 &Generic_MakeWorkDir('MAKEWORKLIBRARY',"${LibPath}UDEB"); |
|
257 |
|
258 &Generic_Releaseables; |
|
259 } |
|
260 |
|
261 my $uidfile; |
|
262 sub PMBld { |
|
263 |
|
264 my @SrcList=&main::SrcList; |
|
265 my $BaseTrg=&main::BaseTrg; |
|
266 my $Bld=&main::Bld; |
|
267 my $ChopBldPath=&main::Path_Chop(&main::BldPath); |
|
268 my $DefFile=&main::DefFile; |
|
269 my $EPOCIncPath=&main::EPOCIncPath; |
|
270 my $FirstLib=&main::FirstLib; |
|
271 my $BasicTrgType=&main::BasicTrgType; |
|
272 my @LibList; |
|
273 my $RelPath=&main::RelPath; |
|
274 my $Trg=&main::Trg; |
|
275 my $TrgPath=&main::TrgPath; |
|
276 my $TrgType=&main::TrgType; |
|
277 |
|
278 $uidfile = "$BaseTrg.UID"; |
|
279 |
|
280 if ($Bld =~ /DEB/) { |
|
281 @LibList=&main::DebugLibList; |
|
282 } else { |
|
283 @LibList=&main::LibList; |
|
284 } |
|
285 |
|
286 my $BLDTRGPATH = "\$(EPOCTRG$Bld)\\"; |
|
287 if ($TrgPath) { |
|
288 $BLDTRGPATH .= "\$(TRGDIR)\\"; # handles TARGETPATH |
|
289 } |
|
290 |
|
291 |
|
292 # releasables |
|
293 my @releaseables; |
|
294 |
|
295 my $toolspath=&main::EPOCToolsPath(); |
|
296 push @releaseables, "$toolspath$Trg"; |
|
297 |
|
298 &main::Output( |
|
299 "WHAT$Bld : WHATGENERIC\n", |
|
300 "\n", |
|
301 "CLEAN$Bld : CLEANBUILD$Bld CLEANRELEASE$Bld\n", |
|
302 "\n", |
|
303 "CLEANBUILD$Bld : \n", |
|
304 "\t\@perl -S ermdir.pl \"\$(EPOCBLD$Bld)\"\n", |
|
305 "\n", |
|
306 "CLEANRELEASE$Bld : CLEANGENERIC\n", |
|
307 "\n" |
|
308 ); |
|
309 |
|
310 &Generic_WhatCleanTargets($Bld, "WHAT$Bld", "CLEANRELEASE$Bld", @releaseables); |
|
311 &Generic_MakeWorkDir("MAKEWORK$Bld", &main::BldPath); |
|
312 &Generic_MakeWorkDir("MAKEWORK$Bld", "$RelPath$TrgPath"); |
|
313 |
|
314 &main::Output( |
|
315 "\n", |
|
316 "\n" |
|
317 ); |
|
318 |
|
319 &main::Output( |
|
320 "LISTING$Bld : MAKEWORK$Bld" |
|
321 ); |
|
322 foreach (@SrcList) { |
|
323 my $BaseSrc = &main::Path_Split('Base', $_); |
|
324 my $Ext = &main::Path_Split('Ext', $_); |
|
325 $BaseSrc = "uid" if ($BaseSrc eq $uidfile); |
|
326 |
|
327 &main::Output( |
|
328 " \\\n\tLISTING$Bld$BaseSrc" |
|
329 ); |
|
330 } |
|
331 &main::Output( |
|
332 "\n", |
|
333 "\n" |
|
334 ); |
|
335 |
|
336 &main::Output( |
|
337 "LIBS$Bld=" |
|
338 ); |
|
339 |
|
340 foreach (@LibList) { |
|
341 &main::Output( |
|
342 " \\\n\t", &Generic_Quote("\$(EPOCLINK$Bld)\\$_") |
|
343 ); |
|
344 } |
|
345 &main::Output( |
|
346 "\n", |
|
347 "\n" |
|
348 ); |
|
349 |
|
350 &main::Output( |
|
351 "LINK_OBJS$Bld=" |
|
352 ); |
|
353 my $have_uidfile = 0; |
|
354 foreach (@SrcList) { |
|
355 my $BaseSrc = &main::Path_Split('Base', $_); |
|
356 my $Ext = &main::Path_Split('Ext', $_); |
|
357 if ($BaseSrc eq $uidfile) { |
|
358 $have_uidfile = 1; |
|
359 next; |
|
360 } |
|
361 &main::Output( |
|
362 " \\\n", |
|
363 "\t", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.o") |
|
364 ); |
|
365 } |
|
366 |
|
367 if ($have_uidfile) { |
|
368 # ensure that the uid file is at the end of the list, as it's implicit in |
|
369 # CodeWarrior IDE projects. |
|
370 &main::Output( |
|
371 " \\\n", |
|
372 "\t", &Generic_Quote("\$(EPOCBLD$Bld)\\uid.o") |
|
373 ); |
|
374 } |
|
375 &main::Output( |
|
376 "\n", |
|
377 "\n" |
|
378 ); |
|
379 |
|
380 &main::OutFormat( |
|
381 "COMMON_LINK_FLAGS$Bld=", |
|
382 ' -msgstyle gcc', |
|
383 ' -stdlib' # use default runtime library for compiler help functions |
|
384 ); |
|
385 if ($MWLD eq "mwcc.exe") { |
|
386 &main::OutFormat( |
|
387 ' -warnings on' # on by default in mwccsym2.exe |
|
388 ); |
|
389 } |
|
390 |
|
391 &main::OutFormat( |
|
392 ' -subsystem console' |
|
393 ); |
|
394 |
|
395 if ($Bld=~/DEB$/o) { |
|
396 &main::OutFormat( |
|
397 ' -g' |
|
398 ); |
|
399 } |
|
400 |
|
401 &main::Output( |
|
402 "\n", |
|
403 "\n" |
|
404 ); |
|
405 |
|
406 &main::Output( |
|
407 "LINK_FLAGS$Bld= \$(COMMON_LINK_FLAGS$Bld) \$(LIBS$Bld) \\\n\t", |
|
408 " -o \"$BLDTRGPATH$Trg\"" |
|
409 ); |
|
410 |
|
411 &main::Output( |
|
412 ' -noimplib' |
|
413 ); |
|
414 |
|
415 &main::Output( |
|
416 "\n", |
|
417 "\n" |
|
418 ); |
|
419 |
|
420 &main::Output( |
|
421 &Generic_Quote("$BLDTRGPATH$Trg"), " : \$(LINK_OBJS$Bld) " |
|
422 ); |
|
423 if (-e $DefFile) { # effectively "if project frozen ..." |
|
424 &main::Output( |
|
425 &Generic_Quote($DefFile) |
|
426 ); |
|
427 } |
|
428 |
|
429 &main::Output( |
|
430 " \$(LIBS$Bld)\n" |
|
431 ); |
|
432 |
|
433 # Perform the final link step |
|
434 &main::Output( |
|
435 "\t$MWLD " |
|
436 ); |
|
437 |
|
438 &main::Output( |
|
439 "\$(LINK_FLAGS$Bld) \$(LINK_OBJS$Bld)\n", |
|
440 ); |
|
441 |
|
442 &main::Output( |
|
443 "\tcopy \"$BLDTRGPATH$Trg\" \"",&main::EPOCToolsPath,"$Trg\"\n" |
|
444 ); |
|
445 |
|
446 &main::Output( |
|
447 "\n", |
|
448 "\n" |
|
449 ); |
|
450 } |
|
451 |
|
452 sub PMStartSrcList { |
|
453 |
|
454 &main::Output( |
|
455 "# SOURCES\n", |
|
456 "\n" |
|
457 ); |
|
458 } |
|
459 |
|
460 |
|
461 sub PMStartSrc { |
|
462 my $Src=&main::Src; |
|
463 |
|
464 &main::Output( |
|
465 "# Source $Src\n", |
|
466 "\n" |
|
467 ); |
|
468 } |
|
469 |
|
470 sub PMSrcDepend { |
|
471 my @BldList=&main::BldList; |
|
472 my @DepList=&main::DepList; |
|
473 my $BaseSrc=&main::BaseSrc; |
|
474 $BaseSrc = "uid" if ($BaseSrc eq $uidfile); |
|
475 |
|
476 return if (@DepList == 0); |
|
477 |
|
478 foreach (@BldList) { |
|
479 &main::Output( |
|
480 &Generic_Quote("\$(EPOCBLD$_)\\$BaseSrc.o"), " \\\n", |
|
481 ); |
|
482 } |
|
483 &main::Output( |
|
484 ":" |
|
485 ); |
|
486 foreach (@DepList) { |
|
487 &main::Output( |
|
488 " \\\n\t", &Generic_Quote($_) |
|
489 ); |
|
490 } |
|
491 &main::Output( |
|
492 "\n", |
|
493 "\n" |
|
494 ); |
|
495 } |
|
496 |
|
497 sub PMSrcBldDepend { |
|
498 my $Bld=&main::Bld; |
|
499 my @DepList=&main::DepList; |
|
500 my $BaseSrc=&main::BaseSrc; |
|
501 $BaseSrc = "uid" if ($BaseSrc eq $uidfile); |
|
502 |
|
503 return if (@DepList == 0); |
|
504 |
|
505 &main::Output( |
|
506 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.o"), " :", |
|
507 ); |
|
508 foreach (@DepList) { |
|
509 &main::Output( |
|
510 " \\\n\t", &Generic_Quote($_) |
|
511 ); |
|
512 } |
|
513 &main::Output( |
|
514 "\n", |
|
515 "\n" |
|
516 ); |
|
517 } |
|
518 |
|
519 sub PMEndSrcBld { |
|
520 my $BaseSrc=&main::BaseSrc; |
|
521 $BaseSrc = "uid" if ($BaseSrc eq $uidfile); |
|
522 my $Bld=&main::Bld; |
|
523 my $Plat=&main::Plat; |
|
524 my $Src=&main::Src; |
|
525 my $SrcPath=&main::SrcPath; |
|
526 |
|
527 &main::Output( |
|
528 &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.o"), " : ", |
|
529 &Generic_Quote("$SrcPath$Src"), "\n", |
|
530 "\t\$(CW$Bld) -o \"\$\@\" -c \"$SrcPath$Src\"\n", |
|
531 "\n", |
|
532 # assembler listing target - uses implicit rule to do disassembly |
|
533 "LISTING$Bld$BaseSrc : ", &Generic_Quote("\$(EPOCBLD$Bld)\\$BaseSrc.lis"), "\n", |
|
534 "\t", &Generic_CopyAction("$SrcPath$BaseSrc.$Plat.lst"), |
|
535 "\n" |
|
536 ); |
|
537 } |
|
538 |
|
539 sub PMEndSrc { |
|
540 |
|
541 &main::Output( |
|
542 "\n", |
|
543 "\n" |
|
544 ); |
|
545 } |
|
546 |
|
547 sub PMEndSrcList { |
|
548 |
|
549 my $show_options = "source"; |
|
550 $show_options = "source,unmangled,comments" if ($MWLD eq "mwldsym2.exe"); |
|
551 |
|
552 &main::Output( |
|
553 "\n", |
|
554 "# Implicit rule for generating .lis files\n", |
|
555 "\n", |
|
556 ".SUFFIXES : .lis .o\n", |
|
557 "\n", |
|
558 ".o.lis:\n", |
|
559 "\t$MWLD -S -show $show_options \$< -o \$\@\n", |
|
560 "\n", |
|
561 "\n" |
|
562 ); |
|
563 |
|
564 # Deal with accumulated MAKEDIRS etc. |
|
565 |
|
566 &Generic_End; |
|
567 } |
|
568 |
|
569 1; |