From: jwang36 Date: Fri, 18 Aug 2006 10:25:20 +0000 (+0000) Subject: - Fixed EDKT146; The override warning message has been reduced to almost none. X-Git-Tag: edk2-stable201903~24549 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=1fa1cb752a62f624ff8e7d81c89b89b56c44dc13 - 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 --- diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java index 874e08ce2f..5b76176a64 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java @@ -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 lineSet = new HashSet(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 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. diff --git a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java index b8d92ed33e..dc12f6e23e 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java @@ -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)); } } } diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java index 117e40f5e0..8e7ee3b941 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java @@ -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 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 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 @@ -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; } diff --git a/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java index df1af186bf..059b8ee765 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java +++ b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java @@ -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("(\\\\)", "/")); } /** diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java b/Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java index 3c146f0246..5022f932bf 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java @@ -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 diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/PropertyManager.java b/Tools/Source/GenBuild/org/tianocore/build/global/PropertyManager.java index 50a2ead4aa..1bd7cf97da 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/PropertyManager.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/PropertyManager.java @@ -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> propertyTableStack = new Stack>(); + // + // The very original properties + // private static HashMap orgPropertyTable = null; + // + // The last changes of properties + // private static HashMap oldPropertyTable = null; + // + // The current changes of properties + // private static HashMap 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(); @@ -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(); } + /** + 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)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); - - if (oldPropertyTable == null || bakPropertyTable == null) { - return; - } - - String oldValue = oldPropertyTable.get(name); - if (oldValue == null) { - oldValue = value; - } - bakPropertyTable.put(name, oldValue); } + /** + 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; + 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); } } diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java index 1086bb8d49..4e2a0704c0 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java @@ -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 map = null; - // / - // / mapStack is used to do nested query - // / + // + // mapStack is used to do nested query + // private static Stack> mapStack = new Stack>(); - // / - // / 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 diff --git a/Tools/Source/TianoTools/MakeDeps/MakeDeps.c b/Tools/Source/TianoTools/MakeDeps/MakeDeps.c index e4206251e6..62964d0037 100755 --- a/Tools/Source/TianoTools/MakeDeps/MakeDeps.c +++ b/Tools/Source/TianoTools/MakeDeps/MakeDeps.c @@ -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);