diff options
24 files changed, 143 insertions, 137 deletions
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 2a6fa05ab8..671f02133a 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -922,7 +922,7 @@ class WorkspaceAutoGen(AutoGen): ## Return the directory to store FV files
def _GetFvDir(self):
if self._FvDir is None:
- self._FvDir = path.join(self.BuildDir, 'FV')
+ self._FvDir = path.join(self.BuildDir, TAB_FV_DIRECTORY)
return self._FvDir
## Return the directory to store all intermediate and final files built
@@ -1325,7 +1325,7 @@ class PlatformAutoGen(AutoGen): def UpdateNVStoreMaxSize(self,OrgVpdFile):
if self.VariableInfo:
- VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)
+ VpdMapFilePath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY, "%s.map" % self.Platform.VpdToolGuid)
PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]
if PcdNvStoreDfBuffer:
@@ -1718,7 +1718,7 @@ class PlatformAutoGen(AutoGen): # Process VPD map file generated by third party BPDG tool
if NeedProcessVpdMapFile:
- VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)
+ VpdMapFilePath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY, "%s.map" % self.Platform.VpdToolGuid)
if os.path.exists(VpdMapFilePath):
VpdFile.Read(VpdMapFilePath)
@@ -1769,7 +1769,7 @@ class PlatformAutoGen(AutoGen): self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList
def FixVpdOffset(self,VpdFile ):
- FvPath = os.path.join(self.BuildDir, "FV")
+ FvPath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY)
if not os.path.exists(FvPath):
try:
os.makedirs(FvPath)
@@ -1782,7 +1782,7 @@ class PlatformAutoGen(AutoGen): # retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.
BPDGToolName = None
for ToolDef in self.ToolDefinition.values():
- if ToolDef.has_key("GUID") and ToolDef["GUID"] == self.Platform.VpdToolGuid:
+ if ToolDef.has_key(TAB_GUID) and ToolDef[TAB_GUID] == self.Platform.VpdToolGuid:
if not ToolDef.has_key("PATH"):
EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % self.Platform.VpdToolGuid)
BPDGToolName = ToolDef["PATH"]
@@ -3031,7 +3031,7 @@ class ModuleAutoGen(AutoGen): def _GetFfsOutputDir(self):
if self._FfsOutputDir is None:
if GlobalData.gFdfParser is not None:
- self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, "FV", "Ffs", self.Guid + self.Name)
+ self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, TAB_FV_DIRECTORY, "Ffs", self.Guid + self.Name)
else:
self._FfsOutputDir = ''
return self._FfsOutputDir
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 45542ed463..89a3e56be3 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1613,7 +1613,7 @@ def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH): #
def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH):
if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
- GuidType = "GUID"
+ GuidType = TAB_GUID
else:
GuidType = "EFI_GUID"
@@ -1637,7 +1637,7 @@ def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH): #
def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH):
if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
- GuidType = "GUID"
+ GuidType = TAB_GUID
else:
GuidType = "EFI_GUID"
@@ -1661,7 +1661,7 @@ def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH): #
def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH):
if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
- GuidType = "GUID"
+ GuidType = TAB_GUID
else:
GuidType = "EFI_GUID"
@@ -1698,7 +1698,7 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH): if TokenSpaceList:
AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in this module\n\n")
if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]:
- GuidType = "GUID"
+ GuidType = TAB_GUID
else:
GuidType = "EFI_GUID"
for Item in TokenSpaceList:
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index b48ddcd59e..fab6859edb 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -972,7 +972,7 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH): AutoGenC.Append(AdditionalAutoGenC.String)
if Info.IsBinaryModule:
- DbFileName = os.path.join(Info.PlatformInfo.BuildDir, "FV", Phase + "PcdDataBase.raw")
+ DbFileName = os.path.join(Info.PlatformInfo.BuildDir, TAB_FV_DIRECTORY, Phase + "PcdDataBase.raw")
else:
DbFileName = os.path.join(Info.OutputDir, Phase + "PcdDataBase.raw")
DbFile = StringIO()
@@ -1054,7 +1054,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase): PcdDriverAutoGenData[(skuname,skuid)] = (AdditionalAutoGenH, AdditionalAutoGenC)
VarCheckTableData[(skuname,skuid)] = VarCheckTab
if Platform.Platform.VarCheckFlag:
- dest = os.path.join(Platform.BuildDir, 'FV')
+ dest = os.path.join(Platform.BuildDir, TAB_FV_DIRECTORY)
VarCheckTable = CreateVarCheckBin(VarCheckTableData)
VarCheckTable.dump(dest, Phase)
AdditionalAutoGenH, AdditionalAutoGenC = CreateAutoGen(PcdDriverAutoGenData)
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index 2662132e51..5030df27b4 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -40,6 +40,7 @@ TAB_UINT16 = 'UINT16' TAB_UINT32 = 'UINT32'
TAB_UINT64 = 'UINT64'
TAB_VOID = 'VOID*'
+TAB_GUID = 'GUID'
TAB_PCD_CLEAN_NUMERIC_TYPES = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64}
TAB_PCD_NUMERIC_TYPES = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN'}
@@ -48,6 +49,7 @@ TAB_PCD_NUMERIC_TYPES_VOID = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BO TAB_EDK_SOURCE = '$(EDK_SOURCE)'
TAB_EFI_SOURCE = '$(EFI_SOURCE)'
TAB_WORKSPACE = '$(WORKSPACE)'
+TAB_FV_DIRECTORY = 'FV'
TAB_ARCH_NULL = ''
TAB_ARCH_COMMON = 'COMMON'
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index 53504c110d..9fec10d2bb 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -951,7 +951,7 @@ class ValueExpressionEx(ValueExpression): Size = 0
ValueStr = ''
TokenSpaceGuidName = ''
- if Item.startswith('GUID') and Item.endswith(')'):
+ if Item.startswith(TAB_GUID) and Item.endswith(')'):
try:
TokenSpaceGuidName = re.search('GUID\((\w+)\)', Item).group(1)
except:
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index f05ae39ebb..3d205197ab 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1219,7 +1219,7 @@ class tdict: def IsFieldValueAnArray (Value):
Value = Value.strip()
- if Value.startswith('GUID') and Value.endswith(')'):
+ if Value.startswith(TAB_GUID) and Value.endswith(')'):
return True
if Value.startswith('L"') and Value.endswith('"') and len(list(Value[2:-1])) > 1:
return True
@@ -1316,7 +1316,7 @@ def ParseFieldValue (Value): if Size > 8:
raise BadExpression('Value (%s) Size larger than %d' % (Value, Size))
return Value, 8
- if Value.startswith('GUID') and Value.endswith(')'):
+ if Value.startswith(TAB_GUID) and Value.endswith(')'):
Value = Value.split('(', 1)[1][:-1].strip()
if Value[0] == '{' and Value[-1] == '}':
TmpValue = GuidStructureStringToGuidString(Value)
diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py index 99d7392aaa..29caa00c0d 100644 --- a/BaseTools/Source/Python/GenFds/DataSection.py +++ b/BaseTools/Source/Python/GenFds/DataSection.py @@ -82,7 +82,7 @@ class DataSection (DataSectionClassObject): CopyLongFilePath(MapFile, CopyMapFile)
#Get PE Section alignment when align is set to AUTO
- if self.Alignment == 'Auto' and self.SecType in ('TE', 'PE32'):
+ if self.Alignment == 'Auto' and self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
ImageObj = PeImageClass (Filename)
if ImageObj.SectionAlignment < 0x400:
self.Alignment = str (ImageObj.SectionAlignment)
@@ -92,7 +92,7 @@ class DataSection (DataSectionClassObject): self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
NoStrip = True
- if self.SecType in ('TE', 'PE32'):
+ if self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
if self.KeepReloc is not None:
NoStrip = self.KeepReloc
@@ -110,7 +110,7 @@ class DataSection (DataSectionClassObject): )
self.SectFileName = StrippedFile
- if self.SecType == 'TE':
+ if self.SecType == BINARY_FILE_TYPE_TE:
TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
GenFdsGlobalVariable.GenerateFirmwareImage(
TeFile,
diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Source/Python/GenFds/DepexSection.py index d04160e890..f42162d5a2 100644 --- a/BaseTools/Source/Python/GenFds/DepexSection.py +++ b/BaseTools/Source/Python/GenFds/DepexSection.py @@ -96,13 +96,13 @@ class DepexSection (DepexSectionClassObject): if self.DepexType == 'PEI_DEPEX_EXP':
ModuleType = SUP_MODULE_PEIM
- SecType = 'PEI_DEPEX'
+ SecType = BINARY_FILE_TYPE_PEI_DEPEX
elif self.DepexType == 'DXE_DEPEX_EXP':
ModuleType = SUP_MODULE_DXE_DRIVER
- SecType = 'DXE_DEPEX'
+ SecType = BINARY_FILE_TYPE_DXE_DEPEX
elif self.DepexType == 'SMM_DEPEX_EXP':
ModuleType = SUP_MODULE_DXE_SMM_DRIVER
- SecType = 'SMM_DEPEX'
+ SecType = BINARY_FILE_TYPE_SMM_DEPEX
else:
EdkLogger.error("GenFds", FORMAT_INVALID,
"Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py index 1be23b4bf7..5405d0a8da 100644 --- a/BaseTools/Source/Python/GenFds/EfiSection.py +++ b/BaseTools/Source/Python/GenFds/EfiSection.py @@ -67,7 +67,7 @@ class EfiSection (EfiSectionClassObject): StringData = FfsInf.__ExtendMacro__(self.StringData)
ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)')
NoStrip = True
- if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in ('TE', 'PE32'):
+ if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
if FfsInf.KeepReloc is not None:
NoStrip = FfsInf.KeepReloc
elif FfsInf.KeepRelocFromRule is not None:
@@ -171,9 +171,9 @@ class EfiSection (EfiSectionClassObject): OutputFileList.append(OutputFile)
#
- # If Section Type is 'UI'
+ # If Section Type is BINARY_FILE_TYPE_UI
#
- elif SectionType == 'UI':
+ elif SectionType == BINARY_FILE_TYPE_UI:
InfOverrideUiString = False
if FfsInf.Ui is not None:
@@ -242,7 +242,7 @@ class EfiSection (EfiSectionClassObject): File = GenFdsGlobalVariable.MacroExtend(File, Dict)
#Get PE Section alignment when align is set to AUTO
- if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
+ if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
ImageObj = PeImageClass (File)
if ImageObj.SectionAlignment < 0x400:
Align = str (ImageObj.SectionAlignment)
@@ -287,7 +287,7 @@ class EfiSection (EfiSectionClassObject): """For TE Section call GenFw to generate TE image"""
- if SectionType == 'TE':
+ if SectionType == BINARY_FILE_TYPE_TE:
TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
GenFdsGlobalVariable.GenerateFirmwareImage(
TeFile,
diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py index cc4124ad90..188ca28cd7 100644 --- a/BaseTools/Source/Python/GenFds/Fd.py +++ b/BaseTools/Source/Python/GenFds/Fd.py @@ -27,6 +27,7 @@ from Common import EdkLogger from Common.BuildToolError import *
from Common.Misc import SaveFileOnChange
from GenFds import GenFds
+from Common.DataType import BINARY_FILE_TYPE_FV
## generate FD
#
@@ -158,7 +159,7 @@ class FD(FDClassObject): FvAddDict ={}
FvList = []
for RegionObj in self.RegionList:
- if RegionObj.RegionType == 'FV':
+ if RegionObj.RegionType == BINARY_FILE_TYPE_FV:
if len(RegionObj.RegionDataList) == 1:
RegionData = RegionObj.RegionDataList[0]
FvList.append(RegionData.upper())
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 469cb128ba..49ed4041a2 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -1843,7 +1843,7 @@ class FdfParser: if not self.__GetNextWord():
return True
- if not self.__Token in ("SET", "FV", "FILE", "DATA", "CAPSULE", "INF"):
+ if not self.__Token in ("SET", BINARY_FILE_TYPE_FV, "FILE", "DATA", "CAPSULE", "INF"):
#
# If next token is a word which is not a valid FV type, it might be part of [PcdOffset[|PcdSize]]
# Or it might be next region's offset described by an expression which starts with a PCD.
@@ -1874,7 +1874,7 @@ class FdfParser: if not self.__GetNextWord():
return True
- elif self.__Token == "FV":
+ elif self.__Token == BINARY_FILE_TYPE_FV:
self.__UndoToken()
self.__GetRegionFvType( RegionObj)
@@ -1918,8 +1918,8 @@ class FdfParser: #
def __GetRegionFvType(self, RegionObj):
- if not self.__IsKeyword( "FV"):
- raise Warning("expected Keyword 'FV'", self.FileName, self.CurrentLineNumber)
+ if not self.__IsKeyword( BINARY_FILE_TYPE_FV):
+ raise Warning("expected Keyword BINARY_FILE_TYPE_FV", self.FileName, self.CurrentLineNumber)
if not self.__IsToken( "="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
@@ -1927,10 +1927,10 @@ class FdfParser: if not self.__GetNextToken():
raise Warning("expected FV name", self.FileName, self.CurrentLineNumber)
- RegionObj.RegionType = "FV"
+ RegionObj.RegionType = BINARY_FILE_TYPE_FV
RegionObj.RegionDataList.append((self.__Token).upper())
- while self.__IsKeyword( "FV"):
+ while self.__IsKeyword( BINARY_FILE_TYPE_FV):
if not self.__IsToken( "="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
@@ -2528,7 +2528,7 @@ class FdfParser: if self.__GetStringData():
FfsInfObj.Version = self.__Token
- if self.__IsKeyword( "UI"):
+ if self.__IsKeyword( BINARY_FILE_TYPE_UI):
if not self.__IsToken( "="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
@@ -2641,7 +2641,7 @@ class FdfParser: #
@staticmethod
def __SectionCouldHaveRelocFlag (SectionType):
- if SectionType in ('TE', 'PE32'):
+ if SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
return True
else:
return False
@@ -2674,7 +2674,7 @@ class FdfParser: if not self.__GetNextToken():
raise Warning("expected File name or section data", self.FileName, self.CurrentLineNumber)
- if self.__Token == "FV":
+ if self.__Token == BINARY_FILE_TYPE_FV:
if not self.__IsToken( "="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
@@ -2881,7 +2881,7 @@ class FdfParser: VerSectionObj.FileName = self.__Token
Obj.SectionList.append(VerSectionObj)
- elif self.__IsKeyword( "UI"):
+ elif self.__IsKeyword( BINARY_FILE_TYPE_UI):
if AlignValue == 'Auto':
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
if not self.__IsToken( "="):
@@ -2965,10 +2965,10 @@ class FdfParser: self.SetFileBufferPos(OldPos)
return False
- if self.__Token not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
- "UI", "VERSION", "PEI_DEPEX", "SUBTYPE_GUID", "SMM_DEPEX"):
+ if self.__Token not in ("COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+ BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, "SUBTYPE_GUID", BINARY_FILE_TYPE_SMM_DEPEX):
raise Warning("Unknown section type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
- if AlignValue == 'Auto'and (not self.__Token == 'PE32') and (not self.__Token == 'TE'):
+ if AlignValue == 'Auto'and (not self.__Token == BINARY_FILE_TYPE_PE32) and (not self.__Token == BINARY_FILE_TYPE_TE):
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
# DataSection
@@ -3386,7 +3386,7 @@ class FdfParser: #
def __GetFvStatement(self, CapsuleObj, FMPCapsule = False):
- if not self.__IsKeyword("FV"):
+ if not self.__IsKeyword(BINARY_FILE_TYPE_FV):
return False
if not self.__IsToken("="):
@@ -3534,7 +3534,7 @@ class FdfParser: AfileBaseName = os.path.basename(AfileName)
if os.path.splitext(AfileBaseName)[1] not in [".bin",".BIN",".Bin",".dat",".DAT",".Dat",".data",".DATA",".Data"]:
- raise Warning('invalid binary file type, should be one of "bin","BIN","Bin","dat","DAT","Dat","data","DATA","Data"', \
+ raise Warning('invalid binary file type, should be one of "bin",BINARY_FILE_TYPE_BIN,"Bin","dat","DAT","Dat","data","DATA","Data"', \
self.FileName, self.CurrentLineNumber)
if not os.path.isabs(AfileName):
@@ -3767,8 +3767,8 @@ class FdfParser: SectionName = self.__Token
- if SectionName not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
- "UI", "PEI_DEPEX", "VERSION", "SUBTYPE_GUID", "SMM_DEPEX"):
+ if SectionName not in ("COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+ BINARY_FILE_TYPE_UI, BINARY_FILE_TYPE_PEI_DEPEX, "VERSION", "SUBTYPE_GUID", BINARY_FILE_TYPE_SMM_DEPEX):
raise Warning("Unknown leaf section name '%s'" % SectionName, self.FileName, self.CurrentLineNumber)
@@ -3783,7 +3783,7 @@ class FdfParser: if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
"256K", "512K", "1M", "2M", "4M", "8M", "16M"):
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
- if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
+ if self.__Token == 'Auto' and (not SectionName == BINARY_FILE_TYPE_PE32) and (not SectionName == BINARY_FILE_TYPE_TE):
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
SectAlignment = self.__Token
@@ -3824,8 +3824,8 @@ class FdfParser: return False
SectionName = self.__Token
- if SectionName not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
- "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
+ if SectionName not in ("COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+ BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID, BINARY_FILE_TYPE_SMM_DEPEX):
self.__UndoToken()
return False
@@ -3855,8 +3855,8 @@ class FdfParser: FvImageSectionObj.FvName = None
else:
- if not self.__IsKeyword("FV"):
- raise Warning("expected 'FV'", self.FileName, self.CurrentLineNumber)
+ if not self.__IsKeyword(BINARY_FILE_TYPE_FV):
+ raise Warning("expected BINARY_FILE_TYPE_FV", self.FileName, self.CurrentLineNumber)
FvImageSectionObj.FvFileType = self.__Token
if self.__GetAlignment():
@@ -3868,8 +3868,8 @@ class FdfParser: if self.__IsToken('|'):
FvImageSectionObj.FvFileExtension = self.__GetFileExtension()
elif self.__GetNextToken():
- if self.__Token not in ("}", "COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
- "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
+ if self.__Token not in ("}", "COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+ BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID, BINARY_FILE_TYPE_SMM_DEPEX):
FvImageSectionObj.FvFileName = self.__Token
else:
self.__UndoToken()
@@ -3931,7 +3931,7 @@ class FdfParser: if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
"256K", "512K", "1M", "2M", "4M", "8M", "16M"):
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
- if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
+ if self.__Token == 'Auto' and (not SectionName == BINARY_FILE_TYPE_PE32) and (not SectionName == BINARY_FILE_TYPE_TE):
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
EfiSectionObj.Alignment = self.__Token
@@ -3950,8 +3950,8 @@ class FdfParser: if self.__IsToken('|'):
EfiSectionObj.FileExtension = self.__GetFileExtension()
elif self.__GetNextToken():
- if self.__Token not in ("}", "COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
- "UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
+ if self.__Token not in ("}", "COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,\
+ BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, BINARY_FILE_TYPE_GUID, BINARY_FILE_TYPE_SMM_DEPEX):
if self.__Token.startswith('PCD'):
self.__UndoToken()
@@ -3985,7 +3985,7 @@ class FdfParser: #
@staticmethod
def __RuleSectionCouldBeOptional(SectionType):
- if SectionType in ("DXE_DEPEX", "UI", "VERSION", "PEI_DEPEX", "RAW", "SMM_DEPEX"):
+ if SectionType in (BINARY_FILE_TYPE_DXE_DEPEX, BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE_TYPE_PEI_DEPEX, "RAW", BINARY_FILE_TYPE_SMM_DEPEX):
return True
else:
return False
@@ -4015,7 +4015,7 @@ class FdfParser: #
@staticmethod
def __RuleSectionCouldHaveString(SectionType):
- if SectionType in ("UI", "VERSION"):
+ if SectionType in (BINARY_FILE_TYPE_UI, "VERSION"):
return True
else:
return False
@@ -4032,32 +4032,32 @@ class FdfParser: if SectionType == "COMPAT16":
if FileType not in ("COMPAT16", "SEC_COMPAT16"):
raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
- elif SectionType == "PE32":
- if FileType not in ("PE32", "SEC_PE32"):
+ elif SectionType == BINARY_FILE_TYPE_PE32:
+ if FileType not in (BINARY_FILE_TYPE_PE32, "SEC_PE32"):
raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
- elif SectionType == "PIC":
- if FileType not in ("PIC", "PIC"):
+ elif SectionType == BINARY_FILE_TYPE_PIC:
+ if FileType not in (BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_PIC):
raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
- elif SectionType == "TE":
- if FileType not in ("TE", "SEC_TE"):
+ elif SectionType == BINARY_FILE_TYPE_TE:
+ if FileType not in (BINARY_FILE_TYPE_TE, "SEC_TE"):
raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
elif SectionType == "RAW":
- if FileType not in ("BIN", "SEC_BIN", "RAW", "ASL", "ACPI"):
+ if FileType not in (BINARY_FILE_TYPE_BIN, "SEC_BIN", "RAW", "ASL", "ACPI"):
raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
- elif SectionType == "DXE_DEPEX" or SectionType == "SMM_DEPEX":
- if FileType not in ("DXE_DEPEX", "SEC_DXE_DEPEX", "SMM_DEPEX"):
+ elif SectionType == BINARY_FILE_TYPE_DXE_DEPEX or SectionType == BINARY_FILE_TYPE_SMM_DEPEX:
+ if FileType not in (BINARY_FILE_TYPE_DXE_DEPEX, "SEC_DXE_DEPEX", BINARY_FILE_TYPE_SMM_DEPEX):
raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
- elif SectionType == "UI":
- if FileType not in ("UI", "SEC_UI"):
+ elif SectionType == BINARY_FILE_TYPE_UI:
+ if FileType not in (BINARY_FILE_TYPE_UI, "SEC_UI"):
raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
elif SectionType == "VERSION":
if FileType not in ("VERSION", "SEC_VERSION"):
raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
- elif SectionType == "PEI_DEPEX":
- if FileType not in ("PEI_DEPEX", "SEC_PEI_DEPEX"):
+ elif SectionType == BINARY_FILE_TYPE_PEI_DEPEX:
+ if FileType not in (BINARY_FILE_TYPE_PEI_DEPEX, "SEC_PEI_DEPEX"):
raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
- elif SectionType == "GUID":
- if FileType not in ("PE32", "SEC_GUID"):
+ elif SectionType == BINARY_FILE_TYPE_GUID:
+ if FileType not in (BINARY_FILE_TYPE_PE32, "SEC_GUID"):
raise Warning("Incorrect section file type '%s'" % FileType, self.FileName, self.CurrentLineNumber)
## __GetRuleEncapsulationSection() method
@@ -4494,7 +4494,7 @@ class FdfParser: FfsFileObj = OptRomFileStatement.OptRomFileStatement()
- if not self.__IsKeyword("EFI") and not self.__IsKeyword("BIN"):
+ if not self.__IsKeyword("EFI") and not self.__IsKeyword(BINARY_FILE_TYPE_BIN):
raise Warning("expected Binary type (EFI/BIN)", self.FileName, self.CurrentLineNumber)
FfsFileObj.FileType = self.__Token
@@ -4575,7 +4575,7 @@ class FdfParser: if FdName.upper() in self.Profile.FdDict:
FdObj = self.Profile.FdDict[FdName.upper()]
for elementRegion in FdObj.RegionList:
- if elementRegion.RegionType == 'FV':
+ if elementRegion.RegionType == BINARY_FILE_TYPE_FV:
for elementRegionData in elementRegion.RegionDataList:
if elementRegionData.endswith(".fv"):
continue
diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Python/GenFds/Ffs.py index 4de9c74366..df585f3d81 100644 --- a/BaseTools/Source/Python/GenFds/Ffs.py +++ b/BaseTools/Source/Python/GenFds/Ffs.py @@ -42,12 +42,12 @@ class Ffs(FDClassObject): # mapping between section type in FDF and file suffix
SectionSuffix = {
- 'PE32' : '.pe32',
- 'PIC' : '.pic',
- 'TE' : '.te',
- 'DXE_DEPEX' : '.dpx',
+ BINARY_FILE_TYPE_PE32 : '.pe32',
+ BINARY_FILE_TYPE_PIC : '.pic',
+ BINARY_FILE_TYPE_TE : '.te',
+ BINARY_FILE_TYPE_DXE_DEPEX : '.dpx',
'VERSION' : '.ver',
- 'UI' : '.ui',
+ BINARY_FILE_TYPE_UI : '.ui',
'COMPAT16' : '.com16',
'RAW' : '.raw',
'FREEFORM_SUBTYPE_GUID': '.guid',
@@ -55,8 +55,8 @@ class Ffs(FDClassObject): 'FV_IMAGE' : 'fv.sec',
'COMPRESS' : '.com',
'GUIDED' : '.guided',
- 'PEI_DEPEX' : '.dpx',
- 'SMM_DEPEX' : '.dpx'
+ BINARY_FILE_TYPE_PEI_DEPEX : '.dpx',
+ BINARY_FILE_TYPE_SMM_DEPEX : '.dpx'
}
## The constructor
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 9068157ba6..728997f17d 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -381,7 +381,7 @@ class FfsInfStatement(FfsInfStatementClassObject): #
# Only patch file if FileType is PE32 or ModuleType is USER_DEFINED
#
- if FileType != 'PE32' and self.ModuleType != SUP_MODULE_USER_DEFINED:
+ if FileType != BINARY_FILE_TYPE_PE32 and self.ModuleType != SUP_MODULE_USER_DEFINED:
return EfiFile
#
@@ -739,13 +739,13 @@ class FfsInfStatement(FfsInfStatementClassObject): # Convert Fv Section Type for PI1.1 SMM driver.
#
if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
- if SectionType == 'DXE_DEPEX':
- SectionType = 'SMM_DEPEX'
+ if SectionType == BINARY_FILE_TYPE_DXE_DEPEX:
+ SectionType = BINARY_FILE_TYPE_SMM_DEPEX
#
# Framework SMM Driver has no SMM_DEPEX section type
#
if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
- if SectionType == 'SMM_DEPEX':
+ if SectionType == BINARY_FILE_TYPE_SMM_DEPEX:
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
NoStrip = True
if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM):
@@ -767,7 +767,7 @@ class FfsInfStatement(FfsInfStatementClassObject): File = GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)
#Get PE Section alignment when align is set to AUTO
- if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
+ if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
ImageObj = PeImageClass (File)
if ImageObj.SectionAlignment < 0x400:
self.Alignment = str (ImageObj.SectionAlignment)
@@ -790,7 +790,7 @@ class FfsInfStatement(FfsInfStatementClassObject): )
File = StrippedFile
- if SectionType == 'TE':
+ if SectionType == BINARY_FILE_TYPE_TE:
TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
GenFdsGlobalVariable.GenerateFirmwareImage(
TeFile,
@@ -809,7 +809,7 @@ class FfsInfStatement(FfsInfStatementClassObject): GenSecInputFile = GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)
#Get PE Section alignment when align is set to AUTO
- if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
+ if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
ImageObj = PeImageClass (GenSecInputFile)
if ImageObj.SectionAlignment < 0x400:
self.Alignment = str (ImageObj.SectionAlignment)
@@ -833,7 +833,7 @@ class FfsInfStatement(FfsInfStatementClassObject): )
GenSecInputFile = StrippedFile
- if SectionType == 'TE':
+ if SectionType == BINARY_FILE_TYPE_TE:
TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
GenFdsGlobalVariable.GenerateFirmwareImage(
TeFile,
@@ -942,13 +942,13 @@ class FfsInfStatement(FfsInfStatementClassObject): # Convert Fv Section Type for PI1.1 SMM driver.
#
if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
- if Sect.SectionType == 'DXE_DEPEX':
- Sect.SectionType = 'SMM_DEPEX'
+ if Sect.SectionType == BINARY_FILE_TYPE_DXE_DEPEX:
+ Sect.SectionType = BINARY_FILE_TYPE_SMM_DEPEX
#
# Framework SMM Driver has no SMM_DEPEX section type
#
if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:
- if Sect.SectionType == 'SMM_DEPEX':
+ if Sect.SectionType == BINARY_FILE_TYPE_SMM_DEPEX:
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
#
# process the inside FvImage from FvSection or GuidSection
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py index 0fb2bd456a..adb7c185b8 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -29,6 +29,7 @@ from CommonDataClass.FdfClass import FvClassObject from Common.Misc import SaveFileOnChange
from Common.LongFilePathSupport import CopyLongFilePath
from Common.LongFilePathSupport import OpenLongFilePath as open
+from Common.DataType import *
T_CHAR_LF = '\n'
FV_UI_EXT_ENTY_GUID = 'A67DF1FA-8DE8-4E98-AF09-4BDF2EFFBC7C'
@@ -80,7 +81,7 @@ class FV (FvClassObject): if self.CapsuleName is not None:
for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
for RegionObj in FdObj.RegionList:
- if RegionObj.RegionType == 'FV':
+ if RegionObj.RegionType == BINARY_FILE_TYPE_FV:
for RegionData in RegionObj.RegionDataList:
if RegionData.endswith(".fv"):
continue
@@ -236,7 +237,7 @@ class FV (FvClassObject): for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
for RegionObj in FdObj.RegionList:
- if RegionObj.RegionType != 'FV':
+ if RegionObj.RegionType != BINARY_FILE_TYPE_FV:
continue
for RegionData in RegionObj.RegionDataList:
#
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index 54c7d82830..ccd137955d 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -315,7 +315,7 @@ def main(): for Fd in FdfParserObj.Profile.FdDict:
FdObj = FdfParserObj.Profile.FdDict[Fd]
for RegionObj in FdObj.RegionList:
- if RegionObj.RegionType != 'FV':
+ if RegionObj.RegionType != BINARY_FILE_TYPE_FV:
continue
for RegionData in RegionObj.RegionDataList:
if FvObj.UiFvName.upper() == RegionData.upper():
@@ -405,7 +405,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): KeyList[1] + \
'_' + \
KeyList[2]
- if Key in KeyStringList and KeyList[4] == 'GUID':
+ if Key in KeyStringList and KeyList[4] == TAB_GUID:
ToolPathKey = Key + '_' + KeyList[3] + '_PATH'
ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
ToolPath = ToolDefinition.get(ToolPathKey)
@@ -447,7 +447,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): if NameGuid == BuildOption[Op]:
KeyList = Op.split('_')
Key = KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2]
- if Key in KeyStringList and KeyList[4] == 'GUID':
+ if Key in KeyStringList and KeyList[4] == TAB_GUID:
ToolPathKey = Key + '_' + KeyList[3] + '_PATH'
ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
if ToolPathKey in BuildOption:
@@ -589,7 +589,7 @@ class GenFds : if FdObj is None:
for ElementFd in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
for ElementRegion in ElementFd.RegionList:
- if ElementRegion.RegionType == 'FV':
+ if ElementRegion.RegionType == BINARY_FILE_TYPE_FV:
for ElementRegionData in ElementRegion.RegionDataList:
if ElementRegionData is not None and ElementRegionData.upper() == FvObj.UiFvName:
if FvObj.BlockSizeList != []:
@@ -601,7 +601,7 @@ class GenFds : return DefaultBlockSize
else:
for ElementRegion in FdObj.RegionList:
- if ElementRegion.RegionType == 'FV':
+ if ElementRegion.RegionType == BINARY_FILE_TYPE_FV:
for ElementRegionData in ElementRegion.RegionDataList:
if ElementRegionData is not None and ElementRegionData.upper() == FvObj.UiFvName:
if FvObj.BlockSizeList != []:
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index 909d043c2a..2fb98007ab 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -288,7 +288,7 @@ class GenFdsGlobalVariable: # GenFdsGlobalVariable.OutputDirDict = OutputDir
GenFdsGlobalVariable.FdfParser = FdfParser
GenFdsGlobalVariable.WorkSpace = WorkSpace
- GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV')
+ GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.TAB_FV_DIRECTORY)
if not os.path.exists(GenFdsGlobalVariable.FvDir) :
os.makedirs(GenFdsGlobalVariable.FvDir)
GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')
@@ -349,7 +349,7 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.PlatformName = WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,
GlobalData.gGlobalDefines['TARGET'],
GlobalData.gGlobalDefines['TOOLCHAIN']].PlatformName
- GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV')
+ GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.TAB_FV_DIRECTORY)
if not os.path.exists(GenFdsGlobalVariable.FvDir):
os.makedirs(GenFdsGlobalVariable.FvDir)
GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')
diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py index 8f8761b205..a865ac4436 100644 --- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py +++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py @@ -141,7 +141,7 @@ class OptRomInfStatement (FfsInfStatement): OutputFileList = []
for Sect in Rule.SectionList:
- if Sect.SectionType == 'PE32':
+ if Sect.SectionType == BINARY_FILE_TYPE_PE32:
if Sect.FileName is not None:
GenSecInputFile = self.__ExtendMacro__(Sect.FileName)
OutputFileList.append(GenSecInputFile)
diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py index 44f122a712..9d632b6321 100644 --- a/BaseTools/Source/Python/GenFds/Region.py +++ b/BaseTools/Source/Python/GenFds/Region.py @@ -26,6 +26,7 @@ from Common import EdkLogger from Common.BuildToolError import *
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
+from Common.DataType import BINARY_FILE_TYPE_FV
## generate Region
#
@@ -80,10 +81,10 @@ class Region(RegionClassObject): GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' % self.Offset)
GenFdsGlobalVariable.InfLogger(" Region Size = 0x%X" % Size)
GenFdsGlobalVariable.SharpCounter = 0
- if Flag and (self.RegionType != 'FV'):
+ if Flag and (self.RegionType != BINARY_FILE_TYPE_FV):
return
- if self.RegionType == 'FV':
+ if self.RegionType == BINARY_FILE_TYPE_FV:
#
# Get Fv from FvDict
#
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py index 4b368b3ada..5895998158 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -20,7 +20,7 @@ from GenFdsGlobalVariable import GenFdsGlobalVariable import Common.LongFilePathOs as os, glob
from Common import EdkLogger
from Common.BuildToolError import *
-from Common.DataType import TAB_ARCH_COMMON
+from Common.DataType import *
## section base class
#
@@ -29,37 +29,37 @@ class Section (SectionClassObject): SectionType = {
'RAW' : 'EFI_SECTION_RAW',
'FREEFORM' : 'EFI_SECTION_FREEFORM_SUBTYPE_GUID',
- 'PE32' : 'EFI_SECTION_PE32',
- 'PIC' : 'EFI_SECTION_PIC',
- 'TE' : 'EFI_SECTION_TE',
+ BINARY_FILE_TYPE_PE32 : 'EFI_SECTION_PE32',
+ BINARY_FILE_TYPE_PIC : 'EFI_SECTION_PIC',
+ BINARY_FILE_TYPE_TE : 'EFI_SECTION_TE',
'FV_IMAGE' : 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE',
- 'DXE_DEPEX' : 'EFI_SECTION_DXE_DEPEX',
- 'PEI_DEPEX' : 'EFI_SECTION_PEI_DEPEX',
+ BINARY_FILE_TYPE_DXE_DEPEX : 'EFI_SECTION_DXE_DEPEX',
+ BINARY_FILE_TYPE_PEI_DEPEX : 'EFI_SECTION_PEI_DEPEX',
'GUIDED' : 'EFI_SECTION_GUID_DEFINED',
'COMPRESS' : 'EFI_SECTION_COMPRESSION',
- 'UI' : 'EFI_SECTION_USER_INTERFACE',
- 'SMM_DEPEX' : 'EFI_SECTION_SMM_DEPEX'
+ BINARY_FILE_TYPE_UI : 'EFI_SECTION_USER_INTERFACE',
+ BINARY_FILE_TYPE_SMM_DEPEX : 'EFI_SECTION_SMM_DEPEX'
}
BinFileType = {
- 'GUID' : '.guid',
+ BINARY_FILE_TYPE_GUID : '.guid',
'ACPI' : '.acpi',
'ASL' : '.asl' ,
- 'UEFI_APP' : '.app',
- 'LIB' : '.lib',
- 'PE32' : '.pe32',
- 'PIC' : '.pic',
- 'PEI_DEPEX' : '.depex',
+ BINARY_FILE_TYPE_UEFI_APP : '.app',
+ BINARY_FILE_TYPE_LIB : '.lib',
+ BINARY_FILE_TYPE_PE32 : '.pe32',
+ BINARY_FILE_TYPE_PIC : '.pic',
+ BINARY_FILE_TYPE_PEI_DEPEX : '.depex',
'SEC_PEI_DEPEX' : '.depex',
- 'TE' : '.te',
- 'UNI_VER' : '.ver',
- 'VER' : '.ver',
- 'UNI_UI' : '.ui',
- 'UI' : '.ui',
- 'BIN' : '.bin',
+ BINARY_FILE_TYPE_TE : '.te',
+ BINARY_FILE_TYPE_UNI_VER : '.ver',
+ BINARY_FILE_TYPE_VER : '.ver',
+ BINARY_FILE_TYPE_UNI_UI : '.ui',
+ BINARY_FILE_TYPE_UI : '.ui',
+ BINARY_FILE_TYPE_BIN : '.bin',
'RAW' : '.raw',
'COMPAT16' : '.comp16',
- 'FV' : '.fv'
+ BINARY_FILE_TYPE_FV : '.fv'
}
SectFileType = {
@@ -128,8 +128,8 @@ class Section (SectionClassObject): for File in FfsInf.BinFileList:
if File.Arch == TAB_ARCH_COMMON or FfsInf.CurrentArch == File.Arch:
if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A \
- and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX') \
- or (FileType == 'TE'and File.Type == 'PE32'):
+ and FileType == 'DXE_DPEX' and File.Type == BINARY_FILE_TYPE_SMM_DEPEX) \
+ or (FileType == BINARY_FILE_TYPE_TE and File.Type == BINARY_FILE_TYPE_PE32):
if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:
FileList.append(FfsInf.PatchEfiFile(File.Path, File.Type))
else:
diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source/Python/GenFds/UiSection.py index 084f761e12..280500952b 100644 --- a/BaseTools/Source/Python/GenFds/UiSection.py +++ b/BaseTools/Source/Python/GenFds/UiSection.py @@ -22,7 +22,7 @@ import Common.LongFilePathOs as os from GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import UiSectionClassObject
from Common.LongFilePathSupport import OpenLongFilePath as open
-from Common.DataType import SUP_MODULE_SEC
+from Common.DataType import *
## generate UI section
#
@@ -58,7 +58,7 @@ class UiSection (UiSectionClassObject): self.StringData = FfsInf.__ExtendMacro__(self.StringData)
self.FileName = FfsInf.__ExtendMacro__(self.FileName)
- OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get('UI'))
+ OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get(BINARY_FILE_TYPE_UI))
if self.StringData is not None :
NameString = self.StringData
diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py index 3eb7fa3920..a740758591 100644 --- a/BaseTools/Source/Python/Trim/Trim.py +++ b/BaseTools/Source/Python/Trim/Trim.py @@ -23,6 +23,7 @@ from optparse import OptionParser from optparse import make_option
from Common.BuildToolError import *
from Common.Misc import *
+from Common.DataType import *
from Common.BuildVersion import gBUILD_VERSION
import Common.EdkLogger as EdkLogger
from Common.LongFilePathSupport import OpenLongFilePath as open
@@ -303,7 +304,7 @@ def TrimPreprocessedVfr(Source, Target): FoundTypedef = False
TypedefEnd = Index
# keep all "typedef struct" except to GUID, EFI_PLABEL and PAL_CALL_RETURN
- if Line.strip("} ;\r\n") in ["GUID", "EFI_PLABEL", "PAL_CALL_RETURN"]:
+ if Line.strip("} ;\r\n") in [TAB_GUID, "EFI_PLABEL", "PAL_CALL_RETURN"]:
for i in range(TypedefStart, TypedefEnd+1):
Lines[i] = "\n"
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 49bf5df632..6aaa21db5d 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1500,7 +1500,7 @@ class DscBuildData(PlatformBuildClassObject): def get_length(value):
Value = value.strip()
if len(value) > 1:
- if Value.startswith('GUID') and Value.endswith(')'):
+ if Value.startswith(TAB_GUID) and Value.endswith(')'):
return 16
if Value.startswith('L"') and Value.endswith('"'):
return len(Value[2:-1])
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py index 157f7a2d2d..cf5e1df3a5 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -71,7 +71,7 @@ class InfBuildData(ModuleBuildClassObject): # dict used to convert old tool name used in [nmake] section to new ones
_TOOL_CODE_ = {
"C" : "CC",
- "LIB" : "SLINK",
+ BINARY_FILE_TYPE_LIB : "SLINK",
"LINK" : "DLINK",
}
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index e68cd7de2c..608aad1148 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -208,7 +208,7 @@ def FindIncludeFiles(Source, IncludePathList, IncludeFiles): FileName = "Protocol/%(Key)s/%(Key)s.h" % {"Key" : Key}
elif "PPI" in Type:
FileName = "Ppi/%(Key)s/%(Key)s.h" % {"Key" : Key}
- elif "GUID" in Type:
+ elif TAB_GUID in Type:
FileName = "Guid/%(Key)s/%(Key)s.h" % {"Key" : Key}
else:
continue
@@ -1410,7 +1410,7 @@ class PredictionReport(object): if Wa.FdfProfile:
for Fd in Wa.FdfProfile.FdDict:
for FdRegion in Wa.FdfProfile.FdDict[Fd].RegionList:
- if FdRegion.RegionType != "FV":
+ if FdRegion.RegionType != BINARY_FILE_TYPE_FV:
continue
for FvName in FdRegion.RegionDataList:
if FvName in self._FvList:
@@ -1686,7 +1686,7 @@ class FdRegionReport(object): # If the input FdRegion is not a firmware volume,
# we are done.
#
- if self.Type != "FV":
+ if self.Type != BINARY_FILE_TYPE_FV:
return
#
@@ -1780,7 +1780,7 @@ class FdRegionReport(object): FileWrite(File, "Type: %s" % Type)
FileWrite(File, "Base Address: 0x%X" % BaseAddress)
- if self.Type == "FV":
+ if self.Type == BINARY_FILE_TYPE_FV:
FvTotalSize = 0
FvTakenSize = 0
FvFreeSize = 0
@@ -1843,7 +1843,7 @@ class FdRegionReport(object): if (len(self.FvList) > 0):
for FvItem in self.FvList:
Info = self.FvInfo[FvItem]
- self._GenerateReport(File, Info[0], "FV", Info[1], Info[2], FvItem)
+ self._GenerateReport(File, Info[0], TAB_FV_DIRECTORY, Info[1], Info[2], FvItem)
else:
self._GenerateReport(File, "FD Region", self.Type, self.BaseAddress, self.Size)
@@ -1869,7 +1869,7 @@ class FdReport(object): self.BaseAddress = Fd.BaseAddress
self.Size = Fd.Size
self.FdRegionList = [FdRegionReport(FdRegion, Wa) for FdRegion in Fd.RegionList]
- self.FvPath = os.path.join(Wa.BuildDir, "FV")
+ self.FvPath = os.path.join(Wa.BuildDir, TAB_FV_DIRECTORY)
self.VpdFilePath = os.path.join(self.FvPath, "%s.map" % Wa.Platform.VpdToolGuid)
self.VPDBaseAddress = 0
self.VPDSize = 0
|