]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
Update GenBuild to append FLAGS from FPD files to the FLAGS defined in tools_def.txt
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / GlobalData.java
index 52ba681f556365b4a1b22e5cdb6b0062b20be754..ceb19d91db7d78c9400a26f819255e43feec0f1b 100644 (file)
@@ -24,6 +24,8 @@ import java.util.Iterator;
 import java.util.List;\r
 import java.util.Map;\r
 import java.util.Set;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
 \r
 import org.apache.xmlbeans.XmlException;\r
 import org.apache.xmlbeans.XmlObject;\r
@@ -162,10 +164,9 @@ public class GlobalData {
         // CONF dir + tools definition file name\r
         //\r
         File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);\r
-        EdkLog.log("Init", "Using tool definition file [" + toolsDefFile.getPath() + "].");\r
+        EdkLog.log("Init", EdkLog.EDK_ALWAYS, "Using tool definition file [" + toolsDefFile.getPath() + "].");\r
         toolsDef = new ToolChainConfig(toolsDefFile);\r
 \r
-\r
         //\r
         // Parse Framework Database\r
         //\r
@@ -299,8 +300,12 @@ public class GlobalData {
             packageId = (PackageIdentification)iter.next();\r
             moduleId.setPackage(packageId);\r
             Spd spd = spdTable.get(packageId);\r
-            if (spd.getModuleFile(moduleId) != null ) {\r
-                break ;\r
+            File tempMsaFile = null;\r
+            if ((tempMsaFile = spd.getModuleFile(moduleId)) != null ) {\r
+                if (tempMsaFile.getParent().equalsIgnoreCase(moduleId.getMsaFile().getParent())) {\r
+                    break ;\r
+                }\r
+                tempMsaFile = null;\r
             }\r
         }\r
         if (packageId == null){\r
@@ -678,7 +683,7 @@ public class GlobalData {
     ///\r
     /// Tool Chain Related, try to refine and put some logic process to ToolChainFactory\r
     ///\r
-    public static ToolChainInfo getToolChainInfo() {\r
+    public synchronized static ToolChainInfo getToolChainInfo() {\r
         if (toolChainInfo == null) {\r
             toolChainInfo = toolsDef.getConfigInfo().intersection(toolChainEnvInfo);\r
             if (toolChainPlatformInfo != null) {\r
@@ -686,8 +691,8 @@ public class GlobalData {
             }\r
             toolChainInfo.addCommands(toolsDef.getConfigInfo().getCommands());\r
             toolChainInfo.normalize();\r
-            EdkLog.log("Init", "Current build tool chain information summary: ");\r
-            EdkLog.log("Init", toolChainInfo + "");\r
+            EdkLog.log("Init", EdkLog.EDK_ALWAYS, "Current build tool chain information summary: ");\r
+            EdkLog.log("Init", EdkLog.EDK_ALWAYS, toolChainInfo + "");\r
         }\r
         return toolChainInfo;\r
     }\r
@@ -723,16 +728,16 @@ public class GlobalData {
         return false;\r
     }\r
 \r
-    public static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException {\r
+    public synchronized static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException {\r
         ToolChainKey toolChainKey = new ToolChainKey(commandDescription);\r
         ToolChainMap toolChainConfig = toolsDef.getConfig();\r
         String setting = null;\r
 \r
+        setting = toolChainConfig.get(toolChainKey);\r
+        if (setting == null) {\r
+          setting = "";\r
+        }\r
         if (!commandDescription[ToolChainElement.ATTRIBUTE.value].equals(ToolChainAttribute.FLAGS.toString())) {\r
-            setting = toolChainConfig.get(toolChainKey);\r
-            if (setting == null) {\r
-                setting = "";\r
-            }\r
             return setting;\r
         }\r
 \r
@@ -743,7 +748,98 @@ public class GlobalData {
         ToolChainMap option = moduleToolChainOption.get(fpdModuleId);\r
         ToolChainKey toolChainFamilyKey = null;\r
 \r
-        if ((option == null) || (option != null && (setting = option.get(toolChainKey)) == null)) {\r
+        if (option != null && option.get(toolChainKey) != null)  \r
+        {\r
+          String str = option.get(toolChainKey);\r
+\r
+          Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");\r
+          Matcher matcher = myPattern.matcher(str + " ");\r
+          while (matcher.find()) \r
+          {\r
+            setting = setting + " " + str.substring(matcher.start(1), matcher.end(1));\r
+          }\r
+        } \r
+//        else \r
+//        {\r
+          if (toolChainFamilyKey == null) \r
+          {\r
+            toolChainFamilyKey = new ToolChainKey(commandDescription);\r
+            toolChainFamilyKey.setKey(ToolChainAttribute.FAMILY.toString(), ToolChainElement.ATTRIBUTE.value);\r
+            String family = toolChainConfig.get(toolChainFamilyKey);\r
+            toolChainFamilyKey.setKey(family, ToolChainElement.TOOLCHAIN.value);\r
+            toolChainFamilyKey.setKey(ToolChainAttribute.FLAGS.toString(), ToolChainElement.ATTRIBUTE.value);\r
+          }\r
+\r
+          option = moduleToolChainFamilyOption.get(fpdModuleId);\r
+          if (option != null && option.get(toolChainFamilyKey) != null) \r
+          {\r
+            String str = option.get(toolChainFamilyKey);\r
+\r
+            Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");\r
+            Matcher matcher = myPattern.matcher(str + " ");\r
+            while (matcher.find()) \r
+            {\r
+              setting = setting + " " + str.substring(matcher.start(1), matcher.end(1));\r
+            }\r
+          }\r
+//        }\r
+\r
+        //\r
+        // get platform options, if any\r
+        //\r
+        // tool tag first\r
+//        if (platformToolChainOption != null && platformToolChainOption.get(toolChainKey) != null) \r
+        if (platformToolChainOption.get(toolChainKey) != null) \r
+        {\r
+          String str = platformToolChainOption.get(toolChainKey);\r
+\r
+          Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");\r
+          Matcher matcher = myPattern.matcher(str + " ");\r
+          while (matcher.find()) \r
+          {\r
+            setting = setting + " " + str.substring(matcher.start(1), matcher.end(1));\r
+          }\r
+        } \r
+//        else \r
+//        {\r
+          // then tool chain family\r
+          if (toolChainFamilyKey == null) \r
+          {\r
+            toolChainFamilyKey = new ToolChainKey(commandDescription);\r
+            toolChainFamilyKey.setKey(ToolChainAttribute.FAMILY.toString(), ToolChainElement.ATTRIBUTE.value);\r
+            String family = toolChainConfig.get(toolChainFamilyKey);\r
+            toolChainFamilyKey.setKey(family, ToolChainElement.TOOLCHAIN.value);\r
+            toolChainFamilyKey.setKey(ToolChainAttribute.FLAGS.toString(), ToolChainElement.ATTRIBUTE.value);\r
+          }\r
+\r
+//          if (platformToolChainFamilyOption != null && platformToolChainFamilyOption.get(toolChainFamilyKey) != null) \r
+          if (platformToolChainFamilyOption.get(toolChainFamilyKey) != null) \r
+          {\r
+            String str = platformToolChainFamilyOption.get(toolChainFamilyKey);\r
+\r
+            setting = setting + " " + str;\r
+\r
+//            Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");\r
+//            Matcher matcher = myPattern.matcher(str + " ");\r
+//            while (matcher.find()) \r
+//            {\r
+//              setting = setting + " " + str.substring(matcher.start(1), matcher.end(1));\r
+//            }\r
+          }\r
+//        }\r
+\r
+        return setting;\r
+\r
+/*\r
+        //\r
+        // get module specific options, if any\r
+        //\r
+        // tool tag first\r
+        ToolChainMap option = moduleToolChainOption.get(fpdModuleId);\r
+        ToolChainKey toolChainFamilyKey = null;\r
+        \r
+        if ((option == null) || (option != null && (setting = option.get(toolChainKey)) == null)) \r
+        {\r
             //\r
             // then tool chain family\r
             //\r
@@ -783,6 +879,7 @@ public class GlobalData {
         }\r
 \r
         return setting;\r
+*/\r
     }\r
 \r
     public static void setToolChainEnvInfo(ToolChainInfo envInfo) {\r