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
.build
.exception
.EdkException
;
36 import org
.tianocore
.build
.fpd
.FpdParserTask
;
37 import org
.tianocore
.build
.global
.GlobalData
;
38 import org
.tianocore
.build
.global
.OutputManager
;
39 import org
.tianocore
.build
.global
.SurfaceAreaQuery
;
40 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
41 import org
.tianocore
.build
.id
.ModuleIdentification
;
42 import org
.tianocore
.build
.id
.PackageIdentification
;
43 import org
.tianocore
.build
.id
.PlatformIdentification
;
44 import org
.tianocore
.build
.tools
.ModuleItem
;
48 <code>GenBuildTask</code> is an ANT task that can be used in ANT build
49 system. The main function of this task is to parse module's surface area,
50 then generate the corresponding <em>BaseName_build.xml</em> (the real ANT
51 build script) and call this to build the module. The whole process including:
52 1. generate AutoGen.c and AutoGen.h; 2. build all dependent library instances;
53 3. build all source files inlcude AutoGen.c; 4. generate sections;
54 5. generate FFS file if it is driver module while LIB file if it is Library module.
58 The usage is (take module <em>HelloWorld</em> for example):
63 msaFilename="HelloWorld.msa"/>
64 processTo="ALL"/>
67 <p><code>processTo</code> provides a way to customize the whole build process.
68 processTo can be one value of ALL, AUTOGEN, FILES, LIBRARYINSTANCES, SECTIONS, NONE.
69 Default is ALL, means whole
73 This task calls <code>AutoGen</code> to generate <em>AutoGen.c</em> and
74 <em>AutoGen.h</em>. The task also parses the development environment
75 configuration files, such as collecting package information, setting compiler
82 public class GenBuildTask
extends Ant
{
85 /// Module surface area file.
92 private String type
= "all"; // = "build";
95 /// Module's Identification.
97 private ModuleIdentification moduleId
;
99 private Vector
<Property
> properties
= new Vector
<Property
>();
101 private static Stack
<Hashtable
> backupPropertiesStack
= new Stack
<Hashtable
>();
104 private static Hashtable backupProperties
;
107 Public construct method. It is necessary for ANT task.
109 public GenBuildTask() {
114 @throws BuildException
115 From module build, exception from module surface area invalid.
117 public void execute() throws BuildException
{
121 // Enable all specified properties
123 Iterator
<Property
> iter
= properties
.iterator();
124 while (iter
.hasNext()) {
125 Property item
= iter
.next();
126 getProject().setProperty(item
.getName(), item
.getValue());
130 // GenBuild should specify either msaFile or moduleGuid & packageGuid
132 if (msaFile
== null ) {
133 String moduleGuid
= getProject().getProperty("MODULE_GUID");
134 String moduleVersion
= getProject().getProperty("MODULE_VERSION");
135 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
136 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
137 if (moduleGuid
== null || packageGuid
== null) {
138 throw new BuildException("GenBuild parameters error. ");
140 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
141 moduleId
= new ModuleIdentification(moduleGuid
, moduleVersion
);
142 moduleId
.setPackage(packageId
);
143 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(moduleId
);
144 SurfaceAreaQuery
.setDoc(doc
);
145 moduleId
= SurfaceAreaQuery
.getMsaHeader();
148 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(msaFile
);
149 SurfaceAreaQuery
.setDoc(doc
);
150 moduleId
= SurfaceAreaQuery
.getMsaHeader();
152 String
[] producedLibraryClasses
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED");
153 if (producedLibraryClasses
.length
== 0) {
154 moduleId
.setLibrary(false);
157 moduleId
.setLibrary(true);
161 // Judge whether it is single module build or not
163 if (getProject().getProperty("PLATFORM") == null) {
165 // Single Module build
167 prepareSingleModuleBuild();
171 // Platform build. Restore the platform related info
173 String platformName
= getProject().getProperty("PLATFORM");
174 PlatformIdentification platformId
= GlobalData
.getPlatform(platformName
);
175 getProject().setProperty("PLATFORM_DIR", platformId
.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
176 getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId
.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
178 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
179 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
180 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
181 moduleId
.setPackage(packageId
);
185 // If single module : intersection MSA supported ARCHs and tools def!!
186 // else, get arch from pass down
188 String
[] archList
= new String
[0];
189 if ( getProject().getProperty("ARCH") != null ) {
190 archList
= getProject().getProperty("ARCH").split(" ");
193 archList
= GlobalData
.getToolChainInfo().getArchs();
198 // Judge if arch is all supported by current module. If not, throw Exception.
200 List moduleSupportedArchs
= SurfaceAreaQuery
.getModuleSupportedArchs();
201 if (moduleSupportedArchs
!= null) {
202 for (int k
= 0; k
< archList
.length
; k
++) {
203 if ( ! moduleSupportedArchs
.contains(archList
[k
])) {
204 throw new BuildException("ARCH [" + archList
[k
] + "] is not supported by " + moduleId
+ ". " + moduleId
+ " only supports [" + moduleSupportedArchs
+ "].");
209 for (int k
= 0; k
< archList
.length
; k
++) {
210 getProject().setProperty("ARCH", archList
[k
]);
212 FpdModuleIdentification fpdModuleId
= new FpdModuleIdentification(moduleId
, archList
[k
]);
215 // Whether the module is built before
217 if (GlobalData
.isModuleBuilt(fpdModuleId
)) {
221 GlobalData
.registerBuiltModule(fpdModuleId
);
225 // For Every TOOLCHAIN, TARGET
227 String
[] targetList
= GlobalData
.getToolChainInfo().getTargets();
228 for (int i
= 0; i
< targetList
.length
; i
++){
230 // Prepare for target related common properties
233 getProject().setProperty("TARGET", targetList
[i
]);
234 String
[] toolchainList
= GlobalData
.getToolChainInfo().getTagnames();
235 for(int j
= 0; j
< toolchainList
.length
; j
++){
237 // Prepare for toolchain related common properties
240 getProject().setProperty("TOOLCHAIN", toolchainList
[j
]);
242 System
.out
.println("Build " + moduleId
+ " start >>>");
243 System
.out
.println("Target: " + targetList
[i
] + " Tagname: " + toolchainList
[j
] + " Arch: " + archList
[k
]);
244 SurfaceAreaQuery
.setDoc(GlobalData
.getDoc(fpdModuleId
));
247 // Prepare for all other common properties
248 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
249 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
250 // MODULE_DIR, MODULE_RELATIVE_DIR
251 // SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH
252 // LIBS, OBJECTS, SDB_FILES
254 setModuleCommonProperties(archList
[k
]);
257 // OutputManage prepare for
258 // BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR
260 OutputManager
.getInstance().update(getProject());
262 if (type
.equalsIgnoreCase("all") || type
.equalsIgnoreCase("build")) {
263 applyBuild(targetList
[i
], toolchainList
[j
], fpdModuleId
);
265 else if (type
.equalsIgnoreCase("clean")) {
266 applyClean(fpdModuleId
);
268 else if (type
.equalsIgnoreCase("cleanall")) {
269 applyCleanall(fpdModuleId
);
275 }catch (Exception e
){
277 throw new BuildException(e
.getMessage());
282 This method is used to prepare Platform-related information.
284 <p>In Single Module Build mode, platform-related information is not ready.
285 The method read the system environment variable <code>ACTIVE_PLATFORM</code>
286 and search in the Framework Database. Note that platform name in the Framework
287 Database must be unique. </p>
290 private void prepareSingleModuleBuild(){
292 // Find out the package which the module belongs to
293 // TBD: Enhance it!!!!
295 PackageIdentification packageId
= GlobalData
.getPackageForModule(moduleId
);
297 moduleId
.setPackage(packageId
);
300 // Read ACTIVE_PLATFORM's FPD file (Call FpdParserTask's method)
302 String activePlatformName
= getProject().getProperty("ACTIVE_PLATFORM");
304 if (activePlatformName
== null){
305 throw new BuildException("Plese set ACTIVE_PLATFORM if you want to build a single module. ");
308 PlatformIdentification platformId
= GlobalData
.getPlatform(activePlatformName
);
313 FpdParserTask fpdParser
= new FpdParserTask();
314 fpdParser
.setProject(getProject());
315 fpdParser
.parseFpdFile(platformId
.getFpdFile());
318 // Prepare for Platform related common properties
319 // PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
321 getProject().setProperty("PLATFORM", activePlatformName
);
322 getProject().setProperty("PLATFORM_DIR", platformId
.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
323 getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId
.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
328 Set Module-Related information to properties.
330 private void setModuleCommonProperties(String arch
) {
332 // Prepare for all other common properties
333 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
335 PackageIdentification packageId
= moduleId
.getPackage();
336 getProject().setProperty("PACKAGE", packageId
.getName());
337 getProject().setProperty("PACKAGE_GUID", packageId
.getGuid());
338 getProject().setProperty("PACKAGE_VERSION", packageId
.getVersion());
339 getProject().setProperty("PACKAGE_DIR", packageId
.getPackageDir().replaceAll("(\\\\)", "/"));
340 getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId
.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
343 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
344 // MODULE_DIR, MODULE_RELATIVE_DIR
346 getProject().setProperty("MODULE", moduleId
.getName());
347 String baseName
= SurfaceAreaQuery
.getModuleOutputFileBasename();
348 if (baseName
== null) {
349 getProject().setProperty("BASE_NAME", moduleId
.getName());
352 getProject().setProperty("BASE_NAME", baseName
);
354 getProject().setProperty("GUID", moduleId
.getGuid());
355 getProject().setProperty("FILE_GUID", moduleId
.getGuid());
356 getProject().setProperty("VERSION", moduleId
.getVersion());
357 getProject().setProperty("MODULE_TYPE", moduleId
.getModuleType());
358 getProject().setProperty("MODULE_DIR", moduleId
.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
359 getProject().setProperty("MODULE_RELATIVE_DIR", moduleId
.getModuleRelativePath().replaceAll("(\\\\)", "/"));
364 String
[][] subsystemMap
= { { "BASE", "EFI_BOOT_SERVICE_DRIVER"},
365 { "SEC", "EFI_BOOT_SERVICE_DRIVER" },
366 { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" },
367 { "PEIM", "EFI_BOOT_SERVICE_DRIVER" },
368 { "DXE_CORE", "EFI_BOOT_SERVICE_DRIVER" },
369 { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
370 { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" },
371 { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
372 { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
373 { "TOOL", "EFI_BOOT_SERVICE_DRIVER" },
374 { "UEFI_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
375 { "UEFI_APPLICATION", "EFI_APPLICATION" },
376 { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} };
378 String subsystem
= "EFI_BOOT_SERVICE_DRIVER";
379 for (int i
= 0; i
< subsystemMap
.length
; i
++) {
380 if (moduleId
.getModuleType().equalsIgnoreCase(subsystemMap
[i
][0])) {
381 subsystem
= subsystemMap
[i
][1];
385 getProject().setProperty("SUBSYSTEM", subsystem
);
390 if (arch
.equalsIgnoreCase("EBC")) {
391 getProject().setProperty("ENTRYPOINT", "EfiStart");
394 getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");
398 // LIBS, OBJECTS, SDB_FILES
400 getProject().setProperty("OBJECTS", "");
401 getProject().setProperty("SDB_FILES", "");
402 getProject().setProperty("LIBS", "");
405 private void getCompilerFlags(String target
, String toolchain
, FpdModuleIdentification fpdModuleId
) throws EdkException
{
406 String
[] cmd
= GlobalData
.getToolChainInfo().getCommands();
407 for ( int m
= 0; m
< cmd
.length
; m
++) {
409 // Set cmd, like CC, DLINK
411 String
[] key
= new String
[]{target
, toolchain
, fpdModuleId
.getArch(), cmd
[m
], null};
413 String cmdPath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
415 String cmdName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
416 File cmdFile
= new File(cmdPath
+ File
.separatorChar
+ cmdName
);
417 // GlobalData.log.info("PATH: " + cmdFile.getPath());
418 getProject().setProperty(cmd
[m
], cmdFile
.getPath().replaceAll("(\\\\)", "/"));
424 String cmdFlags
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
425 // GlobalData.log.info("Flags: " + cmdFlags);
426 Set
<String
> addset
= new LinkedHashSet
<String
>();
427 Set
<String
> subset
= new LinkedHashSet
<String
>();
428 putFlagsToSet(addset
, cmdFlags
);
429 getProject().setProperty(cmd
[m
] + "_FLAGS", getProject().replaceProperties(getFlags(addset
, subset
)));
435 String extName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
436 // GlobalData.log.info("Ext: " + extName);
437 if ( extName
!= null && ! extName
.equalsIgnoreCase("")) {
438 getProject().setProperty(cmd
[m
] + "_EXT", extName
);
441 getProject().setProperty(cmd
[m
] + "_EXT", "");
448 String toolChainFamily
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
449 // GlobalData.log.info("FAMILY: " + toolChainFamily);
450 if (toolChainFamily
!= null) {
451 getProject().setProperty(cmd
[m
] + "_FAMILY", toolChainFamily
);
458 String spath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
459 // GlobalData.log.info("SPATH: " + spath);
461 getProject().setProperty(cmd
[m
] + "_SPATH", spath
.replaceAll("(\\\\)", "/"));
464 getProject().setProperty(cmd
[m
] + "_SPATH", "");
471 String dpath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
472 // GlobalData.log.info("DPATH: " + dpath);
474 getProject().setProperty(cmd
[m
] + "_DPATH", dpath
.replaceAll("(\\\\)", "/"));
477 getProject().setProperty(cmd
[m
] + "_DPATH", "");
482 public void setMsaFile(File msaFile
) {
483 this.msaFile
= msaFile
;
487 Method is for ANT to initialize MSA file.
489 @param msaFilename MSA file name
491 public void setMsaFile(String msaFilename
) {
492 String moduleDir
= getProject().getProperty("MODULE_DIR");
495 // If is Single Module Build, then use the Base Dir defined in build.xml
497 if (moduleDir
== null) {
498 moduleDir
= getProject().getBaseDir().getPath();
500 msaFile
= new File(moduleDir
+ File
.separatorChar
+ msaFilename
);
503 public void addConfiguredModuleItem(ModuleItem moduleItem
) {
504 PackageIdentification packageId
= new PackageIdentification(moduleItem
.getPackageGuid(), moduleItem
.getPackageVersion());
505 ModuleIdentification moduleId
= new ModuleIdentification(moduleItem
.getModuleGuid(), moduleItem
.getModuleVersion());
506 moduleId
.setPackage(packageId
);
507 this.moduleId
= moduleId
;
515 public void addProperty(Property p
) {
516 properties
.addElement(p
);
519 public void setType(String type
) {
523 private void applyBuild(String buildTarget
, String buildTagname
, FpdModuleIdentification fpdModuleId
) throws EdkException
{
527 // AutoGen autogen = new AutoGen(getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId);
528 // autogen.genAutogen();
532 // Get compiler flags
534 getCompilerFlags(buildTarget
, buildTagname
, fpdModuleId
);
539 ModuleIdentification
[] libinstances
= SurfaceAreaQuery
.getLibraryInstance(fpdModuleId
.getArch());
540 String propertyLibs
= "";
541 for (int i
= 0; i
< libinstances
.length
; i
++) {
542 propertyLibs
+= " " + getProject().getProperty("BIN_DIR") + File
.separatorChar
+ libinstances
[i
].getName() + ".lib";
544 getProject().setProperty("LIBS", propertyLibs
.replaceAll("(\\\\)", "/"));
547 // if it is CUSTOM_BUILD
548 // then call the exist BaseName_build.xml directly.
550 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
551 GlobalData
.log
.info("Call user-defined " + moduleId
.getName() + "_build.xml");
553 ant
.setProject(getProject());
554 ant
.setAntfile(getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
555 ant
.setInheritAll(true);
562 // Generate ${BASE_NAME}_build.xml
565 String ffsKeyword
= SurfaceAreaQuery
.getModuleFfsKeyword();
566 ModuleBuildFileGenerator fileGenerator
= new ModuleBuildFileGenerator(getProject(), ffsKeyword
, fpdModuleId
);
567 String buildFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
568 fileGenerator
.genBuildFile(buildFilename
);
571 // Ant call ${BASE_NAME}_build.xml
574 ant
.setProject(getProject());
575 ant
.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
576 ant
.setInheritAll(true);
581 private void applyClean(FpdModuleIdentification fpdModuleId
){
583 // if it is CUSTOM_BUILD
584 // then call the exist BaseName_build.xml directly.
586 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
587 GlobalData
.log
.info("Call user-defined " + moduleId
.getName() + "_build.xml");
589 ant
.setProject(getProject());
590 ant
.setAntfile(getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
591 ant
.setTarget("clean");
592 ant
.setInheritAll(true);
599 ant
.setProject(getProject());
600 ant
.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
601 ant
.setTarget("clean");
602 ant
.setInheritAll(true);
607 // Delete current module's DEST_DIR_OUTPUT
611 private void applyCleanall(FpdModuleIdentification fpdModuleId
){
613 // if it is CUSTOM_BUILD
614 // then call the exist BaseName_build.xml directly.
616 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
617 GlobalData
.log
.info("Call user-defined " + moduleId
.getName() + "_build.xml");
619 ant
.setProject(getProject());
620 ant
.setAntfile(getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
621 ant
.setTarget("cleanall");
622 ant
.setInheritAll(true);
629 ant
.setProject(getProject());
630 ant
.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
631 ant
.setTarget("cleanall");
632 ant
.setInheritAll(true);
637 // Delete current module's DEST_DIR_OUTPUT
645 Separate the string and instore in set.
647 <p> String is separated by Java Regulation Expression
648 "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+". </p>
653 "/nologo", "/W3", "/WX"
654 "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
657 @param set store the separated string
658 @param str string to separate
660 private void putFlagsToSet(Set
<String
> set
, String str
) {
661 if (str
== null || str
.length() == 0) {
665 Pattern myPattern
= Pattern
.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
666 Matcher matcher
= myPattern
.matcher(str
+ " ");
667 while (matcher
.find()) {
668 String item
= str
.substring(matcher
.start(1), matcher
.end(1));
674 Generate the final flags string will be used by compile command.
676 @param add the add flags set
677 @param sub the sub flags set
678 @return final flags after add set substract sub set
680 private String
getFlags(Set
<String
> add
, Set
<String
> sub
) {
683 Iterator iter
= add
.iterator();
684 while (iter
.hasNext()) {
685 String str
= (String
) iter
.next();
686 result
+= str
.substring(1, str
.length() - 1) + " ";
692 Generate the flags string with original format. The format is defined by
693 Java Regulation Expression "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+". </p>
698 "/nologo", "/W3", "/WX"
699 "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
702 @param add the add flags set
703 @param sub the sub flags set
704 @return flags with original format
706 private String
getRawFlags(Set
<String
> add
, Set
<String
> sub
) {
707 String result
= null;
709 Iterator iter
= add
.iterator();
710 while (iter
.hasNext()) {
711 String str
= (String
) iter
.next();
712 result
+= "\"" + str
.substring(1, str
.length() - 1) + "\", ";
717 private String
parseOptionString(String optionString
, Set
<String
> addSet
, Set
<String
> subSet
) {
718 boolean overrideOption
= false;
719 Pattern pattern
= Pattern
.compile("ADD\\.\\[(.+)\\]");
720 Matcher matcher
= pattern
.matcher(optionString
);
722 while (matcher
.find()) {
723 overrideOption
= true;
724 String addOption
= optionString
.substring(matcher
.start(1), matcher
.end(1)).trim();
725 putFlagsToSet(addSet
, addOption
);
729 pattern
= Pattern
.compile("SUB\\.\\[(.+)\\]");
730 matcher
= pattern
.matcher(optionString
);
732 while (matcher
.find()) {
733 overrideOption
= true;
734 String subOption
= optionString
.substring(matcher
.start(1), matcher
.end(1)).trim();
735 putFlagsToSet(subSet
, subOption
);
738 if (overrideOption
== true) {
745 private void pushProperties() {
746 backupPropertiesStack
.push(getProject().getProperties());
749 private void popProperties() {
750 Hashtable backupProperties
= backupPropertiesStack
.pop();
751 Set keys
= backupProperties
.keySet();
752 Iterator iter
= keys
.iterator();
753 while (iter
.hasNext()) {
754 String item
= (String
)iter
.next();
755 getProject().setProperty(item
, (String
)backupProperties
.get(item
));