public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jaben Carsey <jaben.carsey@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Yonghong Zhu <yonghong.zhu@intel.com>
Subject: [PATCH v1 19/27] BaseTools: Replace Binary File type strings with predefined constant
Date: Fri, 20 Apr 2018 08:51:39 -0700	[thread overview]
Message-ID: <67ec988deb43275c4d34f124ade40e79d05d9691.1524239028.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1524239027.git.jaben.carsey@intel.com>
In-Reply-To: <cover.1524239027.git.jaben.carsey@intel.com>

BINARY_FILE_TYPE_FW was 'FW'
BINARY_FILE_TYPE_GUID was 'GUID'
BINARY_FILE_TYPE_PREEFORM was 'PREEFORM'
BINARY_FILE_TYPE_UEFI_APP was 'UEFI_APP'
BINARY_FILE_TYPE_UNI_UI was 'UNI_UI'
BINARY_FILE_TYPE_UNI_VER was 'UNI_VER'
BINARY_FILE_TYPE_LIB was 'LIB'
BINARY_FILE_TYPE_PE32 was 'PE32'
BINARY_FILE_TYPE_PIC was 'PIC'
BINARY_FILE_TYPE_PEI_DEPEX was 'PEI_DEPEX'
BINARY_FILE_TYPE_DXE_DEPEX was 'DXE_DEPEX'
BINARY_FILE_TYPE_SMM_DEPEX was 'SMM_DEPEX'
BINARY_FILE_TYPE_TE was 'TE'
BINARY_FILE_TYPE_VER was 'VER'
BINARY_FILE_TYPE_UI was 'UI'
BINARY_FILE_TYPE_BIN was 'BIN'
BINARY_FILE_TYPE_FV was 'FV'

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py             | 12 +--
 BaseTools/Source/Python/AutoGen/GenC.py                |  8 +-
 BaseTools/Source/Python/AutoGen/GenPcdDb.py            |  4 +-
 BaseTools/Source/Python/Common/Expression.py           |  2 +-
 BaseTools/Source/Python/Common/Misc.py                 |  4 +-
 BaseTools/Source/Python/GenFds/DataSection.py          |  6 +-
 BaseTools/Source/Python/GenFds/DepexSection.py         |  6 +-
 BaseTools/Source/Python/GenFds/EfiSection.py           | 10 +--
 BaseTools/Source/Python/GenFds/Fd.py                   |  3 +-
 BaseTools/Source/Python/GenFds/FdfParser.py            | 92 ++++++++++----------
 BaseTools/Source/Python/GenFds/Ffs.py                  | 14 +--
 BaseTools/Source/Python/GenFds/FfsInfStatement.py      | 22 ++---
 BaseTools/Source/Python/GenFds/Fv.py                   |  4 +-
 BaseTools/Source/Python/GenFds/GenFds.py               | 10 +--
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py |  4 +-
 BaseTools/Source/Python/GenFds/OptRomInfStatement.py   |  2 +-
 BaseTools/Source/Python/GenFds/Region.py               |  5 +-
 BaseTools/Source/Python/GenFds/Section.py              | 46 +++++-----
 BaseTools/Source/Python/GenFds/UiSection.py            |  2 +-
 BaseTools/Source/Python/Trim/Trim.py                   |  2 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py      |  2 +-
 BaseTools/Source/Python/Workspace/InfBuildData.py      |  2 +-
 BaseTools/Source/Python/build/BuildReport.py           | 12 +--
 23 files changed, 138 insertions(+), 136 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 9b2164ed8216..534fbe79fad9 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -923,7 +923,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, BINARY_FILE_TYPE_FV)
         return self._FvDir
 
     ## Return the directory to store all intermediate and final files built
@@ -1326,7 +1326,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, BINARY_FILE_TYPE_FV, "%s.map" % self.Platform.VpdToolGuid)
             PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]
 
             if PcdNvStoreDfBuffer:
@@ -1719,7 +1719,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, BINARY_FILE_TYPE_FV, "%s.map" % self.Platform.VpdToolGuid)
                     if os.path.exists(VpdMapFilePath):
                         VpdFile.Read(VpdMapFilePath)
 
@@ -1770,7 +1770,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, BINARY_FILE_TYPE_FV)
         if not os.path.exists(FvPath):
             try:
                 os.makedirs(FvPath)
