From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 B430081CE0 for ; Tue, 1 Nov 2016 02:38:59 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP; 01 Nov 2016 02:39:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,579,1473145200"; d="scan'208";a="896363085" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga003.jf.intel.com with ESMTP; 01 Nov 2016 02:39:01 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 1 Nov 2016 02:38:59 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 1 Nov 2016 02:38:59 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.206]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.96]) with mapi id 14.03.0248.002; Tue, 1 Nov 2016 17:38:56 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch] BaseTools: Fix a bug for ExpandMacros to support mixed case ENV var Thread-Index: AQHSMNXE9WiXz8wXfkCeKFiQYPwO8qDD5cjQ Date: Tue, 1 Nov 2016 09:38:55 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14B49CC17@shsmsx102.ccr.corp.intel.com> References: <1477629766-39008-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1477629766-39008-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Tue, 01 Nov 2016 09:38:59 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Yonghong Zhu > Sent: Friday, October 28, 2016 12:43 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [edk2] [Patch] BaseTools: Fix a bug for ExpandMacros to support > mixed case ENV var >=20 > 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. >=20 > 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(-) >=20 > 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 Win= dows > which cause the key in the self.MacroDictionary is uppercase, but Ref may > not > EnvReference =3D 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 =3D Value.replace(Ref, "") > else: > - Value =3D Value.replace(Ref, self.MacroDictionary[Ref]) > - > + if Ref in self.MacroDictionary: > + Value =3D Value.replace(Ref, self.MacroDictionary[Re= f]) > + else: > + Value =3D Value.replace(Ref, self.MacroDictionary[Re= f.upper()]) >=20 > MacroReference =3D gMacroRefPattern.findall(Value) > for Ref in MacroReference: > if Ref not in self.MacroDictionary: > return False, Ref > -- > 2.6.1.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel