From: Gary Lin <glin@suse.com>
To: edk2-devel@lists.01.org
Cc: Yonghong Zhu <yonghong.zhu@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [PATCH v3 20/20] BaseTools: Move ImageBinDict to GenFdsGlobalVariable.py
Date: Thu, 21 Jun 2018 12:43:46 +0800 [thread overview]
Message-ID: <20180621044346.28495-21-glin@suse.com> (raw)
In-Reply-To: <20180621044346.28495-1-glin@suse.com>
Move "ImageBinDict" from GenFds.py to GenFdsGlobalVariable.py so that we
can remove the requirement to import GenFds.GenFds in Capsule.py, Fd.py and
Fv.py. This breaks the following circular imports:
* GenFds.FdfParser => GenFds.Capsule => GenFds.GenFds => GenFds.FdfParser
* GenFds.FdfParser => GenFds.Fd => GenFds.GenFds => GenFds.FdfParser
* GenFds.FdfParser => GenFds.Fd => GenFds.Fv => GenFds.GenFds =>
GenFds.FdfParser
Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
---
BaseTools/Source/Python/GenFds/Capsule.py | 6 +++---
BaseTools/Source/Python/GenFds/Fd.py | 14 +++++++-------
BaseTools/Source/Python/GenFds/Fv.py | 10 +++++-----
BaseTools/Source/Python/GenFds/GenFds.py | 2 --
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 3 +++
5 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py
index ddb11ac3093e..787ae710660a 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -203,8 +203,8 @@ class Capsule (CapsuleClassObject) :
#
def GenCapsule(self):
from .GenFds import GenFds
- if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict:
- return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap']
+ if self.UiCapsuleName.upper() + 'cap' in GenFdsGlobalVariable.ImageBinDict:
+ return GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.upper() + 'cap']
GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCapsuleName)
if ('CAPSULE_GUID' in self.TokensDict and
@@ -238,7 +238,7 @@ class Capsule (CapsuleClassObject) :
GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s Capsule Successfully" %self.UiCapsuleName)
GenFdsGlobalVariable.SharpCounter = 0
- GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] = CapOutputFile
+ GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] = CapOutputFile
return CapOutputFile
## Generate inf file for capsule
diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py
index 9e7d0fbfc534..e4cb90a57df3 100644
--- a/BaseTools/Source/Python/GenFds/Fd.py
+++ b/BaseTools/Source/Python/GenFds/Fd.py
@@ -48,8 +48,8 @@ class FD(FDClassObject):
#
def GenFd (self, Flag = False):
from .GenFds import GenFds
- if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict:
- return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd']
+ if self.FdUiName.upper() + 'fd' in GenFdsGlobalVariable.ImageBinDict:
+ return GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper() + 'fd']
#
# Print Information
@@ -94,7 +94,7 @@ class FD(FDClassObject):
PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
PadRegion.Size = RegionObj.Offset - PadRegion.Offset
if not Flag:
- PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
+ PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
PreviousRegionStart = RegionObj.Offset
PreviousRegionSize = RegionObj.Size
#
@@ -103,7 +103,7 @@ class FD(FDClassObject):
if PreviousRegionSize > self.Size:
pass
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
- RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
+ RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
FdBuffer = BytesIO('')
PreviousRegionStart = -1
@@ -124,7 +124,7 @@ class FD(FDClassObject):
PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
PadRegion.Size = RegionObj.Offset - PadRegion.Offset
if not Flag:
- PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
+ PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
PreviousRegionStart = RegionObj.Offset
PreviousRegionSize = RegionObj.Size
#
@@ -138,7 +138,7 @@ class FD(FDClassObject):
# Call each region's AddToBuffer function
#
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
- RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict, Flag=Flag)
+ RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict, Flag=Flag)
#
# Write the buffer contents to Fd file
#
@@ -146,7 +146,7 @@ class FD(FDClassObject):
if not Flag:
SaveFileOnChange(FdFileName, FdBuffer.getvalue())
FdBuffer.close()
- GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] = FdFileName
+ GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper() + 'fd'] = FdFileName
return FdFileName
## generate VTF
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index 947aaad09903..b48c0cfcc782 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -72,8 +72,8 @@ class FV (FvClassObject):
def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :
from .GenFds import GenFds
- if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict:
- return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv']
+ if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFdsGlobalVariable.ImageBinDict:
+ return GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv']
#
# Check whether FV in Capsule is in FD flash region.
@@ -86,7 +86,7 @@ class FV (FvClassObject):
for RegionData in RegionObj.RegionDataList:
if RegionData.endswith(".fv"):
continue
- elif RegionData.upper() + 'fv' in GenFds.ImageBinDict:
+ elif RegionData.upper() + 'fv' in GenFdsGlobalVariable.ImageBinDict:
continue
elif self.UiFvName.upper() == RegionData.upper():
GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))
@@ -141,7 +141,7 @@ class FV (FvClassObject):
FvOutputFile = self.CreateFileName
if Flag:
- GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
+ GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
return FvOutputFile
FvInfoFileName = os.path.join(GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf')
@@ -221,7 +221,7 @@ class FV (FvClassObject):
# FvAlignmentValue is less than 1K
self.FvAlignment = str (FvAlignmentValue)
FvFileObj.close()
- GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
+ GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv'] = 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/Python/GenFds/GenFds.py
index 4a8559adbaec..5986b6d4a613 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -416,8 +416,6 @@ def myOptionParser():
#
class GenFds :
FdfParsef = None
- # FvName, FdName, CapName in FDF, Image file name
- ImageBinDict = {}
OnlyGenerateThisFd = None
OnlyGenerateThisFv = None
OnlyGenerateThisCap = None
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 9f20c402527f..e3d5c93b6855 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -92,6 +92,9 @@ class GenFdsGlobalVariable:
SectionHeader = struct.Struct("3B 1B")
+ # FvName, FdName, CapName in FDF, Image file name
+ ImageBinDict = {}
+
## LoadBuildRule
#
@staticmethod
--
2.17.1
prev parent reply other threads:[~2018-06-21 4:44 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-21 4:43 [PATCH v3 00/20] BaseTools: One step toward python3 Gary Lin
2018-06-21 4:43 ` [PATCH v3 01/20] BaseTools: Fix a typo in ini.py Gary Lin
2018-06-21 15:46 ` Carsey, Jaben
2018-06-21 4:43 ` [PATCH v3 02/20] BaseTools: Refactor python except statements Gary Lin
2018-06-21 6:27 ` Gary Lin
2018-06-21 4:43 ` [PATCH v3 03/20] BaseTools: Refactor python print statements Gary Lin
2018-06-21 4:43 ` [PATCH v3 04/20] BaseTools: Remove the old python "not-equal" Gary Lin
2018-06-21 4:43 ` [PATCH v3 05/20] BaseTools: Use the python3-range functions Gary Lin
2018-06-21 12:40 ` Zhu, Yonghong
2018-06-22 2:04 ` Gary Lin
2018-06-22 5:29 ` Zhu, Yonghong
2018-06-22 8:21 ` Gary Lin
2018-06-22 8:45 ` Gary Lin
2018-06-22 8:53 ` Zhu, Yonghong
2018-06-22 9:13 ` Gary Lin
2018-06-22 9:22 ` Zhu, Yonghong
2018-06-22 9:24 ` Zhu, Yonghong
2018-06-22 9:48 ` Gary Lin
2018-06-22 10:22 ` Zhu, Yonghong
2018-06-25 3:34 ` Gary Lin
2018-06-25 5:58 ` Zhu, Yonghong
2018-06-25 6:18 ` Gary Lin
2018-06-21 4:43 ` [PATCH v3 06/20] BaseTools: Remove tuple parameter in python scripts Gary Lin
2018-06-21 4:43 ` [PATCH v3 07/20] BaseTools: Remove the deprecated hash_key() Gary Lin
2018-06-21 4:43 ` [PATCH v3 08/20] BaseTools: Replace StandardError with Expression Gary Lin
2018-06-21 4:43 ` [PATCH v3 09/20] BaseTools: Remove types.TypeType Gary Lin
2018-06-21 4:43 ` [PATCH v3 10/20] BaseTools: Refactor python raise statement Gary Lin
2018-06-21 4:43 ` [PATCH v3 11/20] BaseTools: Adjust the spaces around commas and colons Gary Lin
2018-06-21 4:43 ` [PATCH v3 12/20] BaseTools: Migrate to the new octal literal Gary Lin
2018-06-21 4:43 ` [PATCH v3 13/20] BaseTools: Unify long int and int in python scripts Gary Lin
2018-06-21 4:43 ` [PATCH v3 14/20] BaseTools: Fix old python2 idioms Gary Lin
2018-06-21 4:43 ` [PATCH v3 15/20] BaseTools: Replace StringIO.StringIO with io.BytesIO Gary Lin
2018-06-21 4:43 ` [PATCH v3 16/20] BaseTools: Treat GenFds.py and build.py as python modules Gary Lin
2018-06-21 4:43 ` [PATCH v3 17/20] BaseTools: Adopt absolute import for python scripts Gary Lin
2018-06-21 4:43 ` [PATCH v3 18/20] BaseTools: Move OverrideAttribs to OptRomInfStatement.py Gary Lin
2018-06-21 4:43 ` [PATCH v3 19/20] BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py Gary Lin
2018-06-21 4:43 ` Gary Lin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180621044346.28495-21-glin@suse.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox