[edk2] [Patch] BaseTools: Reset FdsGlobalVariable

BobCF bob.c.feng at intel.com
Thu Dec 20 03:37:43 PST 2018


https://bugzilla.tianocore.org/show_bug.cgi?id=1418
This patch is going to fix a regression issue that is introduced
by commit b3497bad1221704a5dbc5da0b10f42625f1ad2ed.

Before commit b3497b, build launched a external GenFds.py to generate
Fd, so the global variable in GenFds.py was reset in each execution.

After commit b3497b, each GenFds run in the same python interpeter, so
we need to explicitly reset global variable in each GenFdsApi call.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng at intel.com>
Cc: Liming Gao <liming.gao at intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel at linaro.org>
---
 BaseTools/Source/Python/GenFds/GenFds.py | 51 ++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 51655cc09c..447aa7f5eb 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -39,10 +39,12 @@ from Common.BuildToolError import FatalError, GENFDS_ERROR, CODE_ERROR, FORMAT_I
 from Workspace.WorkspaceDatabase import WorkspaceDatabase
 
 from .FdfParser import FdfParser, Warning
 from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from .FfsFileStatement import FileStatement
+import Common.DataType as DataType
+from struct import Struct
 
 ## Version and Copyright
 versionNumber = "1.0" + ' ' + gBUILD_VERSION
 __version__ = "%prog Version " + versionNumber
 __copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation  All rights reserved."
@@ -60,15 +62,64 @@ def main():
     global Options
     Options = myOptionParser()
     EdkLogger.Initialize()
     return GenFdsApi(OptionsToCommandDict(Options))
 
+def resetFdsGlobalVariable():
+    GenFdsGlobalVariable.FvDir = ''
+    GenFdsGlobalVariable.OutputDirDict = {}
+    GenFdsGlobalVariable.BinDir = ''
+    # will be FvDir + os.sep + 'Ffs'
+    GenFdsGlobalVariable.FfsDir = ''
+    GenFdsGlobalVariable.FdfParser = None
+    GenFdsGlobalVariable.LibDir = ''
+    GenFdsGlobalVariable.WorkSpace = None
+    GenFdsGlobalVariable.WorkSpaceDir = ''
+    GenFdsGlobalVariable.ConfDir = ''
+    GenFdsGlobalVariable.EdkSourceDir = ''
+    GenFdsGlobalVariable.OutputDirFromDscDict = {}
+    GenFdsGlobalVariable.TargetName = ''
+    GenFdsGlobalVariable.ToolChainTag = ''
+    GenFdsGlobalVariable.RuleDict = {}
+    GenFdsGlobalVariable.ArchList = None
+    GenFdsGlobalVariable.VtfDict = {}
+    GenFdsGlobalVariable.ActivePlatform = None
+    GenFdsGlobalVariable.FvAddressFileName = ''
+    GenFdsGlobalVariable.VerboseMode = False
+    GenFdsGlobalVariable.DebugLevel = -1
+    GenFdsGlobalVariable.SharpCounter = 0
+    GenFdsGlobalVariable.SharpNumberPerLine = 40
+    GenFdsGlobalVariable.FdfFile = ''
+    GenFdsGlobalVariable.FdfFileTimeStamp = 0
+    GenFdsGlobalVariable.FixedLoadAddress = False
+    GenFdsGlobalVariable.PlatformName = ''
+
+    GenFdsGlobalVariable.BuildRuleFamily = DataType.TAB_COMPILER_MSFT
+    GenFdsGlobalVariable.ToolChainFamily = DataType.TAB_COMPILER_MSFT
+    GenFdsGlobalVariable.__BuildRuleDatabase = None
+    GenFdsGlobalVariable.GuidToolDefinition = {}
+    GenFdsGlobalVariable.FfsCmdDict = {}
+    GenFdsGlobalVariable.SecCmdList = []
+    GenFdsGlobalVariable.CopyList   = []
+    GenFdsGlobalVariable.ModuleFile = ''
+    GenFdsGlobalVariable.EnableGenfdsMultiThread = False
+
+    GenFdsGlobalVariable.LargeFileInFvFlags = []
+    GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID = '5473C07A-3DCB-4dca-BD6F-1E9689E7349A'
+    GenFdsGlobalVariable.LARGE_FILE_SIZE = 0x1000000
+
+    GenFdsGlobalVariable.SectionHeader = Struct("3B 1B")
+
+    # FvName, FdName, CapName in FDF, Image file name
+    GenFdsGlobalVariable.ImageBinDict = {}
+
 def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=None):
     global Workspace
     Workspace = ""
     ArchList = None
     ReturnCode = 0
+    resetFdsGlobalVariable()
 
     try:
         if FdsCommandDict.get("verbose"):
             EdkLogger.SetLevel(EdkLogger.VERBOSE)
             GenFdsGlobalVariable.VerboseMode = True
-- 
2.19.1.windows.1



More information about the edk2-devel mailing list