2 This file is ANT task GenBuild.
4 The file is used to parse a specified Module, and generate its build time
5 ANT script build.xml, then call the the ANT script to build the module.
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 package org
.tianocore
.build
;
19 import java
.util
.Hashtable
;
20 import java
.util
.Iterator
;
21 import java
.util
.LinkedHashSet
;
22 import java
.util
.List
;
25 import java
.util
.Stack
;
26 import java
.util
.Vector
;
27 import java
.util
.regex
.Matcher
;
28 import java
.util
.regex
.Pattern
;
30 import org
.apache
.tools
.ant
.BuildException
;
31 import org
.apache
.tools
.ant
.taskdefs
.Ant
;
32 import org
.apache
.tools
.ant
.taskdefs
.Property
;
33 import org
.apache
.xmlbeans
.XmlObject
;
35 import org
.tianocore
.common
.definitions
.ToolDefinitions
;
36 import org
.tianocore
.common
.exception
.EdkException
;
37 import org
.tianocore
.common
.logger
.EdkLog
;
38 import org
.tianocore
.build
.autogen
.AutoGen
;
39 import org
.tianocore
.build
.fpd
.FpdParserTask
;
40 import org
.tianocore
.build
.global
.GenBuildLogger
;
41 import org
.tianocore
.build
.global
.GlobalData
;
42 import org
.tianocore
.build
.global
.OutputManager
;
43 import org
.tianocore
.build
.global
.PropertyManager
;
44 import org
.tianocore
.build
.global
.SurfaceAreaQuery
;
45 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
46 import org
.tianocore
.build
.id
.ModuleIdentification
;
47 import org
.tianocore
.build
.id
.PackageIdentification
;
48 import org
.tianocore
.build
.id
.PlatformIdentification
;
49 import org
.tianocore
.build
.tools
.ModuleItem
;
53 <code>GenBuildTask</code> is an ANT task that can be used in ANT build
56 <p>The main function of this task is to parse module's surface area (MSA),
57 then generate the corresponding <em>BaseName_build.xml</em> (the real ANT
58 build script) and call this to build the module. The whole process including:
61 1. generate AutoGen.c and AutoGen.h;
62 2. build all dependent library instances;
63 3. build all source files inlcude AutoGen.c;
65 5. generate FFS file if it is driver module while LIB file if it is Library module.
70 The usage is (take module <em>HelloWorld</em> for example):
75 msaFile="${PACKAGE_DIR}/Application/HelloWorld/HelloWorld.msa"
80 This task calls <code>AutoGen</code> to generate <em>AutoGen.c</em> and
85 This task will also set properties for current module, such as PACKAGE,
86 PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
87 (relative to Workspace), MODULE or BASE_NAME, GUID, VERSION, MODULE_DIR,
88 MODULE_RELATIVE_DIR (relative to Package), CONFIG_DIR, BIN_DIR,
89 DEST_DIR_DEBUG, DEST_DIR_OUTPUT, TARGET, ARCH, TOOLCHAIN, TOOLCHAIN_FAMILY,
90 SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH, all compiler command related
91 properties (CC, CC_FLAGS, CC_DPATH, CC_SPATH, CC_FAMILY, CC_EXT).
96 public class GenBuildTask
extends Ant
{
99 /// Module surface area file.
103 private String type
= "all";
106 /// Module's Identification.
108 private ModuleIdentification moduleId
;
110 private Vector
<Property
> properties
= new Vector
<Property
>();
112 private static Stack
<Hashtable
> backupPropertiesStack
= new Stack
<Hashtable
>();
114 private boolean isSingleModuleBuild
= false;
117 Public construct method. It is necessary for ANT task.
119 public GenBuildTask() {
124 @throws BuildException
125 From module build, exception from module surface area invalid.
127 public void execute() throws BuildException
{
131 GenBuildLogger logger
= new GenBuildLogger(getProject());
132 EdkLog
.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
133 EdkLog
.setLogger(logger
);
135 PropertyManager
.setProject(getProject());
136 PropertyManager
.save();
138 // Enable all specified properties
140 Iterator
<Property
> iter
= properties
.iterator();
141 while (iter
.hasNext()) {
142 Property item
= iter
.next();
143 PropertyManager
.setProperty(item
.getName(), item
.getValue());
147 // GenBuild should specify either msaFile or moduleGuid & packageGuid
149 if (msaFile
== null ) {
150 String moduleGuid
= getProject().getProperty("MODULE_GUID");
151 String moduleVersion
= getProject().getProperty("MODULE_VERSION");
152 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
153 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
154 if (moduleGuid
== null || packageGuid
== null) {
155 throw new BuildException("GenBuild parameter error.");
157 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
158 moduleId
= new ModuleIdentification(moduleGuid
, moduleVersion
);
159 moduleId
.setPackage(packageId
);
160 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(moduleId
);
161 SurfaceAreaQuery
.setDoc(doc
);
162 moduleId
= SurfaceAreaQuery
.getMsaHeader();
164 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(msaFile
);
165 SurfaceAreaQuery
.setDoc(doc
);
166 moduleId
= SurfaceAreaQuery
.getMsaHeader();
168 String
[] producedLibraryClasses
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED",null);
169 if (producedLibraryClasses
.length
== 0) {
170 moduleId
.setLibrary(false);
172 moduleId
.setLibrary(true);
176 // Judge whether it is single module build or not
178 if (isSingleModuleBuild
) {
180 // Single Module build
182 prepareSingleModuleBuild();
185 // Platform build. Restore the platform related info
187 String filename
= getProject().getProperty("PLATFORM_FILE");
188 PlatformIdentification platformId
= GlobalData
.getPlatform(filename
);
189 PropertyManager
.setProperty("PLATFORM_DIR", platformId
.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
190 PropertyManager
.setProperty("PLATFORM_RELATIVE_DIR", platformId
.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
192 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
193 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
194 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
195 moduleId
.setPackage(packageId
);
199 // If single module : get arch from pass down, otherwise intersection MSA
200 // supported ARCHs and tools def
202 Set
<String
> archListSupByToolChain
= new LinkedHashSet
<String
>();
203 String
[] archs
= GlobalData
.getToolChainInfo().getArchs();
205 for (int i
= 0; i
< archs
.length
; i
++) {
206 archListSupByToolChain
.add(archs
[i
]);
209 Set
<String
> archSet
= new LinkedHashSet
<String
>();
211 if ( getProject().getProperty("ARCH") != null) {
212 String
[] fpdArchList
= getProject().getProperty("ARCH").split(" ");
214 for (int i
= 0; i
< fpdArchList
.length
; i
++) {
215 if (archListSupByToolChain
.contains(fpdArchList
[i
])) {
216 archSet
.add(fpdArchList
[i
]);
220 archSet
= archListSupByToolChain
;
223 String
[] archList
= archSet
.toArray(new String
[archSet
.size()]);
226 // Judge if arch is all supported by current module. If not, throw Exception.
228 List moduleSupportedArchs
= SurfaceAreaQuery
.getModuleSupportedArchs();
229 if (moduleSupportedArchs
!= null) {
230 for (int k
= 0; k
< archList
.length
; k
++) {
231 if ( ! moduleSupportedArchs
.contains(archList
[k
])) {
232 throw new BuildException("Specified architecture [" + archList
[k
] + "] is not supported by " + moduleId
+ ". The module " + moduleId
+ " only supports [" + moduleSupportedArchs
+ "] architectures.");
237 for (int k
= 0; k
< archList
.length
; k
++) {
239 PropertyManager
.setProperty("ARCH", archList
[k
]);
241 FpdModuleIdentification fpdModuleId
= new FpdModuleIdentification(moduleId
, archList
[k
]);
244 // Whether the module is built before
246 if (moduleId
.isLibrary() == false && GlobalData
.hasFpdModuleSA(fpdModuleId
) == false) {
247 System
.out
.println("\nWARNING: " + moduleId
+ " for " + archList
[k
] + " was not found in current platform FPD file!\n");
249 } else if (GlobalData
.isModuleBuilt(fpdModuleId
)) {
252 GlobalData
.registerBuiltModule(fpdModuleId
);
256 // For Every TOOLCHAIN, TARGET
258 String
[] targetList
= GlobalData
.getToolChainInfo().getTargets();
259 for (int i
= 0; i
< targetList
.length
; i
++){
261 // Prepare for target related common properties
264 PropertyManager
.setProperty("TARGET", targetList
[i
]);
265 String
[] toolchainList
= GlobalData
.getToolChainInfo().getTagnames();
266 for(int j
= 0; j
< toolchainList
.length
; j
++){
268 // check if any tool is defined for current target + toolchain + arch
269 // don't do anything if no tools found
271 if (GlobalData
.isCommandSet(targetList
[i
], toolchainList
[j
], archList
[k
]) == false) {
272 System
.out
.println("Warning: No build issued. No tools were found for [target=" + targetList
[i
] + " toolchain=" + toolchainList
[j
] + " arch=" + archList
[k
] + "]\n");
277 // Prepare for toolchain related common properties
280 PropertyManager
.setProperty("TOOLCHAIN", toolchainList
[j
]);
282 System
.out
.println("Build " + moduleId
+ " start >>>");
283 System
.out
.println("Target: " + targetList
[i
] + " Tagname: " + toolchainList
[j
] + " Arch: " + archList
[k
]);
284 SurfaceAreaQuery
.setDoc(GlobalData
.getDoc(fpdModuleId
));
287 // Prepare for all other common properties
288 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
289 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
290 // MODULE_DIR, MODULE_RELATIVE_DIR
291 // SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH
293 setModuleCommonProperties(archList
[k
]);
296 // OutputManage prepare for
297 // BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR
299 OutputManager
.getInstance().update(getProject());
301 if (type
.equalsIgnoreCase("all") || type
.equalsIgnoreCase("build")) {
302 applyBuild(targetList
[i
], toolchainList
[j
], fpdModuleId
);
303 } else if (type
.equalsIgnoreCase("clean")) {
304 applyClean(fpdModuleId
);
305 } else if (type
.equalsIgnoreCase("cleanall")) {
306 applyCleanall(fpdModuleId
);
312 PropertyManager
.restore();
316 This method is used to prepare Platform-related information.
318 <p>In Single Module Build mode, platform-related information is not ready.
319 The method read the system environment variable <code>ACTIVE_PLATFORM</code>
320 and search in the Framework Database. Note that platform name in the Framework
321 Database must be unique. </p>
324 private void prepareSingleModuleBuild(){
326 // Find out the package which the module belongs to
327 // TBD: Enhance it!!!!
329 PackageIdentification packageId
= GlobalData
.getPackageForModule(moduleId
);
331 moduleId
.setPackage(packageId
);
334 // Read ACTIVE_PLATFORM's FPD file
336 String filename
= getProject().getProperty("PLATFORM_FILE");
338 if (filename
== null){
339 throw new BuildException("Please set ACTIVE_PLATFORM in the file: Tools/Conf/target.txt if you want to build a single module!");
342 PlatformIdentification platformId
= GlobalData
.getPlatform(filename
);
345 // Read FPD file (Call FpdParserTask's method)
347 FpdParserTask fpdParser
= new FpdParserTask();
348 fpdParser
.setProject(getProject());
349 fpdParser
.parseFpdFile(platformId
.getFpdFile());
352 // Prepare for Platform related common properties
353 // PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
355 PropertyManager
.setProperty("PLATFORM", platformId
.getName());
356 PropertyManager
.setProperty("PLATFORM_DIR", platformId
.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
357 PropertyManager
.setProperty("PLATFORM_RELATIVE_DIR", platformId
.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
362 Set Module-Related information to properties.
364 @param arch current build ARCH
366 private void setModuleCommonProperties(String arch
) {
368 // Prepare for all other common properties
369 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
371 PackageIdentification packageId
= moduleId
.getPackage();
372 PropertyManager
.setProperty("PACKAGE", packageId
.getName());
373 PropertyManager
.setProperty("PACKAGE_GUID", packageId
.getGuid());
374 PropertyManager
.setProperty("PACKAGE_VERSION", packageId
.getVersion());
375 PropertyManager
.setProperty("PACKAGE_DIR", packageId
.getPackageDir().replaceAll("(\\\\)", "/"));
376 PropertyManager
.setProperty("PACKAGE_RELATIVE_DIR", packageId
.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
379 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
380 // MODULE_DIR, MODULE_RELATIVE_DIR
382 PropertyManager
.setProperty("MODULE", moduleId
.getName());
383 String baseName
= SurfaceAreaQuery
.getModuleOutputFileBasename();
384 if (baseName
== null) {
385 PropertyManager
.setProperty("BASE_NAME", moduleId
.getName());
387 PropertyManager
.setProperty("BASE_NAME", baseName
);
389 PropertyManager
.setProperty("GUID", moduleId
.getGuid());
390 PropertyManager
.setProperty("FILE_GUID", moduleId
.getGuid());
391 PropertyManager
.setProperty("VERSION", moduleId
.getVersion());
392 PropertyManager
.setProperty("MODULE_TYPE", moduleId
.getModuleType());
393 PropertyManager
.setProperty("MODULE_DIR", moduleId
.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
394 PropertyManager
.setProperty("MODULE_RELATIVE_DIR", moduleId
.getModuleRelativePath().replaceAll("(\\\\)", "/"));
399 String
[][] subsystemMap
= { { "BASE", "EFI_BOOT_SERVICE_DRIVER"},
400 { "SEC", "EFI_BOOT_SERVICE_DRIVER" },
401 { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" },
402 { "PEIM", "EFI_BOOT_SERVICE_DRIVER" },
403 { "DXE_CORE", "EFI_BOOT_SERVICE_DRIVER" },
404 { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
405 { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" },
406 { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
407 { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
408 { "TOOL", "EFI_BOOT_SERVICE_DRIVER" },
409 { "UEFI_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
410 { "UEFI_APPLICATION", "EFI_APPLICATION" },
411 { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} };
413 String subsystem
= "EFI_BOOT_SERVICE_DRIVER";
414 for (int i
= 0; i
< subsystemMap
.length
; i
++) {
415 if (moduleId
.getModuleType().equalsIgnoreCase(subsystemMap
[i
][0])) {
416 subsystem
= subsystemMap
[i
][1];
420 PropertyManager
.setProperty("SUBSYSTEM", subsystem
);
425 if (arch
.equalsIgnoreCase("EBC")) {
426 PropertyManager
.setProperty("ENTRYPOINT", "EfiStart");
428 PropertyManager
.setProperty("ENTRYPOINT", "_ModuleEntryPoint");
431 PropertyManager
.setProperty("OBJECTS", "");
434 private void getCompilerFlags(String target
, String toolchain
, FpdModuleIdentification fpdModuleId
) throws EdkException
{
435 String
[] cmd
= GlobalData
.getToolChainInfo().getCommands();
436 for ( int m
= 0; m
< cmd
.length
; m
++) {
438 // Set cmd, like CC, DLINK
440 String
[] key
= new String
[]{target
, toolchain
, fpdModuleId
.getArch(), cmd
[m
], null};
441 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_PATH
;
442 String cmdPath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
443 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_NAME
;
444 String cmdName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
445 File cmdFile
= new File(cmdPath
+ File
.separatorChar
+ cmdName
);
446 PropertyManager
.setProperty(cmd
[m
], cmdFile
.getPath().replaceAll("(\\\\)", "/"));
451 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_FLAGS
;
452 String cmdFlags
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
453 Set
<String
> addset
= new LinkedHashSet
<String
>();
454 Set
<String
> subset
= new LinkedHashSet
<String
>();
455 putFlagsToSet(addset
, cmdFlags
);
456 PropertyManager
.setProperty(cmd
[m
] + "_FLAGS", getProject().replaceProperties(getFlags(addset
, subset
)));
461 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_EXT
;
462 String extName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
463 if ( extName
!= null && ! extName
.equalsIgnoreCase("")) {
464 PropertyManager
.setProperty(cmd
[m
] + "_EXT", extName
);
466 PropertyManager
.setProperty(cmd
[m
] + "_EXT", "");
472 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_FAMILY
;
473 String toolChainFamily
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
474 if (toolChainFamily
!= null) {
475 PropertyManager
.setProperty(cmd
[m
] + "_FAMILY", toolChainFamily
);
481 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_SPATH
;
482 String spath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
484 PropertyManager
.setProperty(cmd
[m
] + "_SPATH", spath
.replaceAll("(\\\\)", "/"));
486 PropertyManager
.setProperty(cmd
[m
] + "_SPATH", "");
492 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_DPATH
;
493 String dpath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
495 PropertyManager
.setProperty(cmd
[m
] + "_DPATH", dpath
.replaceAll("(\\\\)", "/"));
497 PropertyManager
.setProperty(cmd
[m
] + "_DPATH", "");
502 public void setMsaFile(File msaFile
) {
503 this.msaFile
= msaFile
;
507 Method is for ANT to initialize MSA file.
509 @param msaFilename MSA file name
511 public void setMsaFile(String msaFilename
) {
512 String moduleDir
= getProject().getProperty("MODULE_DIR");
515 // If is Single Module Build, then use the Base Dir defined in build.xml
517 if (moduleDir
== null) {
518 moduleDir
= getProject().getBaseDir().getPath();
520 msaFile
= new File(moduleDir
+ File
.separatorChar
+ msaFilename
);
523 public void addConfiguredModuleItem(ModuleItem moduleItem
) {
524 PackageIdentification packageId
= new PackageIdentification(moduleItem
.getPackageGuid(), moduleItem
.getPackageVersion());
525 ModuleIdentification moduleId
= new ModuleIdentification(moduleItem
.getModuleGuid(), moduleItem
.getModuleVersion());
526 moduleId
.setPackage(packageId
);
527 this.moduleId
= moduleId
;
535 public void addProperty(Property p
) {
536 properties
.addElement(p
);
539 public void setType(String type
) {
543 private void applyBuild(String buildTarget
, String buildTagname
, FpdModuleIdentification fpdModuleId
) throws BuildException
{
548 AutoGen autogen
= new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId
.getModule(),fpdModuleId
.getArch());
549 autogen
.genAutogen();
553 // Get compiler flags
556 getCompilerFlags(buildTarget
, buildTagname
, fpdModuleId
);
558 catch (EdkException ee
) {
559 throw new BuildException(ee
.getMessage());
565 ModuleIdentification
[] libinstances
= SurfaceAreaQuery
.getLibraryInstance(fpdModuleId
.getArch());
566 String propertyLibs
= "";
567 for (int i
= 0; i
< libinstances
.length
; i
++) {
568 propertyLibs
+= " " + getProject().getProperty("BIN_DIR") + File
.separatorChar
+ libinstances
[i
].getName() + ".lib";
570 PropertyManager
.setProperty("LIBS", propertyLibs
.replaceAll("(\\\\)", "/"));
573 // if it is CUSTOM_BUILD
574 // then call the exist BaseName_build.xml directly.
576 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
577 System
.out
.println("Call user-defined " + moduleId
.getName() + "_build.xml");
579 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
580 antCall(antFilename
, null);
586 // Generate ${BASE_NAME}_build.xml
589 String ffsKeyword
= SurfaceAreaQuery
.getModuleFfsKeyword();
590 ModuleBuildFileGenerator fileGenerator
= new ModuleBuildFileGenerator(getProject(), ffsKeyword
, fpdModuleId
);
591 String buildFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
592 fileGenerator
.genBuildFile(buildFilename
);
595 // Ant call ${BASE_NAME}_build.xml
597 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
598 antCall(antFilename
, null);
601 private void applyClean(FpdModuleIdentification fpdModuleId
){
603 // if it is CUSTOM_BUILD
604 // then call the exist BaseName_build.xml directly.
606 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
607 System
.out
.println("Calling user-defined " + moduleId
.getName() + "_build.xml");
609 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
610 antCall(antFilename
, "clean");
615 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
616 antCall(antFilename
, "clean");
619 private void applyCleanall(FpdModuleIdentification fpdModuleId
){
621 // if it is CUSTOM_BUILD
622 // then call the exist BaseName_build.xml directly.
624 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
625 System
.out
.println("Calling user-defined " + moduleId
.getName() + "_build.xml");
627 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
628 antCall(antFilename
, "cleanall");
633 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
634 antCall(antFilename
, "cleanall");
637 private void antCall(String antFilename
, String target
) {
639 ant
.setProject(getProject());
640 ant
.setAntfile(antFilename
);
641 if (target
!= null) {
642 ant
.setTarget(target
);
644 ant
.setInheritAll(true);
651 Separate the string and instore in set.
653 <p> String is separated by Java Regulation Expression
654 "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+". </p>
659 "/nologo", "/W3", "/WX"
660 "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
663 @param set store the separated string
664 @param str string to separate
666 private void putFlagsToSet(Set
<String
> set
, String str
) {
667 if (str
== null || str
.length() == 0) {
671 Pattern myPattern
= Pattern
.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
672 Matcher matcher
= myPattern
.matcher(str
+ " ");
673 while (matcher
.find()) {
674 String item
= str
.substring(matcher
.start(1), matcher
.end(1));
680 Generate the final flags string will be used by compile command.
682 @param add the add flags set
683 @param sub the sub flags set
684 @return final flags after add set substract sub set
686 private String
getFlags(Set
<String
> add
, Set
<String
> sub
) {
689 Iterator iter
= add
.iterator();
690 while (iter
.hasNext()) {
691 String str
= (String
) iter
.next();
692 result
+= str
.substring(1, str
.length() - 1) + " ";
697 public void setSingleModuleBuild(boolean isSingleModuleBuild
) {
698 this.isSingleModuleBuild
= isSingleModuleBuild
;