- Fixed EDKT146; The override warning message has been reduced to almost none.
- Changed MakeDeps tool to generate .dep file which can be used directly by ANT task wrapper - Made several code optimizations and format clean git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1324 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
e485bb4bff
commit
1fa1cb752a
@ -182,11 +182,6 @@ public class MakeDeps extends Task {
|
|||||||
EdkLog.log(EdkLog.EDK_INFO, "MakeDeps failed!");
|
EdkLog.log(EdkLog.EDK_INFO, "MakeDeps failed!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// change the old DEP file format (makefile compatible) to just file list
|
|
||||||
if (!cleanup()) {
|
|
||||||
throw new BuildException(depsFile + " was not generated!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -326,75 +321,6 @@ public class MakeDeps extends Task {
|
|||||||
inputFileList.add(inputFile);
|
inputFileList.add(inputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
The original file generated by MakeDeps.exe is for makefile uses. The target
|
|
||||||
part (before :) is not useful for ANT. This method will do the removal.
|
|
||||||
|
|
||||||
@returns true if cleaned files is saved successfully
|
|
||||||
@returns false if error occurs in file I/O system
|
|
||||||
**/
|
|
||||||
private boolean cleanup() {
|
|
||||||
File df = new File(depsFile);
|
|
||||||
|
|
||||||
if (!df.exists()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
LineNumberReader lineReader = null;
|
|
||||||
FileReader fileReader = null;
|
|
||||||
Set<String> lineSet = new HashSet<String>(100); // used to remove duplicated lines
|
|
||||||
try {
|
|
||||||
fileReader = new FileReader(df);
|
|
||||||
lineReader = new LineNumberReader(fileReader);
|
|
||||||
|
|
||||||
///
|
|
||||||
/// clean-up each line in deps file
|
|
||||||
//
|
|
||||||
String line = null;
|
|
||||||
while ((line = lineReader.readLine()) != null) {
|
|
||||||
String[] filePath = line.split(" : ");
|
|
||||||
if (filePath.length == 2) {
|
|
||||||
///
|
|
||||||
/// keep the file name after ":"
|
|
||||||
///
|
|
||||||
lineSet.add(cleanupPathName(filePath[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lineReader.close();
|
|
||||||
fileReader.close();
|
|
||||||
|
|
||||||
///
|
|
||||||
/// we may have explicitly specified dependency files
|
|
||||||
///
|
|
||||||
StringTokenizer fileTokens = new StringTokenizer(extraDeps, ";");
|
|
||||||
while (fileTokens.hasMoreTokens()) {
|
|
||||||
lineSet.add(cleanupPathName(fileTokens.nextToken()));
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
|
||||||
/// compose the final file content
|
|
||||||
///
|
|
||||||
StringBuffer cleanedLines = new StringBuffer(40960);
|
|
||||||
Iterator<String> it = lineSet.iterator();
|
|
||||||
while (it.hasNext()) {
|
|
||||||
String filePath = it.next();
|
|
||||||
cleanedLines.append(filePath);
|
|
||||||
cleanedLines.append("\n");
|
|
||||||
}
|
|
||||||
///
|
|
||||||
/// overwrite old dep file with new content
|
|
||||||
///
|
|
||||||
FileWriter fileWriter = null;
|
|
||||||
fileWriter = new FileWriter(df);
|
|
||||||
fileWriter.write(cleanedLines.toString());
|
|
||||||
fileWriter.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log (e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check if the dependency list file should be (re-)generated or not.
|
Check if the dependency list file should be (re-)generated or not.
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import org.apache.tools.ant.BuildException;
|
|||||||
import org.apache.tools.ant.Task;
|
import org.apache.tools.ant.Task;
|
||||||
import org.tianocore.build.fpd.FpdParserTask;
|
import org.tianocore.build.fpd.FpdParserTask;
|
||||||
import org.tianocore.build.global.GlobalData;
|
import org.tianocore.build.global.GlobalData;
|
||||||
|
import org.tianocore.build.global.PropertyManager;
|
||||||
import org.tianocore.build.toolchain.ConfigReader;
|
import org.tianocore.build.toolchain.ConfigReader;
|
||||||
import org.tianocore.build.toolchain.ToolChainInfo;
|
import org.tianocore.build.toolchain.ToolChainInfo;
|
||||||
import org.tianocore.common.definitions.ToolDefinitions;
|
import org.tianocore.common.definitions.ToolDefinitions;
|
||||||
@ -135,7 +136,7 @@ public class FrameworkBuildTask extends Task{
|
|||||||
// Global Data initialization
|
// Global Data initialization
|
||||||
//
|
//
|
||||||
File workspacePath = new File(getProject().getProperty("WORKSPACE"));
|
File workspacePath = new File(getProject().getProperty("WORKSPACE"));
|
||||||
getProject().setProperty("WORKSPACE_DIR", workspacePath.getPath().replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty(getProject(), "WORKSPACE_DIR", workspacePath.getPath().replaceAll("(\\\\)", "/"));
|
||||||
GlobalData.initInfo(dbFilename, workspacePath.getPath(), toolsDefFilename);
|
GlobalData.initInfo(dbFilename, workspacePath.getPath(), toolsDefFilename);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -203,7 +204,7 @@ public class FrameworkBuildTask extends Task{
|
|||||||
GenBuildTask genBuildTask = new GenBuildTask();
|
GenBuildTask genBuildTask = new GenBuildTask();
|
||||||
genBuildTask.setSingleModuleBuild(true);
|
genBuildTask.setSingleModuleBuild(true);
|
||||||
genBuildTask.setType(type);
|
genBuildTask.setType(type);
|
||||||
getProject().setProperty("PLATFORM_FILE", activePlatform);
|
PropertyManager.setProperty(getProject(), "PLATFORM_FILE", activePlatform);
|
||||||
genBuildTask.setProject(getProject());
|
genBuildTask.setProject(getProject());
|
||||||
genBuildTask.setMsaFile(buildFile);
|
genBuildTask.setMsaFile(buildFile);
|
||||||
genBuildTask.execute();
|
genBuildTask.execute();
|
||||||
@ -226,7 +227,7 @@ public class FrameworkBuildTask extends Task{
|
|||||||
// If system environment variable is not in ANT properties, add it
|
// If system environment variable is not in ANT properties, add it
|
||||||
//
|
//
|
||||||
if (getProject().getProperty(name) == null) {
|
if (getProject().getProperty(name) == null) {
|
||||||
getProject().setProperty(name, sysProperties.get(name));
|
PropertyManager.setProperty(getProject(), name, sysProperties.get(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ import org.tianocore.build.fpd.FpdParserTask;
|
|||||||
import org.tianocore.build.global.GenBuildLogger;
|
import org.tianocore.build.global.GenBuildLogger;
|
||||||
import org.tianocore.build.global.GlobalData;
|
import org.tianocore.build.global.GlobalData;
|
||||||
import org.tianocore.build.global.OutputManager;
|
import org.tianocore.build.global.OutputManager;
|
||||||
|
import org.tianocore.build.global.PropertyManager;
|
||||||
import org.tianocore.build.global.SurfaceAreaQuery;
|
import org.tianocore.build.global.SurfaceAreaQuery;
|
||||||
import org.tianocore.build.id.FpdModuleIdentification;
|
import org.tianocore.build.id.FpdModuleIdentification;
|
||||||
import org.tianocore.build.id.ModuleIdentification;
|
import org.tianocore.build.id.ModuleIdentification;
|
||||||
@ -131,14 +132,15 @@ public class GenBuildTask extends Ant {
|
|||||||
EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
|
EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
|
||||||
EdkLog.setLogger(logger);
|
EdkLog.setLogger(logger);
|
||||||
|
|
||||||
pushProperties();
|
PropertyManager.setProject(getProject());
|
||||||
|
PropertyManager.save();
|
||||||
//
|
//
|
||||||
// Enable all specified properties
|
// Enable all specified properties
|
||||||
//
|
//
|
||||||
Iterator<Property> iter = properties.iterator();
|
Iterator<Property> iter = properties.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Property item = iter.next();
|
Property item = iter.next();
|
||||||
getProject().setProperty(item.getName(), item.getValue());
|
PropertyManager.setProperty(item.getName(), item.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -184,8 +186,8 @@ public class GenBuildTask extends Ant {
|
|||||||
//
|
//
|
||||||
String filename = getProject().getProperty("PLATFORM_FILE");
|
String filename = getProject().getProperty("PLATFORM_FILE");
|
||||||
PlatformIdentification platformId = GlobalData.getPlatform(filename);
|
PlatformIdentification platformId = GlobalData.getPlatform(filename);
|
||||||
getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
|
||||||
getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
|
||||||
|
|
||||||
String packageGuid = getProject().getProperty("PACKAGE_GUID");
|
String packageGuid = getProject().getProperty("PACKAGE_GUID");
|
||||||
String packageVersion = getProject().getProperty("PACKAGE_VERSION");
|
String packageVersion = getProject().getProperty("PACKAGE_VERSION");
|
||||||
@ -234,7 +236,7 @@ public class GenBuildTask extends Ant {
|
|||||||
|
|
||||||
for (int k = 0; k < archList.length; k++) {
|
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]);
|
FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, archList[k]);
|
||||||
|
|
||||||
@ -245,7 +247,7 @@ public class GenBuildTask extends Ant {
|
|||||||
System.out.println("\nWARNING: " + moduleId + " for " + archList[k] + " was not found in current platform FPD file!\n");
|
System.out.println("\nWARNING: " + moduleId + " for " + archList[k] + " was not found in current platform FPD file!\n");
|
||||||
continue;
|
continue;
|
||||||
} else if (GlobalData.isModuleBuilt(fpdModuleId)) {
|
} else if (GlobalData.isModuleBuilt(fpdModuleId)) {
|
||||||
return;
|
break;
|
||||||
} else {
|
} else {
|
||||||
GlobalData.registerBuiltModule(fpdModuleId);
|
GlobalData.registerBuiltModule(fpdModuleId);
|
||||||
}
|
}
|
||||||
@ -259,7 +261,7 @@ public class GenBuildTask extends Ant {
|
|||||||
// Prepare for target related common properties
|
// Prepare for target related common properties
|
||||||
// TARGET
|
// TARGET
|
||||||
//
|
//
|
||||||
getProject().setProperty("TARGET", targetList[i]);
|
PropertyManager.setProperty("TARGET", targetList[i]);
|
||||||
String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();
|
String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();
|
||||||
for(int j = 0; j < toolchainList.length; j ++){
|
for(int j = 0; j < toolchainList.length; j ++){
|
||||||
//
|
//
|
||||||
@ -275,7 +277,7 @@ public class GenBuildTask extends Ant {
|
|||||||
// Prepare for toolchain related common properties
|
// Prepare for toolchain related common properties
|
||||||
// TOOLCHAIN
|
// TOOLCHAIN
|
||||||
//
|
//
|
||||||
getProject().setProperty("TOOLCHAIN", toolchainList[j]);
|
PropertyManager.setProperty("TOOLCHAIN", toolchainList[j]);
|
||||||
|
|
||||||
System.out.println("Build " + moduleId + " start >>>");
|
System.out.println("Build " + moduleId + " start >>>");
|
||||||
System.out.println("Target: " + targetList[i] + " Tagname: " + toolchainList[j] + " Arch: " + archList[k]);
|
System.out.println("Target: " + targetList[i] + " Tagname: " + toolchainList[j] + " Arch: " + archList[k]);
|
||||||
@ -307,7 +309,7 @@ public class GenBuildTask extends Ant {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
popProperties();
|
PropertyManager.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -350,9 +352,9 @@ public class GenBuildTask extends Ant {
|
|||||||
// Prepare for Platform related common properties
|
// Prepare for Platform related common properties
|
||||||
// PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
|
// PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
|
||||||
//
|
//
|
||||||
getProject().setProperty("PLATFORM", platformId.getName());
|
PropertyManager.setProperty("PLATFORM", platformId.getName());
|
||||||
getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
|
||||||
getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -367,29 +369,29 @@ public class GenBuildTask extends Ant {
|
|||||||
// PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
|
// PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
|
||||||
//
|
//
|
||||||
PackageIdentification packageId = moduleId.getPackage();
|
PackageIdentification packageId = moduleId.getPackage();
|
||||||
getProject().setProperty("PACKAGE", packageId.getName());
|
PropertyManager.setProperty("PACKAGE", packageId.getName());
|
||||||
getProject().setProperty("PACKAGE_GUID", packageId.getGuid());
|
PropertyManager.setProperty("PACKAGE_GUID", packageId.getGuid());
|
||||||
getProject().setProperty("PACKAGE_VERSION", packageId.getVersion());
|
PropertyManager.setProperty("PACKAGE_VERSION", packageId.getVersion());
|
||||||
getProject().setProperty("PACKAGE_DIR", packageId.getPackageDir().replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty("PACKAGE_DIR", packageId.getPackageDir().replaceAll("(\\\\)", "/"));
|
||||||
getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty("PACKAGE_RELATIVE_DIR", packageId.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
|
||||||
|
|
||||||
//
|
//
|
||||||
// MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
|
// MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
|
||||||
// MODULE_DIR, MODULE_RELATIVE_DIR
|
// MODULE_DIR, MODULE_RELATIVE_DIR
|
||||||
//
|
//
|
||||||
getProject().setProperty("MODULE", moduleId.getName());
|
PropertyManager.setProperty("MODULE", moduleId.getName());
|
||||||
String baseName = SurfaceAreaQuery.getModuleOutputFileBasename();
|
String baseName = SurfaceAreaQuery.getModuleOutputFileBasename();
|
||||||
if (baseName == null) {
|
if (baseName == null) {
|
||||||
getProject().setProperty("BASE_NAME", moduleId.getName());
|
PropertyManager.setProperty("BASE_NAME", moduleId.getName());
|
||||||
} else {
|
} else {
|
||||||
getProject().setProperty("BASE_NAME", baseName);
|
PropertyManager.setProperty("BASE_NAME", baseName);
|
||||||
}
|
}
|
||||||
getProject().setProperty("GUID", moduleId.getGuid());
|
PropertyManager.setProperty("GUID", moduleId.getGuid());
|
||||||
getProject().setProperty("FILE_GUID", moduleId.getGuid());
|
PropertyManager.setProperty("FILE_GUID", moduleId.getGuid());
|
||||||
getProject().setProperty("VERSION", moduleId.getVersion());
|
PropertyManager.setProperty("VERSION", moduleId.getVersion());
|
||||||
getProject().setProperty("MODULE_TYPE", moduleId.getModuleType());
|
PropertyManager.setProperty("MODULE_TYPE", moduleId.getModuleType());
|
||||||
getProject().setProperty("MODULE_DIR", moduleId.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty("MODULE_DIR", moduleId.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
|
||||||
getProject().setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/"));
|
||||||
|
|
||||||
//
|
//
|
||||||
// SUBSYSTEM
|
// SUBSYSTEM
|
||||||
@ -415,18 +417,18 @@ public class GenBuildTask extends Ant {
|
|||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getProject().setProperty("SUBSYSTEM", subsystem);
|
PropertyManager.setProperty("SUBSYSTEM", subsystem);
|
||||||
|
|
||||||
//
|
//
|
||||||
// ENTRYPOINT
|
// ENTRYPOINT
|
||||||
//
|
//
|
||||||
if (arch.equalsIgnoreCase("EBC")) {
|
if (arch.equalsIgnoreCase("EBC")) {
|
||||||
getProject().setProperty("ENTRYPOINT", "EfiStart");
|
PropertyManager.setProperty("ENTRYPOINT", "EfiStart");
|
||||||
} else {
|
} else {
|
||||||
getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");
|
PropertyManager.setProperty("ENTRYPOINT", "_ModuleEntryPoint");
|
||||||
}
|
}
|
||||||
|
|
||||||
getProject().setProperty("OBJECTS", "");
|
PropertyManager.setProperty("OBJECTS", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getCompilerFlags(String target, String toolchain, FpdModuleIdentification fpdModuleId) throws EdkException {
|
private void getCompilerFlags(String target, String toolchain, FpdModuleIdentification fpdModuleId) throws EdkException {
|
||||||
@ -441,7 +443,7 @@ public class GenBuildTask extends Ant {
|
|||||||
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_NAME;
|
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_NAME;
|
||||||
String cmdName = GlobalData.getCommandSetting(key, fpdModuleId);
|
String cmdName = GlobalData.getCommandSetting(key, fpdModuleId);
|
||||||
File cmdFile = new File(cmdPath + File.separatorChar + cmdName);
|
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
|
// set CC_FLAGS
|
||||||
@ -451,7 +453,7 @@ public class GenBuildTask extends Ant {
|
|||||||
Set<String> addset = new LinkedHashSet<String>();
|
Set<String> addset = new LinkedHashSet<String>();
|
||||||
Set<String> subset = new LinkedHashSet<String>();
|
Set<String> subset = new LinkedHashSet<String>();
|
||||||
putFlagsToSet(addset, cmdFlags);
|
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
|
// Set CC_EXT
|
||||||
@ -459,9 +461,9 @@ public class GenBuildTask extends Ant {
|
|||||||
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_EXT;
|
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_EXT;
|
||||||
String extName = GlobalData.getCommandSetting(key, fpdModuleId);
|
String extName = GlobalData.getCommandSetting(key, fpdModuleId);
|
||||||
if ( extName != null && ! extName.equalsIgnoreCase("")) {
|
if ( extName != null && ! extName.equalsIgnoreCase("")) {
|
||||||
getProject().setProperty(cmd[m] + "_EXT", extName);
|
PropertyManager.setProperty(cmd[m] + "_EXT", extName);
|
||||||
} else {
|
} else {
|
||||||
getProject().setProperty(cmd[m] + "_EXT", "");
|
PropertyManager.setProperty(cmd[m] + "_EXT", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -470,7 +472,7 @@ public class GenBuildTask extends Ant {
|
|||||||
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FAMILY;
|
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FAMILY;
|
||||||
String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId);
|
String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId);
|
||||||
if (toolChainFamily != null) {
|
if (toolChainFamily != null) {
|
||||||
getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily);
|
PropertyManager.setProperty(cmd[m] + "_FAMILY", toolChainFamily);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -479,9 +481,9 @@ public class GenBuildTask extends Ant {
|
|||||||
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_SPATH;
|
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_SPATH;
|
||||||
String spath = GlobalData.getCommandSetting(key, fpdModuleId);
|
String spath = GlobalData.getCommandSetting(key, fpdModuleId);
|
||||||
if (spath != null) {
|
if (spath != null) {
|
||||||
getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));
|
||||||
} else {
|
} else {
|
||||||
getProject().setProperty(cmd[m] + "_SPATH", "");
|
PropertyManager.setProperty(cmd[m] + "_SPATH", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -490,9 +492,9 @@ public class GenBuildTask extends Ant {
|
|||||||
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_DPATH;
|
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_DPATH;
|
||||||
String dpath = GlobalData.getCommandSetting(key, fpdModuleId);
|
String dpath = GlobalData.getCommandSetting(key, fpdModuleId);
|
||||||
if (dpath != null) {
|
if (dpath != null) {
|
||||||
getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));
|
||||||
} else {
|
} else {
|
||||||
getProject().setProperty(cmd[m] + "_DPATH", "");
|
PropertyManager.setProperty(cmd[m] + "_DPATH", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -565,7 +567,7 @@ public class GenBuildTask extends Ant {
|
|||||||
for (int i = 0; i < libinstances.length; i++) {
|
for (int i = 0; i < libinstances.length; i++) {
|
||||||
propertyLibs += " " + getProject().getProperty("BIN_DIR") + File.separatorChar + libinstances[i].getName() + ".lib";
|
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
|
// if it is CUSTOM_BUILD
|
||||||
@ -692,20 +694,6 @@ public class GenBuildTask extends Ant {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
public void setSingleModuleBuild(boolean isSingleModuleBuild) {
|
||||||
this.isSingleModuleBuild = isSingleModuleBuild;
|
this.isSingleModuleBuild = isSingleModuleBuild;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ import org.apache.tools.ant.Project;
|
|||||||
import org.tianocore.build.fpd.FpdParserTask;
|
import org.tianocore.build.fpd.FpdParserTask;
|
||||||
import org.tianocore.build.global.GlobalData;
|
import org.tianocore.build.global.GlobalData;
|
||||||
import org.tianocore.build.global.SurfaceAreaQuery;
|
import org.tianocore.build.global.SurfaceAreaQuery;
|
||||||
|
import org.tianocore.build.global.PropertyManager;
|
||||||
import org.tianocore.build.id.FpdModuleIdentification;
|
import org.tianocore.build.id.FpdModuleIdentification;
|
||||||
import org.tianocore.build.id.ModuleIdentification;
|
import org.tianocore.build.id.ModuleIdentification;
|
||||||
import org.tianocore.build.id.PackageIdentification;
|
import org.tianocore.build.id.PackageIdentification;
|
||||||
@ -483,7 +484,7 @@ public class ModuleBuildFileGenerator {
|
|||||||
for (int i = 0; i < sourceFiles.length; i++) {
|
for (int i = 0; i < sourceFiles.length; i++) {
|
||||||
str += " " + sourceFiles[i][1];
|
str += " " + sourceFiles[i][1];
|
||||||
}
|
}
|
||||||
project.setProperty("SOURCE_FILES", str.replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty(project, "SOURCE_FILES", str.replaceAll("(\\\\)", "/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@ package org.tianocore.build.global;
|
|||||||
|
|
||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import org.tianocore.build.global.PropertyManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
OutputManager class is used to setup output directories (BIN_DIR, DEST_DIR_OUTPUT,
|
OutputManager class is used to setup output directories (BIN_DIR, DEST_DIR_OUTPUT,
|
||||||
@ -143,11 +144,11 @@ public class OutputManager {
|
|||||||
//
|
//
|
||||||
// Set properties
|
// Set properties
|
||||||
//
|
//
|
||||||
project.setProperty("BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty(project, "BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
|
||||||
project.setProperty("FV_DIR", fvDir.replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty(project, "FV_DIR", fvDir.replaceAll("(\\\\)", "/"));
|
||||||
project.setProperty("BIN_DIR", binDir.replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty(project, "BIN_DIR", binDir.replaceAll("(\\\\)", "/"));
|
||||||
project.setProperty("DEST_DIR_DEBUG", (destDir + File.separatorChar + "DEBUG").replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty(project, "DEST_DIR_DEBUG", (destDir + File.separatorChar + "DEBUG").replaceAll("(\\\\)", "/"));
|
||||||
project.setProperty("DEST_DIR_OUTPUT", (destDir + File.separatorChar + "OUTPUT").replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty(project, "DEST_DIR_OUTPUT", (destDir + File.separatorChar + "OUTPUT").replaceAll("(\\\\)", "/"));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create all directory if necessary
|
// Create all directory if necessary
|
||||||
@ -186,7 +187,7 @@ public class OutputManager {
|
|||||||
//
|
//
|
||||||
// Set to property
|
// Set to property
|
||||||
//
|
//
|
||||||
project.setProperty("BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
|
PropertyManager.setProperty(project, "BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create all directory if necessary
|
// Create all directory if necessary
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
/** @file
|
||||||
|
PropertyManager class.
|
||||||
|
|
||||||
|
PropertyManager class wraps Project.setProperty and tracks overrided properties.
|
||||||
|
|
||||||
|
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
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
**/
|
||||||
package org.tianocore.build.global;
|
package org.tianocore.build.global;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -9,14 +23,46 @@ import java.util.Stack;
|
|||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
import org.apache.tools.ant.PropertyHelper;
|
import org.apache.tools.ant.PropertyHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
PropertyManager uses a incremental way to to track overrided properties when
|
||||||
|
setProperty. This is useful for property recovery in nestly calling build files.
|
||||||
|
Another functionality of this class is to prevent warning message printed when
|
||||||
|
building with "verbose" mode.
|
||||||
|
**/
|
||||||
public class PropertyManager {
|
public class PropertyManager {
|
||||||
|
//
|
||||||
|
// Property table stack, keeps track the history of properties changes
|
||||||
|
//
|
||||||
private static Stack<HashMap<String, String>> propertyTableStack = new Stack<HashMap<String, String>>();
|
private static Stack<HashMap<String, String>> propertyTableStack = new Stack<HashMap<String, String>>();
|
||||||
|
//
|
||||||
|
// The very original properties
|
||||||
|
//
|
||||||
private static HashMap<String, String> orgPropertyTable = null;
|
private static HashMap<String, String> orgPropertyTable = null;
|
||||||
|
//
|
||||||
|
// The last changes of properties
|
||||||
|
//
|
||||||
private static HashMap<String, String> oldPropertyTable = null;
|
private static HashMap<String, String> oldPropertyTable = null;
|
||||||
|
//
|
||||||
|
// The current changes of properties
|
||||||
|
//
|
||||||
private static HashMap<String, String> bakPropertyTable = null;
|
private static HashMap<String, String> bakPropertyTable = null;
|
||||||
|
//
|
||||||
|
// The Project of tracking properties
|
||||||
|
//
|
||||||
private static Project prj = null;
|
private static Project prj = null;
|
||||||
|
//
|
||||||
|
// PropertyHelper of this project for setting property quietly
|
||||||
|
//
|
||||||
|
private static PropertyHelper ph = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Backup properties that have been overrided onto the stack for later recovery.
|
||||||
|
**/
|
||||||
public static void save() {
|
public static void save() {
|
||||||
|
//
|
||||||
|
// If this is the first time to save properties changes, keep all properties
|
||||||
|
// of this project as the original property table.
|
||||||
|
//
|
||||||
if (orgPropertyTable == null) {
|
if (orgPropertyTable == null) {
|
||||||
Hashtable prjProperties = prj.getProperties();
|
Hashtable prjProperties = prj.getProperties();
|
||||||
orgPropertyTable = new HashMap<String, String>();
|
orgPropertyTable = new HashMap<String, String>();
|
||||||
@ -29,6 +75,10 @@ public class PropertyManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If there're already overrided properties, push it onto stack; otherwise
|
||||||
|
// prepare taking new overrided property by allocating space for it.
|
||||||
|
//
|
||||||
if (bakPropertyTable != null) {
|
if (bakPropertyTable != null) {
|
||||||
propertyTableStack.push(bakPropertyTable);
|
propertyTableStack.push(bakPropertyTable);
|
||||||
oldPropertyTable = bakPropertyTable;
|
oldPropertyTable = bakPropertyTable;
|
||||||
@ -38,25 +88,40 @@ public class PropertyManager {
|
|||||||
bakPropertyTable = new HashMap<String, String>();
|
bakPropertyTable = new HashMap<String, String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Restore the properties backup
|
||||||
|
**/
|
||||||
public static void restore() {
|
public static void restore() {
|
||||||
if (bakPropertyTable == null) {
|
if (bakPropertyTable == null) {
|
||||||
|
//
|
||||||
|
// No properties backup, do nothing
|
||||||
|
//
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set keys = bakPropertyTable.keySet();
|
Set keys = bakPropertyTable.keySet();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Re-set properties in backup
|
||||||
|
//
|
||||||
Iterator iter = keys.iterator();
|
Iterator iter = keys.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
String name = (String)iter.next();
|
String name = (String)iter.next();
|
||||||
String value = (String)bakPropertyTable.get(name);
|
String value = (String)bakPropertyTable.get(name);
|
||||||
setProperty(prj, name, value);
|
ph.setProperty(null, name, value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If there's backup history, get top one for next recovery
|
||||||
|
//
|
||||||
if (propertyTableStack.size() > 0) {
|
if (propertyTableStack.size() > 0) {
|
||||||
bakPropertyTable = (HashMap<String, String>)propertyTableStack.pop();
|
bakPropertyTable = (HashMap<String, String>)propertyTableStack.pop();
|
||||||
} else {
|
} else {
|
||||||
bakPropertyTable = null;
|
bakPropertyTable = null; // no recovery any more
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine last overrided properties for incremental judgement
|
||||||
|
//
|
||||||
if (propertyTableStack.size() == 0) {
|
if (propertyTableStack.size() == 0) {
|
||||||
oldPropertyTable = orgPropertyTable;
|
oldPropertyTable = orgPropertyTable;
|
||||||
} else {
|
} else {
|
||||||
@ -64,37 +129,68 @@ public class PropertyManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set current Project for save() and restore() use.
|
||||||
|
|
||||||
|
@param prj
|
||||||
|
**/
|
||||||
public static void setProject(Project prj) {
|
public static void setProject(Project prj) {
|
||||||
PropertyManager.prj = prj;
|
PropertyManager.prj = prj;
|
||||||
|
PropertyManager.ph = PropertyHelper.getPropertyHelper(prj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set a property for current project. It will also be put into property
|
||||||
|
history record if the record table has been setup.
|
||||||
|
|
||||||
|
@param name Property name
|
||||||
|
@param value Property value
|
||||||
|
**/
|
||||||
public static void setProperty(String name, String value) {
|
public static void setProperty(String name, String value) {
|
||||||
if (prj == null) {
|
if (prj == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setProperty(prj, name, value);
|
setProperty(prj, name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set a property for current project. It will also be put into property
|
||||||
|
history record if the record table has been setup.
|
||||||
|
|
||||||
|
@param project The Project for which the property will be set
|
||||||
|
@param name Property name
|
||||||
|
@param value Property value
|
||||||
|
**/
|
||||||
|
public static void setProperty(Project project, String name, String value) {
|
||||||
|
if (project == null) {
|
||||||
|
if (prj == null) {
|
||||||
|
return; // a Project must be given; otherwise nothing can be set
|
||||||
|
}
|
||||||
|
project = prj;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Using PropertyHelper to set a property can be quiet (no override
|
||||||
|
// warning preset).
|
||||||
|
//
|
||||||
|
PropertyHelper.getPropertyHelper(project).setProperty(null, name, value, false);
|
||||||
|
|
||||||
|
//
|
||||||
|
// If no property override history record is found, do nothing further
|
||||||
|
//
|
||||||
if (oldPropertyTable == null || bakPropertyTable == null) {
|
if (oldPropertyTable == null || bakPropertyTable == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Put a copy of given property in history record.
|
||||||
|
//
|
||||||
String oldValue = oldPropertyTable.get(name);
|
String oldValue = oldPropertyTable.get(name);
|
||||||
if (oldValue == null) {
|
if (oldValue == null) {
|
||||||
oldValue = value;
|
oldValue = value;
|
||||||
}
|
}
|
||||||
bakPropertyTable.put(name, oldValue);
|
bakPropertyTable.put(name, oldValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setProperty(Project project, String name, String value) {
|
|
||||||
if (project == null) {
|
|
||||||
if (prj == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
project = prj;
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyHelper.getPropertyHelper(project).setProperty(null, name, value, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,32 +82,35 @@ public class SurfaceAreaQuery {
|
|||||||
|
|
||||||
public static String prefix = "http://www.TianoCore.org/2006/Edk2.0";
|
public static String prefix = "http://www.TianoCore.org/2006/Edk2.0";
|
||||||
|
|
||||||
// /
|
//
|
||||||
// / Contains name/value pairs of Surface Area document object. The name is
|
// Contains name/value pairs of Surface Area document object. The name is
|
||||||
// / always the top level element name.
|
// always the top level element name.
|
||||||
// /
|
//
|
||||||
private static Map<String, XmlObject> map = null;
|
private static Map<String, XmlObject> map = null;
|
||||||
|
|
||||||
// /
|
//
|
||||||
// / mapStack is used to do nested query
|
// mapStack is used to do nested query
|
||||||
// /
|
//
|
||||||
private static Stack<Map<String, XmlObject>> mapStack = new Stack<Map<String, XmlObject>>();
|
private static Stack<Map<String, XmlObject>> mapStack = new Stack<Map<String, XmlObject>>();
|
||||||
|
|
||||||
// /
|
//
|
||||||
// / prefix of name space
|
// prefix of name space
|
||||||
// /
|
//
|
||||||
private static String nsPrefix = "sans";
|
private static String nsPrefix = "sans";
|
||||||
|
|
||||||
// /
|
//
|
||||||
// / xmlbeans needs a name space for each Xpath element
|
// xmlbeans needs a name space for each Xpath element
|
||||||
// /
|
//
|
||||||
private static String ns = null;
|
private static String ns = null;
|
||||||
|
|
||||||
// /
|
//
|
||||||
// / keep the namep declaration for xmlbeans Xpath query
|
// keep the namep declaration for xmlbeans Xpath query
|
||||||
// /
|
//
|
||||||
private static String queryDeclaration = null;
|
private static String queryDeclaration = null;
|
||||||
|
|
||||||
|
private static StringBuffer normQueryString = new StringBuffer(4096);
|
||||||
|
private static Pattern xPathPattern = Pattern.compile("([^/]*)(/|//)([^/]+)");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a Surface Area document for query later
|
* Set a Surface Area document for query later
|
||||||
*
|
*
|
||||||
@ -150,13 +153,12 @@ public class SurfaceAreaQuery {
|
|||||||
// / /ns:MsaHeader/ns:ModuleType
|
// / /ns:MsaHeader/ns:ModuleType
|
||||||
// /
|
// /
|
||||||
private static String normalizeQueryString(String[] exp, String from) {
|
private static String normalizeQueryString(String[] exp, String from) {
|
||||||
StringBuffer normQueryString = new StringBuffer(4096);
|
normQueryString.setLength(0);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < exp.length) {
|
while (i < exp.length) {
|
||||||
String newExp = from + exp[i];
|
String newExp = from + exp[i];
|
||||||
Pattern pattern = Pattern.compile("([^/]*)(/|//)([^/]+)");
|
Matcher matcher = xPathPattern.matcher(newExp);
|
||||||
Matcher matcher = pattern.matcher(newExp);
|
|
||||||
|
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
String starter = newExp.substring(matcher.start(1), matcher
|
String starter = newExp.substring(matcher.start(1), matcher
|
||||||
|
@ -652,9 +652,6 @@ Returns:
|
|||||||
//
|
//
|
||||||
// Go through the symbols and do replacements
|
// Go through the symbols and do replacements
|
||||||
//
|
//
|
||||||
strcpy (Str, TargetFileName);
|
|
||||||
ReplaceSymbols (Str, sizeof (Str));
|
|
||||||
fprintf (mGlobals.OutFptr, "%s : ", Str);
|
|
||||||
strcpy (Str, DependentFile);
|
strcpy (Str, DependentFile);
|
||||||
ReplaceSymbols (Str, sizeof (Str));
|
ReplaceSymbols (Str, sizeof (Str));
|
||||||
fprintf (mGlobals.OutFptr, "%s\n", Str);
|
fprintf (mGlobals.OutFptr, "%s\n", Str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user