From nobody Mon Dec 23 14:16:45 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 1517474282294423.75956165274647; Thu, 1 Feb 2018 00:38:02 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 376CA21E0BA1A; Thu, 1 Feb 2018 00:31:45 -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 1C15821E0BA10 for ; Thu, 1 Feb 2018 00:31:42 -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:16 +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:08 +0800 Message-Id: <20180201083608.16036-21-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 20/20] BaseTools: Move ImageBinDict 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" Moving "ImageBinDict" from GenFds.py to GenFdsGlobalVariable.py to remove the requirement to import GenFds.GenFds in Capsule.py, Fd.py and Fv.py. This breaks the following circular imports: * GenFds.FdfParser =3D> GenFds.Capsule =3D> GenFds.GenFds =3D> GenFds.FdfPa= rser * GenFds.FdfParser =3D> GenFds.Fd =3D> GenFds.GenFds =3D> GenFds.FdfParser * GenFds.FdfParser =3D> GenFds.Fd =3D> GenFds.Fv =3D> GenFds.GenFds =3D> GenFds.FdfParser Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Gary Lin --- BaseTools/Source/Python/GenFds/Capsule.py | 7 +++---- BaseTools/Source/Python/GenFds/Fd.py | 15 +++++++-------- BaseTools/Source/Python/GenFds/Fv.py | 11 +++++------ BaseTools/Source/Python/GenFds/GenFds.py | 2 -- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 3 +++ 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/P= ython/GenFds/Capsule.py index 55e9e1dade2f..247fb0c75e1a 100644 --- a/BaseTools/Source/Python/GenFds/Capsule.py +++ b/BaseTools/Source/Python/GenFds/Capsule.py @@ -201,9 +201,8 @@ class Capsule (CapsuleClassObject) : # @retval string Generated Capsule file path # def GenCapsule(self): - from .GenFds import GenFds - if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict.keys(= ): - return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] + if self.UiCapsuleName.upper() + 'cap' in GenFdsGlobalVariable.Imag= eBinDict.keys(): + return GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.up= per() + 'cap'] =20 GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCa= psuleName) if ('CAPSULE_GUID' in self.TokensDict and=20 @@ -237,7 +236,7 @@ class Capsule (CapsuleClassObject) : =20 GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s Capsule Success= fully" %self.UiCapsuleName) GenFdsGlobalVariable.SharpCounter =3D 0 - GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] =3D CapOut= putFile + GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.upper() + 'ca= p'] =3D CapOutputFile return CapOutputFile =20 ## Generate inf file for capsule diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python= /GenFds/Fd.py index 86a0d9a47bfc..1a95a4567cca 100644 --- a/BaseTools/Source/Python/GenFds/Fd.py +++ b/BaseTools/Source/Python/GenFds/Fd.py @@ -46,9 +46,8 @@ class FD(FDClassObject): # @retval string Generated FD file name # def GenFd (self, Flag =3D False): - from .GenFds import GenFds - if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict.keys(): - return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] + if self.FdUiName.upper() + 'fd' in GenFdsGlobalVariable.ImageBinDi= ct.keys(): + return GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper()= + 'fd'] =20 # # Print Information @@ -93,7 +92,7 @@ class FD(FDClassObject): PadRegion.Offset =3D PreviousRegionStart + PreviousReg= ionSize PadRegion.Size =3D RegionObj.Offset - PadRegion.Offset if not Flag: - PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddre= ss, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRa= wDict, self.DefineVarDict) + PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddre= ss, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDi= ct, self.vtfRawDict, self.DefineVarDict) PreviousRegionStart =3D RegionObj.Offset PreviousRegionSize =3D RegionObj.Size # @@ -102,7 +101,7 @@ class FD(FDClassObject): if PreviousRegionSize > self.Size: pass GenFdsGlobalVariable.VerboseLogger('Call each region\'s Ad= dToBuffer function') - RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, sel= f.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, = self.DefineVarDict) + RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, sel= f.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, sel= f.vtfRawDict, self.DefineVarDict) =20 FdBuffer =3D BytesIO('') PreviousRegionStart =3D -1 @@ -123,7 +122,7 @@ class FD(FDClassObject): PadRegion.Offset =3D PreviousRegionStart + PreviousRegionS= ize PadRegion.Size =3D RegionObj.Offset - PadRegion.Offset if not Flag: - PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self= .BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, s= elf.DefineVarDict) + PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self= .BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self= .vtfRawDict, self.DefineVarDict) PreviousRegionStart =3D RegionObj.Offset PreviousRegionSize =3D RegionObj.Size # @@ -137,7 +136,7 @@ class FD(FDClassObject): # Call each region's AddToBuffer function # GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToB= uffer function') - RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockS= izeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.Def= ineVarDict, Flag=3DFlag) + RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockS= izeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRaw= Dict, self.DefineVarDict, Flag=3DFlag) # # Write the buffer contents to Fd file # @@ -145,7 +144,7 @@ class FD(FDClassObject): if not Flag: SaveFileOnChange(FdFileName, FdBuffer.getvalue()) FdBuffer.close() - GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] =3D FdFileName + GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper() + 'fd'] = =3D FdFileName return FdFileName =20 ## generate VTF diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python= /GenFds/Fv.py index bff661e43e7e..d398d7393df6 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -70,9 +70,8 @@ class FV (FvClassObject): # @retval string Generated FV file path # def AddToBuffer (self, Buffer, BaseAddress=3DNone, BlockSize=3D None, = BlockNum=3DNone, ErasePloarity=3D'1', VtfDict=3DNone, MacroDict =3D {}, Fla= g=3DFalse) : - from .GenFds import GenFds - if BaseAddress =3D=3D None and self.UiFvName.upper() + 'fv' in Gen= Fds.ImageBinDict.keys(): - return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] + if BaseAddress =3D=3D None and self.UiFvName.upper() + 'fv' in Gen= FdsGlobalVariable.ImageBinDict.keys(): + return GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper()= + 'fv'] =20 # # Check whether FV in Capsule is in FD flash region. @@ -86,7 +85,7 @@ class FV (FvClassObject): for RegionData in RegionObj.RegionDataList: if RegionData.endswith(".fv"): continue - elif RegionData.upper() + 'fv' in GenFds.Image= BinDict.keys(): + elif RegionData.upper() + 'fv' in GenFdsGlobal= Variable.ImageBinDict.keys(): continue elif self.UiFvName.upper() =3D=3D RegionData.u= pper(): GenFdsGlobalVariable.ErrorLogger("Capsule = %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, s= elf.UiFvName.upper())) @@ -141,7 +140,7 @@ class FV (FvClassObject): FvOutputFile =3D self.CreateFileName =20 if Flag: - GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] =3D FvOutput= File + GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv'= ] =3D FvOutputFile return FvOutputFile =20 FvInfoFileName =3D os.path.join(GenFdsGlobalVariable.FfsDir, self.= UiFvName + '.inf') @@ -221,7 +220,7 @@ class FV (FvClassObject): # FvAlignmentValue is less than 1K self.FvAlignment =3D str (FvAlignmentValue) FvFileObj.close() - GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] =3D FvOu= tputFile + GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + = 'fv'] =3D FvOutputFile GenFdsGlobalVariable.LargeFileInFvFlags.pop() else: GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV= file." %self.UiFvName) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index 953069fc52f7..58793cc9533d 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -462,8 +462,6 @@ def myOptionParser(): # class GenFds : FdfParsef =3D None - # FvName, FdName, CapName in FDF, Image file name - ImageBinDict =3D {} OnlyGenerateThisFd =3D None OnlyGenerateThisFv =3D None OnlyGenerateThisCap =3D None diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index a534fcb9371a..f4b619334e7f 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -93,6 +93,9 @@ class GenFdsGlobalVariable: =20 SectionHeader =3D struct.Struct("3B 1B") =20 + # FvName, FdName, CapName in FDF, Image file name + ImageBinDict =3D {} + ## LoadBuildRule # @staticmethod --=20 2.16.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel