From nobody Sat Feb 7 10:14:42 2026 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 1531477166066916.6982456036583; Fri, 13 Jul 2018 03:19:26 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 48FEC2098844A; Fri, 13 Jul 2018 03:19:18 -0700 (PDT) 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 B639D2098844A for ; Fri, 13 Jul 2018 03:19:16 -0700 (PDT) Received: from localhost.localdomain (unknown.telstraglobal.net [134.159.103.118]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Fri, 13 Jul 2018 12:19:13 +0200 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: Fri, 13 Jul 2018 18:18:35 +0800 Message-Id: <20180713101847.7485-5-glin@suse.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180713101847.7485-1-glin@suse.com> References: <20180713101847.7485-1-glin@suse.com> Subject: [edk2] [PATCH v2 04/16] BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 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. Besides, FindExtendTool is tweaked slightly with the following changes: ToolDefClassObject.ToolDefDict =3D> ToolDefDict TAB_GUID =3D> DataType.TAB_GUID TAB_TOD_DEFINES_TARGET =3D> DataType.TAB_TOD_DEFINES_TARGET TAB_TOD_DEFINES_TOOL_CHAIN_TAG =3D> DataType.TAB_TOD_DEFINES_TOOL_CHAIN_TAG TAB_TOD_DEFINES_TARGET_ARCH =3D> DataType.TAB_TOD_DEFINES_TARGET_ARCH 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 | 92 --------------= ----- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 94 ++++++++++++++= +++++- BaseTools/Source/Python/GenFds/GuidSection.py | 2 +- 4 files changed, 95 insertions(+), 95 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/P= ython/GenFds/Capsule.py index 27932ef0020c..8471cd5d0f7a 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 @@ -65,7 +66,6 @@ class Capsule (CapsuleClassObject) : # UINT32 CapsuleImageSize; # } EFI_CAPSULE_HEADER; # - from .GenFds import FindExtendTool Header =3D BytesIO() # # Use FMP capsule GUID: 6DCBD5ED-E82D-4C44-BDA1-7194199AD92A diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index c0b60b9b3c1f..865c5099d1eb 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -368,98 +368,6 @@ def SingleCheckCallback(option, opt_str, value, parser= ): else: parser.error("Option %s only allows one instance in command line!"= % option) =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 is 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: - 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.lower() =3D=3D ToolDef[1].lower() : - KeyList =3D ToolDef[0].split('_') - Key =3D KeyList[0] + \ - '_' + \ - KeyList[1] + \ - '_' + \ - KeyList[2] - if Key in KeyStringList and KeyList[4] =3D=3D TAB_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 is 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 list(BuildOption.keys()): - 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 TAB_GUID: - ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' - ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS' - if ToolPathKey in BuildOption: - ToolPathTmp =3D BuildOption[ToolPathKey] - if ToolOptionKey in BuildOption: - ToolOption =3D BuildOption[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 eeb3ec2197a8..52aa7a1538f7 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -27,7 +27,7 @@ from Common import EdkLogger from Common.Misc import SaveFileOnChange =20 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 @@ -843,3 +843,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 is 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: + 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.lower() =3D=3D ToolDef[1].lower() : + KeyList =3D ToolDef[0].split('_') + Key =3D KeyList[0] + \ + '_' + \ + KeyList[1] + \ + '_' + \ + KeyList[2] + if Key in KeyStringList and KeyList[4] =3D=3D DataType.TAB_GUI= D: + ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' + ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS' + ToolPath =3D ToolDefinition.get(ToolPathKey) + ToolOption =3D ToolDefinition.get(ToolOptionKey) + if ToolPathTmp is 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 [DataType.TAB_TOD_DEFINES_TARGET, DataType.TAB_TO= D_DEFINES_TOOL_CHAIN_TAG, DataType.TAB_TOD_DEFINES_TARGET_ARCH] + for Index in range(2, -1, -1): + for Key in list(BuildOption.keys()): + 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 DataType= .TAB_GUID: + ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' + ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS' + if ToolPathKey in BuildOption: + ToolPathTmp =3D BuildOption[ToolPathKey] + if ToolOptionKey in BuildOption: + ToolOption =3D BuildOption[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 e41c2fd31e6c..fd660737f421 100644 --- a/BaseTools/Source/Python/GenFds/GuidSection.py +++ b/BaseTools/Source/Python/GenFds/GuidSection.py @@ -22,6 +22,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 @@ -131,7 +132,6 @@ class GuidSection(GuidSectionClassObject) : ExternalTool =3D None ExternalOption =3D None if self.NameGuid is not None: - from .GenFds import FindExtendTool ExternalTool, ExternalOption =3D FindExtendTool(self.KeyString= List, self.CurrentArchList, self.NameGuid) =20 # --=20 2.18.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel