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
.autogen
.AutoGen
;
36 import org
.tianocore
.build
.fpd
.FpdParserTask
;
37 import org
.tianocore
.build
.global
.GenBuildLogger
;
38 import org
.tianocore
.build
.global
.GlobalData
;
39 import org
.tianocore
.build
.global
.OutputManager
;
40 import org
.tianocore
.build
.global
.SurfaceAreaQuery
;
41 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
42 import org
.tianocore
.build
.id
.ModuleIdentification
;
43 import org
.tianocore
.build
.id
.PackageIdentification
;
44 import org
.tianocore
.build
.id
.PlatformIdentification
;
45 import org
.tianocore
.build
.tools
.ModuleItem
;
46 import org
.tianocore
.exception
.EdkException
;
47 import org
.tianocore
.logger
.EdkLog
;
51 <code>GenBuildTask</code> is an ANT task that can be used in ANT build
52 system. The main function of this task is to parse module's surface area,
53 then generate the corresponding <em>BaseName_build.xml</em> (the real ANT
54 build script) and call this to build the module. The whole process including:
55 1. generate AutoGen.c and AutoGen.h; 2. build all dependent library instances;
56 3. build all source files inlcude AutoGen.c; 4. generate sections;
57 5. generate FFS file if it is driver module while LIB file if it is Library module.
61 The usage is (take module <em>HelloWorld</em> for example):
66 msaFilename="HelloWorld.msa"/>
67 processTo="ALL"/>
70 <p><code>processTo</code> provides a way to customize the whole build process.
71 processTo can be one value of ALL, AUTOGEN, FILES, LIBRARYINSTANCES, SECTIONS, NONE.
72 Default is ALL, means whole
76 This task calls <code>AutoGen</code> to generate <em>AutoGen.c</em> and
77 <em>AutoGen.h</em>. The task also parses the development environment
78 configuration files, such as collecting package information, setting compiler
85 public class GenBuildTask
extends Ant
{
88 /// Module surface area file.
95 private String type
= "all"; // = "build";
98 /// Module's Identification.
100 private ModuleIdentification moduleId
;
102 private Vector
<Property
> properties
= new Vector
<Property
>();
104 private static Stack
<Hashtable
> backupPropertiesStack
= new Stack
<Hashtable
>();
106 private boolean isSingleModuleBuild
= false;
109 Public construct method. It is necessary for ANT task.
111 public GenBuildTask() {
116 @throws BuildException
117 From module build, exception from module surface area invalid.
119 public void execute() throws BuildException
{
123 GenBuildLogger logger
= new GenBuildLogger(getProject());
124 EdkLog
.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
125 EdkLog
.setLogger(logger
);
130 // Enable all specified properties
132 Iterator
<Property
> iter
= properties
.iterator();
133 while (iter
.hasNext()) {
134 Property item
= iter
.next();
135 getProject().setProperty(item
.getName(), item
.getValue());
139 // GenBuild should specify either msaFile or moduleGuid & packageGuid
141 if (msaFile
== null ) {
142 String moduleGuid
= getProject().getProperty("MODULE_GUID");
143 String moduleVersion
= getProject().getProperty("MODULE_VERSION");
144 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
145 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
146 if (moduleGuid
== null || packageGuid
== null) {
147 throw new BuildException("GenBuild parameters error. ");
149 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
150 moduleId
= new ModuleIdentification(moduleGuid
, moduleVersion
);
151 moduleId
.setPackage(packageId
);
152 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(moduleId
);
153 SurfaceAreaQuery
.setDoc(doc
);
154 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");
162 if (producedLibraryClasses
.length
== 0) {
163 moduleId
.setLibrary(false);
166 moduleId
.setLibrary(true);
170 // Judge whether it is single module build or not
172 if (isSingleModuleBuild
) {
174 // Single Module build
176 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 : intersection MSA supported ARCHs and tools def!!
195 // else, get arch from pass down
197 String
[] archList
= new String
[0];
198 if ( getProject().getProperty("ARCH") != null ) {
199 archList
= getProject().getProperty("ARCH").split(" ");
202 archList
= GlobalData
.getToolChainInfo().getArchs();
207 // Judge if arch is all supported by current module. If not, throw Exception.
209 List moduleSupportedArchs
= SurfaceAreaQuery
.getModuleSupportedArchs();
210 if (moduleSupportedArchs
!= null) {
211 for (int k
= 0; k
< archList
.length
; k
++) {
212 if ( ! moduleSupportedArchs
.contains(archList
[k
])) {
213 throw new BuildException("ARCH [" + archList
[k
] + "] is not supported by " + moduleId
+ ". " + moduleId
+ " only supports [" + moduleSupportedArchs
+ "].");
218 for (int k
= 0; k
< archList
.length
; k
++) {
219 getProject().setProperty("ARCH", archList
[k
]);
221 FpdModuleIdentification fpdModuleId
= new FpdModuleIdentification(moduleId
, archList
[k
]);
224 // Whether the module is built before
226 if (GlobalData
.isModuleBuilt(fpdModuleId
)) {
230 GlobalData
.registerBuiltModule(fpdModuleId
);
234 // For Every TOOLCHAIN, TARGET
236 String
[] targetList
= GlobalData
.getToolChainInfo().getTargets();
237 for (int i
= 0; i
< targetList
.length
; i
++){
239 // Prepare for target related common properties
242 getProject().setProperty("TARGET", targetList
[i
]);
243 String
[] toolchainList
= GlobalData
.getToolChainInfo().getTagnames();
244 for(int j
= 0; j
< toolchainList
.length
; j
++){
246 // Prepare for toolchain related common properties
249 getProject().setProperty("TOOLCHAIN", toolchainList
[j
]);
251 System
.out
.println("Build " + moduleId
+ " start >>>");
252 System
.out
.println("Target: " + targetList
[i
] + " Tagname: " + toolchainList
[j
] + " Arch: " + archList
[k
]);
253 SurfaceAreaQuery
.setDoc(GlobalData
.getDoc(fpdModuleId
));
256 // Prepare for all other common properties
257 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
258 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
259 // MODULE_DIR, MODULE_RELATIVE_DIR
260 // SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH
261 // LIBS, OBJECTS, SDB_FILES
263 setModuleCommonProperties(archList
[k
]);
266 // OutputManage prepare for
267 // BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR
269 OutputManager
.getInstance().update(getProject());
271 if (type
.equalsIgnoreCase("all") || type
.equalsIgnoreCase("build")) {
272 applyBuild(targetList
[i
], toolchainList
[j
], fpdModuleId
);
274 else if (type
.equalsIgnoreCase("clean")) {
275 applyClean(fpdModuleId
);
277 else if (type
.equalsIgnoreCase("cleanall")) {
278 applyCleanall(fpdModuleId
);
284 }catch (Exception e
){
286 throw new BuildException(e
.getMessage());
291 This method is used to prepare Platform-related information.
293 <p>In Single Module Build mode, platform-related information is not ready.
294 The method read the system environment variable <code>ACTIVE_PLATFORM</code>
295 and search in the Framework Database. Note that platform name in the Framework
296 Database must be unique. </p>
299 private void prepareSingleModuleBuild(){
301 // Find out the package which the module belongs to
302 // TBD: Enhance it!!!!
304 PackageIdentification packageId
= GlobalData
.getPackageForModule(moduleId
);
306 moduleId
.setPackage(packageId
);
309 // Read ACTIVE_PLATFORM's FPD file (Call FpdParserTask's method)
311 String filename
= getProject().getProperty("PLATFORM_FILE");
313 if (filename
== null){
314 throw new BuildException("Plese set ACTIVE_PLATFORM if you want to build a single module. ");
317 PlatformIdentification platformId
= GlobalData
.getPlatform(filename
);
322 FpdParserTask fpdParser
= new FpdParserTask();
323 fpdParser
.setProject(getProject());
324 fpdParser
.parseFpdFile(platformId
.getFpdFile());
327 // Prepare for Platform related common properties
328 // PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
330 getProject().setProperty("PLATFORM", platformId
.getName());
331 getProject().setProperty("PLATFORM_DIR", platformId
.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
332 getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId
.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
337 Set Module-Related information to properties.
339 private void setModuleCommonProperties(String arch
) {
341 // Prepare for all other common properties
342 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
344 PackageIdentification packageId
= moduleId
.getPackage();
345 getProject().setProperty("PACKAGE", packageId
.getName());
346 getProject().setProperty("PACKAGE_GUID", packageId
.getGuid());
347 getProject().setProperty("PACKAGE_VERSION", packageId
.getVersion());
348 getProject().setProperty("PACKAGE_DIR", packageId
.getPackageDir().replaceAll("(\\\\)", "/"));
349 getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId
.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
352 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
353 // MODULE_DIR, MODULE_RELATIVE_DIR
355 getProject().setProperty("MODULE", moduleId
.getName());
356 String baseName
= SurfaceAreaQuery
.getModuleOutputFileBasename();
357 if (baseName
== null) {
358 getProject().setProperty("BASE_NAME", moduleId
.getName());
361 getProject().setProperty("BASE_NAME", baseName
);
363 getProject().setProperty("GUID", moduleId
.getGuid());
364 getProject().setProperty("FILE_GUID", moduleId
.getGuid());
365 getProject().setProperty("VERSION", moduleId
.getVersion());
366 getProject().setProperty("MODULE_TYPE", moduleId
.getModuleType());
367 getProject().setProperty("MODULE_DIR", moduleId
.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
368 getProject().setProperty("MODULE_RELATIVE_DIR", moduleId
.getModuleRelativePath().replaceAll("(\\\\)", "/"));
373 String
[][] subsystemMap
= { { "BASE", "EFI_BOOT_SERVICE_DRIVER"},
374 { "SEC", "EFI_BOOT_SERVICE_DRIVER" },
375 { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" },
376 { "PEIM", "EFI_BOOT_SERVICE_DRIVER" },
377 { "DXE_CORE", "EFI_BOOT_SERVICE_DRIVER" },
378 { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
379 { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" },
380 { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
381 { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
382 { "TOOL", "EFI_BOOT_SERVICE_DRIVER" },
383 { "UEFI_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
384 { "UEFI_APPLICATION", "EFI_APPLICATION" },
385 { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} };
387 String subsystem
= "EFI_BOOT_SERVICE_DRIVER";
388 for (int i
= 0; i
< subsystemMap
.length
; i
++) {
389 if (moduleId
.getModuleType().equalsIgnoreCase(subsystemMap
[i
][0])) {
390 subsystem
= subsystemMap
[i
][1];
394 getProject().setProperty("SUBSYSTEM", subsystem
);
399 if (arch
.equalsIgnoreCase("EBC")) {
400 getProject().setProperty("ENTRYPOINT", "EfiStart");
403 getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");
407 // LIBS, OBJECTS, SDB_FILES
409 getProject().setProperty("OBJECTS", "");
410 getProject().setProperty("SDB_FILES", "");
411 getProject().setProperty("LIBS", "");
414 private void getCompilerFlags(String target
, String toolchain
, FpdModuleIdentification fpdModuleId
) throws EdkException
{
415 String
[] cmd
= GlobalData
.getToolChainInfo().getCommands();
416 for ( int m
= 0; m
< cmd
.length
; m
++) {
418 // Set cmd, like CC, DLINK
420 String
[] key
= new String
[]{target
, toolchain
, fpdModuleId
.getArch(), cmd
[m
], null};
422 String cmdPath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
424 String cmdName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
425 File cmdFile
= new File(cmdPath
+ File
.separatorChar
+ cmdName
);
426 // GlobalData.log.info("PATH: " + cmdFile.getPath());
427 getProject().setProperty(cmd
[m
], cmdFile
.getPath().replaceAll("(\\\\)", "/"));
433 String cmdFlags
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
434 // GlobalData.log.info("Flags: " + cmdFlags);
435 Set
<String
> addset
= new LinkedHashSet
<String
>();
436 Set
<String
> subset
= new LinkedHashSet
<String
>();
437 putFlagsToSet(addset
, cmdFlags
);
438 getProject().setProperty(cmd
[m
] + "_FLAGS", getProject().replaceProperties(getFlags(addset
, subset
)));
444 String extName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
445 // GlobalData.log.info("Ext: " + extName);
446 if ( extName
!= null && ! extName
.equalsIgnoreCase("")) {
447 getProject().setProperty(cmd
[m
] + "_EXT", extName
);
450 getProject().setProperty(cmd
[m
] + "_EXT", "");
457 String toolChainFamily
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
458 // GlobalData.log.info("FAMILY: " + toolChainFamily);
459 if (toolChainFamily
!= null) {
460 getProject().setProperty(cmd
[m
] + "_FAMILY", toolChainFamily
);
467 String spath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
468 // GlobalData.log.info("SPATH: " + spath);
470 getProject().setProperty(cmd
[m
] + "_SPATH", spath
.replaceAll("(\\\\)", "/"));
473 getProject().setProperty(cmd
[m
] + "_SPATH", "");
480 String dpath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
481 // GlobalData.log.info("DPATH: " + dpath);
483 getProject().setProperty(cmd
[m
] + "_DPATH", dpath
.replaceAll("(\\\\)", "/"));
486 getProject().setProperty(cmd
[m
] + "_DPATH", "");
491 public void setMsaFile(File msaFile
) {
492 this.msaFile
= msaFile
;
496 Method is for ANT to initialize MSA file.
498 @param msaFilename MSA file name
500 public void setMsaFile(String msaFilename
) {
501 String moduleDir
= getProject().getProperty("MODULE_DIR");
504 // If is Single Module Build, then use the Base Dir defined in build.xml
506 if (moduleDir
== null) {
507 moduleDir
= getProject().getBaseDir().getPath();
509 msaFile
= new File(moduleDir
+ File
.separatorChar
+ msaFilename
);
512 public void addConfiguredModuleItem(ModuleItem moduleItem
) {
513 PackageIdentification packageId
= new PackageIdentification(moduleItem
.getPackageGuid(), moduleItem
.getPackageVersion());
514 ModuleIdentification moduleId
= new ModuleIdentification(moduleItem
.getModuleGuid(), moduleItem
.getModuleVersion());
515 moduleId
.setPackage(packageId
);
516 this.moduleId
= moduleId
;
524 public void addProperty(Property p
) {
525 properties
.addElement(p
);
528 public void setType(String type
) {
532 private void applyBuild(String buildTarget
, String buildTagname
, FpdModuleIdentification fpdModuleId
) throws EdkException
{
537 AutoGen autogen
= new AutoGen(getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId
.getModule(),fpdModuleId
.getArch());
538 autogen
.genAutogen();
542 // Get compiler flags
544 getCompilerFlags(buildTarget
, buildTagname
, fpdModuleId
);
549 ModuleIdentification
[] libinstances
= SurfaceAreaQuery
.getLibraryInstance(fpdModuleId
.getArch());
550 String propertyLibs
= "";
551 for (int i
= 0; i
< libinstances
.length
; i
++) {
552 propertyLibs
+= " " + getProject().getProperty("BIN_DIR") + File
.separatorChar
+ libinstances
[i
].getName() + ".lib";
554 getProject().setProperty("LIBS", propertyLibs
.replaceAll("(\\\\)", "/"));
557 // if it is CUSTOM_BUILD
558 // then call the exist BaseName_build.xml directly.
560 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
561 GlobalData
.log
.info("Call user-defined " + moduleId
.getName() + "_build.xml");
563 ant
.setProject(getProject());
564 ant
.setAntfile(getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
565 ant
.setInheritAll(true);
572 // Generate ${BASE_NAME}_build.xml
575 String ffsKeyword
= SurfaceAreaQuery
.getModuleFfsKeyword();
576 ModuleBuildFileGenerator fileGenerator
= new ModuleBuildFileGenerator(getProject(), ffsKeyword
, fpdModuleId
);
577 String buildFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
578 fileGenerator
.genBuildFile(buildFilename
);
581 // Ant call ${BASE_NAME}_build.xml
584 ant
.setProject(getProject());
585 ant
.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
586 ant
.setInheritAll(true);
591 private void applyClean(FpdModuleIdentification fpdModuleId
){
593 // if it is CUSTOM_BUILD
594 // then call the exist BaseName_build.xml directly.
596 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
597 GlobalData
.log
.info("Call user-defined " + moduleId
.getName() + "_build.xml");
599 ant
.setProject(getProject());
600 ant
.setAntfile(getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
601 ant
.setTarget("clean");
602 ant
.setInheritAll(true);
609 ant
.setProject(getProject());
610 ant
.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
611 ant
.setTarget("clean");
612 ant
.setInheritAll(true);
617 // Delete current module's DEST_DIR_OUTPUT
621 private void applyCleanall(FpdModuleIdentification fpdModuleId
){
623 // if it is CUSTOM_BUILD
624 // then call the exist BaseName_build.xml directly.
626 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
627 GlobalData
.log
.info("Call user-defined " + moduleId
.getName() + "_build.xml");
629 ant
.setProject(getProject());
630 ant
.setAntfile(getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
631 ant
.setTarget("cleanall");
632 ant
.setInheritAll(true);
639 ant
.setProject(getProject());
640 ant
.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml");
641 ant
.setTarget("cleanall");
642 ant
.setInheritAll(true);
647 // Delete current module's DEST_DIR_OUTPUT
655 Separate the string and instore in set.
657 <p> String is separated by Java Regulation Expression
658 "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+". </p>
663 "/nologo", "/W3", "/WX"
664 "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
667 @param set store the separated string
668 @param str string to separate
670 private void putFlagsToSet(Set
<String
> set
, String str
) {
671 if (str
== null || str
.length() == 0) {
675 Pattern myPattern
= Pattern
.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
676 Matcher matcher
= myPattern
.matcher(str
+ " ");
677 while (matcher
.find()) {
678 String item
= str
.substring(matcher
.start(1), matcher
.end(1));
684 Generate the final flags string will be used by compile command.
686 @param add the add flags set
687 @param sub the sub flags set
688 @return final flags after add set substract sub set
690 private String
getFlags(Set
<String
> add
, Set
<String
> sub
) {
693 Iterator iter
= add
.iterator();
694 while (iter
.hasNext()) {
695 String str
= (String
) iter
.next();
696 result
+= str
.substring(1, str
.length() - 1) + " ";
702 Generate the flags string with original format. The format is defined by
703 Java Regulation Expression "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+". </p>
708 "/nologo", "/W3", "/WX"
709 "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
712 @param add the add flags set
713 @param sub the sub flags set
714 @return flags with original format
716 private String
getRawFlags(Set
<String
> add
, Set
<String
> sub
) {
717 String result
= null;
719 Iterator iter
= add
.iterator();
720 while (iter
.hasNext()) {
721 String str
= (String
) iter
.next();
722 result
+= "\"" + str
.substring(1, str
.length() - 1) + "\", ";
727 private String
parseOptionString(String optionString
, Set
<String
> addSet
, Set
<String
> subSet
) {
728 boolean overrideOption
= false;
729 Pattern pattern
= Pattern
.compile("ADD\\.\\[(.+)\\]");
730 Matcher matcher
= pattern
.matcher(optionString
);
732 while (matcher
.find()) {
733 overrideOption
= true;
734 String addOption
= optionString
.substring(matcher
.start(1), matcher
.end(1)).trim();
735 putFlagsToSet(addSet
, addOption
);
739 pattern
= Pattern
.compile("SUB\\.\\[(.+)\\]");
740 matcher
= pattern
.matcher(optionString
);
742 while (matcher
.find()) {
743 overrideOption
= true;
744 String subOption
= optionString
.substring(matcher
.start(1), matcher
.end(1)).trim();
745 putFlagsToSet(subSet
, subOption
);
748 if (overrideOption
== true) {
755 private void pushProperties() {
756 backupPropertiesStack
.push(getProject().getProperties());
759 private void popProperties() {
760 Hashtable backupProperties
= backupPropertiesStack
.pop();
761 Set keys
= backupProperties
.keySet();
762 Iterator iter
= keys
.iterator();
763 while (iter
.hasNext()) {
764 String item
= (String
)iter
.next();
765 getProject().setProperty(item
, (String
)backupProperties
.get(item
));
769 public void setSingleModuleBuild(boolean isSingleModuleBuild
) {
770 this.isSingleModuleBuild
= isSingleModuleBuild
;