diff options
author | Yonghong Zhu <yonghong.zhu@intel.com> | 2016-10-28 09:24:52 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2016-11-02 09:49:04 +0800 |
commit | 18ca2fec97010e8a79407ec092539218c04ee1c5 (patch) | |
tree | fadd57225c3f95bd6c8aea61cca187959033e239 | |
parent | 2a6402d490a2da818b7650ffe0330d3020e5b020 (diff) | |
download | edk2-platforms-18ca2fec97010e8a79407ec092539218c04ee1c5.tar.xz |
BaseTools: Fix a bug for ExpandMacros to support mixed case ENV var
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>
-rw-r--r-- | BaseTools/Source/Python/Common/ToolDefClassObject.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py index 5dd505c9b9..c65cb8a36d 100644 --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py @@ -1,7 +1,7 @@ ## @file
# This file is used to define each component of tools_def.txt file
#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -236,13 +236,16 @@ class ToolDefClassObject(object): # @retval Value: The string which has been replaced with real value
#
def ExpandMacros(self, Value):
+ # os.environ contains all environment variables uppercase on Windows which cause the key in the self.MacroDictionary is uppercase, but Ref may not
EnvReference = gEnvRefPattern.findall(Value)
for Ref in EnvReference:
- if Ref not in self.MacroDictionary:
+ if Ref not in self.MacroDictionary and Ref.upper() not in self.MacroDictionary:
Value = Value.replace(Ref, "")
else:
- Value = Value.replace(Ref, self.MacroDictionary[Ref])
-
+ if Ref in self.MacroDictionary:
+ Value = Value.replace(Ref, self.MacroDictionary[Ref])
+ else:
+ Value = Value.replace(Ref, self.MacroDictionary[Ref.upper()])
MacroReference = gMacroRefPattern.findall(Value)
for Ref in MacroReference:
|