]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Fix a bug for ExpandMacros to support mixed case ENV var
authorYonghong Zhu <yonghong.zhu@intel.com>
Fri, 28 Oct 2016 01:24:52 +0000 (09:24 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 2 Nov 2016 01:49:04 +0000 (09:49 +0800)
os.environ contains all environment variables uppercase on Windows which
cause the key in the self.MacroDictionary is uppercase, but the real
variable name maybe mixed case, eg:WINSDK81x86, then we can't find the
variable in the self.MacroDictionary.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/Common/ToolDefClassObject.py

index 5dd505c9b9fa992423bef78664b5028663554f6e..c65cb8a36d5af129fb2b9a70514da90ce574ab4f 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to define each component of tools_def.txt file\r
 #\r
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -236,13 +236,16 @@ class ToolDefClassObject(object):
     # @retval Value:  The string which has been replaced with real value\r
     #\r
     def ExpandMacros(self, Value):\r
+        # os.environ contains all environment variables uppercase on Windows which cause the key in the self.MacroDictionary is uppercase, but Ref may not\r
         EnvReference = gEnvRefPattern.findall(Value)\r
         for Ref in EnvReference:\r
-            if Ref not in self.MacroDictionary:\r
+            if Ref not in self.MacroDictionary and Ref.upper() not in self.MacroDictionary:\r
                 Value = Value.replace(Ref, "")\r
             else:\r
-                Value = Value.replace(Ref, self.MacroDictionary[Ref])\r
\r
+                if Ref in self.MacroDictionary:\r
+                    Value = Value.replace(Ref, self.MacroDictionary[Ref])\r
+                else:\r
+                    Value = Value.replace(Ref, self.MacroDictionary[Ref.upper()])\r
 \r
         MacroReference = gMacroRefPattern.findall(Value)\r
         for Ref in MacroReference:\r