]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
- Fixed EDKT146; The override warning message has been reduced to almost none.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / GenBuildTask.java
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.PropertyManager;\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
-        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
-            getProject().setProperty(item.getName(), item.getValue());\r
+            PropertyManager.setProperty(item.getName(), item.getValue());\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
-            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
@@ -234,7 +236,7 @@ public class GenBuildTask extends Ant {
 \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
@@ -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
-                return;\r
+                break;\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
-                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
@@ -275,7 +277,7 @@ public class GenBuildTask extends Ant {
                     // 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
@@ -307,7 +309,7 @@ public class GenBuildTask extends Ant {
             }\r
         }\r
         \r
-        popProperties();\r
+        PropertyManager.restore();\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
-        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
@@ -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
-        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
-        getProject().setProperty("MODULE", moduleId.getName());\r
+        PropertyManager.setProperty("MODULE", moduleId.getName());\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
-            getProject().setProperty("BASE_NAME", baseName);\r
+            PropertyManager.setProperty("BASE_NAME", baseName);\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
@@ -415,18 +417,18 @@ public class GenBuildTask extends Ant {
                 break ;\r
             }\r
         }\r
-        getProject().setProperty("SUBSYSTEM", subsystem);\r
+        PropertyManager.setProperty("SUBSYSTEM", subsystem);\r
 \r
         //\r
         // ENTRYPOINT\r
         //\r
         if (arch.equalsIgnoreCase("EBC")) {\r
-            getProject().setProperty("ENTRYPOINT", "EfiStart");\r
+            PropertyManager.setProperty("ENTRYPOINT", "EfiStart");\r
         } else {\r
-            getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");\r
+            PropertyManager.setProperty("ENTRYPOINT", "_ModuleEntryPoint");\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
@@ -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
-            getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));\r
+            PropertyManager.setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));\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
-            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
@@ -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
-                getProject().setProperty(cmd[m] + "_EXT", extName);\r
+                PropertyManager.setProperty(cmd[m] + "_EXT", extName);\r
             } else {\r
-                getProject().setProperty(cmd[m] + "_EXT", "");\r
+                PropertyManager.setProperty(cmd[m] + "_EXT", "");\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
-                getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily);\r
+                PropertyManager.setProperty(cmd[m] + "_FAMILY", toolChainFamily);\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
-                getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));\r
+                PropertyManager.setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));\r
             } else {\r
-                getProject().setProperty(cmd[m] + "_SPATH", "");\r
+                PropertyManager.setProperty(cmd[m] + "_SPATH", "");\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
-                getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));\r
+                PropertyManager.setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));\r
             } else {\r
-                getProject().setProperty(cmd[m] + "_DPATH", "");\r
+                PropertyManager.setProperty(cmd[m] + "_DPATH", "");\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
-        getProject().setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/"));\r
+        PropertyManager.setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/"));\r
 \r
         //\r
         // if it is CUSTOM_BUILD\r
@@ -692,20 +694,6 @@ public class GenBuildTask extends Ant {
         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