mirror of https://github.com/acidanthera/audk.git
- 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!");
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
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.
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.tools.ant.BuildException;
|
|||
import org.apache.tools.ant.Task;
|
||||
import org.tianocore.build.fpd.FpdParserTask;
|
||||
import org.tianocore.build.global.GlobalData;
|
||||
import org.tianocore.build.global.PropertyManager;
|
||||
import org.tianocore.build.toolchain.ConfigReader;
|
||||
import org.tianocore.build.toolchain.ToolChainInfo;
|
||||
import org.tianocore.common.definitions.ToolDefinitions;
|
||||
|
@ -135,7 +136,7 @@ public class FrameworkBuildTask extends Task{
|
|||
// Global Data initialization
|
||||
//
|
||||
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);
|
||||
|
||||
//
|
||||
|
@ -203,7 +204,7 @@ public class FrameworkBuildTask extends Task{
|
|||
GenBuildTask genBuildTask = new GenBuildTask();
|
||||
genBuildTask.setSingleModuleBuild(true);
|
||||
genBuildTask.setType(type);
|
||||
getProject().setProperty("PLATFORM_FILE", activePlatform);
|
||||
PropertyManager.setProperty(getProject(), "PLATFORM_FILE", activePlatform);
|
||||
genBuildTask.setProject(getProject());
|
||||
genBuildTask.setMsaFile(buildFile);
|
||||
genBuildTask.execute();
|
||||
|
@ -226,7 +227,7 @@ public class FrameworkBuildTask extends Task{
|
|||
// If system environment variable is not in ANT properties, add it
|
||||
//
|
||||
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.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;
|
||||
|
@ -131,14 +132,15 @@ public class GenBuildTask extends Ant {
|
|||
EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
|
||||
EdkLog.setLogger(logger);
|
||||
|
||||
pushProperties();
|
||||
PropertyManager.setProject(getProject());
|
||||
PropertyManager.save();
|
||||
//
|
||||
// Enable all specified properties
|
||||
//
|
||||
Iterator<Property> iter = properties.iterator();
|
||||
while (iter.hasNext()) {
|
||||
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");
|
||||
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");
|
||||
|
@ -234,7 +236,7 @@ public class GenBuildTask extends Ant {
|
|||
|
||||
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]);
|
||||
|
||||
|
@ -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");
|
||||
continue;
|
||||
} else if (GlobalData.isModuleBuilt(fpdModuleId)) {
|
||||
return;
|
||||
break;
|
||||
} else {
|
||||
GlobalData.registerBuiltModule(fpdModuleId);
|
||||
}
|
||||
|
@ -259,7 +261,7 @@ 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 ++){
|
||||
//
|
||||
|
@ -275,7 +277,7 @@ 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]);
|
||||
|
@ -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
|
||||
// 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("(\\\\)", "/"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -367,29 +369,29 @@ 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());
|
||||
PropertyManager.setProperty("BASE_NAME", moduleId.getName());
|
||||
} else {
|
||||
getProject().setProperty("BASE_NAME", baseName);
|
||||
PropertyManager.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("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
|
||||
|
@ -415,18 +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");
|
||||
PropertyManager.setProperty("ENTRYPOINT", "EfiStart");
|
||||
} 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 {
|
||||
|
@ -441,7 +443,7 @@ public class GenBuildTask extends Ant {
|
|||
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
|
||||
|
@ -451,7 +453,7 @@ public class GenBuildTask extends Ant {
|
|||
Set<String> addset = new LinkedHashSet<String>();
|
||||
Set<String> subset = new LinkedHashSet<String>();
|
||||
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
|
||||
|
@ -459,9 +461,9 @@ public class GenBuildTask extends Ant {
|
|||
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 {
|
||||
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;
|
||||
String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId);
|
||||
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;
|
||||
String spath = GlobalData.getCommandSetting(key, fpdModuleId);
|
||||
if (spath != null) {
|
||||
getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));
|
||||
PropertyManager.setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));
|
||||
} 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;
|
||||
String dpath = GlobalData.getCommandSetting(key, fpdModuleId);
|
||||
if (dpath != null) {
|
||||
getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));
|
||||
PropertyManager.setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));
|
||||
} 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++) {
|
||||
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
|
||||
|
@ -692,20 +694,6 @@ public class GenBuildTask extends Ant {
|
|||
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) {
|
||||
this.isSingleModuleBuild = isSingleModuleBuild;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.apache.tools.ant.Project;
|
|||
import org.tianocore.build.fpd.FpdParserTask;
|
||||
import org.tianocore.build.global.GlobalData;
|
||||
import org.tianocore.build.global.SurfaceAreaQuery;
|
||||
import org.tianocore.build.global.PropertyManager;
|
||||
import org.tianocore.build.id.FpdModuleIdentification;
|
||||
import org.tianocore.build.id.ModuleIdentification;
|
||||
import org.tianocore.build.id.PackageIdentification;
|
||||
|
@ -483,7 +484,7 @@ public class ModuleBuildFileGenerator {
|
|||
for (int i = 0; i < sourceFiles.length; i++) {
|
||||
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 java.io.File;
|
||||
import org.tianocore.build.global.PropertyManager;
|
||||
|
||||
/**
|
||||
OutputManager class is used to setup output directories (BIN_DIR, DEST_DIR_OUTPUT,
|
||||
|
@ -143,11 +144,11 @@ public class OutputManager {
|
|||
//
|
||||
// Set properties
|
||||
//
|
||||
project.setProperty("BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
|
||||
project.setProperty("FV_DIR", fvDir.replaceAll("(\\\\)", "/"));
|
||||
project.setProperty("BIN_DIR", binDir.replaceAll("(\\\\)", "/"));
|
||||
project.setProperty("DEST_DIR_DEBUG", (destDir + File.separatorChar + "DEBUG").replaceAll("(\\\\)", "/"));
|
||||
project.setProperty("DEST_DIR_OUTPUT", (destDir + File.separatorChar + "OUTPUT").replaceAll("(\\\\)", "/"));
|
||||
PropertyManager.setProperty(project, "BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
|
||||
PropertyManager.setProperty(project, "FV_DIR", fvDir.replaceAll("(\\\\)", "/"));
|
||||
PropertyManager.setProperty(project, "BIN_DIR", binDir.replaceAll("(\\\\)", "/"));
|
||||
PropertyManager.setProperty(project, "DEST_DIR_DEBUG", (destDir + File.separatorChar + "DEBUG").replaceAll("(\\\\)", "/"));
|
||||
PropertyManager.setProperty(project, "DEST_DIR_OUTPUT", (destDir + File.separatorChar + "OUTPUT").replaceAll("(\\\\)", "/"));
|
||||
|
||||
//
|
||||
// Create all directory if necessary
|
||||
|
@ -186,7 +187,7 @@ public class OutputManager {
|
|||
//
|
||||
// Set to property
|
||||
//
|
||||
project.setProperty("BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
|
||||
PropertyManager.setProperty(project, "BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -9,14 +23,46 @@ import java.util.Stack;
|
|||
import org.apache.tools.ant.Project;
|
||||
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 {
|
||||
//
|
||||
// Property table stack, keeps track the history of properties changes
|
||||
//
|
||||
private static Stack<HashMap<String, String>> propertyTableStack = new Stack<HashMap<String, String>>();
|
||||
//
|
||||
// The very original properties
|
||||
//
|
||||
private static HashMap<String, String> orgPropertyTable = null;
|
||||
//
|
||||
// The last changes of properties
|
||||
//
|
||||
private static HashMap<String, String> oldPropertyTable = null;
|
||||
//
|
||||
// The current changes of properties
|
||||
//
|
||||
private static HashMap<String, String> bakPropertyTable = null;
|
||||
//
|
||||
// The Project of tracking properties
|
||||
//
|
||||
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() {
|
||||
//
|
||||
// If this is the first time to save properties changes, keep all properties
|
||||
// of this project as the original property table.
|
||||
//
|
||||
if (orgPropertyTable == null) {
|
||||
Hashtable prjProperties = prj.getProperties();
|
||||
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) {
|
||||
propertyTableStack.push(bakPropertyTable);
|
||||
oldPropertyTable = bakPropertyTable;
|
||||
|
@ -38,25 +88,40 @@ public class PropertyManager {
|
|||
bakPropertyTable = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
/**
|
||||
Restore the properties backup
|
||||
**/
|
||||
public static void restore() {
|
||||
if (bakPropertyTable == null) {
|
||||
//
|
||||
// No properties backup, do nothing
|
||||
//
|
||||
return;
|
||||
}
|
||||
Set keys = bakPropertyTable.keySet();
|
||||
|
||||
//
|
||||
// Re-set properties in backup
|
||||
//
|
||||
Iterator iter = keys.iterator();
|
||||
while (iter.hasNext()) {
|
||||
String name = (String)iter.next();
|
||||
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) {
|
||||
bakPropertyTable = (HashMap<String, String>)propertyTableStack.pop();
|
||||
} else {
|
||||
bakPropertyTable = null;
|
||||
bakPropertyTable = null; // no recovery any more
|
||||
}
|
||||
|
||||
//
|
||||
// Determine last overrided properties for incremental judgement
|
||||
//
|
||||
if (propertyTableStack.size() == 0) {
|
||||
oldPropertyTable = orgPropertyTable;
|
||||
} else {
|
||||
|
@ -64,37 +129,68 @@ public class PropertyManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Set current Project for save() and restore() use.
|
||||
|
||||
@param prj
|
||||
**/
|
||||
public static void setProject(Project 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) {
|
||||
if (prj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Put a copy of given property in history record.
|
||||
//
|
||||
String oldValue = oldPropertyTable.get(name);
|
||||
if (oldValue == null) {
|
||||
oldValue = value;
|
||||
}
|
||||
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";
|
||||
|
||||
// /
|
||||
// / Contains name/value pairs of Surface Area document object. The name is
|
||||
// / always the top level element name.
|
||||
// /
|
||||
//
|
||||
// Contains name/value pairs of Surface Area document object. The name is
|
||||
// always the top level element name.
|
||||
//
|
||||
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>>();
|
||||
|
||||
// /
|
||||
// / prefix of name space
|
||||
// /
|
||||
//
|
||||
// prefix of name space
|
||||
//
|
||||
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;
|
||||
|
||||
// /
|
||||
// / keep the namep declaration for xmlbeans Xpath query
|
||||
// /
|
||||
//
|
||||
// keep the namep declaration for xmlbeans Xpath query
|
||||
//
|
||||
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
|
||||
*
|
||||
|
@ -150,13 +153,12 @@ public class SurfaceAreaQuery {
|
|||
// / /ns:MsaHeader/ns:ModuleType
|
||||
// /
|
||||
private static String normalizeQueryString(String[] exp, String from) {
|
||||
StringBuffer normQueryString = new StringBuffer(4096);
|
||||
normQueryString.setLength(0);
|
||||
|
||||
int i = 0;
|
||||
while (i < exp.length) {
|
||||
String newExp = from + exp[i];
|
||||
Pattern pattern = Pattern.compile("([^/]*)(/|//)([^/]+)");
|
||||
Matcher matcher = pattern.matcher(newExp);
|
||||
Matcher matcher = xPathPattern.matcher(newExp);
|
||||
|
||||
while (matcher.find()) {
|
||||
String starter = newExp.substring(matcher.start(1), matcher
|
||||
|
|
|
@ -652,9 +652,6 @@ Returns:
|
|||
//
|
||||
// Go through the symbols and do replacements
|
||||
//
|
||||
strcpy (Str, TargetFileName);
|
||||
ReplaceSymbols (Str, sizeof (Str));
|
||||
fprintf (mGlobals.OutFptr, "%s : ", Str);
|
||||
strcpy (Str, DependentFile);
|
||||
ReplaceSymbols (Str, sizeof (Str));
|
||||
fprintf (mGlobals.OutFptr, "%s\n", Str);
|
||||
|
|
Loading…
Reference in New Issue