@@ -1783,7 +1783,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(BINARY_FILE_TYPE_GUID) and ToolDef[BINARY_FILE_TYPE_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"]
@@ -3032,7 +3032,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, BINARY_FILE_TYPE_FV, "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 6b2ee87b2211..ca54ac107e5d 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1614,7 +1614,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 = BINARY_FILE_TYPE_GUID
     else:
         GuidType = "EFI_GUID"
 
@@ -1638,7 +1638,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 = BINARY_FILE_TYPE_GUID
     else:
         GuidType = "EFI_GUID"
 
@@ -1662,7 +1662,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 = BINARY_FILE_TYPE_GUID
     else:
         GuidType = "EFI_GUID"
 
@@ -1699,7 +1699,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 = BINARY_FILE_TYPE_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 9374ca4820ef..63228795c001 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, BINARY_FILE_TYPE_FV, 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, BINARY_FILE_TYPE_FV)
             VarCheckTable = CreateVarCheckBin(VarCheckTableData)
             VarCheckTable.dump(dest, Phase)
         AdditionalAutoGenH, AdditionalAutoGenC =  CreateAutoGen(PcdDriverAutoGenData)
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 99929938fb5a..4b7d65583dc8 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -950,7 +950,7 @@ class ValueExpressionEx(ValueExpression):
                             Size = 0
                             ValueStr = ''
                             TokenSpaceGuidName = ''
-                            if Item.startswith('GUID') and Item.endswith(')'):
+                            if Item.startswith(BINARY_FILE_TYPE_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 4a6a29c7ae80..61617ed589b3 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(BINARY_FILE_TYPE_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(BINARY_FILE_TYPE_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 3c435c2fcc65..c066d4383549 100644
--- a/BaseTools/Source/Python/GenFds/DataSection.py
+++ b/BaseTools/Source/Python/GenFds/DataSection.py
@@ -81,7 +81,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)
@@ -91,7 +91,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
 
@@ -109,7 +109,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 d04160e890f1..f42162d5a27e 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 1be23b4bf7fd..5405d0a8da13 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 cc4124ad902e..188ca28cd7ce 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 23c04123af1b..b8848a25b4b2 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1850,7 +1850,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.
@@ -1881,7 +1881,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)
 
@@ -1925,8 +1925,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)
@@ -1934,10 +1934,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)
@@ -2535,7 +2535,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():
@@ -2648,7 +2648,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
@@ -2681,7 +2681,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():
@@ -2888,7 +2888,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( "="):
@@ -2972,10 +2972,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
@@ -3393,7 +3393,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("="):
@@ -3541,7 +3541,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):
@@ -3774,8 +3774,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)
 
 
@@ -3790,7 +3790,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
 
@@ -3831,8 +3831,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
 
@@ -3862,8 +3862,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():
@@ -3875,8 +3875,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()
@@ -3938,7 +3938,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
 
@@ -3957,8 +3957,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()
@@ -3992,7 +3992,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
@@ -4022,7 +4022,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
@@ -4039,32 +4039,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
@@ -4501,7 +4501,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
 
@@ -4582,7 +4582,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 f6a7f4b007f9..44ad01cb7354 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 8893fcbda1fc..b92fa4d8033c 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 71bcd4c72170..024081734a2b 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -80,7 +80,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 +236,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 54c7d828305f..8bedd9f74411 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] == BINARY_FILE_TYPE_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] == BINARY_FILE_TYPE_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 e692e4e98504..878b13d13c2d 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.BINARY_FILE_TYPE_FV)
         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.BINARY_FILE_TYPE_FV)
         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 8f8761b20589..a865ac4436d5 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 44f122a71216..9d632b6321e2 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 4b368b3ada9d..5895998158b6 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 084f761e1285..31d3edebb4ef 100644
