]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/GenFds.py
BaseTools: use predefined constants instead of local strings
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / GenFds.py
index 26122fc09943d8ca1645296e21c513461315553a..c507b0148af0baccdd7e608e086a655d531d5310 100644 (file)
@@ -24,7 +24,6 @@ import Common.BuildToolError as BuildToolError
 from GenFdsGlobalVariable import GenFdsGlobalVariable\r
 from Workspace.WorkspaceDatabase import WorkspaceDatabase\r
 from Workspace.BuildClassObject import PcdClassObject\r
-from Workspace.BuildClassObject import ModuleBuildClassObject\r
 import RuleComplexFile\r
 from EfiSection import EfiSection\r
 import StringIO\r
@@ -69,22 +68,22 @@ def main():
 \r
     EdkLogger.Initialize()\r
     try:\r
-        if Options.verbose != None:\r
+        if Options.verbose is not None:\r
             EdkLogger.SetLevel(EdkLogger.VERBOSE)\r
             GenFdsGlobalVariable.VerboseMode = True\r
             \r
-        if Options.FixedAddress != None:\r
+        if Options.FixedAddress is not None:\r
             GenFdsGlobalVariable.FixedLoadAddress = True\r
             \r
-        if Options.quiet != None:\r
+        if Options.quiet is not None:\r
             EdkLogger.SetLevel(EdkLogger.QUIET)\r
-        if Options.debug != None:\r
+        if Options.debug is not None:\r
             EdkLogger.SetLevel(Options.debug + 1)\r
             GenFdsGlobalVariable.DebugLevel = Options.debug\r
         else:\r
             EdkLogger.SetLevel(EdkLogger.INFO)\r
 \r
-        if (Options.Workspace == None):\r
+        if (Options.Workspace is None):\r
             EdkLogger.error("GenFds", OPTION_MISSING, "WORKSPACE not defined",\r
                             ExtraData="Please use '-w' switch to pass it or set the WORKSPACE environment variable.")\r
         elif not os.path.exists(Options.Workspace):\r
@@ -179,7 +178,7 @@ def main():
             # if no tool chain given in command line, get it from target.txt\r
             if not GenFdsGlobalVariable.ToolChainTag:\r
                 ToolChainList = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG]\r
-                if ToolChainList == None or len(ToolChainList) == 0:\r
+                if ToolChainList is None or len(ToolChainList) == 0:\r
                     EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE, ExtraData="No toolchain given. Don't know how to build.")\r
                 if len(ToolChainList) != 1:\r
                     EdkLogger.error("GenFds", OPTION_VALUE_INVALID, ExtraData="Only allows one instance for ToolChain.")\r
@@ -239,11 +238,11 @@ def main():
             ArchList = Options.archList.split(',')\r
         else:\r
 #            EdkLogger.error("GenFds", OPTION_MISSING, "Missing build ARCH")\r
-            ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList\r
+            ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList\r
 \r
-        TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList)\r
+        TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList)\r
         if len(TargetArchList) == 0:\r
-            EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList)))\r
+            EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON].SupArchList)))\r
         \r
         for Arch in ArchList:\r
             GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].OutputDirectory)\r
@@ -300,7 +299,7 @@ def main():
                                 "No such a Capsule in FDF file: %s" % Options.uiCapName)\r
 \r
         GenFdsGlobalVariable.WorkSpace = BuildWorkSpace\r
-        if ArchList != None:\r
+        if ArchList is not None:\r
             GenFdsGlobalVariable.ArchList = ArchList\r
 \r
         # Dsc Build Data will handle Pcd Settings from CommandLine.\r
@@ -340,7 +339,7 @@ def main():
         EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError=False)\r
         ReturnCode = FORMAT_INVALID\r
     except FatalError, X:\r
-        if Options.debug != None:\r
+        if Options.debug is not None:\r
             import traceback\r
             EdkLogger.quiet(traceback.format_exc())\r
         ReturnCode = X.args[0]\r
@@ -378,7 +377,7 @@ def SingleCheckCallback(option, opt_str, value, parser):
 def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):\r
     ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase\r
     # if user not specify filter, try to deduce it from global data.\r
-    if KeyStringList == None or KeyStringList == []:\r
+    if KeyStringList is None or KeyStringList == []:\r
         Target = GenFdsGlobalVariable.TargetName\r
         ToolChain = GenFdsGlobalVariable.ToolChainTag\r
         if ToolChain not in ToolDb['TOOL_CHAIN_TAG']:\r
@@ -411,7 +410,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
                 ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'\r
                 ToolPath = ToolDefinition.get(ToolPathKey)\r
                 ToolOption = ToolDefinition.get(ToolOptionKey)\r
