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
.SurfaceAreaQuery
;
44 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
45 import org
.tianocore
.build
.id
.ModuleIdentification
;
46 import org
.tianocore
.build
.id
.PackageIdentification
;
47 import org
.tianocore
.build
.id
.PlatformIdentification
;
48 import org
.tianocore
.build
.tools
.ModuleItem
;
52 <code>GenBuildTask</code> is an ANT task that can be used in ANT build
55 <p>The main function of this task is to parse module's surface area (MSA),
56 then generate the corresponding <em>BaseName_build.xml</em> (the real ANT
57 build script) and call this to build the module. The whole process including:
60 1. generate AutoGen.c and AutoGen.h;
61 2. build all dependent library instances;
62 3. build all source files inlcude AutoGen.c;
64 5. generate FFS file if it is driver module while LIB file if it is Library module.
69 The usage is (take module <em>HelloWorld</em> for example):
74 msaFile="${PACKAGE_DIR}/Application/HelloWorld/HelloWorld.msa"
79 This task calls <code>AutoGen</code> to generate <em>AutoGen.c</em> and
84 This task will also set properties for current module, such as PACKAGE,
85 PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
86 (relative to Workspace), MODULE or BASE_NAME, GUID, VERSION, MODULE_DIR,
87 MODULE_RELATIVE_DIR (relative to Package), CONFIG_DIR, BIN_DIR,
88 DEST_DIR_DEBUG, DEST_DIR_OUTPUT, TARGET, ARCH, TOOLCHAIN, TOOLCHAIN_FAMILY,
89 SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH, all compiler command related
90 properties (CC, CC_FLAGS, CC_DPATH, CC_SPATH, CC_FAMILY, CC_EXT).
95 public class GenBuildTask
extends Ant
{
98 /// Module surface area file.
102 private String type
= "all";
105 /// Module's Identification.
107 private ModuleIdentification moduleId
;
109 private Vector
<Property
> properties
= new Vector
<Property
>();
111 private static Stack
<Hashtable
> backupPropertiesStack
= new Stack
<Hashtable
>();
113 private boolean isSingleModuleBuild
= false;
116 Public construct method. It is necessary for ANT task.
118 public GenBuildTask() {
123 @throws BuildException
124 From module build, exception from module surface area invalid.
126 public void execute() throws BuildException
{
130 GenBuildLogger logger
= new GenBuildLogger(getProject());
131 EdkLog
.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
132 EdkLog
.setLogger(logger
);
136 // Enable all specified properties
138 Iterator
<Property
> iter
= properties
.iterator();
139 while (iter
.hasNext()) {
140 Property item
= iter
.next();
141 getProject().setProperty(item
.getName(), item
.getValue());
145 // GenBuild should specify either msaFile or moduleGuid & packageGuid
147 if (msaFile
== null ) {
148 String moduleGuid
= getProject().getProperty("MODULE_GUID");
149 String moduleVersion
= getProject().getProperty("MODULE_VERSION");
150 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
151 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
152 if (moduleGuid
== null || packageGuid
== null) {
153 throw new BuildException("GenBuild parameter error.");
155 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
156 moduleId
= new ModuleIdentification(moduleGuid
, moduleVersion
);
157 moduleId
.setPackage(packageId
);
158 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(moduleId
);
159 SurfaceAreaQuery
.setDoc(doc
);
160 moduleId
= SurfaceAreaQuery
.getMsaHeader();
162 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(msaFile
);
163 SurfaceAreaQuery
.setDoc(doc
);
164 moduleId
= SurfaceAreaQuery
.getMsaHeader();
166 String
[] producedLibraryClasses
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED",null);
167 if (producedLibraryClasses
.length
== 0) {
168 moduleId
.setLibrary(false);
170 moduleId
.setLibrary(true);
174 // Judge whether it is single module build or not
176 if (isSingleModuleBuild
) {
178 // Single Module build
180 prepareSingleModuleBuild();
183 // Platform build. Restore the platform related info
185 String filename
= getProject().getProperty("PLATFORM_FILE");
186 PlatformIdentification platformId
= GlobalData
.getPlatform(filename
);
187 getProject().setProperty("PLATFORM_DIR", platformId
.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
188 getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId
.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
190 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
191 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
192 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
193 moduleId
.setPackage(packageId
);
197 // If single module : get arch from pass down, otherwise intersection MSA
198 // supported ARCHs and tools def
200 Set
<String
> archListSupByToolChain
= new LinkedHashSet
<String
>();
201 String
[] archs
= GlobalData
.getToolChainInfo().getArchs();
203 for (int i
= 0; i
< archs
.length
; i
++) {
204 archListSupByToolChain
.add(archs
[i
]);
207 Set
<String
> archSet
= new LinkedHashSet
<String
>();
209 if ( getProject().getProperty("ARCH") != null) {
210 String
[] fpdArchList
= getProject().getProperty("ARCH").split(" ");
212 for (int i
= 0; i
< fpdArchList
.length
; i
++) {
213 if (archListSupByToolChain
.contains(fpdArchList
[i
])) {
214 archSet
.add(fpdArchList
[i
]);
218 archSet
= archListSupByToolChain
;
221 String
[] archList
= archSet
.toArray(new String
[archSet
.size()]);
224 // Judge if arch is all supported by current module. If not, throw Exception.
226 List moduleSupportedArchs
= SurfaceAreaQuery
.getModuleSupportedArchs();
227 if (moduleSupportedArchs
!= null) {
228 for (int k
= 0; k
< archList
.length
; k
++) {
229 if ( ! moduleSupportedArchs
.contains(archList
[k
])) {
230 throw new BuildException("Specified architecture [" + archList
[k
] + "] is not supported by " + moduleId
+ ". The module " + moduleId
+ " only supports [" + moduleSupportedArchs
+ "] architectures.");
235 for (int k
= 0; k
< archList
.length
; k
++) {
237 getProject().setProperty("ARCH", archList
[k
]);
239 FpdModuleIdentification fpdModuleId
= new FpdModuleIdentification(moduleId
, archList
[k
]);
242 // Whether the module is built before
244 if (moduleId
.isLibrary() == false && GlobalData
.hasFpdModuleSA(fpdModuleId
) == false) {
245 System
.out
.println("\nWARNING: " + moduleId
+ " for " + archList
[k
] + " was not found in current platform FPD file!\n");
247 } else if (GlobalData
.isModuleBuilt(fpdModuleId
)) {
250 GlobalData
.registerBuiltModule(fpdModuleId
);
254 // For Every TOOLCHAIN, TARGET
256 String
[] targetList
= GlobalData
.getToolChainInfo().getTargets();
257 for (int i
= 0; i
< targetList
.length
; i
++){
259 // Prepare for target related common properties
262 getProject().setProperty("TARGET", targetList
[i
]);
263 String
[] toolchainList
= GlobalData
.getToolChainInfo().getTagnames();
264 for(int j
= 0; j
< toolchainList
.length
; j
++){
266 // check if any tool is defined for current target + toolchain + arch
267 // don't do anything if no tools found
269 if (GlobalData
.isCommandSet(targetList
[i
], toolchainList
[j
], archList
[k
]) == false) {
270 System
.out
.println("Warning: No build issued. No tools were found for [target=" + targetList
[i
] + " toolchain=" + toolchainList
[j
] + " arch=" + archList
[k
] + "]\n");
275 // Prepare for toolchain related common properties
278 getProject().setProperty("TOOLCHAIN", toolchainList
[j
]);
280 System
.out
.println("Build " + moduleId
+ " start >>>");
281 System
.out
.println("Target: " + targetList
[i
] + " Tagname: " + toolchainList
[j
] + " Arch: " + archList
[k
]);
282 SurfaceAreaQuery
.setDoc(GlobalData
.getDoc(fpdModuleId
));
285 // Prepare for all other common properties
286 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
287 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
288 // MODULE_DIR, MODULE_RELATIVE_DIR
289 // SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH
291 setModuleCommonProperties(archList
[k
]);
294 // OutputManage prepare for
295 // BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR
297 OutputManager
.getInstance().update(getProject());
299 if (type
.equalsIgnoreCase("all") || type
.equalsIgnoreCase("build")) {
300 applyBuild(targetList
[i
], toolchainList
[j
], fpdModuleId
);
301 } else if (type
.equalsIgnoreCase("clean")) {
302 applyClean(fpdModuleId
);
303 } else if (type
.equalsIgnoreCase("cleanall")) {
304 applyCleanall(fpdModuleId
);
314 This method is used to prepare Platform-related information.
316 <p>In Single Module Build mode, platform-related information is not ready.
317 The method read the system environment variable <code>ACTIVE_PLATFORM</code>
318 and search in the Framework Database. Note that platform name in the Framework
319 Database must be unique. </p>
322 private void prepareSingleModuleBuild(){
324 // Find out the package which the module belongs to
325 // TBD: Enhance it!!!!
327 PackageIdentification packageId
= GlobalData
.getPackageForModule(moduleId
);
329 moduleId
.setPackage(packageId
);
332 // Read ACTIVE_PLATFORM's FPD file
334 String filename
= getProject().getProperty("PLATFORM_FILE");
336 if (filename
== null){
337 throw new BuildException("Please set ACTIVE_PLATFORM in the file: Tools/Conf/target.txt if you want to build a single module!");
340 PlatformIdentification platformId
= GlobalData
.getPlatform(filename
);
343 // Read FPD file (Call FpdParserTask's method)
345 FpdParserTask fpdParser
= new FpdParserTask();
346 fpdParser
.setProject(getProject());
347 fpdParser
.parseFpdFile(platformId
.getFpdFile());
350 // Prepare for Platform related common properties
351 // PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
353 getProject().setProperty("PLATFORM", platformId
.getName());
354 getProject().setProperty("PLATFORM_DIR", platformId
.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
355 getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId
.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
360 Set Module-Related information to properties.
362 @param arch current build ARCH
364 private void setModuleCommonProperties(String arch
) {
366 // Prepare for all other common properties
367 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
369 PackageIdentification packageId
= moduleId
.getPackage();
370 getProject().setProperty("PACKAGE", packageId
.getName());
371 getProject().setProperty("PACKAGE_GUID", packageId
.getGuid());
372 getProject().setProperty("PACKAGE_VERSION", packageId
.getVersion());
373 getProject().setProperty("PACKAGE_DIR", packageId
.getPackageDir().replaceAll("(\\\\)", "/"));
374 getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId
.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
377 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
378 // MODULE_DIR, MODULE_RELATIVE_DIR
380 getProject().setProperty("MODULE", moduleId
.getName());
381 String baseName
= SurfaceAreaQuery
.getModuleOutputFileBasename();
382 if (baseName
== null) {
383 getProject().setProperty("BASE_NAME", moduleId
.getName());
385 getProject().setProperty("BASE_NAME", baseName
);
387 getProject().setProperty("GUID", moduleId
.getGuid());
388 getProject().setProperty("FILE_GUID", moduleId
.getGuid());
389 getProject().setProperty("VERSION", moduleId
.getVersion());
390 getProject().setProperty("MODULE_TYPE", moduleId
.getModuleType());
391 getProject().setProperty("MODULE_DIR", moduleId
.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
392 getProject().setProperty("MODULE_RELATIVE_DIR", moduleId
.getModuleRelativePath().replaceAll("(\\\\)", "/"));
397 String
[][] subsystemMap
= { { "BASE", "EFI_BOOT_SERVICE_DRIVER"},
398 { "SEC", "EFI_BOOT_SERVICE_DRIVER" },
399 { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" },
400 { "PEIM", "EFI_BOOT_SERVICE_DRIVER" },
401 { "DXE_CORE", "EFI_BOOT_SERVICE_DRIVER" },
402 { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
403 { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" },
404 { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
405 { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
406 { "TOOL", "EFI_BOOT_SERVICE_DRIVER" },
407 { "UEFI_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
408 { "UEFI_APPLICATION", "EFI_APPLICATION" },
409 { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} };
411 String subsystem
= "EFI_BOOT_SERVICE_DRIVER";
412 for (int i
= 0; i
< subsystemMap
.length
; i
++) {
413 if (moduleId
.getModuleType().equalsIgnoreCase(subsystemMap
[i
][0])) {
414 subsystem
= subsystemMap
[i
][1];
418 getProject().setProperty("SUBSYSTEM", subsystem
);
423 if (arch
.equalsIgnoreCase("EBC")) {
424 getProject().setProperty("ENTRYPOINT", "EfiStart");
426 getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");
429 getProject().setProperty("OBJECTS", "");
432 private void getCompilerFlags(String target
, String toolchain
, FpdModuleIdentification fpdModuleId
) throws EdkException
{
433 String
[] cmd
= GlobalData
.getToolChainInfo().getCommands();
434 for ( int m
= 0; m
< cmd
.length
; m
++) {
436 // Set cmd, like CC, DLINK
438 String
[] key
= new String
[]{target
, toolchain
, fpdModuleId
.getArch(), cmd
[m
], null};
439 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_PATH
;
440 String cmdPath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
441 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_NAME
;
442 String cmdName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
443 File cmdFile
= new File(cmdPath
+ File
.separatorChar
+ cmdName
);
444 getProject().setProperty(cmd
[m
], cmdFile
.getPath().replaceAll("(\\\\)", "/"));
449 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_FLAGS
;
450 String cmdFlags
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
451 Set
<String
> addset
= new LinkedHashSet
<String
>();
452 Set
<String
> subset
= new LinkedHashSet
<String
>();
453 putFlagsToSet(addset
, cmdFlags
);
454 getProject().setProperty(cmd
[m
] + "_FLAGS", getProject().replaceProperties(getFlags(addset
, subset
)));
459 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_EXT
;
460 String extName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
461 if ( extName
!= null && ! extName
.equalsIgnoreCase("")) {
462 getProject().setProperty(cmd
[m
] + "_EXT", extName
);
464 getProject().setProperty(cmd
[m
] + "_EXT", "");
470 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_FAMILY
;
471 String toolChainFamily
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
472 if (toolChainFamily
!= null) {
473 getProject().setProperty(cmd
[m
] + "_FAMILY", toolChainFamily
);
479 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_SPATH
;
480 String spath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
482 getProject().setProperty(cmd
[m
] + "_SPATH", spath
.replaceAll("(\\\\)", "/"));
484 getProject().setProperty(cmd
[m
] + "_SPATH", "");
490 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_DPATH
;
491 String dpath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
493 getProject().setProperty(cmd
[m
] + "_DPATH", dpath
.replaceAll("(\\\\)", "/"));
495 getProject().setProperty(cmd
[m
] + "_DPATH", "");
500 public void setMsaFile(File msaFile
) {
501 this.msaFile
= msaFile
;
505 Method is for ANT to initialize MSA file.
507 @param msaFilename MSA file name
509 public void setMsaFile(String msaFilename
) {
510 String moduleDir
= getProject().getProperty("MODULE_DIR");
513 // If is Single Module Build, then use the Base Dir defined in build.xml
515 if (moduleDir
== null) {
516 moduleDir
= getProject().getBaseDir().getPath();
518 msaFile
= new File(moduleDir
+ File
.separatorChar
+ msaFilename
);
521 public void addConfiguredModuleItem(ModuleItem moduleItem
) {
522 PackageIdentification packageId
= new PackageIdentification(moduleItem
.getPackageGuid(), moduleItem
.getPackageVersion());
523 ModuleIdentification moduleId
= new ModuleIdentification(moduleItem
.getModuleGuid(), moduleItem
.getModuleVersion());
524 moduleId
.setPackage(packageId
);
525 this.moduleId
= moduleId
;
533 public void addProperty(Property p
) {
534 properties
.addElement(p
);
537 public void setType(String type
) {
541 private void applyBuild(String buildTarget
, String buildTagname
, FpdModuleIdentification fpdModuleId
) throws BuildException
{
546 AutoGen autogen
= new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId
.getModule(),fpdModuleId
.getArch());
547 autogen
.genAutogen();
551 // Get compiler flags
554 getCompilerFlags(buildTarget
, buildTagname
, fpdModuleId
);
556 catch (EdkException ee
) {
557 throw new BuildException(ee
.getMessage());
563 ModuleIdentification
[] libinstances
= SurfaceAreaQuery
.getLibraryInstance(fpdModuleId
.getArch());
564 String propertyLibs
= "";
565 for (int i
= 0; i
< libinstances
.length
; i
++) {
566 propertyLibs
+= " " + getProject().getProperty("BIN_DIR") + File
.separatorChar
+ libinstances
[i
].getName() + ".lib";
568 getProject().setProperty("LIBS", propertyLibs
.replaceAll("(\\\\)", "/"));
571 // if it is CUSTOM_BUILD
572 // then call the exist BaseName_build.xml directly.
574 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
575 System
.out
.println("Call user-defined " + moduleId
.getName() + "_build.xml");
577 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
578 antCall(antFilename
, null);
584 // Generate ${BASE_NAME}_build.xml
587 String ffsKeyword
= SurfaceAreaQuery
.getModuleFfsKeyword();
588 ModuleBuildFileGenerator fileGenerator
= new ModuleBuildFileGenerator(getProject(), ffsKeyword
, fpdModuleId
);
589 String buildFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
590 fileGenerator
.genBuildFile(buildFilename
);
593 // Ant call ${BASE_NAME}_build.xml
595 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
596 antCall(antFilename
, null);
599 private void applyClean(FpdModuleIdentification fpdModuleId
){
601 // if it is CUSTOM_BUILD
602 // then call the exist BaseName_build.xml directly.
604 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
605 System
.out
.println("Calling user-defined " + moduleId
.getName() + "_build.xml");
607 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
608 antCall(antFilename
, "clean");
613 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
614 antCall(antFilename
, "clean");
617 private void applyCleanall(FpdModuleIdentification fpdModuleId
){
619 // if it is CUSTOM_BUILD
620 // then call the exist BaseName_build.xml directly.
622 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
623 System
.out
.println("Calling user-defined " + moduleId
.getName() + "_build.xml");
625 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
626 antCall(antFilename
, "cleanall");
631 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
632 antCall(antFilename
, "cleanall");
635 private void antCall(String antFilename
, String target
) {
637 ant
.setProject(getProject());
638 ant
.setAntfile(antFilename
);
639 if (target
!= null) {
640 ant
.setTarget(target
);
642 ant
.setInheritAll(true);
649 Separate the string and instore in set.
651 <p> String is separated by Java Regulation Expression
652 "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+". </p>
657 "/nologo", "/W3", "/WX"
658 "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
661 @param set store the separated string
662 @param str string to separate
664 private void putFlagsToSet(Set
<String
> set
, String str
) {
665 if (str
== null || str
.length() == 0) {
669 Pattern myPattern
= Pattern
.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
670 Matcher matcher
= myPattern
.matcher(str
+ " ");
671 while (matcher
.find()) {
672 String item
= str
.substring(matcher
.start(1), matcher
.end(1));
678 Generate the final flags string will be used by compile command.
680 @param add the add flags set
681 @param sub the sub flags set
682 @return final flags after add set substract sub set
684 private String
getFlags(Set
<String
> add
, Set
<String
> sub
) {
687 Iterator iter
= add
.iterator();
688 while (iter
.hasNext()) {
689 String str
= (String
) iter
.next();
690 result
+= str
.substring(1, str
.length() - 1) + " ";
695 private void pushProperties() {
696 backupPropertiesStack
.push(getProject().getProperties());
699 private void popProperties() {
700 Hashtable backupProperties
= backupPropertiesStack
.pop();
701 Set keys
= backupProperties
.keySet();
702 Iterator iter
= keys
.iterator();
703 while (iter
.hasNext()) {
704 String item
= (String
)iter
.next();
705 getProject().setProperty(item
, (String
)backupProperties
.get(item
));
709 public void setSingleModuleBuild(boolean isSingleModuleBuild
) {
710 this.isSingleModuleBuild
= isSingleModuleBuild
;