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.88; helo=mga01.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 28C7B21B02822 for ; Thu, 17 Jan 2019 07:35:10 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jan 2019 07:35:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,489,1539673200"; d="scan'208";a="128587082" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.149]) by orsmga001.jf.intel.com with ESMTP; 17 Jan 2019 07:35:08 -0800 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao Date: Thu, 17 Jan 2019 07:35:04 -0800 Message-Id: <835f1263c2dcbe6ed697aed2565483a6e220d0fe.1547511539.git.jaben.carsey@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [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: Thu, 17 Jan 2019 15:35:10 -0000 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/Python/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 = None): return P.Guids[CName] return None -## 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 packages -# -def ProtocolValue(CName, PackageList, Inffile = None): - for P in PackageList: - ProtocolKeys = P.Protocols.keys() - if Inffile and P._PrivateProtocols: - if not Inffile.startswith(P.MetaFile.Dir): - ProtocolKeys = [x for x in P.Protocols if x not in P._PrivateProtocols] - 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 packages -# -def PpiValue(CName, PackageList, Inffile = None): - for P in PackageList: - PpiKeys = P.Ppis.keys() - if Inffile and P._PrivatePpis: - if not Inffile.startswith(P.MetaFile.Dir): - PpiKeys = [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 template diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/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 OrderedDict from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject +## 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 packages +# +def _ProtocolValue(CName, PackageList, Inffile = None): + for P in PackageList: + ProtocolKeys = P.Protocols.keys() + if Inffile and P._PrivateProtocols: + if not Inffile.startswith(P.MetaFile.Dir): + ProtocolKeys = [x for x in P.Protocols if x not in P._PrivateProtocols] + 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 packages +# +def _PpiValue(CName, PackageList, Inffile = None): + for P in PackageList: + PpiKeys = P.Ppis.keys() + if Inffile and P._PrivatePpis: + if not Inffile.startswith(P.MetaFile.Dir): + PpiKeys = [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 retrieve information stored in database and convert them @@ -645,7 +683,7 @@ class InfBuildData(ModuleBuildClassObject): RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform] for Record in RecordList: CName = Record[0] - Value = ProtocolValue(CName, self.Packages, self.MetaFile.Path) + Value = _ProtocolValue(CName, self.Packages, self.MetaFile.Path) if Value is None: PackageList = "\n\t".join(str(P) for P in self.Packages) EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, @@ -669,7 +707,7 @@ class InfBuildData(ModuleBuildClassObject): RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform] for Record in RecordList: CName = Record[0] - Value = PpiValue(CName, self.Packages, self.MetaFile.Path) + Value = _PpiValue(CName, self.Packages, self.MetaFile.Path) if Value is None: PackageList = "\n\t".join(str(P) for P in self.Packages) EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, @@ -875,9 +913,9 @@ class InfBuildData(ModuleBuildClassObject): Value = Token else: # get the GUID value now - Value = ProtocolValue(Token, self.Packages, self.MetaFile.Path) + Value = _ProtocolValue(Token, self.Packages, self.MetaFile.Path) if Value is None: - Value = PpiValue(Token, self.Packages, self.MetaFile.Path) + Value = _PpiValue(Token, self.Packages, self.MetaFile.Path) if Value is None: Value = GuidValue(Token, self.Packages, self.MetaFile.Path) -- 2.16.2.windows.1