X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FGenFds.py;h=b90b50e53967e4215ba22d1fe13915936f606f32;hb=15e20228258c1714cd90207a52101a5b1b54cd2c;hp=03126e35f47ae3259a094a0274059510baf41b86;hpb=705ed563de86475a32fb555d4238cc10717294f8;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index 03126e35f4..b90b50e539 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -15,6 +15,7 @@ ## # Import Modules # +from __future__ import print_function from optparse import OptionParser import sys import Common.LongFilePathOs as os @@ -24,16 +25,15 @@ import Common.BuildToolError as BuildToolError from GenFdsGlobalVariable import GenFdsGlobalVariable from Workspace.WorkspaceDatabase import WorkspaceDatabase from Workspace.BuildClassObject import PcdClassObject -from Workspace.BuildClassObject import ModuleBuildClassObject import RuleComplexFile from EfiSection import EfiSection -import StringIO +from io import BytesIO import Common.TargetTxtClassObject as TargetTxtClassObject import Common.ToolDefClassObject as ToolDefClassObject from Common.DataType import * import Common.GlobalData as GlobalData from Common import EdkLogger -from Common.String import * +from Common.StringUtils import * from Common.Misc import DirCache, PathClass from Common.Misc import SaveFileOnChange from Common.Misc import ClearDuplicatedInf @@ -47,7 +47,7 @@ from struct import unpack ## Version and Copyright versionNumber = "1.0" + ' ' + gBUILD_VERSION __version__ = "%prog Version " + versionNumber -__copyright__ = "Copyright (c) 2007 - 2017, Intel Corporation All rights reserved." +__copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation All rights reserved." ## Tool entrance method # @@ -69,22 +69,22 @@ def main(): EdkLogger.Initialize() try: - if Options.verbose != None: + if Options.verbose is not None: EdkLogger.SetLevel(EdkLogger.VERBOSE) GenFdsGlobalVariable.VerboseMode = True - - if Options.FixedAddress != None: + + if Options.FixedAddress is not None: GenFdsGlobalVariable.FixedLoadAddress = True - - if Options.quiet != None: + + if Options.quiet is not None: EdkLogger.SetLevel(EdkLogger.QUIET) - if Options.debug != None: + if Options.debug is not None: EdkLogger.SetLevel(Options.debug + 1) GenFdsGlobalVariable.DebugLevel = Options.debug else: EdkLogger.SetLevel(EdkLogger.INFO) - if (Options.Workspace == None): + if (Options.Workspace is None): EdkLogger.error("GenFds", OPTION_MISSING, "WORKSPACE not defined", ExtraData="Please use '-w' switch to pass it or set the WORKSPACE environment variable.") elif not os.path.exists(Options.Workspace): @@ -93,14 +93,14 @@ def main(): else: Workspace = os.path.normcase(Options.Workspace) GenFdsGlobalVariable.WorkSpaceDir = Workspace - if 'EDK_SOURCE' in os.environ.keys(): + if 'EDK_SOURCE' in os.environ: GenFdsGlobalVariable.EdkSourceDir = os.path.normcase(os.environ['EDK_SOURCE']) if (Options.debug): GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace) if Options.GenfdsMultiThread: GenFdsGlobalVariable.EnableGenfdsMultiThread = True os.chdir(GenFdsGlobalVariable.WorkSpaceDir) - + # set multiple workspace PackagesPath = os.getenv("PACKAGES_PATH") mws.setWs(GenFdsGlobalVariable.WorkSpaceDir, PackagesPath) @@ -157,7 +157,7 @@ def main(): # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath) else: - if "CONF_PATH" in os.environ.keys(): + if "CONF_PATH" in os.environ: ConfDirectoryPath = os.path.normcase(os.environ["CONF_PATH"]) else: # Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf @@ -179,7 +179,7 @@ def main(): # if no tool chain given in command line, get it from target.txt if not GenFdsGlobalVariable.ToolChainTag: ToolChainList = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG] - if ToolChainList == None or len(ToolChainList) == 0: + if ToolChainList is None or len(ToolChainList) == 0: EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE, ExtraData="No toolchain given. Don't know how to build.") if len(ToolChainList) != 1: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, ExtraData="Only allows one instance for ToolChain.") @@ -217,18 +217,18 @@ def main(): os.environ["WORKSPACE"] = Workspace # Use the -t and -b option as gGlobalDefines's TOOLCHAIN and TARGET if they are not defined - if "TARGET" not in GlobalData.gGlobalDefines.keys(): + if "TARGET" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines["TARGET"] = GenFdsGlobalVariable.TargetName - if "TOOLCHAIN" not in GlobalData.gGlobalDefines.keys(): + if "TOOLCHAIN" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines["TOOLCHAIN"] = GenFdsGlobalVariable.ToolChainTag - if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines.keys(): + if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = GenFdsGlobalVariable.ToolChainTag """call Workspace build create database""" GlobalData.gDatabasePath = os.path.normpath(os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath)) BuildWorkSpace = WorkspaceDatabase(GlobalData.gDatabasePath) BuildWorkSpace.InitDatabase() - + # # Get files real name in workspace dir # @@ -239,12 +239,12 @@ def main(): ArchList = Options.archList.split(',') else: # EdkLogger.error("GenFds", OPTION_MISSING, "Missing build ARCH") - ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList + ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList - TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON', Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList) + TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList) if len(TargetArchList) == 0: - EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList))) - + EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON].SupArchList))) + for Arch in ArchList: GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].OutputDirectory) GenFdsGlobalVariable.PlatformName = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].PlatformName @@ -279,28 +279,28 @@ def main(): EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file") if (Options.uiFdName) : - if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict.keys(): + if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict: GenFds.OnlyGenerateThisFd = Options.uiFdName else: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, "No such an FD in FDF file: %s" % Options.uiFdName) if (Options.uiFvName) : - if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict.keys(): + if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict: GenFds.OnlyGenerateThisFv = Options.uiFvName else: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, "No such an FV in FDF file: %s" % Options.uiFvName) if (Options.uiCapName) : - if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict.keys(): + if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict: GenFds.OnlyGenerateThisCap = Options.uiCapName else: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, "No such a Capsule in FDF file: %s" % Options.uiCapName) GenFdsGlobalVariable.WorkSpace = BuildWorkSpace - if ArchList != None: + if ArchList is not None: GenFdsGlobalVariable.ArchList = ArchList # Dsc Build Data will handle Pcd Settings from CommandLine. @@ -316,7 +316,7 @@ def main(): for Fd in FdfParserObj.Profile.FdDict: FdObj = FdfParserObj.Profile.FdDict[Fd] for RegionObj in FdObj.RegionList: - if RegionObj.RegionType != 'FV': + if RegionObj.RegionType != BINARY_FILE_TYPE_FV: continue for RegionData in RegionObj.RegionDataList: if FvObj.UiFvName.upper() == RegionData.upper(): @@ -336,11 +336,11 @@ def main(): """Display FV space info.""" GenFds.DisplayFvSpaceInfo(FdfParserObj) - except FdfParser.Warning, X: + except FdfParser.Warning as X: EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError=False) ReturnCode = FORMAT_INVALID - except FatalError, X: - if Options.debug != None: + except FatalError as X: + if Options.debug is not None: import traceback EdkLogger.quiet(traceback.format_exc()) ReturnCode = X.args[0] @@ -378,7 +378,7 @@ def SingleCheckCallback(option, opt_str, value, parser): def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase # if user not specify filter, try to deduce it from global data. - if KeyStringList == None or KeyStringList == []: + if KeyStringList is None or KeyStringList == []: Target = GenFdsGlobalVariable.TargetName ToolChain = GenFdsGlobalVariable.ToolChainTag if ToolChain not in ToolDb['TOOL_CHAIN_TAG']: @@ -389,7 +389,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): KeyStringList.append(Target + '_' + ToolChain + '_' + Arch) if GenFdsGlobalVariable.GuidToolDefinition: - if NameGuid in GenFdsGlobalVariable.GuidToolDefinition.keys(): + if NameGuid in GenFdsGlobalVariable.GuidToolDefinition: return GenFdsGlobalVariable.GuidToolDefinition[NameGuid] ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary @@ -399,19 +399,19 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): ToolOptionKey = None KeyList = None for ToolDef in ToolDefinition.items(): - if NameGuid == ToolDef[1]: + if NameGuid.lower() == ToolDef[1].lower() : KeyList = ToolDef[0].split('_') Key = KeyList[0] + \ '_' + \ KeyList[1] + \ '_' + \ KeyList[2] - if Key in KeyStringList and KeyList[4] == 'GUID': + if Key in KeyStringList and KeyList[4] == TAB_GUID: ToolPathKey = Key + '_' + KeyList[3] + '_PATH' ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS' ToolPath = ToolDefinition.get(ToolPathKey) ToolOption = ToolDefinition.get(ToolOptionKey) - if ToolPathTmp == None: + if ToolPathTmp is None: ToolPathTmp = ToolPath else: if ToolPathTmp != ToolPath: @@ -429,7 +429,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): if BuildOption: ToolList = [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG, TAB_TOD_DEFINES_TARGET_ARCH] for Index in range(2, -1, -1): - for Key in dict(BuildOption): + for Key in list(BuildOption.keys()): List = Key.split('_') if List[Index] == '*': for String in ToolDb[ToolList[Index]]: @@ -448,13 +448,13 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): if NameGuid == BuildOption[Op]: KeyList = Op.split('_') Key = KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2] - if Key in KeyStringList and KeyList[4] == 'GUID': + if Key in KeyStringList and KeyList[4] == TAB_GUID: ToolPathKey = Key + '_' + KeyList[3] + '_PATH' ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS' - if ToolPathKey in BuildOption.keys(): - ToolPathTmp = BuildOption.get(ToolPathKey) - if ToolOptionKey in BuildOption.keys(): - ToolOption = BuildOption.get(ToolOptionKey) + if ToolPathKey in BuildOption: + ToolPathTmp = BuildOption[ToolPathKey] + if ToolOptionKey in BuildOption: + ToolOption = BuildOption[ToolOptionKey] GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption) return ToolPathTmp, ToolOption @@ -523,63 +523,56 @@ class GenFds : GenFdsGlobalVariable.SetDir ('', FdfParser, WorkSpace, ArchList) GenFdsGlobalVariable.VerboseLogger(" Generate all Fd images and their required FV and Capsule images!") - if GenFds.OnlyGenerateThisCap != None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys(): - CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.get(GenFds.OnlyGenerateThisCap.upper()) - if CapsuleObj != None: + if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateThisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict: + CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[GenFds.OnlyGenerateThisCap.upper()] + if CapsuleObj is not None: CapsuleObj.GenCapsule() return - if GenFds.OnlyGenerateThisFd != None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): - FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(GenFds.OnlyGenerateThisFd.upper()) - if FdObj != None: + if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict: + FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()] + if FdObj is not None: FdObj.GenFd() return - elif GenFds.OnlyGenerateThisFd == None and GenFds.OnlyGenerateThisFv == None: - for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): - FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName] + elif GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisFv is None: + for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values(): FdObj.GenFd() GenFdsGlobalVariable.VerboseLogger("\n Generate other FV images! ") - if GenFds.OnlyGenerateThisFv != None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): - FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(GenFds.OnlyGenerateThisFv.upper()) - if FvObj != None: - Buffer = StringIO.StringIO() + if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict: + FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[GenFds.OnlyGenerateThisFv.upper()] + if FvObj is not None: + Buffer = BytesIO() FvObj.AddToBuffer(Buffer) Buffer.close() return - elif GenFds.OnlyGenerateThisFv == None: - for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): - Buffer = StringIO.StringIO('') - FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName] + elif GenFds.OnlyGenerateThisFv is None: + for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values(): + Buffer = BytesIO('') FvObj.AddToBuffer(Buffer) Buffer.close() - - if GenFds.OnlyGenerateThisFv == None and GenFds.OnlyGenerateThisFd == None and GenFds.OnlyGenerateThisCap == None: + + if GenFds.OnlyGenerateThisFv is None and GenFds.OnlyGenerateThisFd is None and GenFds.OnlyGenerateThisCap is None: if GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict != {}: GenFdsGlobalVariable.VerboseLogger("\n Generate other Capsule images!") - for CapsuleName in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys(): - CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[CapsuleName] + for CapsuleObj in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.values(): CapsuleObj.GenCapsule() if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}: GenFdsGlobalVariable.VerboseLogger("\n Generate all Option ROM!") - for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys(): - OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName] + for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.values(): OptRomObj.AddToBuffer(None) @staticmethod def GenFfsMakefile(OutputDir, FdfParser, WorkSpace, ArchList, GlobalData): GenFdsGlobalVariable.SetEnv(FdfParser, WorkSpace, ArchList, GlobalData) - for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): - FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName] + for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values(): FdObj.GenFd(Flag=True) - for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): - FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName] + for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values(): FvObj.AddToBuffer(Buffer=None, Flag=True) if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}: - for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys(): - OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName] + for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.values(): OptRomObj.AddToBuffer(Buffer=None, Flag=True) return GenFdsGlobalVariable.FfsCmdDict @@ -592,14 +585,14 @@ class GenFds : def GetFvBlockSize(FvObj): DefaultBlockSize = 0x1 FdObj = None - if GenFds.OnlyGenerateThisFd != None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): + if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict: FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()] - if FdObj == None: + if FdObj is None: for ElementFd in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values(): for ElementRegion in ElementFd.RegionList: - if ElementRegion.RegionType == 'FV': + if ElementRegion.RegionType == BINARY_FILE_TYPE_FV: for ElementRegionData in ElementRegion.RegionDataList: - if ElementRegionData != None and ElementRegionData.upper() == FvObj.UiFvName: + if ElementRegionData is not None and ElementRegionData.upper() == FvObj.UiFvName: if FvObj.BlockSizeList != []: return FvObj.BlockSizeList[0][0] else: @@ -609,9 +602,9 @@ class GenFds : return DefaultBlockSize else: for ElementRegion in FdObj.RegionList: - if ElementRegion.RegionType == 'FV': + if ElementRegion.RegionType == BINARY_FILE_TYPE_FV: for ElementRegionData in ElementRegion.RegionDataList: - if ElementRegionData != None and ElementRegionData.upper() == FvObj.UiFvName: + if ElementRegionData is not None and ElementRegionData.upper() == FvObj.UiFvName: if FvObj.BlockSizeList != []: return FvObj.BlockSizeList[0][0] else: @@ -624,7 +617,7 @@ class GenFds : # @retval None # def DisplayFvSpaceInfo(FdfParser): - + FvSpaceInfoList = [] MaxFvNameLength = 0 for FvName in FdfParser.Profile.FvDict: @@ -651,10 +644,10 @@ class GenFds : if NameValue[0].strip() == 'EFI_FV_SPACE_SIZE': FreeFound = True Free = NameValue[1].strip() - + if TotalFound and UsedFound and FreeFound: FvSpaceInfoList.append((FvName, Total, Used, Free)) - + GenFdsGlobalVariable.InfLogger('\nFV Space Information') for FvSpaceInfo in FvSpaceInfoList: Name = FvSpaceInfo[0] @@ -675,33 +668,33 @@ class GenFds : # @retval None # def PreprocessImage(BuildDb, DscFile): - PcdDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds + PcdDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds PcdValue = '' for Key in PcdDict: PcdObj = PcdDict[Key] if PcdObj.TokenCName == 'PcdBsBaseAddress': PcdValue = PcdObj.DefaultValue break - + if PcdValue == '': return - + Int64PcdValue = long(PcdValue, 0) - if Int64PcdValue == 0 or Int64PcdValue < -1: + if Int64PcdValue == 0 or Int64PcdValue < -1: return - + TopAddress = 0 if Int64PcdValue > 0: TopAddress = Int64PcdValue - - ModuleDict = BuildDb.BuildObject[DscFile, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules + + ModuleDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules for Key in ModuleDict: - ModuleObj = BuildDb.BuildObject[Key, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] - print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType + ModuleObj = BuildDb.BuildObject[Key, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] + print(ModuleObj.BaseName + ' ' + ModuleObj.ModuleType) def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj): GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, "Guid.xref") - GuidXRefFile = StringIO.StringIO('') + GuidXRefFile = BytesIO('') GuidDict = {} ModuleList = [] FileGuidList = [] @@ -769,7 +762,7 @@ class GenFds : length = F.tell() F.seek(4) TmpStr = unpack('%dh' % ((length - 4) / 2), F.read()) - Name = ''.join([chr(c) for c in TmpStr[:-1]]) + Name = ''.join(chr(c) for c in TmpStr[:-1]) else: FileList = [] if 'fv.sec.txt' in MatchDict: @@ -792,7 +785,7 @@ class GenFds : if not Name: continue - Name = ' '.join(Name) if type(Name) == type([]) else Name + Name = ' '.join(Name) if isinstance(Name, type([])) else Name GuidXRefFile.write("%s %s\n" %(FileStatementGuid, Name)) # Append GUIDs, Protocols, and PPIs to the Xref file