BaseTools/GenFds: cleanup GenFds
1) remove wildcard imports and use explicit imports 2) refactor to use shared variables from Common/DataType 3) rename to not shadow imports 4) don't assign a variable in a loop (just do final assignment) 5) remove spaces, parens, unused or commented out code, etc. 6) merge unnecessary parent classes into child 7) refactor to share DXE and PEI apriori GUIDs from one place this includes changes to Build and EOT files 8) for PEP8, dont use __ for custom methods. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bob C Feng <bob.c.feng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
committed by
Yonghong Zhu
parent
0019375fbc
commit
9e47e6f908
@ -18,21 +18,24 @@
|
||||
from __future__ import absolute_import
|
||||
from .GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import Common.LongFilePathOs as os
|
||||
from CommonDataClass.FdfClass import VtfClassObject
|
||||
from Common.LongFilePathSupport import OpenLongFilePath as open
|
||||
T_CHAR_LF = '\n'
|
||||
from Common.DataType import TAB_LINE_BREAK
|
||||
|
||||
## generate VTF
|
||||
#
|
||||
#
|
||||
class Vtf (VtfClassObject):
|
||||
class Vtf (object):
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
VtfClassObject.__init__(self)
|
||||
self.KeyArch = None
|
||||
self.ArchList = None
|
||||
self.UiName = None
|
||||
self.ResetBin = None
|
||||
self.ComponentStatementList = []
|
||||
|
||||
## GenVtf() method
|
||||
#
|
||||
@ -44,7 +47,6 @@ class Vtf (VtfClassObject):
|
||||
#
|
||||
def GenVtf(self, FdAddressDict) :
|
||||
self.GenBsfInf()
|
||||
OutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.UiName + '.Vtf')
|
||||
BaseAddArg = self.GetBaseAddressArg(FdAddressDict)
|
||||
OutputArg, VtfRawDict = self.GenOutputArg()
|
||||
|
||||
@ -69,57 +71,57 @@ class Vtf (VtfClassObject):
|
||||
FvList = self.GetFvList()
|
||||
self.BsfInfName = os.path.join(GenFdsGlobalVariable.FvDir, self.UiName + '.inf')
|
||||
BsfInf = open(self.BsfInfName, 'w+')
|
||||
if self.ResetBin is not None:
|
||||
BsfInf.writelines ("[OPTIONS]" + T_CHAR_LF)
|
||||
if self.ResetBin:
|
||||
BsfInf.writelines ("[OPTIONS]" + TAB_LINE_BREAK)
|
||||
BsfInf.writelines ("IA32_RST_BIN" + \
|
||||
" = " + \
|
||||
GenFdsGlobalVariable.MacroExtend(GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.ResetBin)) + \
|
||||
T_CHAR_LF)
|
||||
BsfInf.writelines (T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
BsfInf.writelines (TAB_LINE_BREAK)
|
||||
|
||||
BsfInf.writelines ("[COMPONENTS]" + T_CHAR_LF)
|
||||
BsfInf.writelines ("[COMPONENTS]" + TAB_LINE_BREAK)
|
||||
|
||||
for ComponentObj in self.ComponentStatementList :
|
||||
BsfInf.writelines ("COMP_NAME" + \
|
||||
" = " + \
|
||||
ComponentObj.CompName + \
|
||||
T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
if ComponentObj.CompLoc.upper() == 'NONE':
|
||||
BsfInf.writelines ("COMP_LOC" + \
|
||||
" = " + \
|
||||
'N' + \
|
||||
T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
|
||||
elif ComponentObj.FilePos is not None:
|
||||
elif ComponentObj.FilePos:
|
||||
BsfInf.writelines ("COMP_LOC" + \
|
||||
" = " + \
|
||||
ComponentObj.FilePos + \
|
||||
T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
else:
|
||||
Index = FvList.index(ComponentObj.CompLoc.upper())
|
||||
if Index == 0:
|
||||
BsfInf.writelines ("COMP_LOC" + \
|
||||
" = " + \
|
||||
'F' + \
|
||||
T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
elif Index == 1:
|
||||
BsfInf.writelines ("COMP_LOC" + \
|
||||
" = " + \
|
||||
'S' + \
|
||||
T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
|
||||
BsfInf.writelines ("COMP_TYPE" + \
|
||||
" = " + \
|
||||
ComponentObj.CompType + \
|
||||
T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
BsfInf.writelines ("COMP_VER" + \
|
||||
" = " + \
|
||||
ComponentObj.CompVer + \
|
||||
T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
BsfInf.writelines ("COMP_CS" + \
|
||||
" = " + \
|
||||
ComponentObj.CompCs + \
|
||||
T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
|
||||
BinPath = ComponentObj.CompBin
|
||||
if BinPath != '-':
|
||||
@ -127,7 +129,7 @@ class Vtf (VtfClassObject):
|
||||
BsfInf.writelines ("COMP_BIN" + \
|
||||
" = " + \
|
||||
BinPath + \
|
||||
T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
|
||||
SymPath = ComponentObj.CompSym
|
||||
if SymPath != '-':
|
||||
@ -135,12 +137,12 @@ class Vtf (VtfClassObject):
|
||||
BsfInf.writelines ("COMP_SYM" + \
|
||||
" = " + \
|
||||
SymPath + \
|
||||
T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
BsfInf.writelines ("COMP_SIZE" + \
|
||||
" = " + \
|
||||
ComponentObj.CompSize + \
|
||||
T_CHAR_LF)
|
||||
BsfInf.writelines (T_CHAR_LF)
|
||||
TAB_LINE_BREAK)
|
||||
BsfInf.writelines (TAB_LINE_BREAK)
|
||||
|
||||
BsfInf.close()
|
||||
|
||||
|
Reference in New Issue
Block a user