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:
58 1. generate AutoGen.c and AutoGen.h;
59 2. build all dependent library instances;
60 3. build all source files inlcude AutoGen.c;
62 5. generate FFS file if it is driver module while LIB file if it is Library module.
66 The usage is (take module <em>HelloWorld</em> for example):
71 msaFilename="HelloWorld.msa"/>
72 processTo="ALL"/>
75 <p><code>processTo</code> provides a way to customize the whole build process.
76 processTo can be one value of ALL, AUTOGEN, FILES, LIBRARYINSTANCES, SECTIONS, NONE.
77 Default is ALL, means whole
81 This task calls <code>AutoGen</code> to generate <em>AutoGen.c</em> and
82 <em>AutoGen.h</em>. The task also parses the development environment
83 configuration files, such as collecting package information, setting compiler
90 public class GenBuildTask
extends Ant
{
93 /// Module surface area file.
97 private String type
= "all";
100 /// Module's Identification.
102 private ModuleIdentification moduleId
;
104 private Vector
<Property
> properties
= new Vector
<Property
>();
106 private static Stack
<Hashtable
> backupPropertiesStack
= new Stack
<Hashtable
>();
108 private boolean isSingleModuleBuild
= false;
111 Public construct method. It is necessary for ANT task.
113 public GenBuildTask() {
118 @throws BuildException
119 From module build, exception from module surface area invalid.
121 public void execute() throws BuildException
{
125 GenBuildLogger logger
= new GenBuildLogger(getProject());
126 EdkLog
.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
127 EdkLog
.setLogger(logger
);
131 // Enable all specified properties
133 Iterator
<Property
> iter
= properties
.iterator();
134 while (iter
.hasNext()) {
135 Property item
= iter
.next();
136 getProject().setProperty(item
.getName(), item
.getValue());
140 // GenBuild should specify either msaFile or moduleGuid & packageGuid
142 if (msaFile
== null ) {
143 String moduleGuid
= getProject().getProperty("MODULE_GUID");
144 String moduleVersion
= getProject().getProperty("MODULE_VERSION");
145 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
146 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
147 if (moduleGuid
== null || packageGuid
== null) {
148 throw new BuildException("GenBuild parameter error.");
150 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
151 moduleId
= new ModuleIdentification(moduleGuid
, moduleVersion
);
152 moduleId
.setPackage(packageId
);
153 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(moduleId
);
154 SurfaceAreaQuery
.setDoc(doc
);
155 moduleId
= SurfaceAreaQuery
.getMsaHeader();
157 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(msaFile
);
158 SurfaceAreaQuery
.setDoc(doc
);
159 moduleId
= SurfaceAreaQuery
.getMsaHeader();
161 String
[] producedLibraryClasses
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED",null);
162 if (producedLibraryClasses
.length
== 0) {
163 moduleId
.setLibrary(false);
165 moduleId
.setLibrary(true);
169 // Judge whether it is single module build or not
171 if (isSingleModuleBuild
) {
173 // Single Module build
175 prepareSingleModuleBuild();
178 // Platform build. Restore the platform related info
180 String filename
= getProject().getProperty("PLATFORM_FILE");
181 PlatformIdentification platformId
= GlobalData
.getPlatform(filename
);
182 getProject().setProperty("PLATFORM_DIR", platformId
.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
183 getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId
.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
185 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
186 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
187 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
188 moduleId
.setPackage(packageId
);
192 // If single module : get arch from pass down, otherwise intersection MSA
193 // supported ARCHs and tools def
195 Set
<String
> archListSupByToolChain
= new LinkedHashSet
<String
>();
196 String
[] archs
= GlobalData
.getToolChainInfo().getArchs();
198 for (int i
= 0; i
< archs
.length
; i
++) {
199 archListSupByToolChain
.add(archs
[i
]);
202 Set
<String
> archSet
= new LinkedHashSet
<String
>();
204 if ( getProject().getProperty("ARCH") != null) {
205 String
[] fpdArchList
= getProject().getProperty("ARCH").split(" ");
207 for (int i
= 0; i
< fpdArchList
.length
; i
++) {
208 if (archListSupByToolChain
.contains(fpdArchList
[i
])) {
209 archSet
.add(fpdArchList
[i
]);
213 archSet
= archListSupByToolChain
;
216 String
[] archList
= archSet
.toArray(new String
[archSet
.size()]);
219 // Judge if arch is all supported by current module. If not, throw Exception.
221 List moduleSupportedArchs
= SurfaceAreaQuery
.getModuleSupportedArchs();
222 if (moduleSupportedArchs
!= null) {
223 for (int k
= 0; k
< archList
.length
; k
++) {
224 if ( ! moduleSupportedArchs
.contains(archList
[k
])) {
225 throw new BuildException("Specified architecture [" + archList
[k
] + "] is not supported by " + moduleId
+ ". The module " + moduleId
+ " only supports [" + moduleSupportedArchs
+ "] architectures.");
230 for (int k
= 0; k
< archList
.length
; k
++) {
232 getProject().setProperty("ARCH", archList
[k
]);
234 FpdModuleIdentification fpdModuleId
= new FpdModuleIdentification(moduleId
, archList
[k
]);
237 // Whether the module is built before
239 if (moduleId
.isLibrary() == false && GlobalData
.hasFpdModuleSA(fpdModuleId
) == false) {
240 System
.out
.println("\nWARNING: " + moduleId
+ " for " + archList
[k
] + " was not found in current platform FPD file!\n");
242 } else if (GlobalData
.isModuleBuilt(fpdModuleId
)) {
245 GlobalData
.registerBuiltModule(fpdModuleId
);
249 // For Every TOOLCHAIN, TARGET
251 String
[] targetList
= GlobalData
.getToolChainInfo().getTargets();
252 for (int i
= 0; i
< targetList
.length
; i
++){
254 // Prepare for target related common properties
257 getProject().setProperty("TARGET", targetList
[i
]);
258 String
[] toolchainList
= GlobalData
.getToolChainInfo().getTagnames();
259 for(int j
= 0; j
< toolchainList
.length
; j
++){
261 // check if any tool is defined for current target + toolchain + arch
262 // don't do anything if no tools found
264 if (GlobalData
.isCommandSet(targetList
[i
], toolchainList
[j
], archList
[k
]) == false) {
265 System
.out
.println("Warning: No build issued. No tools were found for [target=" + targetList
[i
] + " toolchain=" + toolchainList
[j
] + " arch=" + archList
[k
] + "]\n");
270 // Prepare for toolchain related common properties
273 getProject().setProperty("TOOLCHAIN", toolchainList
[j
]);
275 System
.out
.println("Build " + moduleId
+ " start >>>");
276 System
.out
.println("Target: " + targetList
[i
] + " Tagname: " + toolchainList
[j
] + " Arch: " + archList
[k
]);
277 SurfaceAreaQuery
.setDoc(GlobalData
.getDoc(fpdModuleId
));
280 // Prepare for all other common properties
281 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
282 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
283 // MODULE_DIR, MODULE_RELATIVE_DIR
284 // SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH
286 setModuleCommonProperties(archList
[k
]);
289 // OutputManage prepare for
290 // BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR
292 OutputManager
.getInstance().update(getProject());
294 if (type
.equalsIgnoreCase("all") || type
.equalsIgnoreCase("build")) {
295 applyBuild(targetList
[i
], toolchainList
[j
], fpdModuleId
);
296 } else if (type
.equalsIgnoreCase("clean")) {
297 applyClean(fpdModuleId
);
298 } else if (type
.equalsIgnoreCase("cleanall")) {
299 applyCleanall(fpdModuleId
);
309 This method is used to prepare Platform-related information.
311 <p>In Single Module Build mode, platform-related information is not ready.
312 The method read the system environment variable <code>ACTIVE_PLATFORM</code>
313 and search in the Framework Database. Note that platform name in the Framework
314 Database must be unique. </p>
317 private void prepareSingleModuleBuild(){
319 // Find out the package which the module belongs to
320 // TBD: Enhance it!!!!
322 PackageIdentification packageId
= GlobalData
.getPackageForModule(moduleId
);
324 moduleId
.setPackage(packageId
);
327 // Read ACTIVE_PLATFORM's FPD file
329 String filename
= getProject().getProperty("PLATFORM_FILE");
331 if (filename
== null){
332 throw new BuildException("Please set ACTIVE_PLATFORM in the file: Tools/Conf/target.txt if you want to build a single module!");
335 PlatformIdentification platformId
= GlobalData
.getPlatform(filename
);
338 // Read FPD file (Call FpdParserTask's method)
340 FpdParserTask fpdParser
= new FpdParserTask();
341 fpdParser
.setProject(getProject());
342 fpdParser
.parseFpdFile(platformId
.getFpdFile());
345 // Prepare for Platform related common properties
346 // PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
348 getProject().setProperty("PLATFORM", platformId
.getName());
349 getProject().setProperty("PLATFORM_DIR", platformId
.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
350 getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId
.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
355 Set Module-Related information to properties.
357 @param arch current build ARCH
359 private void setModuleCommonProperties(String arch
) {
361 // Prepare for all other common properties
362 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
364 PackageIdentification packageId
= moduleId
.getPackage();
365 getProject().setProperty("PACKAGE", packageId
.getName());
366 getProject().setProperty("PACKAGE_GUID", packageId
.getGuid());
367 getProject().setProperty("PACKAGE_VERSION", packageId
.getVersion());
368 getProject().setProperty("PACKAGE_DIR", packageId
.getPackageDir().replaceAll("(\\\\)", "/"));
369 getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId
.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
372 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
373 // MODULE_DIR, MODULE_RELATIVE_DIR
375 getProject().setProperty("MODULE", moduleId
.getName());
376 String baseName
= SurfaceAreaQuery
.getModuleOutputFileBasename();
377 if (baseName
== null) {
378 getProject().setProperty("BASE_NAME", moduleId
.getName());
380 getProject().setProperty("BASE_NAME", baseName
);
382 getProject().setProperty("GUID", moduleId
.getGuid());
383 getProject().setProperty("FILE_GUID", moduleId
.getGuid());
384 getProject().setProperty("VERSION", moduleId
.getVersion());
385 getProject().setProperty("MODULE_TYPE", moduleId
.getModuleType());
386 getProject().setProperty("MODULE_DIR", moduleId
.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
387 getProject().setProperty("MODULE_RELATIVE_DIR", moduleId
.getModuleRelativePath().replaceAll("(\\\\)", "/"));
392 String
[][] subsystemMap
= { { "BASE", "EFI_BOOT_SERVICE_DRIVER"},
393 { "SEC", "EFI_BOOT_SERVICE_DRIVER" },
394 { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" },
395 { "PEIM", "EFI_BOOT_SERVICE_DRIVER" },
396 { "DXE_CORE", "EFI_BOOT_SERVICE_DRIVER" },
397 { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
398 { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" },
399 { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
400 { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
401 { "TOOL", "EFI_BOOT_SERVICE_DRIVER" },
402 { "UEFI_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
403 { "UEFI_APPLICATION", "EFI_APPLICATION" },
404 { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} };
406 String subsystem
= "EFI_BOOT_SERVICE_DRIVER";
407 for (int i
= 0; i
< subsystemMap
.length
; i
++) {
408 if (moduleId
.getModuleType().equalsIgnoreCase(subsystemMap
[i
][0])) {
409 subsystem
= subsystemMap
[i
][1];
413 getProject().setProperty("SUBSYSTEM", subsystem
);
418 if (arch
.equalsIgnoreCase("EBC")) {
419 getProject().setProperty("ENTRYPOINT", "EfiStart");
421 getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");
424 getProject().setProperty("OBJECTS", "");
427 private void getCompilerFlags(String target
, String toolchain
, FpdModuleIdentification fpdModuleId
) throws EdkException
{
428 String
[] cmd
= GlobalData
.getToolChainInfo().getCommands();
429 for ( int m
= 0; m
< cmd
.length
; m
++) {
431 // Set cmd, like CC, DLINK
433 String
[] key
= new String
[]{target
, toolchain
, fpdModuleId
.getArch(), cmd
[m
], null};
434 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_PATH
;
435 String cmdPath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
436 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_NAME
;
437 String cmdName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
438 File cmdFile
= new File(cmdPath
+ File
.separatorChar
+ cmdName
);
439 getProject().setProperty(cmd
[m
], cmdFile
.getPath().replaceAll("(\\\\)", "/"));
444 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_FLAGS
;
445 String cmdFlags
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
446 Set
<String
> addset
= new LinkedHashSet
<String
>();
447 Set
<String
> subset
= new LinkedHashSet
<String
>();
448 putFlagsToSet(addset
, cmdFlags
);
449 getProject().setProperty(cmd
[m
] + "_FLAGS", getProject().replaceProperties(getFlags(addset
, subset
)));
454 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_EXT
;
455 String extName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
456 if ( extName
!= null && ! extName
.equalsIgnoreCase("")) {
457 getProject().setProperty(cmd
[m
] + "_EXT", extName
);
459 getProject().setProperty(cmd
[m
] + "_EXT", "");
465 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_FAMILY
;
466 String toolChainFamily
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
467 if (toolChainFamily
!= null) {
468 getProject().setProperty(cmd
[m
] + "_FAMILY", toolChainFamily
);
474 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_SPATH
;
475 String spath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
477 getProject().setProperty(cmd
[m
] + "_SPATH", spath
.replaceAll("(\\\\)", "/"));
479 getProject().setProperty(cmd
[m
] + "_SPATH", "");
485 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_DPATH
;
486 String dpath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
488 getProject().setProperty(cmd
[m
] + "_DPATH", dpath
.replaceAll("(\\\\)", "/"));
490 getProject().setProperty(cmd
[m
] + "_DPATH", "");
495 public void setMsaFile(File msaFile
) {
496 this.msaFile
= msaFile
;
500 Method is for ANT to initialize MSA file.
502 @param msaFilename MSA file name
504 public void setMsaFile(String msaFilename
) {
505 String moduleDir
= getProject().getProperty("MODULE_DIR");
508 // If is Single Module Build, then use the Base Dir defined in build.xml
510 if (moduleDir
== null) {
511 moduleDir
= getProject().getBaseDir().getPath();
513 msaFile
= new File(moduleDir
+ File
.separatorChar
+ msaFilename
);
516 public void addConfiguredModuleItem(ModuleItem moduleItem
) {
517 PackageIdentification packageId
= new PackageIdentification(moduleItem
.getPackageGuid(), moduleItem
.getPackageVersion());
518 ModuleIdentification moduleId
= new ModuleIdentification(moduleItem
.getModuleGuid(), moduleItem
.getModuleVersion());
519 moduleId
.setPackage(packageId
);
520 this.moduleId
= moduleId
;
528 public void addProperty(Property p
) {
529 properties
.addElement(p
);
532 public void setType(String type
) {
536 private void applyBuild(String buildTarget
, String buildTagname
, FpdModuleIdentification fpdModuleId
) throws BuildException
{
541 AutoGen autogen
= new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId
.getModule(),fpdModuleId
.getArch());
542 autogen
.genAutogen();
546 // Get compiler flags
549 getCompilerFlags(buildTarget
, buildTagname
, fpdModuleId
);
551 catch (EdkException ee
) {
552 throw new BuildException(ee
.getMessage());
558 ModuleIdentification
[] libinstances
= SurfaceAreaQuery
.getLibraryInstance(fpdModuleId
.getArch());
559 String propertyLibs
= "";
560 for (int i
= 0; i
< libinstances
.length
; i
++) {
561 propertyLibs
+= " " + getProject().getProperty("BIN_DIR") + File
.separatorChar
+ libinstances
[i
].getName() + ".lib";
563 getProject().setProperty("LIBS", propertyLibs
.replaceAll("(\\\\)", "/"));
566 // if it is CUSTOM_BUILD
567 // then call the exist BaseName_build.xml directly.
569 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
570 GlobalData
.log
.info("Call user-defined " + moduleId
.getName() + "_build.xml");
572 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
573 antCall(antFilename
, null);
579 // Generate ${BASE_NAME}_build.xml
582 String ffsKeyword
= SurfaceAreaQuery
.getModuleFfsKeyword();
583 ModuleBuildFileGenerator fileGenerator
= new ModuleBuildFileGenerator(getProject(), ffsKeyword
, fpdModuleId
);
584 String buildFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
585 fileGenerator
.genBuildFile(buildFilename
);
588 // Ant call ${BASE_NAME}_build.xml
590 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
591 antCall(antFilename
, null);
594 private void applyClean(FpdModuleIdentification fpdModuleId
){
596 // if it is CUSTOM_BUILD
597 // then call the exist BaseName_build.xml directly.
599 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
600 GlobalData
.log
.info("Calling user-defined " + moduleId
.getName() + "_build.xml");
602 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
603 antCall(antFilename
, "clean");
608 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
609 antCall(antFilename
, "clean");
612 private void applyCleanall(FpdModuleIdentification fpdModuleId
){
614 // if it is CUSTOM_BUILD
615 // then call the exist BaseName_build.xml directly.
617 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
618 GlobalData
.log
.info("Calling user-defined " + moduleId
.getName() + "_build.xml");
620 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
621 antCall(antFilename
, "cleanall");
626 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
627 antCall(antFilename
, "cleanall");
630 private void antCall(String antFilename
, String target
) {
632 ant
.setProject(getProject());
633 ant
.setAntfile(antFilename
);
634 if (target
!= null) {
635 ant
.setTarget(target
);
637 ant
.setInheritAll(true);
644 Separate the string and instore in set.
646 <p> String is separated by Java Regulation Expression
647 "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+". </p>
652 "/nologo", "/W3", "/WX"
653 "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
656 @param set store the separated string
657 @param str string to separate
659 private void putFlagsToSet(Set
<String
> set
, String str
) {
660 if (str
== null || str
.length() == 0) {
664 Pattern myPattern
= Pattern
.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
665 Matcher matcher
= myPattern
.matcher(str
+ " ");
666 while (matcher
.find()) {
667 String item
= str
.substring(matcher
.start(1), matcher
.end(1));
673 Generate the final flags string will be used by compile command.
675 @param add the add flags set
676 @param sub the sub flags set
677 @return final flags after add set substract sub set
679 private String
getFlags(Set
<String
> add
, Set
<String
> sub
) {
682 Iterator iter
= add
.iterator();
683 while (iter
.hasNext()) {
684 String str
= (String
) iter
.next();
685 result
+= str
.substring(1, str
.length() - 1) + " ";
690 private void pushProperties() {
691 backupPropertiesStack
.push(getProject().getProperties());
694 private void popProperties() {
695 Hashtable backupProperties
= backupPropertiesStack
.pop();
696 Set keys
= backupProperties
.keySet();
697 Iterator iter
= keys
.iterator();
698 while (iter
.hasNext()) {
699 String item
= (String
)iter
.next();
700 getProject().setProperty(item
, (String
)backupProperties
.get(item
));
704 public void setSingleModuleBuild(boolean isSingleModuleBuild
) {
705 this.isSingleModuleBuild
= isSingleModuleBuild
;