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
.Vector
;
26 import java
.util
.regex
.Matcher
;
27 import java
.util
.regex
.Pattern
;
29 import org
.apache
.tools
.ant
.BuildException
;
30 import org
.apache
.tools
.ant
.BuildListener
;
31 import org
.apache
.tools
.ant
.Project
;
32 import org
.apache
.tools
.ant
.taskdefs
.Ant
;
33 import org
.apache
.tools
.ant
.taskdefs
.Property
;
34 import org
.apache
.xmlbeans
.XmlObject
;
36 import org
.tianocore
.common
.definitions
.ToolDefinitions
;
37 import org
.tianocore
.common
.exception
.EdkException
;
38 import org
.tianocore
.common
.logger
.EdkLog
;
39 import org
.tianocore
.build
.autogen
.AutoGen
;
40 import org
.tianocore
.build
.fpd
.FpdParserTask
;
41 import org
.tianocore
.build
.global
.GenBuildLogger
;
42 import org
.tianocore
.build
.global
.GlobalData
;
43 import org
.tianocore
.build
.global
.OutputManager
;
44 import org
.tianocore
.build
.global
.SurfaceAreaQuery
;
45 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
46 import org
.tianocore
.build
.id
.ModuleIdentification
;
47 import org
.tianocore
.build
.id
.PackageIdentification
;
48 import org
.tianocore
.build
.id
.PlatformIdentification
;
49 import org
.tianocore
.build
.tools
.ModuleItem
;
53 <code>GenBuildTask</code> is an ANT task that can be used in ANT build
56 <p>The main function of this task is to parse module's surface area (MSA),
57 then generate the corresponding <em>BaseName_build.xml</em> (the real ANT
58 build script) and call this to build the module. The whole process including:
61 1. generate AutoGen.c and AutoGen.h;
62 2. build all dependent library instances;
63 3. build all source files inlcude AutoGen.c;
65 5. generate FFS file if it is driver module while LIB file if it is Library module.
70 The usage is (take module <em>HelloWorld</em> for example):
75 msaFile="${PACKAGE_DIR}/Application/HelloWorld/HelloWorld.msa"
80 This task calls <code>AutoGen</code> to generate <em>AutoGen.c</em> and
85 This task will also set properties for current module, such as PACKAGE,
86 PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
87 (relative to Workspace), MODULE or BASE_NAME, GUID, VERSION, MODULE_DIR,
88 MODULE_RELATIVE_DIR (relative to Package), CONFIG_DIR, BIN_DIR,
89 DEST_DIR_DEBUG, DEST_DIR_OUTPUT, TARGET, ARCH, TOOLCHAIN, TOOLCHAIN_FAMILY,
90 SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH, all compiler command related
91 properties (CC, CC_FLAGS, CC_DPATH, CC_SPATH, CC_FAMILY, CC_EXT).
96 public class GenBuildTask
extends Ant
{
99 /// Module surface area file.
103 public ModuleIdentification parentId
;
105 private String type
= "all";
108 /// Module's Identification.
110 private ModuleIdentification moduleId
;
112 private Vector
<Property
> properties
= new Vector
<Property
>();
114 private boolean isSingleModuleBuild
= false;
116 private SurfaceAreaQuery saq
= null;
119 Public construct method. It is necessary for ANT task.
121 public GenBuildTask() {
126 @throws BuildException
127 From module build, exception from module surface area invalid.
129 public void execute() throws BuildException
{
130 if (!FrameworkBuildTask
.multithread
) {
137 GenBuildLogger logger
= new GenBuildLogger(getProject());
138 EdkLog
.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
139 EdkLog
.setLogger(logger
);
142 // Enable all specified properties
144 Iterator
<Property
> iter
= properties
.iterator();
145 while (iter
.hasNext()) {
146 Property item
= iter
.next();
147 getProject().setProperty(item
.getName(), item
.getValue());
151 // GenBuild should specify either msaFile or moduleGuid & packageGuid
153 if (msaFile
== null ) {
154 String moduleGuid
= getProject().getProperty("MODULE_GUID");
155 String moduleVersion
= getProject().getProperty("MODULE_VERSION");
156 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
157 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
158 if (moduleGuid
== null || packageGuid
== null) {
159 throw new BuildException("GenBuild parameter error.");
161 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
162 moduleId
= new ModuleIdentification(moduleGuid
, moduleVersion
);
163 moduleId
.setPackage(packageId
);
164 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(moduleId
);
165 saq
= new SurfaceAreaQuery(doc
);
166 moduleId
= saq
.getMsaHeader();
168 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(msaFile
);
169 saq
= new SurfaceAreaQuery(doc
);
170 moduleId
= saq
.getMsaHeader();
172 String
[] producedLibraryClasses
= saq
.getLibraryClasses("ALWAYS_PRODUCED",null);
173 if (producedLibraryClasses
.length
== 0) {
174 moduleId
.setLibrary(false);
176 moduleId
.setLibrary(true);
180 // Judge whether it is single module build or not
182 if (isSingleModuleBuild
) {
184 // Single Module build
186 prepareSingleModuleBuild();
188 String packageGuid
= getProject().getProperty("PACKAGE_GUID");
189 String packageVersion
= getProject().getProperty("PACKAGE_VERSION");
190 PackageIdentification packageId
= new PackageIdentification(packageGuid
, packageVersion
);
191 moduleId
.setPackage(packageId
);
195 // If single module : get arch from pass down, otherwise intersection MSA
196 // supported ARCHs and tools def
198 Set
<String
> archListSupByToolChain
= new LinkedHashSet
<String
>();
199 String
[] archs
= GlobalData
.getToolChainInfo().getArchs();
201 for (int i
= 0; i
< archs
.length
; i
++) {
202 archListSupByToolChain
.add(archs
[i
]);
205 Set
<String
> archSet
= new LinkedHashSet
<String
>();
207 if ( getProject().getProperty("ARCH") != null) {
208 String
[] fpdArchList
= getProject().getProperty("ARCH").split(" ");
210 for (int i
= 0; i
< fpdArchList
.length
; i
++) {
211 if (archListSupByToolChain
.contains(fpdArchList
[i
])) {
212 archSet
.add(fpdArchList
[i
]);
216 archSet
= archListSupByToolChain
;
219 String
[] archList
= archSet
.toArray(new String
[archSet
.size()]);
222 // Judge if arch is all supported by current module. If not, throw Exception.
224 List moduleSupportedArchs
= saq
.getModuleSupportedArchs();
225 if (moduleSupportedArchs
!= null) {
226 for (int k
= 0; k
< archList
.length
; k
++) {
227 if ( ! moduleSupportedArchs
.contains(archList
[k
])) {
228 throw new BuildException("Specified architecture [" + archList
[k
] + "] is not supported by " + moduleId
+ ". The module " + moduleId
+ " only supports [" + moduleSupportedArchs
+ "] architectures.");
233 for (int k
= 0; k
< archList
.length
; k
++) {
235 getProject().setProperty("ARCH", archList
[k
]);
237 FpdModuleIdentification fpdModuleId
= new FpdModuleIdentification(moduleId
, archList
[k
]);
240 // Whether the module is built before
242 if (moduleId
.isLibrary() == false && GlobalData
.hasFpdModuleSA(fpdModuleId
) == false) {
243 System
.out
.println("\nWARNING: " + moduleId
+ " for " + archList
[k
] + " was not found in current platform FPD file!\n");
245 } else if (GlobalData
.isModuleBuilt(fpdModuleId
)) {
248 GlobalData
.registerBuiltModule(fpdModuleId
);
252 // For Every TOOLCHAIN, TARGET
254 String
[] targetList
= GlobalData
.getToolChainInfo().getTargets();
255 for (int i
= 0; i
< targetList
.length
; i
++){
257 // Prepare for target related common properties
260 getProject().setProperty("TARGET", targetList
[i
]);
261 String
[] toolchainList
= GlobalData
.getToolChainInfo().getTagnames();
262 for(int j
= 0; j
< toolchainList
.length
; j
++){
264 // check if any tool is defined for current target + toolchain + arch
265 // don't do anything if no tools found
267 if (GlobalData
.isCommandSet(targetList
[i
], toolchainList
[j
], archList
[k
]) == false) {
268 System
.out
.println("Warning: No build issued. No tools were found for [target=" + targetList
[i
] + " toolchain=" + toolchainList
[j
] + " arch=" + archList
[k
] + "]\n");
273 // Prepare for toolchain related common properties
276 getProject().setProperty("TOOLCHAIN", toolchainList
[j
]);
278 System
.out
.println("Build " + moduleId
+ " start >>>");
279 System
.out
.println("Target: " + targetList
[i
] + " Tagname: " + toolchainList
[j
] + " Arch: " + archList
[k
]);
280 saq
.push(GlobalData
.getDoc(fpdModuleId
));
283 // Prepare for all other common properties
284 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
285 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
286 // MODULE_DIR, MODULE_RELATIVE_DIR
287 // SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH
289 setModuleCommonProperties(archList
[k
]);
292 // OutputManage prepare for
293 // BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR
295 OutputManager
.getInstance().update(getProject());
297 if (type
.equalsIgnoreCase("all") || type
.equalsIgnoreCase("build")) {
298 applyBuild(targetList
[i
], toolchainList
[j
], fpdModuleId
);
299 } else if (type
.equalsIgnoreCase("clean")) {
300 applyClean(fpdModuleId
);
301 } else if (type
.equalsIgnoreCase("cleanall")) {
302 applyCleanall(fpdModuleId
);
310 This method is used to prepare Platform-related information.
312 <p>In Single Module Build mode, platform-related information is not ready.
313 The method read the system environment variable <code>ACTIVE_PLATFORM</code>
314 and search in the Framework Database. Note that platform name in the Framework
315 Database must be unique. </p>
318 private void prepareSingleModuleBuild(){
320 // Find out the package which the module belongs to
321 // TBD: Enhance it!!!!
323 PackageIdentification packageId
= GlobalData
.getPackageForModule(moduleId
);
325 moduleId
.setPackage(packageId
);
328 // Read ACTIVE_PLATFORM's FPD file
330 String filename
= getProject().getProperty("PLATFORM_FILE");
332 if (filename
== null){
333 throw new BuildException("Please set ACTIVE_PLATFORM in the file: Tools/Conf/target.txt if you want to build a single module!");
336 PlatformIdentification platformId
= GlobalData
.getPlatform(filename
);
339 // Read FPD file (Call FpdParserTask's method)
341 FpdParserTask fpdParser
= new FpdParserTask();
342 fpdParser
.setProject(getProject());
343 fpdParser
.parseFpdFile(platformId
.getFpdFile());
344 getProject().setProperty("ARCH", fpdParser
.getAllArchForModule(moduleId
));
347 private void cleanupProperties() {
348 Project newProject
= new Project();
350 Hashtable
<String
, String
> passdownProperties
= FrameworkBuildTask
.originalProperties
;
351 Iterator
<String
> iter
= passdownProperties
.keySet().iterator();
352 while (iter
.hasNext()) {
353 String item
= iter
.next();
354 newProject
.setProperty(item
, passdownProperties
.get(item
));
357 newProject
.setInputHandler(getProject().getInputHandler());
359 Iterator listenerIter
= getProject().getBuildListeners().iterator();
360 while (listenerIter
.hasNext()) {
361 newProject
.addBuildListener((BuildListener
) listenerIter
.next());
364 getProject().initSubProject(newProject
);
366 setProject(newProject
);
370 Set Module-Related information to properties.
372 @param arch current build ARCH
374 private void setModuleCommonProperties(String arch
) {
376 // Prepare for all other common properties
377 // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
379 PackageIdentification packageId
= moduleId
.getPackage();
380 getProject().setProperty("PACKAGE", packageId
.getName());
381 getProject().setProperty("PACKAGE_GUID", packageId
.getGuid());
382 getProject().setProperty("PACKAGE_VERSION", packageId
.getVersion());
383 getProject().setProperty("PACKAGE_DIR", packageId
.getPackageDir().replaceAll("(\\\\)", "/"));
384 getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId
.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
387 // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
388 // MODULE_DIR, MODULE_RELATIVE_DIR
390 getProject().setProperty("MODULE", moduleId
.getName());
391 String baseName
= saq
.getModuleOutputFileBasename();
392 if (baseName
== null) {
393 getProject().setProperty("BASE_NAME", moduleId
.getName());
395 getProject().setProperty("BASE_NAME", baseName
);
397 getProject().setProperty("GUID", moduleId
.getGuid());
398 getProject().setProperty("FILE_GUID", moduleId
.getGuid());
399 getProject().setProperty("VERSION", moduleId
.getVersion());
400 getProject().setProperty("MODULE_TYPE", moduleId
.getModuleType());
401 getProject().setProperty("MODULE_DIR", moduleId
.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
402 getProject().setProperty("MODULE_RELATIVE_DIR", moduleId
.getModuleRelativePath().replaceAll("(\\\\)", "/"));
407 String
[][] subsystemMap
= { { "BASE", "EFI_BOOT_SERVICE_DRIVER"},
408 { "SEC", "EFI_BOOT_SERVICE_DRIVER" },
409 { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" },
410 { "PEIM", "EFI_BOOT_SERVICE_DRIVER" },
411 { "DXE_CORE", "EFI_BOOT_SERVICE_DRIVER" },
412 { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
413 { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" },
414 { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
415 { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
416 { "TOOL", "EFI_BOOT_SERVICE_DRIVER" },
417 { "UEFI_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
418 { "UEFI_APPLICATION", "EFI_APPLICATION" },
419 { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} };
421 String subsystem
= "EFI_BOOT_SERVICE_DRIVER";
422 for (int i
= 0; i
< subsystemMap
.length
; i
++) {
423 if (moduleId
.getModuleType().equalsIgnoreCase(subsystemMap
[i
][0])) {
424 subsystem
= subsystemMap
[i
][1];
428 getProject().setProperty("SUBSYSTEM", subsystem
);
433 if (arch
.equalsIgnoreCase("EBC")) {
434 getProject().setProperty("ENTRYPOINT", "EfiStart");
436 getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");
439 getProject().setProperty("OBJECTS", "");
442 private void getCompilerFlags(String target
, String toolchain
, FpdModuleIdentification fpdModuleId
) throws EdkException
{
443 String
[] cmd
= GlobalData
.getToolChainInfo().getCommands();
444 for ( int m
= 0; m
< cmd
.length
; m
++) {
446 // Set cmd, like CC, DLINK
448 String
[] key
= new String
[]{target
, toolchain
, fpdModuleId
.getArch(), cmd
[m
], null};
449 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_PATH
;
450 String cmdPath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
451 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_NAME
;
452 String cmdName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
453 File cmdFile
= new File(cmdPath
+ File
.separatorChar
+ cmdName
);
454 getProject().setProperty(cmd
[m
], cmdFile
.getPath().replaceAll("(\\\\)", "/"));
459 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_FLAGS
;
460 String cmdFlags
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
461 Set
<String
> addset
= new LinkedHashSet
<String
>();
462 Set
<String
> subset
= new LinkedHashSet
<String
>();
463 putFlagsToSet(addset
, cmdFlags
);
464 getProject().setProperty(cmd
[m
] + "_FLAGS", getProject().replaceProperties(getFlags(addset
, subset
)));
469 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_EXT
;
470 String extName
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
471 if ( extName
!= null && ! extName
.equalsIgnoreCase("")) {
472 getProject().setProperty(cmd
[m
] + "_EXT", extName
);
474 getProject().setProperty(cmd
[m
] + "_EXT", "");
480 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_FAMILY
;
481 String toolChainFamily
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
482 if (toolChainFamily
!= null) {
483 getProject().setProperty(cmd
[m
] + "_FAMILY", toolChainFamily
);
489 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_SPATH
;
490 String spath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
492 getProject().setProperty(cmd
[m
] + "_SPATH", spath
.replaceAll("(\\\\)", "/"));
494 getProject().setProperty(cmd
[m
] + "_SPATH", "");
500 key
[4] = ToolDefinitions
.TOOLS_DEF_ATTRIBUTE_DPATH
;
501 String dpath
= GlobalData
.getCommandSetting(key
, fpdModuleId
);
503 getProject().setProperty(cmd
[m
] + "_DPATH", dpath
.replaceAll("(\\\\)", "/"));
505 getProject().setProperty(cmd
[m
] + "_DPATH", "");
510 public void setMsaFile(File msaFile
) {
511 this.msaFile
= msaFile
;
515 Method is for ANT to initialize MSA file.
517 @param msaFilename MSA file name
519 public void setMsaFile(String msaFilename
) {
520 String moduleDir
= getProject().getProperty("MODULE_DIR");
523 // If is Single Module Build, then use the Base Dir defined in build.xml
525 if (moduleDir
== null) {
526 moduleDir
= getProject().getBaseDir().getPath();
528 msaFile
= new File(moduleDir
+ File
.separatorChar
+ msaFilename
);
531 public void addConfiguredModuleItem(ModuleItem moduleItem
) {
532 PackageIdentification packageId
= new PackageIdentification(moduleItem
.getPackageGuid(), moduleItem
.getPackageVersion());
533 ModuleIdentification moduleId
= new ModuleIdentification(moduleItem
.getModuleGuid(), moduleItem
.getModuleVersion());
534 moduleId
.setPackage(packageId
);
535 this.moduleId
= moduleId
;
543 public void addProperty(Property p
) {
544 properties
.addElement(p
);
547 public void setType(String type
) {
551 private void applyBuild(String buildTarget
, String buildTagname
, FpdModuleIdentification fpdModuleId
) throws BuildException
{
553 // Call AutoGen to generate AutoGen.c and AutoGen.h
555 AutoGen autogen
= new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId
.getModule(),fpdModuleId
.getArch(), saq
);
556 autogen
.genAutogen();
559 // Get compiler flags
562 getCompilerFlags(buildTarget
, buildTagname
, fpdModuleId
);
564 catch (EdkException ee
) {
565 throw new BuildException(ee
.getMessage());
571 ModuleIdentification
[] libinstances
= saq
.getLibraryInstance(fpdModuleId
.getArch());
572 String propertyLibs
= "";
573 for (int i
= 0; i
< libinstances
.length
; i
++) {
574 propertyLibs
+= " " + getProject().getProperty("BIN_DIR") + File
.separatorChar
+ libinstances
[i
].getName() + ".lib";
576 getProject().setProperty("LIBS", propertyLibs
.replaceAll("(\\\\)", "/"));
579 // Get all includepath and set to INCLUDE_PATHS
581 String
[] includes
= prepareIncludePaths(fpdModuleId
);
584 // if it is CUSTOM_BUILD
585 // then call the exist BaseName_build.xml directly.
587 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
588 System
.out
.println("Call user-defined " + moduleId
.getName() + "_build.xml");
590 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
591 antCall(antFilename
, null);
597 // Generate ${BASE_NAME}_build.xml
600 String ffsKeyword
= saq
.getModuleFfsKeyword();
601 ModuleBuildFileGenerator fileGenerator
= new ModuleBuildFileGenerator(getProject(), ffsKeyword
, fpdModuleId
, includes
, saq
);
602 String buildFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
603 fileGenerator
.genBuildFile(buildFilename
);
606 // Ant call ${BASE_NAME}_build.xml
608 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
609 antCall(antFilename
, null);
612 private void applyClean(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 System
.out
.println("Calling user-defined " + moduleId
.getName() + "_build.xml");
620 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
621 antCall(antFilename
, "clean");
626 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
627 antCall(antFilename
, "clean");
630 private void applyCleanall(FpdModuleIdentification fpdModuleId
){
632 // if it is CUSTOM_BUILD
633 // then call the exist BaseName_build.xml directly.
635 if (moduleId
.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
636 System
.out
.println("Calling user-defined " + moduleId
.getName() + "_build.xml");
638 String antFilename
= getProject().getProperty("MODULE_DIR") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
639 antCall(antFilename
, "cleanall");
644 String antFilename
= getProject().getProperty("DEST_DIR_OUTPUT") + File
.separatorChar
+ moduleId
.getName() + "_build.xml";
645 antCall(antFilename
, "cleanall");
648 private void antCall(String antFilename
, String target
) {
650 ant
.setProject(getProject());
651 ant
.setAntfile(antFilename
);
652 if (target
!= null) {
653 ant
.setTarget(target
);
655 ant
.setInheritAll(true);
662 Separate the string and instore in set.
664 <p> String is separated by Java Regulation Expression
665 "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+". </p>
670 "/nologo", "/W3", "/WX"
671 "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
674 @param set store the separated string
675 @param str string to separate
677 private void putFlagsToSet(Set
<String
> set
, String str
) {
678 if (str
== null || str
.length() == 0) {
682 Pattern myPattern
= Pattern
.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
683 Matcher matcher
= myPattern
.matcher(str
+ " ");
684 while (matcher
.find()) {
685 String item
= str
.substring(matcher
.start(1), matcher
.end(1));
691 Generate the final flags string will be used by compile command.
693 @param add the add flags set
694 @param sub the sub flags set
695 @return final flags after add set substract sub set
697 private String
getFlags(Set
<String
> add
, Set
<String
> sub
) {
700 Iterator iter
= add
.iterator();
701 while (iter
.hasNext()) {
702 String str
= (String
) iter
.next();
703 result
+= str
.substring(1, str
.length() - 1) + " ";
708 public void setSingleModuleBuild(boolean isSingleModuleBuild
) {
709 this.isSingleModuleBuild
= isSingleModuleBuild
;
712 private String
[] prepareIncludePaths(FpdModuleIdentification fpdModuleId
) {
714 // Prepare the includes: PackageDependencies and Output debug direactory
716 Set
<String
> includes
= new LinkedHashSet
<String
>();
717 String arch
= fpdModuleId
.getArch();
722 includes
.add("${WORKSPACE_DIR}" + File
.separatorChar
);
727 includes
.add("${MODULE_DIR}");
728 includes
.add("${MODULE_DIR}" + File
.separatorChar
+ archDir(arch
));
731 // Packages in PackageDenpendencies
733 PackageIdentification
[] packageDependencies
= saq
.getDependencePkg(fpdModuleId
.getArch());
734 for (int i
= 0; i
< packageDependencies
.length
; i
++) {
735 GlobalData
.refreshPackageIdentification(packageDependencies
[i
]);
736 File packageFile
= packageDependencies
[i
].getSpdFile();
737 includes
.add(packageFile
.getParent() + File
.separatorChar
+ "Include");
738 includes
.add(packageFile
.getParent() + File
.separatorChar
+ "Include" + File
.separatorChar
+ archDir(arch
));
742 // All Dependency Library Instance's PackageDependencies
744 ModuleIdentification
[] libinstances
= saq
.getLibraryInstance(fpdModuleId
.getArch());
745 for (int i
= 0; i
< libinstances
.length
; i
++) {
746 saq
.push(GlobalData
.getDoc(libinstances
[i
], fpdModuleId
.getArch()));
747 PackageIdentification
[] libraryPackageDependencies
= saq
.getDependencePkg(fpdModuleId
.getArch());
748 for (int j
= 0; j
< libraryPackageDependencies
.length
; j
++) {
749 GlobalData
.refreshPackageIdentification(libraryPackageDependencies
[j
]);
750 File packageFile
= libraryPackageDependencies
[j
].getSpdFile();
751 includes
.add(packageFile
.getParent() + File
.separatorChar
+ "Include");
752 includes
.add(packageFile
.getParent() + File
.separatorChar
+ "Include" + File
.separatorChar
+ archDir(arch
));
759 // The package which the module belongs to
761 includes
.add(fpdModuleId
.getModule().getPackage().getPackageDir() + File
.separatorChar
+ "Include");
762 includes
.add(fpdModuleId
.getModule().getPackage().getPackageDir() + File
.separatorChar
+ "Include" + File
.separatorChar
+ archDir(arch
));
765 // Debug files output directory
767 includes
.add("${DEST_DIR_DEBUG}");
770 // set to INCLUDE_PATHS property
772 Iterator
<String
> iter
= includes
.iterator();
773 StringBuffer includePaths
= new StringBuffer();
774 while (iter
.hasNext()) {
775 includePaths
.append(iter
.next());
776 includePaths
.append("; ");
778 getProject().setProperty("INCLUDE_PATHS", getProject().replaceProperties(includePaths
.toString()).replaceAll("(\\\\)", "/"));
780 return includes
.toArray(new String
[includes
.size()]);
784 Return the name of the directory that corresponds to the architecture.
785 This is a translation from the XML Schema tag to a directory that
786 corresponds to our directory name coding convention.
789 private String
archDir(String arch
) {
790 return arch
.replaceFirst("X64", "x64")
791 .replaceFirst("IPF", "Ipf")
792 .replaceFirst("IA32", "Ia32")
793 .replaceFirst("ARM", "Arm")
794 .replaceFirst("EBC", "Ebc");
798 public void setExternalProperties(Vector
<Property
> v
) {