From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E24A71A1DEF for ; Thu, 27 Oct 2016 21:42:53 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP; 27 Oct 2016 21:42:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,407,1473145200"; d="scan'208";a="1077037795" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.144]) by fmsmga002.fm.intel.com with ESMTP; 27 Oct 2016 21:42:52 -0700 From: Yonghong Zhu To: edk2-devel@lists.01.org Cc: Liming Gao Date: Fri, 28 Oct 2016 12:42:46 +0800 Message-Id: <1477629766-39008-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [Patch] BaseTools: Fix a bug for ExpandMacros to support mixed case ENV var X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2016 04:42:54 -0000 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 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/Common/ToolDefClassObject.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py index 5dd505c..a71c616 100644 --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py @@ -234,17 +234,20 @@ class ToolDefClassObject(object): # @param Value: The string with unreplaced macros # # @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: if Ref not in self.MacroDictionary: return False, Ref -- 2.6.1.windows.1