]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: optimize buildoptions loop
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>
Thu, 5 Apr 2018 23:13:57 +0000 (07:13 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Tue, 10 Apr 2018 02:05:14 +0000 (10:05 +0800)
change a dict to a double defaultdict to prevent needing to seed innter values.
move "Value" determination under a conditional continue statement

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/AutoGen/AutoGen.py

index 562f3f63fc6054cb6e1a533841e3c5ffbdc0bd0c..9c976c37278c649744b1ec796dd3269a46174f3a 100644 (file)
@@ -2686,40 +2686,31 @@ class PlatformAutoGen(AutoGen):
         AllTools = set(ModuleOptions.keys() + PlatformOptions.keys() +\r
                        PlatformModuleOptions.keys() + ModuleTypeOptions.keys() +\r
                        self.ToolDefinition.keys())\r
-        BuildOptions = {}\r
+        BuildOptions = defaultdict(lambda: defaultdict(str))\r
         for Tool in AllTools:\r
-            if Tool not in BuildOptions:\r
-                BuildOptions[Tool] = {}\r
-\r
             for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions, ModuleTypeOptions, PlatformModuleOptions]:\r
                 if Tool not in Options:\r
                     continue\r
                 for Attr in Options[Tool]:\r
-                    Value = Options[Tool][Attr]\r
                     #\r
                     # Do not generate it in Makefile\r
                     #\r
                     if Attr == TAB_TOD_DEFINES_BUILDRULEORDER:\r
                         continue\r
-                    if Attr not in BuildOptions[Tool]:\r
-                        BuildOptions[Tool][Attr] = ""\r
+                    Value = Options[Tool][Attr]\r
                     # check if override is indicated\r
                     if Value.startswith('='):\r
-                        ToolPath = Value[1:]\r
-                        ToolPath = mws.handleWsMacro(ToolPath)\r
-                        BuildOptions[Tool][Attr] = ToolPath\r
+                        BuildOptions[Tool][Attr] = mws.handleWsMacro(Value[1:])\r
                     else:\r
-                        Value = mws.handleWsMacro(Value)\r
                         if Attr != 'PATH':\r
-                            BuildOptions[Tool][Attr] += " " + Value\r
+                            BuildOptions[Tool][Attr] += " " + mws.handleWsMacro(Value)\r
                         else:\r
-                            BuildOptions[Tool][Attr] = Value\r
+                            BuildOptions[Tool][Attr] = mws.handleWsMacro(Value)\r
+\r
         if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag is not None:\r
             #\r
             # Override UNI flag only for EDK module.\r
             #\r
-            if 'BUILD' not in BuildOptions:\r
-                BuildOptions['BUILD'] = {}\r
             BuildOptions['BUILD']['FLAGS'] = self.Workspace.UniFlag\r
         return BuildOptions, BuildRuleOrder\r
 \r