X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2FGenBuildTask.java;h=8e7ee3b941194e2a3200f3b047526aad23290785;hb=778d35c92a569812c3b2f6d0b913315bdce4c874;hp=1f020b3cc15df0b17b2d66dd247f1901a25b8f4c;hpb=57cc2ee710e6a12621f879dd5e95dc7d4fb8cba9;p=mirror_edk2.git
diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
index 1f020b3cc1..8e7ee3b941 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
@@ -1,9 +1,9 @@
/** @file
- This file is ANT task GenBuild.
-
- The file is used to parse a specified Module, and generate its build time
+ This file is ANT task GenBuild.
+
+ The file is used to parse a specified Module, and generate its build time
ANT script build.xml, then call the the ANT script to build the module.
-
+
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -16,7 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
package org.tianocore.build;
import java.io.File;
-import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -33,67 +32,75 @@ import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.taskdefs.Property;
import org.apache.xmlbeans.XmlObject;
+import org.tianocore.common.definitions.ToolDefinitions;
+import org.tianocore.common.exception.EdkException;
+import org.tianocore.common.logger.EdkLog;
import org.tianocore.build.autogen.AutoGen;
import org.tianocore.build.fpd.FpdParserTask;
import org.tianocore.build.global.GenBuildLogger;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.OutputManager;
+import org.tianocore.build.global.PropertyManager;
import org.tianocore.build.global.SurfaceAreaQuery;
import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PackageIdentification;
import org.tianocore.build.id.PlatformIdentification;
import org.tianocore.build.tools.ModuleItem;
-import org.tianocore.exception.EdkException;
-import org.tianocore.logger.EdkLog;
/**
GenBuildTask
is an ANT task that can be used in ANT build
- system. The main function of this task is to parse module's surface area,
+ system.
+
+
The main function of this task is to parse module's surface area (MSA),
then generate the corresponding BaseName_build.xml (the real ANT
build script) and call this to build the module. The whole process including:
- 1. generate AutoGen.c and AutoGen.h; 2. build all dependent library instances;
- 3. build all source files inlcude AutoGen.c; 4. generate sections;
- 5. generate FFS file if it is driver module while LIB file if it is Library module.
-
+
+ 1. generate AutoGen.c and AutoGen.h;
+ 2. build all dependent library instances;
+ 3. build all source files inlcude AutoGen.c;
+ 4. generate sections;
+ 5. generate FFS file if it is driver module while LIB file if it is Library module.
+
+
+
The usage is (take module HelloWorld for example):
-
+
- <GenBuild
- msaFilename="HelloWorld.msa"/>
- processTo="ALL"/>
+ <GenBuild
+ msaFile="${PACKAGE_DIR}/Application/HelloWorld/HelloWorld.msa"
+ type="cleanall" />
-
- processTo
provides a way to customize the whole build process.
- processTo can be one value of ALL, AUTOGEN, FILES, LIBRARYINSTANCES, SECTIONS, NONE.
- Default is ALL, means whole
-
-
+
This task calls AutoGen
to generate AutoGen.c and
- AutoGen.h. The task also parses the development environment
- configuration files, such as collecting package information, setting compiler
- flags and so on.
+ AutoGen.h.
+
+
+
+ This task will also set properties for current module, such as PACKAGE,
+ PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
+ (relative to Workspace), MODULE or BASE_NAME, GUID, VERSION, MODULE_DIR,
+ MODULE_RELATIVE_DIR (relative to Package), CONFIG_DIR, BIN_DIR,
+ DEST_DIR_DEBUG, DEST_DIR_OUTPUT, TARGET, ARCH, TOOLCHAIN, TOOLCHAIN_FAMILY,
+ SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH, all compiler command related
+ properties (CC, CC_FLAGS, CC_DPATH, CC_SPATH, CC_FAMILY, CC_EXT).
-
@since GenBuild 1.0
**/
public class GenBuildTask extends Ant {
-
+
///
/// Module surface area file.
///
File msaFile;
- ///
- ///
- ///
- private String type = "all"; // = "build";
+ private String type = "all";
///
/// Module's Identification.
@@ -103,9 +110,9 @@ public class GenBuildTask extends Ant {
private Vector properties = new Vector();
private static Stack backupPropertiesStack = new Stack();
-
+
private boolean isSingleModuleBuild = false;
-
+
/**
Public construct method. It is necessary for ANT task.
**/
@@ -113,7 +120,7 @@ public class GenBuildTask extends Ant {
}
/**
-
+
@throws BuildException
From module build, exception from module surface area invalid.
**/
@@ -124,18 +131,18 @@ public class GenBuildTask extends Ant {
GenBuildLogger logger = new GenBuildLogger(getProject());
EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
- // remove !!
- try {
- pushProperties();
+
+ PropertyManager.setProject(getProject());
+ PropertyManager.save();
//
// Enable all specified properties
//
Iterator iter = properties.iterator();
while (iter.hasNext()) {
Property item = iter.next();
- getProject().setProperty(item.getName(), item.getValue());
+ PropertyManager.setProperty(item.getName(), item.getValue());
}
-
+
//
// GenBuild should specify either msaFile or moduleGuid & packageGuid
//
@@ -145,7 +152,7 @@ public class GenBuildTask extends Ant {
String packageGuid = getProject().getProperty("PACKAGE_GUID");
String packageVersion = getProject().getProperty("PACKAGE_VERSION");
if (moduleGuid == null || packageGuid == null) {
- throw new BuildException("GenBuild parameters error. ");
+ throw new BuildException("GenBuild parameter error.");
}
PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);
moduleId = new ModuleIdentification(moduleGuid, moduleVersion);
@@ -153,8 +160,7 @@ public class GenBuildTask extends Ant {
Map doc = GlobalData.getNativeMsa(moduleId);
SurfaceAreaQuery.setDoc(doc);
moduleId = SurfaceAreaQuery.getMsaHeader();
- }
- else {
+ } else {
Map doc = GlobalData.getNativeMsa(msaFile);
SurfaceAreaQuery.setDoc(doc);
moduleId = SurfaceAreaQuery.getMsaHeader();
@@ -162,11 +168,10 @@ public class GenBuildTask extends Ant {
String[] producedLibraryClasses = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED",null);
if (producedLibraryClasses.length == 0) {
moduleId.setLibrary(false);
- }
- else {
+ } else {
moduleId.setLibrary(true);
}
-
+
//
// Judge whether it is single module build or not
//
@@ -175,50 +180,48 @@ public class GenBuildTask extends Ant {
// Single Module build
//
prepareSingleModuleBuild();
- }
- else {
+ } else {
//
// Platform build. Restore the platform related info
//
String filename = getProject().getProperty("PLATFORM_FILE");
PlatformIdentification platformId = GlobalData.getPlatform(filename);
- getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
- getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
-
+ PropertyManager.setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
+ PropertyManager.setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
+
String packageGuid = getProject().getProperty("PACKAGE_GUID");
String packageVersion = getProject().getProperty("PACKAGE_VERSION");
PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);
moduleId.setPackage(packageId);
}
-
+
//
- // If single module : intersection MSA supported ARCHs and tools def!!
- // else, get arch from pass down
+ // If single module : get arch from pass down, otherwise intersection MSA
+ // supported ARCHs and tools def
//
- Set archListSupByToolChain = new LinkedHashSet();
- String[] archs = GlobalData.getToolChainInfo().getArchs();
-
+ Set archListSupByToolChain = new LinkedHashSet();
+ String[] archs = GlobalData.getToolChainInfo().getArchs();
+
for (int i = 0; i < archs.length; i ++) {
archListSupByToolChain.add(archs[i]);
}
-
+
Set archSet = new LinkedHashSet();
-
+
if ( getProject().getProperty("ARCH") != null) {
String[] fpdArchList = getProject().getProperty("ARCH").split(" ");
-
+
for (int i = 0; i < fpdArchList.length; i++) {
if (archListSupByToolChain.contains(fpdArchList[i])) {
archSet.add(fpdArchList[i]);
}
}
- }
- else {
+ } else {
archSet = archListSupByToolChain;
}
-
+
String[] archList = archSet.toArray(new String[archSet.size()]);
-
+
//
// Judge if arch is all supported by current module. If not, throw Exception.
//
@@ -226,28 +229,29 @@ public class GenBuildTask extends Ant {
if (moduleSupportedArchs != null) {
for (int k = 0; k < archList.length; k++) {
if ( ! moduleSupportedArchs.contains(archList[k])) {
- throw new BuildException("ARCH [" + archList[k] + "] is not supported by " + moduleId + ". " + moduleId + " only supports [" + moduleSupportedArchs + "].");
+ throw new BuildException("Specified architecture [" + archList[k] + "] is not supported by " + moduleId + ". The module " + moduleId + " only supports [" + moduleSupportedArchs + "] architectures.");
}
}
}
-
+
for (int k = 0; k < archList.length; k++) {
-
- getProject().setProperty("ARCH", archList[k]);
-
+
+ PropertyManager.setProperty("ARCH", archList[k]);
+
FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, archList[k]);
-
+
//
// Whether the module is built before
//
- if ((moduleId.isLibrary() == false && GlobalData.hasFpdModuleSA(fpdModuleId) == false)
- || GlobalData.isModuleBuilt(fpdModuleId)) {
+ if (moduleId.isLibrary() == false && GlobalData.hasFpdModuleSA(fpdModuleId) == false) {
+ System.out.println("\nWARNING: " + moduleId + " for " + archList[k] + " was not found in current platform FPD file!\n");
continue;
- }
- else {
+ } else if (GlobalData.isModuleBuilt(fpdModuleId)) {
+ break;
+ } else {
GlobalData.registerBuiltModule(fpdModuleId);
}
-
+
//
// For Every TOOLCHAIN, TARGET
//
@@ -257,15 +261,15 @@ public class GenBuildTask extends Ant {
// Prepare for target related common properties
// TARGET
//
- getProject().setProperty("TARGET", targetList[i]);
+ PropertyManager.setProperty("TARGET", targetList[i]);
String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();
for(int j = 0; j < toolchainList.length; j ++){
//
// check if any tool is defined for current target + toolchain + arch
// don't do anything if no tools found
- //
+ //
if (GlobalData.isCommandSet(targetList[i], toolchainList[j], archList[k]) == false) {
- System.out.println("Warning: No build issued. No tools found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");
+ System.out.println("Warning: No build issued. No tools were found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");
continue;
}
@@ -273,54 +277,49 @@ public class GenBuildTask extends Ant {
// Prepare for toolchain related common properties
// TOOLCHAIN
//
- getProject().setProperty("TOOLCHAIN", toolchainList[j]);
+ PropertyManager.setProperty("TOOLCHAIN", toolchainList[j]);
System.out.println("Build " + moduleId + " start >>>");
System.out.println("Target: " + targetList[i] + " Tagname: " + toolchainList[j] + " Arch: " + archList[k]);
SurfaceAreaQuery.setDoc(GlobalData.getDoc(fpdModuleId));
-
+
//
// Prepare for all other common properties
// PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
// MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
// MODULE_DIR, MODULE_RELATIVE_DIR
// SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH
- // LIBS, OBJECTS, SDB_FILES
//
setModuleCommonProperties(archList[k]);
-
+
//
- // OutputManage prepare for
+ // OutputManage prepare for
// BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR
//
OutputManager.getInstance().update(getProject());
-
+
if (type.equalsIgnoreCase("all") || type.equalsIgnoreCase("build")) {
applyBuild(targetList[i], toolchainList[j], fpdModuleId);
- }
- else if (type.equalsIgnoreCase("clean")) {
+ } else if (type.equalsIgnoreCase("clean")) {
applyClean(fpdModuleId);
- }
- else if (type.equalsIgnoreCase("cleanall")) {
+ } else if (type.equalsIgnoreCase("cleanall")) {
applyCleanall(fpdModuleId);
}
}
}
}
- popProperties();
- }catch (Exception e){
- throw new BuildException(e.getMessage());
- }
+
+ PropertyManager.restore();
}
/**
- This method is used to prepare Platform-related information.
-
+ This method is used to prepare Platform-related information.
+
In Single Module Build mode, platform-related information is not ready.
- The method read the system environment variable ACTIVE_PLATFORM
+ The method read the system environment variable ACTIVE_PLATFORM
and search in the Framework Database. Note that platform name in the Framework
Database must be unique.
-
+
**/
private void prepareSingleModuleBuild(){
//
@@ -328,39 +327,41 @@ public class GenBuildTask extends Ant {
// TBD: Enhance it!!!!
//
PackageIdentification packageId = GlobalData.getPackageForModule(moduleId);
-
+
moduleId.setPackage(packageId);
-
+
//
- // Read ACTIVE_PLATFORM's FPD file (Call FpdParserTask's method)
+ // Read ACTIVE_PLATFORM's FPD file
//
String filename = getProject().getProperty("PLATFORM_FILE");
-
+
if (filename == null){
- throw new BuildException("Plese set ACTIVE_PLATFORM if you want to build a single module. ");
+ throw new BuildException("Please set ACTIVE_PLATFORM in the file: Tools/Conf/target.txt if you want to build a single module!");
}
-
+
PlatformIdentification platformId = GlobalData.getPlatform(filename);
-
+
//
- // Read FPD file
+ // Read FPD file (Call FpdParserTask's method)
//
FpdParserTask fpdParser = new FpdParserTask();
fpdParser.setProject(getProject());
fpdParser.parseFpdFile(platformId.getFpdFile());
-
+
//
// Prepare for Platform related common properties
// PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
//
- getProject().setProperty("PLATFORM", platformId.getName());
- getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
- getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
+ PropertyManager.setProperty("PLATFORM", platformId.getName());
+ PropertyManager.setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
+ PropertyManager.setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
}
/**
Set Module-Related information to properties.
+
+ @param arch current build ARCH
**/
private void setModuleCommonProperties(String arch) {
//
@@ -368,48 +369,47 @@ public class GenBuildTask extends Ant {
// PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
//
PackageIdentification packageId = moduleId.getPackage();
- getProject().setProperty("PACKAGE", packageId.getName());
- getProject().setProperty("PACKAGE_GUID", packageId.getGuid());
- getProject().setProperty("PACKAGE_VERSION", packageId.getVersion());
- getProject().setProperty("PACKAGE_DIR", packageId.getPackageDir().replaceAll("(\\\\)", "/"));
- getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
-
+ PropertyManager.setProperty("PACKAGE", packageId.getName());
+ PropertyManager.setProperty("PACKAGE_GUID", packageId.getGuid());
+ PropertyManager.setProperty("PACKAGE_VERSION", packageId.getVersion());
+ PropertyManager.setProperty("PACKAGE_DIR", packageId.getPackageDir().replaceAll("(\\\\)", "/"));
+ PropertyManager.setProperty("PACKAGE_RELATIVE_DIR", packageId.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
+
//
// MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
// MODULE_DIR, MODULE_RELATIVE_DIR
//
- getProject().setProperty("MODULE", moduleId.getName());
+ PropertyManager.setProperty("MODULE", moduleId.getName());
String baseName = SurfaceAreaQuery.getModuleOutputFileBasename();
if (baseName == null) {
- getProject().setProperty("BASE_NAME", moduleId.getName());
- }
- else {
- getProject().setProperty("BASE_NAME", baseName);
- }
- getProject().setProperty("GUID", moduleId.getGuid());
- getProject().setProperty("FILE_GUID", moduleId.getGuid());
- getProject().setProperty("VERSION", moduleId.getVersion());
- getProject().setProperty("MODULE_TYPE", moduleId.getModuleType());
- getProject().setProperty("MODULE_DIR", moduleId.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
- getProject().setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/"));
-
+ PropertyManager.setProperty("BASE_NAME", moduleId.getName());
+ } else {
+ PropertyManager.setProperty("BASE_NAME", baseName);
+ }
+ PropertyManager.setProperty("GUID", moduleId.getGuid());
+ PropertyManager.setProperty("FILE_GUID", moduleId.getGuid());
+ PropertyManager.setProperty("VERSION", moduleId.getVersion());
+ PropertyManager.setProperty("MODULE_TYPE", moduleId.getModuleType());
+ PropertyManager.setProperty("MODULE_DIR", moduleId.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
+ PropertyManager.setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/"));
+
//
// SUBSYSTEM
//
String[][] subsystemMap = { { "BASE", "EFI_BOOT_SERVICE_DRIVER"},
- { "SEC", "EFI_BOOT_SERVICE_DRIVER" },
- { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" },
- { "PEIM", "EFI_BOOT_SERVICE_DRIVER" },
+ { "SEC", "EFI_BOOT_SERVICE_DRIVER" },
+ { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" },
+ { "PEIM", "EFI_BOOT_SERVICE_DRIVER" },
{ "DXE_CORE", "EFI_BOOT_SERVICE_DRIVER" },
- { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
- { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" },
- { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
- { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
- { "TOOL", "EFI_BOOT_SERVICE_DRIVER" },
+ { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
+ { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" },
+ { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
+ { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
+ { "TOOL", "EFI_BOOT_SERVICE_DRIVER" },
{ "UEFI_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
- { "UEFI_APPLICATION", "EFI_APPLICATION" },
- { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} };
-
+ { "UEFI_APPLICATION", "EFI_APPLICATION" },
+ { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} };
+
String subsystem = "EFI_BOOT_SERVICE_DRIVER";
for (int i = 0; i < subsystemMap.length; i++) {
if (moduleId.getModuleType().equalsIgnoreCase(subsystemMap[i][0])) {
@@ -417,24 +417,18 @@ public class GenBuildTask extends Ant {
break ;
}
}
- getProject().setProperty("SUBSYSTEM", subsystem);
-
+ PropertyManager.setProperty("SUBSYSTEM", subsystem);
+
//
// ENTRYPOINT
//
if (arch.equalsIgnoreCase("EBC")) {
- getProject().setProperty("ENTRYPOINT", "EfiStart");
- }
- else {
- getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");
+ PropertyManager.setProperty("ENTRYPOINT", "EfiStart");
+ } else {
+ PropertyManager.setProperty("ENTRYPOINT", "_ModuleEntryPoint");
}
-
- //
- // LIBS, OBJECTS, SDB_FILES
- //
- getProject().setProperty("OBJECTS", "");
- getProject().setProperty("SDB_FILES", "");
- getProject().setProperty("LIBS", "");
+
+ PropertyManager.setProperty("OBJECTS", "");
}
private void getCompilerFlags(String target, String toolchain, FpdModuleIdentification fpdModuleId) throws EdkException {
@@ -444,82 +438,79 @@ public class GenBuildTask extends Ant {
// Set cmd, like CC, DLINK
//
String[] key = new String[]{target, toolchain, fpdModuleId.getArch(), cmd[m], null};
- key[4] = "PATH";
+ key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_PATH;
String cmdPath = GlobalData.getCommandSetting(key, fpdModuleId);
- key[4] = "NAME";
+ key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_NAME;
String cmdName = GlobalData.getCommandSetting(key, fpdModuleId);
File cmdFile = new File(cmdPath + File.separatorChar + cmdName);
- getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));
-
+ PropertyManager.setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));
+
//
// set CC_FLAGS
//
- key[4] = "FLAGS";
+ key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS;
String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId);
Set addset = new LinkedHashSet();
Set subset = new LinkedHashSet();
putFlagsToSet(addset, cmdFlags);
- getProject().setProperty(cmd[m] + "_FLAGS", getProject().replaceProperties(getFlags(addset, subset)));
-
+ PropertyManager.setProperty(cmd[m] + "_FLAGS", getProject().replaceProperties(getFlags(addset, subset)));
+
//
// Set CC_EXT
//
- key[4] = "EXT";
+ key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_EXT;
String extName = GlobalData.getCommandSetting(key, fpdModuleId);
if ( extName != null && ! extName.equalsIgnoreCase("")) {
- getProject().setProperty(cmd[m] + "_EXT", extName);
+ PropertyManager.setProperty(cmd[m] + "_EXT", extName);
+ } else {
+ PropertyManager.setProperty(cmd[m] + "_EXT", "");
}
- else {
- getProject().setProperty(cmd[m] + "_EXT", "");
- }
-
+
//
// set CC_FAMILY
//
- key[4] = "FAMILY";
+ key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FAMILY;
String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId);
if (toolChainFamily != null) {
- getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily);
+ PropertyManager.setProperty(cmd[m] + "_FAMILY", toolChainFamily);
}
-
+
//
// set CC_SPATH
//
- key[4] = "SPATH";
+ key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_SPATH;
String spath = GlobalData.getCommandSetting(key, fpdModuleId);
if (spath != null) {
- getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));
- }
- else {
- getProject().setProperty(cmd[m] + "_SPATH", "");
+ PropertyManager.setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));
+ } else {
+ PropertyManager.setProperty(cmd[m] + "_SPATH", "");
}
-
+
//
// set CC_DPATH
//
- key[4] = "DPATH";
+ key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_DPATH;
String dpath = GlobalData.getCommandSetting(key, fpdModuleId);
if (dpath != null) {
- getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));
- }
- else {
- getProject().setProperty(cmd[m] + "_DPATH", "");
+ PropertyManager.setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));
+ } else {
+ PropertyManager.setProperty(cmd[m] + "_DPATH", "");
}
}
}
-
+
public void setMsaFile(File msaFile) {
this.msaFile = msaFile;
}
/**
- Method is for ANT to initialize MSA file.
-
+ Method is for ANT to initialize MSA file.
+
@param msaFilename MSA file name
**/
public void setMsaFile(String msaFilename) {
String moduleDir = getProject().getProperty("MODULE_DIR");
-
+
//
// If is Single Module Build, then use the Base Dir defined in build.xml
//
@@ -528,17 +519,17 @@ public class GenBuildTask extends Ant {
}
msaFile = new File(moduleDir + File.separatorChar + msaFilename);
}
-
+
public void addConfiguredModuleItem(ModuleItem moduleItem) {
PackageIdentification packageId = new PackageIdentification(moduleItem.getPackageGuid(), moduleItem.getPackageVersion());
ModuleIdentification moduleId = new ModuleIdentification(moduleItem.getModuleGuid(), moduleItem.getModuleVersion());
moduleId.setPackage(packageId);
this.moduleId = moduleId;
}
-
+
/**
- Add a property.
-
+ Add a property.
+
@param p property
**/
public void addProperty(Property p) {
@@ -548,20 +539,25 @@ public class GenBuildTask extends Ant {
public void setType(String type) {
this.type = type;
}
-
- private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws EdkException{
+
+ private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws BuildException{
//
// AutoGen
//
-
+
AutoGen autogen = new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId.getModule(),fpdModuleId.getArch());
autogen.genAutogen();
-
-
+
+
//
// Get compiler flags
//
- getCompilerFlags(buildTarget, buildTagname, fpdModuleId);
+ try {
+ getCompilerFlags(buildTarget, buildTagname, fpdModuleId);
+ }
+ catch (EdkException ee) {
+ throw new BuildException(ee.getMessage());
+ }
//
// Prepare LIBS
@@ -571,23 +567,21 @@ public class GenBuildTask extends Ant {
for (int i = 0; i < libinstances.length; i++) {
propertyLibs += " " + getProject().getProperty("BIN_DIR") + File.separatorChar + libinstances[i].getName() + ".lib";
}
- getProject().setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/"));
-
+ PropertyManager.setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/"));
+
//
// if it is CUSTOM_BUILD
// then call the exist BaseName_build.xml directly.
//
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
- GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml");
- Ant ant = new Ant();
- ant.setProject(getProject());
- ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml");
- ant.setInheritAll(true);
- ant.init();
- ant.execute();
+ System.out.println("Call user-defined " + moduleId.getName() + "_build.xml");
+
+ String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
+ antCall(antFilename, null);
+
return ;
}
-
+
//
// Generate ${BASE_NAME}_build.xml
// TBD
@@ -596,94 +590,76 @@ public class GenBuildTask extends Ant {
ModuleBuildFileGenerator fileGenerator = new ModuleBuildFileGenerator(getProject(), ffsKeyword, fpdModuleId);
String buildFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
fileGenerator.genBuildFile(buildFilename);
-
+
//
// Ant call ${BASE_NAME}_build.xml
//
- Ant ant = new Ant();
- ant.setProject(getProject());
- ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml");
- ant.setInheritAll(true);
- ant.init();
- ant.execute();
+ String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
+ antCall(antFilename, null);
}
-
+
private void applyClean(FpdModuleIdentification fpdModuleId){
//
// if it is CUSTOM_BUILD
// then call the exist BaseName_build.xml directly.
//
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
- GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml");
- Ant ant = new Ant();
- ant.setProject(getProject());
- ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml");
- ant.setTarget("clean");
- ant.setInheritAll(true);
- ant.init();
- ant.execute();
+ System.out.println("Calling user-defined " + moduleId.getName() + "_build.xml");
+
+ String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
+ antCall(antFilename, "clean");
+
return ;
}
-
- Ant ant = new Ant();
- ant.setProject(getProject());
- ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml");
- ant.setTarget("clean");
- ant.setInheritAll(true);
- ant.init();
- ant.execute();
-
- //
- // Delete current module's DEST_DIR_OUTPUT
- // TBD
+
+ String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
+ antCall(antFilename, "clean");
}
-
+
private void applyCleanall(FpdModuleIdentification fpdModuleId){
//
// if it is CUSTOM_BUILD
// then call the exist BaseName_build.xml directly.
//
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
- GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml");
- Ant ant = new Ant();
- ant.setProject(getProject());
- ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml");
- ant.setTarget("cleanall");
- ant.setInheritAll(true);
- ant.init();
- ant.execute();
+ System.out.println("Calling user-defined " + moduleId.getName() + "_build.xml");
+
+ String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
+ antCall(antFilename, "cleanall");
+
return ;
}
+ String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
+ antCall(antFilename, "cleanall");
+ }
+
+ private void antCall(String antFilename, String target) {
Ant ant = new Ant();
ant.setProject(getProject());
- ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml");
- ant.setTarget("cleanall");
+ ant.setAntfile(antFilename);
+ if (target != null) {
+ ant.setTarget(target);
+ }
ant.setInheritAll(true);
ant.init();
ant.execute();
-
- //
- // Delete current module's DEST_DIR_OUTPUT
- // TBD
}
-
-
/**
Separate the string and instore in set.
-
- String is separated by Java Regulation Expression
+
+
String is separated by Java Regulation Expression
"[^\\\\]?(\".*?[^\\\\]\")[ \t,]+".
-
+
For example:
-
+
"/nologo", "/W3", "/WX"
"/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
-
+
@param set store the separated string
@param str string to separate
**/
@@ -699,10 +675,10 @@ public class GenBuildTask extends Ant {
set.add(item);
}
}
-
+
/**
- Generate the final flags string will be used by compile command.
-
+ Generate the final flags string will be used by compile command.
+
@param add the add flags set
@param sub the sub flags set
@return final flags after add set substract sub set
@@ -718,74 +694,6 @@ public class GenBuildTask extends Ant {
return result;
}
- /**
- Generate the flags string with original format. The format is defined by
- Java Regulation Expression "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+".
-
- For example:
-
-
- "/nologo", "/W3", "/WX"
- "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
-
-
- @param add the add flags set
- @param sub the sub flags set
- @return flags with original format
- **/
- private String getRawFlags(Set add, Set sub) {
- String result = null;
- add.removeAll(sub);
- Iterator iter = add.iterator();
- while (iter.hasNext()) {
- String str = (String) iter.next();
- result += "\"" + str.substring(1, str.length() - 1) + "\", ";
- }
- return result;
- }
-
- private String parseOptionString(String optionString, Set addSet, Set subSet) {
- boolean overrideOption = false;
- Pattern pattern = Pattern.compile("ADD\\.\\[(.+)\\]");
- Matcher matcher = pattern.matcher(optionString);
-
- while (matcher.find()) {
- overrideOption = true;
- String addOption = optionString.substring(matcher.start(1), matcher.end(1)).trim();
- putFlagsToSet(addSet, addOption);
-
- }
-
- pattern = Pattern.compile("SUB\\.\\[(.+)\\]");
- matcher = pattern.matcher(optionString);
-
- while (matcher.find()) {
- overrideOption = true;
- String subOption = optionString.substring(matcher.start(1), matcher.end(1)).trim();
- putFlagsToSet(subSet, subOption);
- }
-
- if (overrideOption == true) {
- return null;
- }
-
- return optionString;
- }
-
- private void pushProperties() {
- backupPropertiesStack.push(getProject().getProperties());
- }
-
- private void popProperties() {
- Hashtable backupProperties = backupPropertiesStack.pop();
- Set keys = backupProperties.keySet();
- Iterator iter = keys.iterator();
- while (iter.hasNext()) {
- String item = (String)iter.next();
- getProject().setProperty(item, (String)backupProperties.get(item));
- }
- }
-
public void setSingleModuleBuild(boolean isSingleModuleBuild) {
this.isSingleModuleBuild = isSingleModuleBuild;
}