From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E7E79203569A3 for ; Wed, 2 May 2018 00:04:47 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 May 2018 00:04:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,354,1520924400"; d="scan'208";a="51661663" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 02 May 2018 00:04:46 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 2 May 2018 00:04:46 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 2 May 2018 00:04:45 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.210]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.40]) with mapi id 14.03.0319.002; Wed, 2 May 2018 15:04:43 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v2 19/27] BaseTools: Replace Binary File type strings with predefined constant Thread-Index: AQHT3X/hgeVh3u+u+kqiWbn4n23UtqQcDINg Date: Wed, 2 May 2018 07:04:42 +0000 Message-ID: References: <7c2a6f45076e6af2934a68d042ef2ee9196e55e0.1524761578.git.jaben.carsey@intel.com> In-Reply-To: <7c2a6f45076e6af2934a68d042ef2ee9196e55e0.1524761578.git.jaben.carsey@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 19/27] BaseTools: Replace Binary File type strings with predefined constant X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2018 07:04:48 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben=20 Sent: Friday, April 27, 2018 12:58 AM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Zhu, Yonghong Subject: [PATCH v2 19/27] BaseTools: Replace Binary File type strings with = predefined constant 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' v2 - split apart FV and GUID types with different meanings. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- 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/DataType.py | 2 + 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 +-- 24 files changed, 140 insertions(+), 136 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index 2a6fa05ab819..671f02133aca 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 =3D path.join(self.BuildDir, 'FV') + self._FvDir =3D path.join(self.BuildDir, TAB_FV_DIRECTORY) return self._FvDir =20 ## Return the directory to store all intermediate and final files buil= t @@ -1325,7 +1325,7 @@ class PlatformAutoGen(AutoGen): =20 def UpdateNVStoreMaxSize(self,OrgVpdFile): if self.VariableInfo: - VpdMapFilePath =3D os.path.join(self.BuildDir, "FV", "%s.map" = % self.Platform.VpdToolGuid) + VpdMapFilePath =3D os.path.join(self.BuildDir, TAB_FV_DIRECTOR= Y, "%s.map" % self.Platform.VpdToolGuid) PcdNvStoreDfBuffer =3D [item for item in self._DynamicPcdList = if item.TokenCName =3D=3D "PcdNvStoreDefaultValueBuffer" and item.TokenSpac= eGuidCName =3D=3D "gEfiMdeModulePkgTokenSpaceGuid"] =20 if PcdNvStoreDfBuffer: @@ -1718,7 +1718,7 @@ class PlatformAutoGen(AutoGen): =20 # Process VPD map file generated by third party BPDG tool if NeedProcessVpdMapFile: - VpdMapFilePath =3D os.path.join(self.BuildDir, "FV", "= %s.map" % self.Platform.VpdToolGuid) + VpdMapFilePath =3D os.path.join(self.BuildDir, TAB_FV_= DIRECTORY, "%s.map" % self.Platform.VpdToolGuid) if os.path.exists(VpdMapFilePath): VpdFile.Read(VpdMapFilePath) =20 @@ -1769,7 +1769,7 @@ class PlatformAutoGen(AutoGen): self.AllPcdList =3D self._NonDynamicPcdList + self._DynamicPcdList =20 def FixVpdOffset(self,VpdFile ): - FvPath =3D os.path.join(self.BuildDir, "FV") + FvPath =3D 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 =3D None for ToolDef in self.ToolDefinition.values(): - if ToolDef.has_key("GUID") and ToolDef["GUID"] =3D=3D self= .Platform.VpdToolGuid: + if ToolDef.has_key(TAB_GUID) and ToolDef[TAB_GUID] =3D=3D = 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 =3D 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 =3D path.join(self.PlatformInfo.BuildDi= r, "FV", "Ffs", self.Guid + self.Name) + self._FfsOutputDir =3D path.join(self.PlatformInfo.BuildDi= r, TAB_FV_DIRECTORY, "Ffs", self.Guid + self.Name) else: self._FfsOutputDir =3D '' return self._FfsOutputDir diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Pyt= hon/AutoGen/GenC.py index 73cda208a7eb..4ceadd449222 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1612,7 +1612,7 @@ def CreateModuleUnloadImageCode(Info, AutoGenC, AutoG= enH): # def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH): if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]: - GuidType =3D "GUID" + GuidType =3D TAB_GUID else: GuidType =3D "EFI_GUID" =20 @@ -1636,7 +1636,7 @@ def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH= ): # def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH): if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]: - GuidType =3D "GUID" + GuidType =3D TAB_GUID else: GuidType =3D "EFI_GUID" =20 @@ -1660,7 +1660,7 @@ def CreateProtocolDefinitionCode(Info, AutoGenC, Auto= GenH): # def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH): if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]: - GuidType =3D "GUID" + GuidType =3D TAB_GUID else: GuidType =3D "EFI_GUID" =20 @@ -1697,7 +1697,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 =3D "GUID" + GuidType =3D TAB_GUID else: GuidType =3D "EFI_GUID" =20 for Item in TokenSpaceList: diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source= /Python/AutoGen/GenPcdDb.py index b48ddcd59ec8..fab6859edb2f 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) =20 if Info.IsBinaryModule: - DbFileName =3D os.path.join(Info.PlatformInfo.BuildDir, "FV", Phas= e + "PcdDataBase.raw") + DbFileName =3D os.path.join(Info.PlatformInfo.BuildDir, TAB_FV_DIR= ECTORY, Phase + "PcdDataBase.raw") else: DbFileName =3D os.path.join(Info.OutputDir, Phase + "PcdDataBase.r= aw") DbFile =3D StringIO() @@ -1054,7 +1054,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform= ,Phase): PcdDriverAutoGenData[(skuname,skuid)] =3D (AdditionalAutoGenH,= AdditionalAutoGenC) VarCheckTableData[(skuname,skuid)] =3D VarCheckTab if Platform.Platform.VarCheckFlag: - dest =3D os.path.join(Platform.BuildDir, 'FV') + dest =3D os.path.join(Platform.BuildDir, TAB_FV_DIRECTORY) VarCheckTable =3D CreateVarCheckBin(VarCheckTableData) VarCheckTable.dump(dest, Phase) AdditionalAutoGenH, AdditionalAutoGenC =3D CreateAutoGen(PcdDrive= rAutoGenData) diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/= Python/Common/DataType.py index 2662132e5106..5030df27b4da 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -40,6 +40,7 @@ TAB_UINT16 =3D 'UINT16' TAB_UINT32 =3D 'UINT32' TAB_UINT64 =3D 'UINT64' TAB_VOID =3D 'VOID*' +TAB_GUID =3D 'GUID' =20 TAB_PCD_CLEAN_NUMERIC_TYPES =3D {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UI= NT64} TAB_PCD_NUMERIC_TYPES =3D {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, = 'BOOLEAN'} @@ -48,6 +49,7 @@ TAB_PCD_NUMERIC_TYPES_VOID =3D {TAB_UINT8, TAB_UINT16, TA= B_UINT32, TAB_UINT64, 'BO TAB_EDK_SOURCE =3D '$(EDK_SOURCE)' TAB_EFI_SOURCE =3D '$(EFI_SOURCE)' TAB_WORKSPACE =3D '$(WORKSPACE)' +TAB_FV_DIRECTORY =3D 'FV' =20 TAB_ARCH_NULL =3D '' TAB_ARCH_COMMON =3D 'COMMON' diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 53504c110d6d..9fec10d2bb9c 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -951,7 +951,7 @@ class ValueExpressionEx(ValueExpression): Size =3D 0 ValueStr =3D '' TokenSpaceGuidName =3D '' - if Item.startswith('GUID') and Item.endswith('= )'): + if Item.startswith(TAB_GUID) and Item.endswith= (')'): try: TokenSpaceGuidName =3D re.search('GUID= \((\w+)\)', Item).group(1) except: diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index f05ae39ebb29..3d205197abfc 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1219,7 +1219,7 @@ class tdict: =20 def IsFieldValueAnArray (Value): Value =3D 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 =3D Value.split('(', 1)[1][:-1].strip() if Value[0] =3D=3D '{' and Value[-1] =3D=3D '}': TmpValue =3D GuidStructureStringToGuidString(Value) diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Sour= ce/Python/GenFds/DataSection.py index 99d7392aaab3..29caa00c0d8d 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) =20 #Get PE Section alignment when align is set to AUTO - if self.Alignment =3D=3D 'Auto' and self.SecType in ('TE', 'PE32')= : + if self.Alignment =3D=3D 'Auto' and self.SecType in (BINARY_FILE_T= YPE_TE, BINARY_FILE_TYPE_PE32): ImageObj =3D PeImageClass (Filename) if ImageObj.SectionAlignment < 0x400: self.Alignment =3D str (ImageObj.SectionAlignment) @@ -92,7 +92,7 @@ class DataSection (DataSectionClassObject): self.Alignment =3D str (ImageObj.SectionAlignment / 0x1000= 00) + 'M' =20 NoStrip =3D 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 =3D self.KeepReloc =20 @@ -110,7 +110,7 @@ class DataSection (DataSectionClassObject): ) self.SectFileName =3D StrippedFile =20 - if self.SecType =3D=3D 'TE': + if self.SecType =3D=3D BINARY_FILE_TYPE_TE: TeFile =3D os.path.join( OutputPath, ModuleName + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( TeFile, diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Sou= rce/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): =20 if self.DepexType =3D=3D 'PEI_DEPEX_EXP': ModuleType =3D SUP_MODULE_PEIM - SecType =3D 'PEI_DEPEX' + SecType =3D BINARY_FILE_TYPE_PEI_DEPEX elif self.DepexType =3D=3D 'DXE_DEPEX_EXP': ModuleType =3D SUP_MODULE_DXE_DRIVER - SecType =3D 'DXE_DEPEX' + SecType =3D BINARY_FILE_TYPE_DXE_DEPEX elif self.DepexType =3D=3D 'SMM_DEPEX_EXP': ModuleType =3D SUP_MODULE_DXE_SMM_DRIVER - SecType =3D 'SMM_DEPEX' + SecType =3D 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/Sourc= e/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 =3D FfsInf.__ExtendMacro__(self.StringData) ModuleNameStr =3D FfsInf.__ExtendMacro__('$(MODULE_NAME)') NoStrip =3D 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 =3D FfsInf.KeepReloc elif FfsInf.KeepRelocFromRule is not None: @@ -171,9 +171,9 @@ class EfiSection (EfiSectionClassObject): OutputFileList.append(OutputFile) =20 # - # If Section Type is 'UI' + # If Section Type is BINARY_FILE_TYPE_UI # - elif SectionType =3D=3D 'UI': + elif SectionType =3D=3D BINARY_FILE_TYPE_UI: =20 InfOverrideUiString =3D False if FfsInf.Ui is not None: @@ -242,7 +242,7 @@ class EfiSection (EfiSectionClassObject): File =3D GenFdsGlobalVariable.MacroExtend(File, Dict) =20 #Get PE Section alignment when align is set to AUTO - if self.Alignment =3D=3D 'Auto' and (SectionType =3D= =3D 'PE32' or SectionType =3D=3D 'TE'): + if self.Alignment =3D=3D 'Auto' and (SectionType =3D= =3D BINARY_FILE_TYPE_PE32 or SectionType =3D=3D BINARY_FILE_TYPE_TE): ImageObj =3D PeImageClass (File) if ImageObj.SectionAlignment < 0x400: Align =3D str (ImageObj.SectionAlignment) @@ -287,7 +287,7 @@ class EfiSection (EfiSectionClassObject): =20 """For TE Section call GenFw to generate TE image""" =20 - if SectionType =3D=3D 'TE': + if SectionType =3D=3D BINARY_FILE_TYPE_TE: TeFile =3D 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 =20 ## generate FD # @@ -158,7 +159,7 @@ class FD(FDClassObject): FvAddDict =3D{} FvList =3D [] for RegionObj in self.RegionList: - if RegionObj.RegionType =3D=3D 'FV': + if RegionObj.RegionType =3D=3D BINARY_FILE_TYPE_FV: if len(RegionObj.RegionDataList) =3D=3D 1: RegionData =3D RegionObj.RegionDataList[0] FvList.append(RegionData.upper()) diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index 469cb128ba5f..49ed4041a287 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 =20 - if not self.__Token in ("SET", "FV", "FILE", "DATA", "CAPSULE", "I= NF"): + 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 mig= ht be part of [PcdOffset[|PcdSize]] # Or it might be next region's offset described by an expressi= on which starts with a PCD. @@ -1874,7 +1874,7 @@ class FdfParser: if not self.__GetNextWord(): return True =20 - elif self.__Token =3D=3D "FV": + elif self.__Token =3D=3D BINARY_FILE_TYPE_FV: self.__UndoToken() self.__GetRegionFvType( RegionObj) =20 @@ -1918,8 +1918,8 @@ class FdfParser: # def __GetRegionFvType(self, RegionObj): =20 - if not self.__IsKeyword( "FV"): - raise Warning("expected Keyword 'FV'", self.FileName, self.Cur= rentLineNumber) + if not self.__IsKeyword( BINARY_FILE_TYPE_FV): + raise Warning("expected Keyword BINARY_FILE_TYPE_FV", self.Fil= eName, self.CurrentLineNumber) =20 if not self.__IsToken( "=3D"): raise Warning("expected '=3D'", self.FileName, self.CurrentLin= eNumber) @@ -1927,10 +1927,10 @@ class FdfParser: if not self.__GetNextToken(): raise Warning("expected FV name", self.FileName, self.CurrentL= ineNumber) =20 - RegionObj.RegionType =3D "FV" + RegionObj.RegionType =3D BINARY_FILE_TYPE_FV RegionObj.RegionDataList.append((self.__Token).upper()) =20 - while self.__IsKeyword( "FV"): + while self.__IsKeyword( BINARY_FILE_TYPE_FV): =20 if not self.__IsToken( "=3D"): raise Warning("expected '=3D'", self.FileName, self.Curren= tLineNumber) @@ -2528,7 +2528,7 @@ class FdfParser: if self.__GetStringData(): FfsInfObj.Version =3D self.__Token =20 - if self.__IsKeyword( "UI"): + if self.__IsKeyword( BINARY_FILE_TYPE_UI): if not self.__IsToken( "=3D"): raise Warning("expected '=3D'", self.FileName, self.Curren= tLineNumber) 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.FileN= ame, self.CurrentLineNumber) =20 - if self.__Token =3D=3D "FV": + if self.__Token =3D=3D BINARY_FILE_TYPE_FV: if not self.__IsToken( "=3D"): raise Warning("expected '=3D'", self.FileName, self.Curren= tLineNumber) if not self.__GetNextToken(): @@ -2881,7 +2881,7 @@ class FdfParser: VerSectionObj.FileName =3D self.__Token Obj.SectionList.append(VerSectionObj) =20 - elif self.__IsKeyword( "UI"): + elif self.__IsKeyword( BINARY_FILE_TYPE_UI): if AlignValue =3D=3D 'Auto': raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) if not self.__IsToken( "=3D"): @@ -2965,10 +2965,10 @@ class FdfParser: self.SetFileBufferPos(OldPos) return False =20 - if self.__Token not in ("COMPAT16", "PE32", "PIC", "TE", "FV_I= MAGE", "RAW", "DXE_DEPEX",\ - "UI", "VERSION", "PEI_DEPEX", "SUBTYPE_GUID= ", "SMM_DEPEX"): + if self.__Token not in ("COMPAT16", BINARY_FILE_TYPE_PE32, BIN= ARY_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 =3D=3D 'Auto'and (not self.__Token =3D=3D 'PE32'= ) and (not self.__Token =3D=3D 'TE'): + if AlignValue =3D=3D 'Auto'and (not self.__Token =3D=3D BINARY= _FILE_TYPE_PE32) and (not self.__Token =3D=3D BINARY_FILE_TYPE_TE): raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) =20 # DataSection @@ -3386,7 +3386,7 @@ class FdfParser: # def __GetFvStatement(self, CapsuleObj, FMPCapsule =3D False): =20 - if not self.__IsKeyword("FV"): + if not self.__IsKeyword(BINARY_FILE_TYPE_FV): return False =20 if not self.__IsToken("=3D"): @@ -3534,7 +3534,7 @@ class FdfParser: AfileBaseName =3D os.path.basename(AfileName) =20 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) =20 if not os.path.isabs(AfileName): @@ -3767,8 +3767,8 @@ class FdfParser: =20 SectionName =3D self.__Token =20 - if SectionName not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IM= AGE", "RAW", "DXE_DEPEX",\ - "UI", "PEI_DEPEX", "VERSION", "SUBTYPE= _GUID", "SMM_DEPEX"): + if SectionName not in ("COMPAT16", BINARY_FILE_TYPE_PE32, BINA= RY_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'" % SectionNa= me, self.FileName, self.CurrentLineNumber) =20 =20 @@ -3783,7 +3783,7 @@ class FdfParser: if self.__Token not in ("Auto", "8", "16", "32", "64", "12= 8", "512", "1K", "4K", "32K" ,"64K", "128K", "256K", "512K", "1M", "2M", "4M", = "8M", "16M"): raise Warning("Incorrect alignment '%s'" % self.__Toke= n, self.FileName, self.CurrentLineNumber) - if self.__Token =3D=3D 'Auto' and (not SectionName =3D=3D = 'PE32') and (not SectionName =3D=3D 'TE'): + if self.__Token =3D=3D 'Auto' and (not SectionName =3D=3D = BINARY_FILE_TYPE_PE32) and (not SectionName =3D=3D BINARY_FILE_TYPE_TE): raise Warning("Auto alignment can only be used in PE32= or TE section ", self.FileName, self.CurrentLineNumber) SectAlignment =3D self.__Token =20 @@ -3824,8 +3824,8 @@ class FdfParser: return False SectionName =3D self.__Token =20 - 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_F= ILE_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 =20 @@ -3855,8 +3855,8 @@ class FdfParser: FvImageSectionObj.FvName =3D None =20 else: - if not self.__IsKeyword("FV"): - raise Warning("expected 'FV'", self.FileName, self.Cur= rentLineNumber) + if not self.__IsKeyword(BINARY_FILE_TYPE_FV): + raise Warning("expected BINARY_FILE_TYPE_FV", self.Fil= eName, self.CurrentLineNumber) FvImageSectionObj.FvFileType =3D self.__Token =20 if self.__GetAlignment(): @@ -3868,8 +3868,8 @@ class FdfParser: if self.__IsToken('|'): FvImageSectionObj.FvFileExtension =3D self.__GetFileEx= tension() 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_T= YPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BIN= ARY_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 =3D 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, s= elf.FileName, self.CurrentLineNumber) - if self.__Token =3D=3D 'Auto' and (not SectionName =3D=3D 'PE3= 2') and (not SectionName =3D=3D 'TE'): + if self.__Token =3D=3D 'Auto' and (not SectionName =3D=3D BINA= RY_FILE_TYPE_PE32) and (not SectionName =3D=3D BINARY_FILE_TYPE_TE): raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) EfiSectionObj.Alignment =3D self.__Token =20 @@ -3950,8 +3950,8 @@ class FdfParser: if self.__IsToken('|'): EfiSectionObj.FileExtension =3D 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_PE= I_DEPEX, BINARY_FILE_TYPE_GUID, BINARY_FILE_TYPE_SMM_DEPEX): =20 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 =3D=3D "COMPAT16": if FileType not in ("COMPAT16", "SEC_COMPAT16"): raise Warning("Incorrect section file type '%s'" % FileTyp= e, self.FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "PE32": - if FileType not in ("PE32", "SEC_PE32"): + elif SectionType =3D=3D BINARY_FILE_TYPE_PE32: + if FileType not in (BINARY_FILE_TYPE_PE32, "SEC_PE32"): raise Warning("Incorrect section file type '%s'" % FileTyp= e, self.FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "PIC": - if FileType not in ("PIC", "PIC"): + elif SectionType =3D=3D BINARY_FILE_TYPE_PIC: + if FileType not in (BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_PIC= ): raise Warning("Incorrect section file type '%s'" % FileTyp= e, self.FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "TE": - if FileType not in ("TE", "SEC_TE"): + elif SectionType =3D=3D BINARY_FILE_TYPE_TE: + if FileType not in (BINARY_FILE_TYPE_TE, "SEC_TE"): raise Warning("Incorrect section file type '%s'" % FileTyp= e, self.FileName, self.CurrentLineNumber) elif SectionType =3D=3D "RAW": - if FileType not in ("BIN", "SEC_BIN", "RAW", "ASL", "ACPI"): + if FileType not in (BINARY_FILE_TYPE_BIN, "SEC_BIN", "RAW", "A= SL", "ACPI"): raise Warning("Incorrect section file type '%s'" % FileTyp= e, self.FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "DXE_DEPEX" or SectionType =3D=3D "SMM_DEP= EX": - if FileType not in ("DXE_DEPEX", "SEC_DXE_DEPEX", "SMM_DEPEX")= : + elif SectionType =3D=3D BINARY_FILE_TYPE_DXE_DEPEX or SectionType = =3D=3D 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'" % FileTyp= e, self.FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "UI": - if FileType not in ("UI", "SEC_UI"): + elif SectionType =3D=3D BINARY_FILE_TYPE_UI: + if FileType not in (BINARY_FILE_TYPE_UI, "SEC_UI"): raise Warning("Incorrect section file type '%s'" % FileTyp= e, self.FileName, self.CurrentLineNumber) elif SectionType =3D=3D "VERSION": if FileType not in ("VERSION", "SEC_VERSION"): raise Warning("Incorrect section file type '%s'" % FileTyp= e, self.FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "PEI_DEPEX": - if FileType not in ("PEI_DEPEX", "SEC_PEI_DEPEX"): + elif SectionType =3D=3D BINARY_FILE_TYPE_PEI_DEPEX: + if FileType not in (BINARY_FILE_TYPE_PEI_DEPEX, "SEC_PEI_DEPEX= "): raise Warning("Incorrect section file type '%s'" % FileTyp= e, self.FileName, self.CurrentLineNumber) - elif SectionType =3D=3D "GUID": - if FileType not in ("PE32", "SEC_GUID"): + elif SectionType =3D=3D BINARY_FILE_TYPE_GUID: + if FileType not in (BINARY_FILE_TYPE_PE32, "SEC_GUID"): raise Warning("Incorrect section file type '%s'" % FileTyp= e, self.FileName, self.CurrentLineNumber) =20 ## __GetRuleEncapsulationSection() method @@ -4494,7 +4494,7 @@ class FdfParser: =20 FfsFileObj =3D OptRomFileStatement.OptRomFileStatement() =20 - if not self.__IsKeyword("EFI") and not self.__IsKeyword("BIN"): + if not self.__IsKeyword("EFI") and not self.__IsKeyword(BINARY_FIL= E_TYPE_BIN): raise Warning("expected Binary type (EFI/BIN)", self.FileName,= self.CurrentLineNumber) FfsFileObj.FileType =3D self.__Token =20 @@ -4575,7 +4575,7 @@ class FdfParser: if FdName.upper() in self.Profile.FdDict: FdObj =3D self.Profile.FdDict[FdName.upper()] for elementRegion in FdObj.RegionList: - if elementRegion.RegionType =3D=3D 'FV': + if elementRegion.RegionType =3D=3D 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/Pytho= n/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): =20 # mapping between section type in FDF and file suffix SectionSuffix =3D { - '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' } =20 ## The constructor diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/= Source/Python/GenFds/FfsInfStatement.py index 9068157ba616..728997f17d1a 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_DEFINE= D # =20 - if FileType !=3D 'PE32' and self.ModuleType !=3D SUP_MODULE_USER_D= EFINED: + if FileType !=3D BINARY_FILE_TYPE_PE32 and self.ModuleType !=3D SU= P_MODULE_USER_DEFINED: return EfiFile =20 # @@ -739,13 +739,13 @@ class FfsInfStatement(FfsInfStatementClassObject): # Convert Fv Section Type for PI1.1 SMM driver. # if self.ModuleType =3D=3D SUP_MODULE_DXE_SMM_DRIVER and int(self.P= iSpecVersion, 16) >=3D 0x0001000A: - if SectionType =3D=3D 'DXE_DEPEX': - SectionType =3D 'SMM_DEPEX' + if SectionType =3D=3D BINARY_FILE_TYPE_DXE_DEPEX: + SectionType =3D BINARY_FILE_TYPE_SMM_DEPEX # # Framework SMM Driver has no SMM_DEPEX section type # if self.ModuleType =3D=3D SUP_MODULE_DXE_SMM_DRIVER and int(self.P= iSpecVersion, 16) < 0x0001000A: - if SectionType =3D=3D 'SMM_DEPEX': + if SectionType =3D=3D BINARY_FILE_TYPE_SMM_DEPEX: EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework= SMM module doesn't support SMM_DEPEX section type", File=3Dself.InfFileNam= e) NoStrip =3D True if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MO= DULE_PEIM): @@ -767,7 +767,7 @@ class FfsInfStatement(FfsInfStatementClassObject): File =3D GenFdsGlobalVariable.MacroExtend(File, Dict, self= .CurrentArch) =20 #Get PE Section alignment when align is set to AUTO - if self.Alignment =3D=3D 'Auto' and (SectionType =3D=3D 'P= E32' or SectionType =3D=3D 'TE'): + if self.Alignment =3D=3D 'Auto' and (SectionType =3D=3D BI= NARY_FILE_TYPE_PE32 or SectionType =3D=3D BINARY_FILE_TYPE_TE): ImageObj =3D PeImageClass (File) if ImageObj.SectionAlignment < 0x400: self.Alignment =3D str (ImageObj.SectionAlignment) @@ -790,7 +790,7 @@ class FfsInfStatement(FfsInfStatementClassObject): ) File =3D StrippedFile =20 - if SectionType =3D=3D 'TE': + if SectionType =3D=3D BINARY_FILE_TYPE_TE: TeFile =3D os.path.join( self.OutputPath, self.ModuleG= uid + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( TeFile, @@ -809,7 +809,7 @@ class FfsInfStatement(FfsInfStatementClassObject): GenSecInputFile =3D GenFdsGlobalVariable.MacroExtend(GenSecInp= utFile, Dict, self.CurrentArch) =20 #Get PE Section alignment when align is set to AUTO - if self.Alignment =3D=3D 'Auto' and (SectionType =3D=3D 'PE32'= or SectionType =3D=3D 'TE'): + if self.Alignment =3D=3D 'Auto' and (SectionType =3D=3D BINARY= _FILE_TYPE_PE32 or SectionType =3D=3D BINARY_FILE_TYPE_TE): ImageObj =3D PeImageClass (GenSecInputFile) if ImageObj.SectionAlignment < 0x400: self.Alignment =3D str (ImageObj.SectionAlignment) @@ -833,7 +833,7 @@ class FfsInfStatement(FfsInfStatementClassObject): ) GenSecInputFile =3D StrippedFile =20 - if SectionType =3D=3D 'TE': + if SectionType =3D=3D BINARY_FILE_TYPE_TE: TeFile =3D 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 =3D=3D SUP_MODULE_DXE_SMM_DRIVER and int(se= lf.PiSpecVersion, 16) >=3D 0x0001000A: - if Sect.SectionType =3D=3D 'DXE_DEPEX': - Sect.SectionType =3D 'SMM_DEPEX' + if Sect.SectionType =3D=3D BINARY_FILE_TYPE_DXE_DEPEX: + Sect.SectionType =3D BINARY_FILE_TYPE_SMM_DEPEX # # Framework SMM Driver has no SMM_DEPEX section type # if self.ModuleType =3D=3D SUP_MODULE_DXE_SMM_DRIVER and int(se= lf.PiSpecVersion, 16) < 0x0001000A: - if Sect.SectionType =3D=3D 'SMM_DEPEX': + if Sect.SectionType =3D=3D BINARY_FILE_TYPE_SMM_DEPEX: EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Frame= work SMM module doesn't support SMM_DEPEX section type", File=3Dself.InfFil= eName) # # 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 0fb2bd456a6d..37ad57d797d0 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.val= ues(): for RegionObj in FdObj.RegionList: - if RegionObj.RegionType =3D=3D 'FV': + if RegionObj.RegionType =3D=3D BINARY_FILE_TYPE_FV: for RegionData in RegionObj.RegionDataList: if RegionData.endswith(".fv"): continue @@ -236,7 +236,7 @@ class FV (FvClassObject): =20 for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values(= ): for RegionObj in FdObj.RegionList: - if RegionObj.RegionType !=3D 'FV': + if RegionObj.RegionType !=3D BINARY_FILE_TYPE_FV: continue for RegionData in RegionObj.RegionDataList: # diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index 54c7d828305f..ccd137955dd8 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 =3D FdfParserObj.Profile.FdDict[Fd] for RegionObj in FdObj.RegionList: - if RegionObj.RegionType !=3D 'FV': + if RegionObj.RegionType !=3D BINARY_FILE_TYPE_FV: continue for RegionData in RegionObj.RegionDataList: if FvObj.UiFvName.upper() =3D=3D RegionData.up= per(): @@ -405,7 +405,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, Name= Guid): KeyList[1] + \ '_' + \ KeyList[2] - if Key in KeyStringList and KeyList[4] =3D=3D 'GUID': + if Key in KeyStringList and KeyList[4] =3D=3D TAB_GUID: ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS' ToolPath =3D ToolDefinition.get(ToolPathKey) @@ -447,7 +447,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, Name= Guid): if NameGuid =3D=3D BuildOption[Op]: KeyList =3D Op.split('_') Key =3D KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2= ] - if Key in KeyStringList and KeyList[4] =3D=3D 'GUID': + if Key in KeyStringList and KeyList[4] =3D=3D TAB_GUID= : ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' ToolOptionKey =3D 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 =3D=3D 'FV': + if ElementRegion.RegionType =3D=3D BINARY_FILE_TYPE_FV= : for ElementRegionData in ElementRegion.RegionDataL= ist: if ElementRegionData is not None and ElementRe= gionData.upper() =3D=3D FvObj.UiFvName: if FvObj.BlockSizeList !=3D []: @@ -601,7 +601,7 @@ class GenFds : return DefaultBlockSize else: for ElementRegion in FdObj.RegionList: - if ElementRegion.RegionType =3D=3D 'FV': + if ElementRegion.RegionType =3D=3D BINARY_FILE_TYPE_FV= : for ElementRegionData in ElementRegion.RegionDataL= ist: if ElementRegionData is not None and ElementRe= gionData.upper() =3D=3D FvObj.UiFvName: if FvObj.BlockSizeList !=3D []: diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index 909d043c2a22..2fb98007ab37 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -288,7 +288,7 @@ class GenFdsGlobalVariable: # GenFdsGlobalVariable.OutputDirDict =3D OutputDir GenFdsGlobalVariable.FdfParser =3D FdfParser GenFdsGlobalVariable.WorkSpace =3D WorkSpace - GenFdsGlobalVariable.FvDir =3D os.path.join(GenFdsGlobalVariable.O= utputDirDict[ArchList[0]], 'FV') + GenFdsGlobalVariable.FvDir =3D os.path.join(GenFdsGlobalVariable.O= utputDirDict[ArchList[0]], DataType.TAB_FV_DIRECTORY) if not os.path.exists(GenFdsGlobalVariable.FvDir) : os.makedirs(GenFdsGlobalVariable.FvDir) GenFdsGlobalVariable.FfsDir =3D os.path.join(GenFdsGlobalVariable.= FvDir, 'Ffs') @@ -349,7 +349,7 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.PlatformName =3D WorkSpace.Db.BuildObject= [GenFdsGlobalVariable.ActivePlatform, Arch, Glob= alData.gGlobalDefines['TARGET'], Glob= alData.gGlobalDefines['TOOLCHAIN']].PlatformName - GenFdsGlobalVariable.FvDir =3D os.path.join(GenFdsGlobalVariable.O= utputDirDict[ArchList[0]], 'FV') + GenFdsGlobalVariable.FvDir =3D os.path.join(GenFdsGlobalVariable.O= utputDirDict[ArchList[0]], DataType.TAB_FV_DIRECTORY) if not os.path.exists(GenFdsGlobalVariable.FvDir): os.makedirs(GenFdsGlobalVariable.FvDir) GenFdsGlobalVariable.FfsDir =3D os.path.join(GenFdsGlobalVariable.= FvDir, 'Ffs') diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseToo= ls/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): =20 OutputFileList =3D [] for Sect in Rule.SectionList: - if Sect.SectionType =3D=3D 'PE32': + if Sect.SectionType =3D=3D BINARY_FILE_TYPE_PE32: if Sect.FileName is not None: GenSecInputFile =3D self.__ExtendMacro__(Sect.FileName= ) OutputFileList.append(GenSecInputFile) diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Py= thon/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 =20 ## generate Region # @@ -80,10 +81,10 @@ class Region(RegionClassObject): GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x= %X' % self.Offset) GenFdsGlobalVariable.InfLogger(" Region Size =3D 0x%X" % Siz= e) GenFdsGlobalVariable.SharpCounter =3D 0 - if Flag and (self.RegionType !=3D 'FV'): + if Flag and (self.RegionType !=3D BINARY_FILE_TYPE_FV): return =20 - if self.RegionType =3D=3D 'FV': + if self.RegionType =3D=3D BINARY_FILE_TYPE_FV: # # Get Fv from FvDict # diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/P= ython/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 * =20 ## section base class # @@ -29,37 +29,37 @@ class Section (SectionClassObject): SectionType =3D { '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' } =20 BinFileType =3D { - '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' } =20 SectFileType =3D { @@ -128,8 +128,8 @@ class Section (SectionClassObject): for File in FfsInf.BinFileList: if File.Arch =3D=3D TAB_ARCH_COMMON or FfsInf.CurrentArch = =3D=3D File.Arch: if File.Type =3D=3D FileType or (int(FfsInf.PiSpecVers= ion, 16) >=3D 0x0001000A \ - and FileType =3D=3D 'DXE_= DPEX'and File.Type =3D=3D 'SMM_DEPEX') \ - or (FileType =3D=3D 'TE'a= nd File.Type =3D=3D 'PE32'): + and FileType =3D=3D 'DXE_= DPEX' and File.Type =3D=3D BINARY_FILE_TYPE_SMM_DEPEX) \ + or (FileType =3D=3D BINAR= Y_FILE_TYPE_TE and File.Type =3D=3D BINARY_FILE_TYPE_PE32): if '*' in FfsInf.TargetOverrideList or File.Target= =3D=3D '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOve= rrideList =3D=3D []: 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 =3D FfsInf.__ExtendMacro__(self.StringData) self.FileName =3D FfsInf.__ExtendMacro__(self.FileName) =20 - OutputFile =3D os.path.join(OutputPath, ModuleName + SUP_MODULE_SE= C + SecNum + Ffs.SectionSuffix.get('UI')) + OutputFile =3D os.path.join(OutputPath, ModuleName + SUP_MODULE_SE= C + SecNum + Ffs.SectionSuffix.get(BINARY_FILE_TYPE_UI)) =20 if self.StringData is not None : NameString =3D self.StringData diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python= /Trim/Trim.py index 3eb7fa39209d..0503b5a28d1b 100644 --- a/BaseTools/Source/Python/Trim/Trim.py +++ b/BaseTools/Source/Python/Trim/Trim.py @@ -303,7 +303,7 @@ def TrimPreprocessedVfr(Source, Target): FoundTypedef =3D False TypedefEnd =3D 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_R= ETURN"]: + if Line.strip("} ;\r\n") in [TAB_GUID, "EFI_PLABEL", "PAL_CALL= _RETURN"]: for i in range(TypedefStart, TypedefEnd+1): Lines[i] =3D "\n" =20 diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index bc9726202d3c..0432ef7d2a0f 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1505,7 +1505,7 @@ class DscBuildData(PlatformBuildClassObject): def get_length(value): Value =3D 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 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 on= es _TOOL_CODE_ =3D { "C" : "CC", - "LIB" : "SLINK", + BINARY_FILE_TYPE_LIB : "SLINK", "LINK" : "DLINK", } =20 diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Sourc= e/Python/build/BuildReport.py index a771b5b3c739..c33703ce0747 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -208,7 +208,7 @@ def FindIncludeFiles(Source, IncludePathList, IncludeFi= les): FileName =3D "Protocol/%(Key)s/%(Key)s.h" % {"Key" : Key} elif "PPI" in Type: FileName =3D "Ppi/%(Key)s/%(Key)s.h" % {"Key" : Key} - elif "GUID" in Type: + elif TAB_GUID in Type: FileName =3D "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 !=3D "FV": + if FdRegion.RegionType !=3D 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 !=3D "FV": + if self.Type !=3D BINARY_FILE_TYPE_FV: return =20 # @@ -1780,7 +1780,7 @@ class FdRegionReport(object): FileWrite(File, "Type: %s" % Type) FileWrite(File, "Base Address: 0x%X" % BaseAddress) =20 - if self.Type =3D=3D "FV": + if self.Type =3D=3D BINARY_FILE_TYPE_FV: FvTotalSize =3D 0 FvTakenSize =3D 0 FvFreeSize =3D 0 @@ -1843,7 +1843,7 @@ class FdRegionReport(object): if (len(self.FvList) > 0): for FvItem in self.FvList: Info =3D 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.BaseAd= dress, self.Size) =20 @@ -1869,7 +1869,7 @@ class FdReport(object): self.BaseAddress =3D Fd.BaseAddress self.Size =3D Fd.Size self.FdRegionList =3D [FdRegionReport(FdRegion, Wa) for FdRegion i= n Fd.RegionList] - self.FvPath =3D os.path.join(Wa.BuildDir, "FV") + self.FvPath =3D os.path.join(Wa.BuildDir, TAB_FV_DIRECTORY) self.VpdFilePath =3D os.path.join(self.FvPath, "%s.map" % Wa.Platf= orm.VpdToolGuid) self.VPDBaseAddress =3D 0 self.VPDSize =3D 0 --=20 2.16.2.windows.1