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:
59 1. generate AutoGen.c and AutoGen.h;
60 2. build all dependent library instances;
61 3. build all source files inlcude AutoGen.c;
63 5. generate FFS file if it is driver module while LIB file if it is Library module.
68 The usage is (take module <em>HelloWorld</em> for example):
73 msaFilename="HelloWorld.msa"/>
74 processTo="ALL"/>
77 <p><code>processTo</code> provides a way to customize the whole build process.
78 processTo can be one value of ALL, AUTOGEN, FILES, LIBRARYINSTANCES, SECTIONS, NONE.
79 Default is ALL, means whole
83 This task calls <code>AutoGen</code> to generate <em>AutoGen.c</em> and
84 <em>AutoGen.h</em>. The task also parses the development environment
85 configuration files, such as collecting package information, setting compiler
92 public class GenBuildTask
extends Ant
{
95 /// Module surface area file.
99 private String type
= "all";
102 /// Module's Identification.
104 private ModuleIdentification moduleId
;
106 private Vector
<Property
> properties
= new Vector
<Property
>();
108 private static Stack
<Hashtable
> backupPropertiesStack
= new Stack
<Hashtable
>();
110 private boolean isSingleModuleBuild
= false;
113 Public construct method. It is necessary for ANT task.
115 public GenBuildTask() {
120 @throws BuildException
121 From module build, exception from module surface area invalid.
123 public void execute() throws BuildException
{
127 GenBuildLogger logger
= new GenBuildLogger(getProject());
128 EdkLog
.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
129 EdkLog
.setLogger(logger
);
133 // Enable all specified properties
135 Iterator
<Property
> iter
= properties
.iterator();
136 while (iter
.hasNext()) {
137 Property item
= iter
.next();
138 getProject().setProperty(item
.getName(), item
.getValue());
142 // GenBuild should specify either msaFile or moduleGuid & packageGuid
144 if (msaFile
== null ) {
145 String moduleGuid
= getProject().getProperty("MODULE_GUID");
146 String moduleVersion
= getProject().getProperty("MODULE_VERSION");
147 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
148 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
149 if (moduleGuid
== null || packageGuid
== null) {
150 throw new BuildException("GenBuild parameter error.");
152 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
153 moduleId
= new ModuleIdentification(moduleGuid
, moduleVersion
);
154 moduleId
.setPackage(packageId
);
155 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(moduleId
);
156 SurfaceAreaQuery
.setDoc(doc
);
157 moduleId
= SurfaceAreaQuery
.getMsaHeader();
159 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(msaFile
);
160 SurfaceAreaQuery
.setDoc(doc
);
161 moduleId
= SurfaceAreaQuery
.getMsaHeader();
163 String
[] producedLibraryClasses
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED",null);
164 if (producedLibraryClasses
.length
== 0) {
165 moduleId
.setLibrary(false);
167 moduleId
.setLibrary(true);
171 // Judge whether it is single module build or not
173 if (isSingleModuleBuild
) {
175 // Single Module build
177 prepareSingleModuleBuild();
180 // Platform build. Restore the platform related info
182 String filename
= getProject().getProperty("PLATFORM_FILE");
183 PlatformIdentification platformId
= GlobalData
.getPlatform(filename
);
184 getProject().setProperty("PLATFORM_DIR", platformId
.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
185 getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId
.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
187 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
188 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
189 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
190 moduleId
.setPackage(packageId
);
194 // If single module : get arch from pass down, otherwise intersection MSA
195 // supported ARCHs and tools def
197 Set
<String
> archListSupByToolChain
= new LinkedHashSet
<String
>();
198 String
[] archs
= GlobalData
.getToolChainInfo().getArchs();
200 for (int i
= 0; i
< archs
.length
; i
++) {
201 archListSupByToolChain
.add(archs
[i
]);
204 Set
<String
> archSet
= new LinkedHashSet
<String
>();
206 if ( getProject().getProperty("ARCH") != null) {
207 String
[] fpdArchList
= getProject().getProperty("ARCH").split(" ");
209 for (int i
= 0; i
< fpdArchList
.length
; i
++) {
210 if (archListSupByToolChain
.contains(fpdArchList
[i
])) {
211 archSet
.add(fpdArchList
[i
]);
215 archSet
= archListSupByToolChain
;
218 String
[] archList
= archSet
.toArray(new String
[archSet
.size()]);
221 // Judge if arch is all supported by current module. If not, throw Exception.
223 List moduleSupportedArchs
= SurfaceAreaQuery
.getModuleSupportedArchs();
224 if (moduleSupportedArchs
!= null) {
225 for (int k
= 0; k
< archList
.length
; k
++) {
226 if ( ! moduleSupportedArchs
.contains(archList
[k
])) {
227 throw new BuildException("Specified architecture [" + archList
[k
] + "] is not supported by " + moduleId
+ ". The module " + moduleId
+ " only supports [" + moduleSupportedArchs
+ "] architectures.");
232 for (int k
= 0; k
< archList
.length
; k
++) {
234 getProject().setProperty("ARCH", archList
[k
]);
236 FpdModuleIdentification fpdModuleId
= new FpdModuleIdentification(moduleId
, archList
[k
]);
239 // Whether the module is built before
241 if (moduleId
.isLibrary() == false && GlobalData
.hasFpdModuleSA(fpdModuleId
) == false) {
242 System
.out
.println("\nWARNING: " + moduleId
+ " for " + archList
[k
] + " was not found in current platform FPD file!\n");
244 } else if (GlobalData
.isModuleBuilt(fpdModuleId
)) {
247 GlobalData
.registerBuiltModule(fpdModuleId
);
251 // For Every TOOLCHAIN, TARGET
253 String
[] targetList
= GlobalData
.getToolChainInfo().getTargets();
254 for (int i
= 0; i
< targetList
.length
; i
++){
256 // Prepare for target related common properties
259 getProject().setProperty("TARGET", targetList
[i
]);
260 String
[] toolchainList
= GlobalData
.getToolChainInfo().getTagnames();
261 for(int j
= 0; j
< toolchainList
.length
; j
++){
263 // check if any tool is defined for current target + toolchain + arch
264 // don't do anything if no tools found
266 if (GlobalData
.isCommandSet(targetList
[i
], toolchainList
[j
], archList
[k
]) == false) {
267 System
.out
.println("Warning: No build issued. No tools were found for [target=" + targetList
[i
] + " toolchain=" + toolchainList
[j
] + " arch=" + archList
[k
] + "]\n");
272 // Prepare for toolchain related common properties
275 getProject().setProperty("TOOLCHAIN", toolchainList
[j
]);
277 System
.out
.println("Build " + moduleId
+ " start >>>");
278 System
.out
.println("Target: " + targetList
[i
] + " Tagname: " + toolchainList
[j
] + " Arch: " + archList
[k
]);
279 SurfaceAreaQuery
.setDoc(GlobalData
.getDoc(fpdModuleId
));
282 // Prepare for all other common properties
283 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
284 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
285 // MODULE_DIR, MODULE_RELATIVE_DIR
286 // SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH
288 setModuleCommonProperties(archList
[k
]);
291 // OutputManage prepare for
292 // BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR
294 OutputManager
.getInstance().update(getProject());
296 if (type
.equalsIgnoreCase("all") || type
.equalsIgnoreCase("build")) {
297 applyBuild(targetList
[i
], toolchainList
[j
], fpdModuleId
);
298 } else if (type
.equalsIgnoreCase("clean")) {
299 applyClean(fpdModuleId
);
300 } else if (type
.equalsIgnoreCase("cleanall")) {
301 applyCleanall(fpdModuleId
);
311 This method is used to prepare Platform-related information.
313 <p>In Single Module Build mode, platform-related information is not ready.
314 The method read the system environment variable <code>ACTIVE_PLATFORM</code>
315 and search in the Framework Database. Note that platform name in the Framework
316 Database must be unique. </p>
319 private void prepareSingleModuleBuild(){
321 // Find out the package which the module belongs to
322 // TBD: Enhance it!!!!
324 PackageIdentification packageId
= GlobalData
.getPackageForModule(moduleId
);
326 moduleId
.setPackage(packageId
);
329 // Read ACTIVE_PLATFORM's FPD file
331 String filename
= getProject().getProperty("PLATFORM_FILE");
333 if (filename
== null){
334 throw new BuildException("Please set ACTIVE_PLATFORM in the file: Tools/Conf/target.txt if you want to build a single module!");
337 PlatformIdentification platformId
= GlobalData
.getPlatform(filename
);
340 // Read FPD file (Call FpdParserTask's method)
342 FpdParserTask fpdParser
= new FpdParserTask();
343 fpdParser
.setProject(getProject());
344 fpdParser
.parseFpdFile(platformId
.getFpdFile());
347 // Prepare for Platform related common properties
348 // PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
350 getProject().setProperty("PLATFORM", platformId
.getName());
351 getProject().setProperty("PLATFORM_DIR", platformId
.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
352 getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId
.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
357 Set Module-Related information to properties.
359 @param arch current build ARCH
361 private void setModuleCommonProperties(String arch
) {
363 // Prepare for all other common properties
364 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
366 PackageIdentification packageId
= moduleId
.getPackage();
367 getProject().setProperty("PACKAGE", packageId
.getName());
368 getProject().setProperty("PACKAGE_GUID", packageId
.getGuid());
369 getProject().setProperty("PACKAGE_VERSION", packageId
.getVersion());
370 getProject().setProperty("PACKAGE_DIR", packageId
.getPackageDir().replaceAll("(\\\\)", "/"));
371 getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId
.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
374 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
375 // MODULE_DIR, MODULE_RELATIVE_DIR
377 getProject().setProperty("MODULE", moduleId
.getName());
378 String baseName
= SurfaceAreaQuery
.getModuleOutputFileBasename();
379 if (baseName
== null) {
380 getProject().setProperty("BASE_NAME", moduleId
.getName());
382 getProject().setProperty("BASE_NAME", baseName
);
384 getProject().setProperty("GUID", moduleId
.getGuid());
385 getProject().setProperty("FILE_GUID", moduleId
.getGuid());
386 getProject().setProperty("VERSION", moduleId
.getVersion());
387 getProject().setProperty("MODULE_TYPE", moduleId
.getModuleType());
388 getProject().setProperty("MODULE_DIR", moduleId
.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
389 getProject().setProperty("MODULE_RELATIVE_DIR", moduleId
.getModuleRelativePath().replaceAll("(\\\\)", "/"));
394 String
[][] subsystemMap
= { { "BASE", "EFI_BOOT_SERVICE_DRIVER"},
395 { "SEC", "EFI_BOOT_SERVICE_DRIVER" },
396 { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" },
397 { "PEIM", "EFI_BOOT_SERVICE_DRIVER" },
398 { "DXE_CORE", "EFI_BOOT_SERVICE_DRIVER" },
399 { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
400 { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" },
401 { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
402 { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
403 { "TOOL", "EFI_BOOT_SERVICE_DRIVER" },
404 { "UEFI_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
405 { "UEFI_APPLICATION", "EFI_APPLICATION" },
406 { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} };
408 String subsystem
= "EFI_BOOT_SERVICE_DRIVER";
409 for (int i
= 0; i
< subsystemMap
.length
; i
++) {
410 if (moduleId
.getModuleType().equalsIgnoreCase(subsystemMap
[i
][0])) {
411 subsystem
= subsystemMap
[i
][1];
415 getProject().setProperty("SUBSYSTEM", subsystem
);
420 if (arch
.equalsIgnoreCase("EBC")) {
421 getProject().setProperty("ENTRYPOINT", "EfiStart");
423 getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");
426 getProject().setProperty("OBJECTS", "");
429 private void getCompilerFlags(String target
, String toolchain
, FpdModuleIdentification fpdModuleId
) throws EdkException
{
430 String
[] cmd
= GlobalData
.getToolChainInfo().getCommands();
431 for ( int m
= 0; m
< cmd
.length
; m
++) {
433 // Set cmd, like CC, DLINK
435 String
[] key
= new String
[]{target
, toolchain
, fpdModuleId
.getArch(), cmd
[m
], null};
436 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_PATH
;
437 String cmdPath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
438 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_NAME
;
439 String cmdName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
440 File cmdFile
= new File(cmdPath
+ File
.separatorChar
+ cmdName
);
441 getProject().setProperty(cmd
[m
], cmdFile
.getPath().replaceAll("(\\\\)", "/"));
446 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_FLAGS
;
447 String cmdFlags
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
448 Set
<String
> addset
= new LinkedHashSet
<String
>();
449 Set
<String
> subset
= new LinkedHashSet
<String
>();
450 putFlagsToSet(addset
, cmdFlags
);
451 getProject().setProperty(cmd
[m
] + "_FLAGS", getProject().replaceProperties(getFlags(addset
, subset
)));
456 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_EXT
;
457 String extName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
458 if ( extName
!= null && ! extName
.equalsIgnoreCase("")) {
459 getProject().setProperty(cmd
[m
] + "_EXT", extName
);
461 getProject().setProperty(cmd
[m
] + "_EXT", "");
467 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_FAMILY
;
468 String toolChainFamily
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
469 if (toolChainFamily
!= null) {
470 getProject().setProperty(cmd
[m
] + "_FAMILY", toolChainFamily
);
476 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_SPATH
;
477 String spath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
479 getProject().setProperty(cmd
[m
] + "_SPATH", spath
.replaceAll("(\\\\)", "/"));
481 getProject().setProperty(cmd
[m
] + "_SPATH", "");
487 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_DPATH
;
488 String dpath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
490 getProject().setProperty(cmd
[m
] + "_DPATH", dpath
.replaceAll("(\\\\)", "/"));
492 getProject().setProperty(cmd
[m
] + "_DPATH", "");
497 public void setMsaFile(File msaFile
) {
498 this.msaFile
= msaFile
;
502 Method is for ANT to initialize MSA file.
504 @param msaFilename MSA file name
506 public void setMsaFile(String msaFilename
) {
507 String moduleDir
= getProject().getProperty("MODULE_DIR");
510 // If is Single Module Build, then use the Base Dir defined in build.xml
512 if (moduleDir
== null) {
513 moduleDir
= getProject().getBaseDir().getPath();
515 msaFile
= new File(moduleDir
+ File
.separatorChar
+ msaFilename
);
518 public void addConfiguredModuleItem(ModuleItem moduleItem
) {
519 PackageIdentification packageId
= new PackageIdentification(moduleItem
.getPackageGuid(), moduleItem
.getPackageVersion());
520 ModuleIdentification moduleId
= new ModuleIdentification(moduleItem
.getModuleGuid(), moduleItem
.getModuleVersion());
521 moduleId
.setPackage(packageId
);
522 this.moduleId
= moduleId
;
530 public void addProperty(Property p
) {
531 properties
.addElement(p
);
534 public void setType(String type
) {
538 private void applyBuild(String buildTarget
, String buildTagname
, FpdModuleIdentification fpdModuleId
) throws BuildException
{
543 AutoGen autogen
= new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId
.getModule(),fpdModuleId
.getArch());
544 autogen
.genAutogen();
548 // Get compiler flags
551 getCompilerFlags(buildTarget
, buildTagname
, fpdModuleId
);
553 catch (EdkException ee
) {
554 throw new BuildException(ee
.getMessage());
560 ModuleIdentification
[] libinstances
= SurfaceAreaQuery
.getLibraryInstance(fpdModuleId
.getArch());
561 String propertyLibs
= "";
562 for (int i
= 0; i
< libinstances
.length
; i
++) {
563 propertyLibs
+= " " + getProject().getProperty("BIN_DIR") + File
.separatorChar
+ libinstances
[i
].getName() + ".lib";
565 getProject().setProperty("LIBS", propertyLibs
.replaceAll("(\\\\)", "/"));
568 // if it is CUSTOM_BUILD
569 // then call the exist BaseName_build.xml directly.
571 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
572 GlobalData
.log
.info("Call user-defined " + moduleId
.getName() + "_build.xml");
574 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
575 antCall(antFilename
, null);
581 // Generate ${BASE_NAME}_build.xml
584 String ffsKeyword
= SurfaceAreaQuery
.getModuleFfsKeyword();
585 ModuleBuildFileGenerator fileGenerator
= new ModuleBuildFileGenerator(getProject(), ffsKeyword
, fpdModuleId
);
586 String buildFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
587 fileGenerator
.genBuildFile(buildFilename
);
590 // Ant call ${BASE_NAME}_build.xml
592 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
593 antCall(antFilename
, null);
596 private void applyClean(FpdModuleIdentification fpdModuleId
){
598 // if it is CUSTOM_BUILD
599 // then call the exist BaseName_build.xml directly.
601 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
602 GlobalData
.log
.info("Calling user-defined " + moduleId
.getName() + "_build.xml");
604 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
605 antCall(antFilename
, "clean");
610 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
611 antCall(antFilename
, "clean");
614 private void applyCleanall(FpdModuleIdentification fpdModuleId
){
616 // if it is CUSTOM_BUILD
617 // then call the exist BaseName_build.xml directly.
619 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
620 GlobalData
.log
.info("Calling user-defined " + moduleId
.getName() + "_build.xml");
622 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
623 antCall(antFilename
, "cleanall");
628 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
629 antCall(antFilename
, "cleanall");
632 private void antCall(String antFilename
, String target
) {
634 ant
.setProject(getProject());
635 ant
.setAntfile(antFilename
);
636 if (target
!= null) {
637 ant
.setTarget(target
);
639 ant
.setInheritAll(true);
646 Separate the string and instore in set.
648 <p> String is separated by Java Regulation Expression
649 "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+". </p>
654 "/nologo", "/W3", "/WX"
655 "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
658 @param set store the separated string
659 @param str string to separate
661 private void putFlagsToSet(Set
<String
> set
, String str
) {
662 if (str
== null || str
.length() == 0) {
666 Pattern myPattern
= Pattern
.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
667 Matcher matcher
= myPattern
.matcher(str
+ " ");
668 while (matcher
.find()) {
669 String item
= str
.substring(matcher
.start(1), matcher
.end(1));
675 Generate the final flags string will be used by compile command.
677 @param add the add flags set
678 @param sub the sub flags set
679 @return final flags after add set substract sub set
681 private String
getFlags(Set
<String
> add
, Set
<String
> sub
) {
684 Iterator iter
= add
.iterator();
685 while (iter
.hasNext()) {
686 String str
= (String
) iter
.next();
687 result
+= str
.substring(1, str
.length() - 1) + " ";
692 private void pushProperties() {
693 backupPropertiesStack
.push(getProject().getProperties());
696 private void popProperties() {
697 Hashtable backupProperties
= backupPropertiesStack
.pop();
698 Set keys
= backupProperties
.keySet();
699 Iterator iter
= keys
.iterator();
700 while (iter
.hasNext()) {
701 String item
= (String
)iter
.next();
702 getProject().setProperty(item
, (String
)backupProperties
.get(item
));
706 public void setSingleModuleBuild(boolean isSingleModuleBuild
) {
707 this.isSingleModuleBuild
= isSingleModuleBuild
;