-                if ToolPathTmp == None:\r
+                if ToolPathTmp is None:\r
                     ToolPathTmp = ToolPath\r
                 else:\r
                     if ToolPathTmp != ToolPath:\r
@@ -523,38 +522,38 @@ class GenFds :
         GenFdsGlobalVariable.SetDir ('', FdfParser, WorkSpace, ArchList)\r
 \r
         GenFdsGlobalVariable.VerboseLogger(" Generate all Fd images and their required FV and Capsule images!")\r
-        if GenFds.OnlyGenerateThisCap != None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():\r
+        if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():\r
             CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.get(GenFds.OnlyGenerateThisCap.upper())\r
-            if CapsuleObj != None:\r
+            if CapsuleObj is not None:\r
                 CapsuleObj.GenCapsule()\r
                 return\r
 \r
-        if GenFds.OnlyGenerateThisFd != None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
+        if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
             FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(GenFds.OnlyGenerateThisFd.upper())\r
-            if FdObj != None:\r
+            if FdObj is not None:\r
                 FdObj.GenFd()\r
                 return\r
-        elif GenFds.OnlyGenerateThisFd == None and GenFds.OnlyGenerateThisFv == None:\r
+        elif GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisFv is None:\r
             for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
                 FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]\r
                 FdObj.GenFd()\r
 \r
         GenFdsGlobalVariable.VerboseLogger("\n Generate other FV images! ")\r
-        if GenFds.OnlyGenerateThisFv != None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():\r
+        if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():\r
             FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(GenFds.OnlyGenerateThisFv.upper())\r
-            if FvObj != None:\r
+            if FvObj is not None:\r
                 Buffer = StringIO.StringIO()\r
                 FvObj.AddToBuffer(Buffer)\r
                 Buffer.close()\r
                 return\r
-        elif GenFds.OnlyGenerateThisFv == None:\r
+        elif GenFds.OnlyGenerateThisFv is None:\r
             for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():\r
                 Buffer = StringIO.StringIO('')\r
                 FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]\r
                 FvObj.AddToBuffer(Buffer)\r
                 Buffer.close()\r
         \r
-        if GenFds.OnlyGenerateThisFv == None and GenFds.OnlyGenerateThisFd == None and GenFds.OnlyGenerateThisCap == None:\r
+        if GenFds.OnlyGenerateThisFv is None and GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisCap is None:\r
             if GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict != {}:\r
                 GenFdsGlobalVariable.VerboseLogger("\n Generate other Capsule images!")\r
                 for CapsuleName in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys():\r
@@ -592,14 +591,14 @@ class GenFds :
     def GetFvBlockSize(FvObj):\r
         DefaultBlockSize = 0x1\r
         FdObj = None\r
-        if GenFds.OnlyGenerateThisFd != None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
+        if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
             FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()]\r
-        if FdObj == None:\r
+        if FdObj is None:\r
             for ElementFd in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():\r
                 for ElementRegion in ElementFd.RegionList:\r
                     if ElementRegion.RegionType == 'FV':\r
                         for ElementRegionData in ElementRegion.RegionDataList:\r
-                            if ElementRegionData != None and ElementRegionData.upper() == FvObj.UiFvName:\r
+                            if ElementRegionData is not None and ElementRegionData.upper() == FvObj.UiFvName:\r
                                 if FvObj.BlockSizeList != []:\r
                                     return FvObj.BlockSizeList[0][0]\r
                                 else:\r
@@ -611,7 +610,7 @@ class GenFds :
             for ElementRegion in FdObj.RegionList:\r
                     if ElementRegion.RegionType == 'FV':\r
                         for ElementRegionData in ElementRegion.RegionDataList:\r
-                            if ElementRegionData != None and ElementRegionData.upper() == FvObj.UiFvName:\r
+                            if ElementRegionData is not None and ElementRegionData.upper() == FvObj.UiFvName:\r
                                 if FvObj.BlockSizeList != []:\r
                                     return FvObj.BlockSizeList[0][0]\r
                                 else:\r
@@ -675,7 +674,7 @@ class GenFds :
     #   @retval None\r
     #\r
     def PreprocessImage(BuildDb, DscFile):\r
-        PcdDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds\r
+        PcdDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds\r
         PcdValue = ''\r
         for Key in PcdDict:\r
             PcdObj = PcdDict[Key]\r
@@ -694,9 +693,9 @@ class GenFds :
         if Int64PcdValue > 0:\r
             TopAddress = Int64PcdValue\r
             \r
-        ModuleDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules\r
+        ModuleDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules\r
         for Key in ModuleDict:\r
-            ModuleObj = BuildDb.BuildObject[Key, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
+            ModuleObj = BuildDb.BuildObject[Key, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
             print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType\r
 \r
     def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):\r