]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/GenBuild/org/tianocore/build/global/GlobalData.java
a) Cleaned tools_def.template
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / global / GlobalData.java
index ceb19d91db7d78c9400a26f819255e43feec0f1b..9138036c7885b5742fd6929de0356bd4a2693167 100644 (file)
@@ -132,6 +132,7 @@ public class GlobalData {
     private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainOption = new HashMap<FpdModuleIdentification, ToolChainMap>();\r
     private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainFamilyOption = new HashMap<FpdModuleIdentification, ToolChainMap>();\r
 \r
+    private static Pattern flagPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");\r
     /**\r
       Parse framework database (DB) and all SPD files listed in DB to initialize\r
       the environment for next build. This method will only be executed only once\r
@@ -733,153 +734,71 @@ public class GlobalData {
         ToolChainMap toolChainConfig = toolsDef.getConfig();\r
         String setting = null;\r
 \r
+        //\r
+        // Default in tools_def.txt\r
+        // \r
         setting = toolChainConfig.get(toolChainKey);\r
         if (setting == null) {\r
-          setting = "";\r
+            setting = "";\r
         }\r
         if (!commandDescription[ToolChainElement.ATTRIBUTE.value].equals(ToolChainAttribute.FLAGS.toString())) {\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.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
+        // tool's option can be in .fpd and/or .msa file\r
+        //\r
+        String optionString;\r
+        ToolChainMap option = null;\r
+        ToolChainKey toolChainFamilyKey = new ToolChainKey(commandDescription);\r
 \r
-        return setting;\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
         //\r
-        // get module specific options, if any\r
+        // Platform's tool chain family option\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
-            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
-            option = moduleToolChainFamilyOption.get(fpdModuleId);\r
-            if (option != null) {\r
-                setting = option.get(toolChainFamilyKey);\r
-            }\r
+        optionString = platformToolChainFamilyOption.get(toolChainFamilyKey);\r
+        if (optionString != null) {\r
+            setting += (" " + optionString);\r
         }\r
 \r
         //\r
-        // get platform options, if any\r
+        // Platform's tool chain tag option\r
         //\r
-        if (setting == null) {\r
-            // tool tag first\r
-            if (platformToolChainOption == null || (setting = platformToolChainOption.get(toolChainKey)) == null) {\r
-                // then tool chain family\r
-                if (toolChainFamilyKey == null) {\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
+        optionString = platformToolChainOption.get(toolChainKey);\r
+        if (optionString != null) {\r
+            Matcher matcher = flagPattern.matcher(optionString + " ");\r
+            while (matcher.find()) {\r
+                setting += (" " + optionString.substring(matcher.start(1), matcher.end(1)));\r
+            }\r
+        }\r
 \r
-                setting = platformToolChainFamilyOption.get(toolChainFamilyKey);\r
+        //\r
+        // Module's tool chain family option\r
+        //\r
+        option = moduleToolChainFamilyOption.get(fpdModuleId);\r
+        if (option != null && (optionString = option.get(toolChainFamilyKey)) != null) {\r
+            Matcher matcher = flagPattern.matcher(optionString + " ");\r
+            while (matcher.find()) {\r
+                setting += (" " + optionString.substring(matcher.start(1), matcher.end(1)));\r
             }\r
         }\r
 \r
-        if (setting == null) {\r
-            setting = "";\r
+        //\r
+        // Module's tool chain tag option\r
+        //\r
+        option = moduleToolChainOption.get(fpdModuleId);\r
+        if (option != null && (optionString = option.get(toolChainKey)) != null) {\r
+            Matcher matcher = flagPattern.matcher(optionString + " ");\r
+            while (matcher.find()) {\r
+                setting += (" " + optionString.substring(matcher.start(1), matcher.end(1)));\r
+            }\r
         }\r
 \r
         return setting;\r
-*/\r
     }\r
 \r
     public static void setToolChainEnvInfo(ToolChainInfo envInfo) {\r