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.65; helo=mga03.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 691792277AF17 for ; Tue, 24 Apr 2018 00:38:13 -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 orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Apr 2018 00:38:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,321,1520924400"; d="scan'208";a="49418243" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga001.fm.intel.com with ESMTP; 24 Apr 2018 00:38:12 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 24 Apr 2018 00:38:12 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 24 Apr 2018 00:38:12 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.210]) by shsmsx102.ccr.corp.intel.com ([169.254.2.79]) with mapi id 14.03.0319.002; Tue, 24 Apr 2018 15:38:08 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v1 19/27] BaseTools: Replace Binary File type strings with predefined constant Thread-Index: AQHT2L+NLcWP/fKFDEmmpo2PQtMak6QPfl6Q Date: Tue, 24 Apr 2018 07:38:07 +0000 Message-ID: References: <67ec988deb43275c4d34f124ade40e79d05d9691.1524239028.git.jaben.carsey@intel.com> In-Reply-To: <67ec988deb43275c4d34f124ade40e79d05d9691.1524239028.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 v1 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: Tue, 24 Apr 2018 07:38:13 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Jaben, 1. use the BINARY_FILE_TYPE_FV to replace 'FV' in the file path may be str= ange. How about we still keep to use 'FV' ? 2. how about we create another constant name for 'GUID' ? I think some pl= ace's replacement is a little odd, eg: Value.startswith(BINARY_FILE_TYPE_GU= ID). Do you have any suggestions on the naming conventions ? Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben=20 Sent: Friday, April 20, 2018 11:52 PM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Zhu, Yonghong Subject: [PATCH v1 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' 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/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 =3D path.join(self.BuildDir, 'FV') + self._FvDir =3D path.join(self.BuildDir, BINARY_FILE_TYPE_FV) return self._FvDir =20 ## Return the directory to store all intermediate and final files buil= t @@ -1326,7 +1326,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, BINARY_FILE_TYP= E_FV, "%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: @@ -1719,7 +1719,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, BINARY_= FILE_TYPE_FV, "%s.map" % self.Platform.VpdToolGuid) if os.path.exists(VpdMapFilePath): VpdFile.Read(VpdMapFilePath) =20 @@ -1770,7 +1770,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, 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 =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(BINARY_FILE_TYPE_GUID) and ToolDef[BINA= RY_FILE_TYPE_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"] @@ -3032,7 +3032,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, BINARY_FILE_TYPE_FV, "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 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, AutoG= enH): # def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH): if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]: - GuidType =3D "GUID" + GuidType =3D BINARY_FILE_TYPE_GUID else: GuidType =3D "EFI_GUID" =20 @@ -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 =3D "GUID" + GuidType =3D BINARY_FILE_TYPE_GUID else: GuidType =3D "EFI_GUID" =20 @@ -1662,7 +1662,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 BINARY_FILE_TYPE_GUID else: GuidType =3D "EFI_GUID" =20 @@ -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 =3D "GUID" + GuidType =3D BINARY_FILE_TYPE_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 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) =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, BINARY_FIL= E_TYPE_FV, 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, BINARY_FILE_TYPE_FV) VarCheckTable =3D CreateVarCheckBin(VarCheckTableData) VarCheckTable.dump(dest, Phase) AdditionalAutoGenH, AdditionalAutoGenC =3D CreateAutoGen(PcdDrive= rAutoGenData) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/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 =3D 0 ValueStr =3D '' TokenSpaceGuidName =3D '' - if Item.startswith('GUID') and Item.endswith('= )'): + if Item.startswith(BINARY_FILE_TYPE_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 4a6a29c7ae80..61617ed589b3 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(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 =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 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) =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) @@ -91,7 +91,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 @@ -109,7 +109,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 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 =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. @@ -1881,7 +1881,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 @@ -1925,8 +1925,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) @@ -1934,10 +1934,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) @@ -2535,7 +2535,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(): @@ -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.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(): @@ -2888,7 +2888,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"): @@ -2972,10 +2972,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 @@ -3393,7 +3393,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"): @@ -3541,7 +3541,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): @@ -3774,8 +3774,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 @@ -3790,7 +3790,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 @@ -3831,8 +3831,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 @@ -3862,8 +3862,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(): @@ -3875,8 +3875,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() @@ -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, 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 @@ -3957,8 +3957,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() @@ -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 =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 @@ -4501,7 +4501,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 @@ -4582,7 +4582,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 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_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 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.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..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 =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 BINARY_FILE_TYPE= _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 BINARY_F= ILE_TYPE_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 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 =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.BINARY_FILE_TYPE_FV) 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.BINARY_FILE_TYPE_FV) 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..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 =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 [BINARY_FILE_TYPE_GUID, "EFI_PLABE= L", "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 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 =3D value.strip() if len(value) > 1: - if Value.startswith('GUID') and Value.endswith(')'): + if Value.startswith(BINARY_FILE_TYPE_GUID) and Value.endsw= ith(')'): 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 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, 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 BINARY_FILE_TYPE_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], BINARY_FILE_TYPE_FV, I= nfo[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, BINARY_FILE_TYPE_FV) 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