From nobody Mon Dec 23 13:45:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1517474275216899.8086261033767; Thu, 1 Feb 2018 00:37:55 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BED8421E0BA17; Thu, 1 Feb 2018 00:31:43 -0800 (PST) Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (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 2E20F21E0BA09 for ; Thu, 1 Feb 2018 00:31:41 -0800 (PST) Received: from localhost.localdomain (unknown.telstraglobal.net [134.159.103.118]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Thu, 01 Feb 2018 09:37:14 +0100 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=195.135.221.5; helo=smtp.nue.novell.com; envelope-from=glin@suse.com; receiver=edk2-devel@lists.01.org From: Gary Lin To: edk2-devel@lists.01.org Date: Thu, 1 Feb 2018 16:36:07 +0800 Message-Id: <20180201083608.16036-20-glin@suse.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180201083608.16036-1-glin@suse.com> References: <20180201083608.16036-1-glin@suse.com> Subject: [edk2] [PATCH v2 19/20] BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Importing "FindExtendTool" from GenFds.GenFds could create the following circular imports: * GenFds.FdfParser =3D> GenFds.Capsule =3D> GenFds.GenFds =3D> GenFds.FdfPa= rser * GenFds.FdfParser =3D> GenFds.Fd =3D> GenFds.Fv =3D> GenFds.AprioriSection= =3D> GenFds.FfsFileStatement =3D> GenFds.GuidSection =3D> GenFds.GenFds =3D> GenFds.FdfParser This commit moves "FindExtendTool" to GenFdsGlobalVariable.py to break the circles. Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Gary Lin --- BaseTools/Source/Python/GenFds/Capsule.py | 2 +- BaseTools/Source/Python/GenFds/GenFds.py | 93 --------------= ----- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 95 ++++++++++++++= +++++- BaseTools/Source/Python/GenFds/GuidSection.py | 2 +- 4 files changed, 96 insertions(+), 96 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/P= ython/GenFds/Capsule.py index fb929065634e..55e9e1dade2f 100644 --- a/BaseTools/Source/Python/GenFds/Capsule.py +++ b/BaseTools/Source/Python/GenFds/Capsule.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import from .GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import FindExtendTool from CommonDataClass.FdfClass import CapsuleClassObject import Common.LongFilePathOs as os import subprocess @@ -56,7 +57,6 @@ class Capsule (CapsuleClassObject) : # @retval string Generated Capsule file path # def GenFmpCapsule(self): - from .GenFds import FindExtendTool # # Generate capsule header # typedef struct { diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index 7c1df37778fb..953069fc52f7 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -415,99 +415,6 @@ def CheckBuildOptionPcd(): =20 GlobalData.BuildOptionPcd[i] =3D (TokenSpaceGuidCName, TokenCN= ame, NewValue) =20 - -## FindExtendTool() -# -# Find location of tools to process data -# -# @param KeyStringList Filter for inputs of section generation -# @param CurrentArchList Arch list -# @param NameGuid The Guid name -# -def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): - ToolDb =3D ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir= ).ToolsDefTxtDatabase - # if user not specify filter, try to deduce it from global data. - if KeyStringList =3D=3D None or KeyStringList =3D=3D []: - Target =3D GenFdsGlobalVariable.TargetName - ToolChain =3D GenFdsGlobalVariable.ToolChainTag - if ToolChain not in ToolDb['TOOL_CHAIN_TAG']: - EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external= tool because tool tag %s is not defined in tools_def.txt!" % ToolChain) - KeyStringList =3D [Target + '_' + ToolChain + '_' + CurrentArchLis= t[0]] - for Arch in CurrentArchList: - if Target + '_' + ToolChain + '_' + Arch not in KeyStringList: - KeyStringList.append(Target + '_' + ToolChain + '_' + Arch) - - if GenFdsGlobalVariable.GuidToolDefinition: - if NameGuid in GenFdsGlobalVariable.GuidToolDefinition.keys(): - return GenFdsGlobalVariable.GuidToolDefinition[NameGuid] - - ToolDefinition =3D ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable= .ConfDir).ToolsDefTxtDictionary - ToolPathTmp =3D None - ToolOption =3D None - ToolPathKey =3D None - ToolOptionKey =3D None - KeyList =3D None - for ToolDef in ToolDefinition.items(): - if NameGuid =3D=3D ToolDef[1]: - KeyList =3D ToolDef[0].split('_') - Key =3D KeyList[0] + \ - '_' + \ - KeyList[1] + \ - '_' + \ - KeyList[2] - if Key in KeyStringList and KeyList[4] =3D=3D 'GUID': - ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' - ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS' - ToolPath =3D ToolDefinition.get(ToolPathKey) - ToolOption =3D ToolDefinition.get(ToolOptionKey) - if ToolPathTmp =3D=3D None: - ToolPathTmp =3D ToolPath - else: - if ToolPathTmp !=3D ToolPath: - EdkLogger.error("GenFds", GENFDS_ERROR, "Don't kno= w which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath)) - - BuildOption =3D {} - for Arch in CurrentArchList: - Platform =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlob= alVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlo= balVariable.ToolChainTag] - # key is (ToolChainFamily, ToolChain, CodeBase) - for item in Platform.BuildOptions: - if '_PATH' in item[1] or '_FLAGS' in item[1] or '_GUID' in ite= m[1]: - if not item[0] or (item[0] and GenFdsGlobalVariable.ToolCh= ainFamily=3D=3D item[0]): - if item[1] not in BuildOption: - BuildOption[item[1]] =3D Platform.BuildOptions[ite= m] - if BuildOption: - ToolList =3D [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHA= IN_TAG, TAB_TOD_DEFINES_TARGET_ARCH] - for Index in range(2, -1, -1): - for Key in dict(BuildOption): - List =3D Key.split('_') - if List[Index] =3D=3D '*': - for String in ToolDb[ToolList[Index]]: - if String in [Arch, GenFdsGlobalVariable.Targe= tName, GenFdsGlobalVariable.ToolChainTag]: - List[Index] =3D String - NewKey =3D '%s_%s_%s_%s_%s' % tuple(List) - if NewKey not in BuildOption: - BuildOption[NewKey] =3D BuildOption[Ke= y] - continue - del BuildOption[Key] - elif List[Index] not in ToolDb[ToolList[Index]]: - del BuildOption[Key] - if BuildOption: - if not KeyList: - for Op in BuildOption: - if NameGuid =3D=3D BuildOption[Op]: - KeyList =3D Op.split('_') - Key =3D KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2] - if Key in KeyStringList and KeyList[4] =3D=3D 'GUID': - ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' - ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS' - if ToolPathKey in BuildOption.keys(): - ToolPathTmp =3D BuildOption.get(ToolPathKey) - if ToolOptionKey in BuildOption.keys(): - ToolOption =3D BuildOption.get(ToolOptionKey) - - GenFdsGlobalVariable.GuidToolDefinition[NameGuid] =3D (ToolPathTmp, To= olOption) - return ToolPathTmp, ToolOption - ## Parse command line options # # Using standard Python module optparse to parse command line option of th= is tool. diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index d7fd58c7482f..a534fcb9371a 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -27,8 +27,9 @@ from Common.BuildToolError import * from Common import EdkLogger from Common.Misc import SaveFileOnChange =20 +from Common.DataType import TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_C= HAIN_TAG, TAB_TOD_DEFINES_TARGET_ARCH from Common.TargetTxtClassObject import TargetTxtClassObject -from Common.ToolDefClassObject import ToolDefClassObject +from Common.ToolDefClassObject import ToolDefClassObject, ToolDefDict from AutoGen.BuildEngine import BuildRule import Common.DataType as DataType from Common.Misc import PathClass @@ -845,3 +846,95 @@ class GenFdsGlobalVariable: DebugLogger =3D staticmethod(DebugLogger) MacroExtend =3D staticmethod (MacroExtend) GetPcdValue =3D staticmethod(GetPcdValue) + +## FindExtendTool() +# +# Find location of tools to process data +# +# @param KeyStringList Filter for inputs of section generation +# @param CurrentArchList Arch list +# @param NameGuid The Guid name +# +def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): + ToolDb =3D ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDataba= se + # if user not specify filter, try to deduce it from global data. + if KeyStringList =3D=3D None or KeyStringList =3D=3D []: + Target =3D GenFdsGlobalVariable.TargetName + ToolChain =3D GenFdsGlobalVariable.ToolChainTag + if ToolChain not in ToolDb['TOOL_CHAIN_TAG']: + EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external= tool because tool tag %s is not defined in tools_def.txt!" % ToolChain) + KeyStringList =3D [Target + '_' + ToolChain + '_' + CurrentArchLis= t[0]] + for Arch in CurrentArchList: + if Target + '_' + ToolChain + '_' + Arch not in KeyStringList: + KeyStringList.append(Target + '_' + ToolChain + '_' + Arch) + + if GenFdsGlobalVariable.GuidToolDefinition: + if NameGuid in GenFdsGlobalVariable.GuidToolDefinition.keys(): + return GenFdsGlobalVariable.GuidToolDefinition[NameGuid] + + ToolDefinition =3D ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefT= xtDictionary + ToolPathTmp =3D None + ToolOption =3D None + ToolPathKey =3D None + ToolOptionKey =3D None + KeyList =3D None + for ToolDef in ToolDefinition.items(): + if NameGuid =3D=3D ToolDef[1]: + KeyList =3D ToolDef[0].split('_') + Key =3D KeyList[0] + \ + '_' + \ + KeyList[1] + \ + '_' + \ + KeyList[2] + if Key in KeyStringList and KeyList[4] =3D=3D 'GUID': + ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' + ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS' + ToolPath =3D ToolDefinition.get(ToolPathKey) + ToolOption =3D ToolDefinition.get(ToolOptionKey) + if ToolPathTmp =3D=3D None: + ToolPathTmp =3D ToolPath + else: + if ToolPathTmp !=3D ToolPath: + EdkLogger.error("GenFds", GENFDS_ERROR, "Don't kno= w which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath)) + + BuildOption =3D {} + for Arch in CurrentArchList: + Platform =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlob= alVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlo= balVariable.ToolChainTag] + # key is (ToolChainFamily, ToolChain, CodeBase) + for item in Platform.BuildOptions: + if '_PATH' in item[1] or '_FLAGS' in item[1] or '_GUID' in ite= m[1]: + if not item[0] or (item[0] and GenFdsGlobalVariable.ToolCh= ainFamily=3D=3D item[0]): + if item[1] not in BuildOption: + BuildOption[item[1]] =3D Platform.BuildOptions[ite= m] + if BuildOption: + ToolList =3D [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHA= IN_TAG, TAB_TOD_DEFINES_TARGET_ARCH] + for Index in range(2, -1, -1): + for Key in dict(BuildOption): + List =3D Key.split('_') + if List[Index] =3D=3D '*': + for String in ToolDb[ToolList[Index]]: + if String in [Arch, GenFdsGlobalVariable.Targe= tName, GenFdsGlobalVariable.ToolChainTag]: + List[Index] =3D String + NewKey =3D '%s_%s_%s_%s_%s' % tuple(List) + if NewKey not in BuildOption: + BuildOption[NewKey] =3D BuildOption[Ke= y] + continue + del BuildOption[Key] + elif List[Index] not in ToolDb[ToolList[Index]]: + del BuildOption[Key] + if BuildOption: + if not KeyList: + for Op in BuildOption: + if NameGuid =3D=3D BuildOption[Op]: + KeyList =3D Op.split('_') + Key =3D KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2] + if Key in KeyStringList and KeyList[4] =3D=3D 'GUID': + ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' + ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS' + if ToolPathKey in BuildOption.keys(): + ToolPathTmp =3D BuildOption.get(ToolPathKey) + if ToolOptionKey in BuildOption.keys(): + ToolOption =3D BuildOption.get(ToolOptionKey) + + GenFdsGlobalVariable.GuidToolDefinition[NameGuid] =3D (ToolPathTmp, To= olOption) + return ToolPathTmp, ToolOption diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Sour= ce/Python/GenFds/GuidSection.py index 877dabc196e1..679934dc7794 100644 --- a/BaseTools/Source/Python/GenFds/GuidSection.py +++ b/BaseTools/Source/Python/GenFds/GuidSection.py @@ -21,6 +21,7 @@ import subprocess from .Ffs import Ffs import Common.LongFilePathOs as os from .GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import FindExtendTool from CommonDataClass.FdfClass import GuidSectionClassObject from Common import ToolDefClassObject import sys @@ -129,7 +130,6 @@ class GuidSection(GuidSectionClassObject) : ExternalTool =3D None ExternalOption =3D None if self.NameGuid !=3D None: - from .GenFds import FindExtendTool ExternalTool, ExternalOption =3D FindExtendTool(self.KeyString= List, self.CurrentArchList, self.NameGuid) =20 # --=20 2.16.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel