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.151; helo=mga17.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 92CC221962301 for ; Wed, 16 Jan 2019 23:47:00 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 23:46:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,488,1539673200"; d="scan'208";a="110562449" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga008.jf.intel.com with ESMTP; 16 Jan 2019 23:46:59 -0800 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 16 Jan 2019 23:46:59 -0800 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 16 Jan 2019 23:46:59 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.196]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.85]) with mapi id 14.03.0415.000; Thu, 17 Jan 2019 15:46:56 +0800 From: "Feng, Bob C" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [Patch v1 2/5] BaseTools/Workspace/InfBuildData: move functions Thread-Index: AQHUqRPh/VYnZnjY8EC+RNYlTFzMPqWzH3HA Date: Thu, 17 Jan 2019 07:46:55 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D16005CF90@SHSMSX101.ccr.corp.intel.com> References: <835f1263c2dcbe6ed697aed2565483a6e220d0fe.1547145461.git.jaben.carsey@intel.com> In-Reply-To: <835f1263c2dcbe6ed697aed2565483a6e220d0fe.1547145461.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 v1 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: Thu, 17 Jan 2019 07:47:00 -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: Friday, January 11, 2019 2:40 AM To: edk2-devel@lists.01.org Cc: Feng, Bob C ; Gao, Liming Subject: [Patch v1 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