]> git.proxmox.com Git - mirror_edk2.git/commitdiff
- Fixed EDKT146; The override warning message has been reduced to almost none.
authorjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 18 Aug 2006 10:25:20 +0000 (10:25 +0000)
committerjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 18 Aug 2006 10:25:20 +0000 (10:25 +0000)
- 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

Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java
Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java
Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java
Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java
Tools/Source/GenBuild/org/tianocore/build/global/PropertyManager.java
Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
Tools/Source/TianoTools/MakeDeps/MakeDeps.c

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