From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 422F7211B85CE for ; Thu, 17 Jan 2019 16:17:50 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jan 2019 16:17:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,489,1539673200"; d="scan'208";a="135607411" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga002.fm.intel.com with ESMTP; 17 Jan 2019 16:17:49 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 17 Jan 2019 16:17:49 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 17 Jan 2019 16:17:49 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.196]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.44]) with mapi id 14.03.0415.000; Fri, 18 Jan 2019 08:17:46 +0800 From: "Feng, Bob C" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [Patch V2 2/5] BaseTools/Workspace/InfBuildData: move functions Thread-Index: AQHUrnpLgOiTDEu4q0aMKVajH6u78KW0KYCQ Date: Fri, 18 Jan 2019 00:17:46 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D16005DBBC@SHSMSX101.ccr.corp.intel.com> References: <835f1263c2dcbe6ed697aed2565483a6e220d0fe.1547511539.git.jaben.carsey@intel.com> In-Reply-To: <835f1263c2dcbe6ed697aed2565483a6e220d0fe.1547511539.git.jaben.carsey@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch V2 2/5] BaseTools/Workspace/InfBuildData: move functions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2019 00:17:50 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: Carsey, Jaben=20 Sent: Thursday, January 17, 2019 11:35 PM To: edk2-devel@lists.01.org Cc: Feng, Bob C ; Gao, Liming Subject: [Patch V2 2/5] BaseTools/Workspace/InfBuildData: move functions Move ProtocolValue and PpiValue from Common.Misc to this file. There were no other consumers of these 2 functions. Cc: Bob Feng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Common/Misc.py | 38 ---------------- BaseTools/Source/Python/Workspace/InfBuildData.py | 46 ++++++++++++++++++-= - 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index 43e016febcbb..25d8f9807fa3 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -611,44 +611,6 @@ def GuidValue(CName, PackageList, Inffile =3D None): return P.Guids[CName] return None =20 -## Get Protocol value from given packages -# -# @param CName The CName of the GUID -# @param PackageList List of packages looking-up in -# @param Inffile The driver file -# -# @retval GuidValue if the CName is found in any given package -# @retval None if the CName is not found in all given package= s -# -def ProtocolValue(CName, PackageList, Inffile =3D None): - for P in PackageList: - ProtocolKeys =3D P.Protocols.keys() - if Inffile and P._PrivateProtocols: - if not Inffile.startswith(P.MetaFile.Dir): - ProtocolKeys =3D [x for x in P.Protocols if x not in P._Pr= ivateProtocols] - if CName in ProtocolKeys: - return P.Protocols[CName] - return None - -## Get PPI value from given packages -# -# @param CName The CName of the GUID -# @param PackageList List of packages looking-up in -# @param Inffile The driver file -# -# @retval GuidValue if the CName is found in any given package -# @retval None if the CName is not found in all given package= s -# -def PpiValue(CName, PackageList, Inffile =3D None): - for P in PackageList: - PpiKeys =3D P.Ppis.keys() - if Inffile and P._PrivatePpis: - if not Inffile.startswith(P.MetaFile.Dir): - PpiKeys =3D [x for x in P.Ppis if x not in P._PrivatePpis] - if CName in PpiKeys: - return P.Ppis[CName] - return None - ## A string template class # # This class implements a template for string replacement. A string templ= ate diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTo= ols/Source/Python/Workspace/InfBuildData.py index 99bbecfd1f87..351f596d76b4 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -21,6 +21,44 @@ from .MetaFileParser import * from collections import O= rderedDict from Workspace.BuildClassObject import ModuleBuildClassObject, = LibraryClassObject, PcdClassObject =20 +## Get Protocol value from given packages # +# @param CName The CName of the GUID +# @param PackageList List of packages looking-up in +# @param Inffile The driver file +# +# @retval GuidValue if the CName is found in any given package +# @retval None if the CName is not found in all given package= s +# +def _ProtocolValue(CName, PackageList, Inffile =3D None): + for P in PackageList: + ProtocolKeys =3D P.Protocols.keys() + if Inffile and P._PrivateProtocols: + if not Inffile.startswith(P.MetaFile.Dir): + ProtocolKeys =3D [x for x in P.Protocols if x not in P._Pr= ivateProtocols] + if CName in ProtocolKeys: + return P.Protocols[CName] + return None + +## Get PPI value from given packages +# +# @param CName The CName of the GUID +# @param PackageList List of packages looking-up in +# @param Inffile The driver file +# +# @retval GuidValue if the CName is found in any given package +# @retval None if the CName is not found in all given package= s +# +def _PpiValue(CName, PackageList, Inffile =3D None): + for P in PackageList: + PpiKeys =3D P.Ppis.keys() + if Inffile and P._PrivatePpis: + if not Inffile.startswith(P.MetaFile.Dir): + PpiKeys =3D [x for x in P.Ppis if x not in P._PrivatePpis] + if CName in PpiKeys: + return P.Ppis[CName] + return None + ## Module build information from INF file # # This class is used to ret= rieve information stored in database and convert them @@ -645,7 +683,7 @@ c= lass InfBuildData(ModuleBuildClassObject): RecordList =3D self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self.= _Platform] for Record in RecordList: CName =3D Record[0] - Value =3D ProtocolValue(CName, self.Packages, self.MetaFile.Pa= th) + Value =3D _ProtocolValue(CName, self.Packages,=20 + self.MetaFile.Path) if Value is None: PackageList =3D "\n\t".join(str(P) for P in self.Packages) EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, @@ -669,7= +707,7 @@ class InfBuildData(ModuleBuildClassObject): RecordList =3D self._RawData[MODEL_EFI_PPI, self._Arch, self._Plat= form] for Record in RecordList: CName =3D Record[0] - Value =3D PpiValue(CName, self.Packages, self.MetaFile.Path) + Value =3D _PpiValue(CName, self.Packages, self.MetaFile.Path) if Value is None: PackageList =3D "\n\t".join(str(P) for P in self.Packages) EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, @@ -875,9= +913,9 @@ class InfBuildData(ModuleBuildClassObject): Value =3D Token else: # get the GUID value now - Value =3D ProtocolValue(Token, self.Packages, self= .MetaFile.Path) + Value =3D _ProtocolValue(Token, self.Packages,=20 + self.MetaFile.Path) if Value is None: - Value =3D PpiValue(Token, self.Packages, self.= MetaFile.Path) + Value =3D _PpiValue(Token, self.Packages,=20 + self.MetaFile.Path) if Value is None: Value =3D GuidValue(Token, self.Packages, = self.MetaFile.Path) =20 -- 2.16.2.windows.1