]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/FfsInfStatement.py
BaseTools: Replace StandardError with Expression
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FfsInfStatement.py
index f973cf2f0b76671ce1cc0c7e2e3ff3a4f4be3f38..b26821b29052ae7b3fcf8d262541de23c40ff38d 100644 (file)
@@ -29,7 +29,7 @@ import RuleSimpleFile
 import RuleComplexFile\r
 from CommonDataClass.FdfClass import FfsInfStatementClassObject\r
 from Common.MultipleWorkspace import MultipleWorkspace as mws\r
-from Common.String import *\r
+from Common.StringUtils import *\r
 from Common.Misc import PathClass\r
 from Common.Misc import GuidStructureByteArrayToGuidString\r
 from Common.Misc import ProcessDuplicatedInf\r
@@ -249,7 +249,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
             Pcd = InfPcds[PcdKey]\r
             if not hasattr(Pcd, 'Offset'):\r
                 continue\r
-            if Pcd.Type != 'PatchableInModule':\r
+            if Pcd.Type != TAB_PCDS_PATCHABLE_IN_MODULE:\r
                 continue\r
             # Override Patchable PCD value by the value from DSC\r
             PatchPcd = None\r
@@ -297,7 +297,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
 \r
             # Check value, if value are equal, no need to patch\r
             if Pcd.DatumType == TAB_VOID:\r
-                if Pcd.InfDefaultValue == DefaultValue or DefaultValue in [None, '']:\r
+                if Pcd.InfDefaultValue == DefaultValue or not DefaultValue:\r
                     continue\r
                 # Get the string size from FDF or DSC\r
                 if DefaultValue[0] == 'L':\r
@@ -310,7 +310,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 if DscOverride:\r
                     Pcd.MaxDatumSize = PatchPcd.MaxDatumSize\r
                 # If no defined the maximum size in DSC, try to get current size from INF\r
-                if Pcd.MaxDatumSize in ['', None]:\r
+                if not Pcd.MaxDatumSize:\r
                     Pcd.MaxDatumSize = str(len(Pcd.InfDefaultValue.split(',')))\r
             else:\r
                 Base1 = Base2 = 10\r
@@ -381,7 +381,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #\r
         # Only patch file if FileType is PE32 or ModuleType is USER_DEFINED\r
         #  \r
-        if FileType != 'PE32' and self.ModuleType != SUP_MODULE_USER_DEFINED:\r
+        if FileType != BINARY_FILE_TYPE_PE32 and self.ModuleType != SUP_MODULE_USER_DEFINED:\r
             return EfiFile\r
 \r
         #\r
@@ -739,13 +739,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
         # Convert Fv Section Type for PI1.1 SMM driver.\r
         #\r
         if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:\r
-            if SectionType == 'DXE_DEPEX':\r
-                SectionType = 'SMM_DEPEX'\r
+            if SectionType == BINARY_FILE_TYPE_DXE_DEPEX:\r
+                SectionType = BINARY_FILE_TYPE_SMM_DEPEX\r
         #\r
         # Framework SMM Driver has no SMM_DEPEX section type\r
         #\r
         if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:\r
-            if SectionType == 'SMM_DEPEX':\r
+            if SectionType == BINARY_FILE_TYPE_SMM_DEPEX:\r
                 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)\r
         NoStrip = True\r
         if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM):\r
@@ -767,7 +767,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 File = GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)\r
 \r
                 #Get PE Section alignment when align is set to AUTO\r
-                if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):\r
+                if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):\r
                     ImageObj = PeImageClass (File)\r
                     if ImageObj.SectionAlignment < 0x400:\r
                         self.Alignment = str (ImageObj.SectionAlignment)\r
@@ -790,7 +790,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                         )\r
                     File = StrippedFile\r
 \r
-                if SectionType == 'TE':\r
+                if SectionType == BINARY_FILE_TYPE_TE:\r
                     TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')\r
                     GenFdsGlobalVariable.GenerateFirmwareImage(\r
                             TeFile,\r
@@ -809,7 +809,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
             GenSecInputFile = GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)\r
 \r
             #Get PE Section alignment when align is set to AUTO\r
-            if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):\r
+            if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):\r
                 ImageObj = PeImageClass (GenSecInputFile)\r
                 if ImageObj.SectionAlignment < 0x400:\r
                     self.Alignment = str (ImageObj.SectionAlignment)\r
@@ -833,7 +833,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
                     )\r
                 GenSecInputFile = StrippedFile\r
 \r
-            if SectionType == 'TE':\r
+            if SectionType == BINARY_FILE_TYPE_TE:\r
                 TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')\r
                 GenFdsGlobalVariable.GenerateFirmwareImage(\r
                         TeFile,\r
@@ -942,13 +942,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
             # Convert Fv Section Type for PI1.1 SMM driver.\r
             #\r
             if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:\r
-                if Sect.SectionType == 'DXE_DEPEX':\r
-                    Sect.SectionType = 'SMM_DEPEX'\r
+                if Sect.SectionType == BINARY_FILE_TYPE_DXE_DEPEX:\r
+                    Sect.SectionType = BINARY_FILE_TYPE_SMM_DEPEX\r
             #\r
             # Framework SMM Driver has no SMM_DEPEX section type\r
             #\r
             if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:\r
-                if Sect.SectionType == 'SMM_DEPEX':\r
+                if Sect.SectionType == BINARY_FILE_TYPE_SMM_DEPEX:\r
                     EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)\r
             #\r
             # process the inside FvImage from FvSection or GuidSection\r