]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools: Fixed Build Option override bugs.
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / AutoGen.py
index 0e7482a87a832033c62dd06b0643d226505b7ecb..ca7d5abb623efe4301fdfdde77af0d0f67febf6b 100644 (file)
@@ -1963,7 +1963,8 @@ class PlatformAutoGen(AutoGen):
             # Key[0] -- tool family\r
             # Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE\r
             #\r
-            if Key[0] == self.BuildRuleFamily :\r
+            if (Key[0] == self.BuildRuleFamily and\r
+                (ModuleStyle == None or len(Key) < 3 or (len(Key) > 2 and Key[2] == ModuleStyle))):\r
                 Target, ToolChain, Arch, CommandType, Attr = Key[1].split('_')\r
                 if Target == self.BuildTarget or Target == "*":\r
                     if ToolChain == self.ToolChain or ToolChain == "*":\r
@@ -1999,7 +2000,7 @@ class PlatformAutoGen(AutoGen):
                                             if Options.get((self.BuildRuleFamily, NowKey)) != None: \r
                                                 Options.pop((self.BuildRuleFamily, NowKey))\r
                                                            \r
-        \r
+        OverrideOpt = set()\r
         for Key in Options:\r
             if ModuleStyle != None and len (Key) > 2:\r
                 # Check Module style is EDK or EDKII.\r
@@ -2025,7 +2026,9 @@ class PlatformAutoGen(AutoGen):
                     if Arch == "*" or Arch == self.Arch:\r
                         if Tool not in BuildOptions:\r
                             BuildOptions[Tool] = {}\r
-                        if Attr != "FLAGS" or Attr not in BuildOptions[Tool]:\r
+                        if Options[Key].startswith('='):\r
+                            OverrideOpt.add((Tool, Attr))\r
+                        if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or (Tool, Attr) in OverrideOpt:\r
                             BuildOptions[Tool][Attr] = Options[Key]\r
                         else:\r
                             # append options for the same tool\r
@@ -2033,7 +2036,8 @@ class PlatformAutoGen(AutoGen):
         # Build Option Family has been checked, which need't to be checked again for family.\r
         if FamilyMatch or FamilyIsNull:\r
             return BuildOptions\r
-        \r
+\r
+        OverrideOpt = set()\r
         for Key in Options:\r
             if ModuleStyle != None and len (Key) > 2:\r
                 # Check Module style is EDK or EDKII.\r
@@ -2057,7 +2061,9 @@ class PlatformAutoGen(AutoGen):
                     if Arch == "*" or Arch == self.Arch:\r
                         if Tool not in BuildOptions:\r
                             BuildOptions[Tool] = {}\r
-                        if Attr != "FLAGS" or Attr not in BuildOptions[Tool]:\r
+                        if Options[Key].startswith('='):\r
+                            OverrideOpt.add((Tool, Attr))\r
+                        if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or (Tool, Attr) in OverrideOpt:\r
                             BuildOptions[Tool][Attr] = Options[Key]\r
                         else:\r
                             # append options for the same tool\r
@@ -2097,6 +2103,7 @@ class PlatformAutoGen(AutoGen):
                        PlatformModuleOptions.keys() + ModuleTypeOptions.keys() +\r
                        self.ToolDefinition.keys())\r
         BuildOptions = {}\r
+        OverrideTool = set()\r
         for Tool in AllTools:\r
             if Tool not in BuildOptions:\r
                 BuildOptions[Tool] = {}\r
@@ -2115,8 +2122,9 @@ class PlatformAutoGen(AutoGen):
                         BuildOptions[Tool][Attr] = ""\r
                     # check if override is indicated\r
                     if Value.startswith('='):\r
+                        OverrideTool.add((Tool, Attr))\r
                         BuildOptions[Tool][Attr] = Value[1:]\r
-                    else:\r
+                    elif (Tool, Attr) not in OverrideTool:\r
                         BuildOptions[Tool][Attr] += " " + Value\r
         if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag != None:\r
             #\r