--- a/BaseTools/Source/Python/GenFds/UiSection.py
+++ b/BaseTools/Source/Python/GenFds/UiSection.py
@@ -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 3eb7fa39209d..3afe759667ac 100644
--- a/BaseTools/Source/Python/Trim/Trim.py
+++ b/BaseTools/Source/Python/Trim/Trim.py
@@ -303,7 +303,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 [BINARY_FILE_TYPE_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 373441521723..6943fab4e5c8 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1506,7 +1506,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(BINARY_FILE_TYPE_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 157f7a2d2de8..cf5e1df3a523 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 c8948b5cfbd9..f551c3ac8f91 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 BINARY_FILE_TYPE_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], BINARY_FILE_TYPE_FV, 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, BINARY_FILE_TYPE_FV)
         self.VpdFilePath = os.path.join(self.FvPath, "%s.map" % Wa.Platform.VpdToolGuid)
         self.VPDBaseAddress = 0
         self.VPDSize = 0
-- 
2.16.2.windows.1



  parent reply	other threads:[~2018-04-20 15:51 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 15:51 [PATCH v1 00/27] BaseTools refactoring Jaben Carsey
2018-04-20 15:51 ` [PATCH v1 01/27] BaseTools: Misc - refactor RegEx to minimize multiple compiling Jaben Carsey
2018-04-25  8:49   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 02/27] BaseTools: GenPatchPcdTable " Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 03/27] BaseTools: Share RegEx between files Jaben Carsey
2018-04-25  8:51   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 04/27] BaseTools: Workspace - refactor RegEx to minimize multiple compiling Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 05/27] BaseTools: Autogen - replace string constants with those from DataType Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 06/27] BaseTools: simplify if call Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 07/27] BaseTools: Workspace - refactor GetStructurePcdInfo Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 08/27] BaseTools: AutoGen - remove dictionary populated, but never accessed Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 09/27] BaseTools: AutoGen - remove unused variables Jaben Carsey
2018-04-25  8:52   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 10/27] BaseTools: Remove extra .keys() Jaben Carsey
2018-04-25  8:51   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 11/27] BaseTools: Workspace/MetaFileParser - refactor dicts Jaben Carsey
2018-04-20 15:51 ` [PATCH v1 12/27] BaseTools: remove dict from DscBuildData Jaben Carsey
2018-04-25  8:50   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 13/27] BaseTools: replace string constants used for module types Jaben Carsey
2018-04-25  5:57   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 14/27] BaseTools: Define and use a set for common list Jaben Carsey
2018-05-02  6:48   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 15/27] BaseTools: Share a dictionary instead of keeping multiples Jaben Carsey
2018-04-20 15:51 ` [PATCH v1 16/27] BaseTools: Replace EDK Component strings with predefined constant Jaben Carsey
2018-04-24  7:42   ` Zhu, Yonghong
2018-04-24 14:13     ` Carsey, Jaben
2018-04-20 15:51 ` [PATCH v1 17/27] BaseTools: DataType - cleanup list constants Jaben Carsey
2018-05-04 11:14   ` Laszlo Ersek
2018-05-04 14:18     ` Carsey, Jaben
2018-05-04 15:03       ` Laszlo Ersek
2018-04-20 15:51 ` [PATCH v1 18/27] BaseTools: Replace PCD type strings with predefined constant Jaben Carsey
2018-04-25  6:00   ` Zhu, Yonghong
2018-04-20 15:51 ` Jaben Carsey [this message]
2018-04-24  7:38   ` [PATCH v1 19/27] BaseTools: Replace Binary File " Zhu, Yonghong
2018-04-24 14:12     ` Carsey, Jaben
2018-04-20 15:51 ` [PATCH v1 20/27] BaseTools: remove duplicate variable Jaben Carsey
2018-04-25  8:51   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 21/27] BaseTools: replace string with predefined constant Jaben Carsey
2018-04-25  6:04   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 22/27] BaseTools: remove redundant if comparison Jaben Carsey
2018-05-02  6:49   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 23/27] BaseTools: AutoGen - use dafultdict instead of dict Jaben Carsey
2018-04-20 15:51 ` [PATCH v1 24/27] BaseTools: GenFds - simplify testing for Hex number Jaben Carsey
2018-04-25  8:51   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto initialize Jaben Carsey
2018-04-25  8:52   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 26/27] BaseTools: remove unused MigrationUtilities.py Jaben Carsey
2018-05-02  6:49   ` Zhu, Yonghong
2018-04-20 15:51 ` [PATCH v1 27/27] BaseTools: CommonClass - remove unused classes Jaben Carsey
2018-04-25  8:51   ` Zhu, Yonghong

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=67ec988deb43275c4d34f124ade40e79d05d9691.1524239028.git.jaben.carsey@intel.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