X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FGenFdsGlobalVariable.py;h=c2e82de891d3594cc08cfbcd769f476200455762;hp=909d043c2a22f24509fff7378ba2956f8e948783;hb=caf744956d4c8c0ef358bdc3df2cdb10265c2ea8;hpb=be409b67566348f75b69e66ef9604b248e053553 diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index 909d043c2a..c2e82de891 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -102,7 +102,7 @@ class GenFdsGlobalVariable: TargetTxt.LoadTargetTxtFile(BuildConfigurationFile) if DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF in TargetTxt.TargetTxtDictionary: BuildRuleFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF] - if BuildRuleFile in [None, '']: + if not BuildRuleFile: BuildRuleFile = 'Conf/build_rule.txt' GenFdsGlobalVariable.__BuildRuleDatabase = BuildRule(BuildRuleFile) ToolDefinitionFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF] @@ -288,7 +288,7 @@ class GenFdsGlobalVariable: # GenFdsGlobalVariable.OutputDirDict = OutputDir GenFdsGlobalVariable.FdfParser = FdfParser GenFdsGlobalVariable.WorkSpace = WorkSpace - GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV') + GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.TAB_FV_DIRECTORY) if not os.path.exists(GenFdsGlobalVariable.FvDir) : os.makedirs(GenFdsGlobalVariable.FvDir) GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs') @@ -349,7 +349,7 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.PlatformName = WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GlobalData.gGlobalDefines['TARGET'], GlobalData.gGlobalDefines['TOOLCHAIN']].PlatformName - GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV') + GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.TAB_FV_DIRECTORY) if not os.path.exists(GenFdsGlobalVariable.FvDir): os.makedirs(GenFdsGlobalVariable.FvDir) GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs') @@ -439,36 +439,33 @@ class GenFdsGlobalVariable: @staticmethod def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None, - GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None, BuildNumber=None, DummyFile=None, IsMakefile=False): + GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=[], BuildNumber=None, DummyFile=None, IsMakefile=False): Cmd = ["GenSec"] - if Type not in [None, '']: - Cmd += ["-s", Type] - if CompressionType not in [None, '']: - Cmd += ["-c", CompressionType] + if Type: + Cmd += ("-s", Type) + if CompressionType: + Cmd += ("-c", CompressionType) if Guid is not None: - Cmd += ["-g", Guid] + Cmd += ("-g", Guid) if DummyFile is not None: - Cmd += ["--dummy", DummyFile] - if GuidHdrLen not in [None, '']: - Cmd += ["-l", GuidHdrLen] - if len(GuidAttr) != 0: - #Add each guided attribute - for Attr in GuidAttr: - Cmd += ["-r", Attr] - if InputAlign is not None: - #Section Align is only for dummy section without section type - for SecAlign in InputAlign: - Cmd += ["--sectionalign", SecAlign] + Cmd += ("--dummy", DummyFile) + if GuidHdrLen: + Cmd += ("-l", GuidHdrLen) + #Add each guided attribute + for Attr in GuidAttr: + Cmd += ("-r", Attr) + #Section Align is only for dummy section without section type + for SecAlign in InputAlign: + Cmd += ("--sectionalign", SecAlign) CommandFile = Output + '.txt' - if Ui not in [None, '']: - #Cmd += ["-n", '"' + Ui + '"'] + if Ui: if IsMakefile: if Ui == "$(MODULE_NAME)": - Cmd += ['-n', Ui] + Cmd += ('-n', Ui) else: - Cmd += ["-n", '"' + Ui + '"'] - Cmd += ["-o", Output] + Cmd += ("-n", '"' + Ui + '"') + Cmd += ("-o", Output) if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList: GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip()) else: @@ -480,11 +477,11 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15) SaveFileOnChange(Output, SectionData.tostring()) - elif Ver not in [None, '']: - Cmd += ["-n", Ver] + elif Ver: + Cmd += ("-n", Ver) if BuildNumber: - Cmd += ["-j", BuildNumber] - Cmd += ["-o", Output] + Cmd += ("-j", BuildNumber) + Cmd += ("-o", Output) SaveFileOnChange(CommandFile, ' '.join(Cmd), False) if IsMakefile: @@ -495,7 +492,7 @@ class GenFdsGlobalVariable: return GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section") else: - Cmd += ["-o", Output] + Cmd += ("-o", Output) Cmd += Input SaveFileOnChange(CommandFile, ' '.join(Cmd), False) @@ -526,22 +523,22 @@ class GenFdsGlobalVariable: Cmd = ["GenFfs", "-t", Type, "-g", Guid] mFfsValidAlign = ["0", "8", "16", "128", "512", "1K", "4K", "32K", "64K", "128K", "256K", "512K", "1M", "2M", "4M", "8M", "16M"] if Fixed == True: - Cmd += ["-x"] + Cmd.append("-x") if CheckSum: - Cmd += ["-s"] - if Align not in [None, '']: + Cmd.append("-s") + if Align: if Align not in mFfsValidAlign: Align = GenFdsGlobalVariable.GetAlignment (Align) for index in range(0, len(mFfsValidAlign) - 1): if ((Align > GenFdsGlobalVariable.GetAlignment(mFfsValidAlign[index])) and (Align <= GenFdsGlobalVariable.GetAlignment(mFfsValidAlign[index + 1]))): break Align = mFfsValidAlign[index + 1] - Cmd += ["-a", Align] + Cmd += ("-a", Align) - Cmd += ["-o", Output] + Cmd += ("-o", Output) for I in range(0, len(Input)): Cmd += ("-i", Input[I]) - if SectionAlign not in [None, '', []] and SectionAlign[I] not in [None, '']: + if SectionAlign and SectionAlign[I]: Cmd += ("-n", SectionAlign[I]) CommandFile = Output + '.txt' @@ -566,27 +563,27 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input)) Cmd = ["GenFv"] - if BaseAddress not in [None, '']: - Cmd += ["-r", BaseAddress] + if BaseAddress: + Cmd += ("-r", BaseAddress) if ForceRebase == False: - Cmd += ["-F", "FALSE"] + Cmd += ("-F", "FALSE") elif ForceRebase == True: - Cmd += ["-F", "TRUE"] + Cmd += ("-F", "TRUE") if Capsule: - Cmd += ["-c"] + Cmd.append("-c") if Dump: - Cmd += ["-p"] - if AddressFile not in [None, '']: - Cmd += ["-a", AddressFile] - if MapFile not in [None, '']: - Cmd += ["-m", MapFile] + Cmd.append("-p") + if AddressFile: + Cmd += ("-a", AddressFile) + if MapFile: + Cmd += ("-m", MapFile) if FileSystemGuid: - Cmd += ["-g", FileSystemGuid] - Cmd += ["-o", Output] + Cmd += ("-g", FileSystemGuid) + Cmd += ("-o", Output) for I in Input: - Cmd += ["-i", I] + Cmd += ("-i", I) GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FV") @@ -597,13 +594,13 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input)) Cmd = ["GenVtf"] - if BaseAddress not in [None, ''] and FvSize not in [None, ''] \ + if BaseAddress and FvSize \ and len(BaseAddress) == len(FvSize): for I in range(0, len(BaseAddress)): - Cmd += ["-r", BaseAddress[I], "-s", FvSize[I]] - Cmd += ["-o", Output] + Cmd += ("-r", BaseAddress[I], "-s", FvSize[I]) + Cmd += ("-o", Output) for F in Input: - Cmd += ["-f", F] + Cmd += ("-f", F) GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate VTF") @@ -617,26 +614,26 @@ class GenFdsGlobalVariable: Cmd = ["GenFw"] if Type.lower() == "te": - Cmd += ["-t"] - if SubType not in [None, '']: - Cmd += ["-e", SubType] - if TimeStamp not in [None, '']: - Cmd += ["-s", TimeStamp] - if Align not in [None, '']: - Cmd += ["-a", Align] - if Padding not in [None, '']: - Cmd += ["-p", Padding] + Cmd.append("-t") + if SubType: + Cmd += ("-e", SubType) + if TimeStamp: + Cmd += ("-s", TimeStamp) + if Align: + Cmd += ("-a", Align) + if Padding: + Cmd += ("-p", Padding) if Zero: - Cmd += ["-z"] + Cmd.append("-z") if Strip: - Cmd += ["-l"] + Cmd.append("-l") if Replace: - Cmd += ["-r"] + Cmd.append("-r") if Join: - Cmd += ["-j"] + Cmd.append("-j") if Convert: - Cmd += ["-m"] - Cmd += ["-o", Output] + Cmd.append("-m") + Cmd += ("-o", Output) Cmd += Input if IsMakefile: if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList: @@ -652,18 +649,18 @@ class GenFdsGlobalVariable: if len(EfiInput) > 0: if Compress: - Cmd += ["-ec"] + Cmd.append("-ec") else: - Cmd += ["-e"] + Cmd.append("-e") for EfiFile in EfiInput: - Cmd += [EfiFile] + Cmd.append(EfiFile) InputList.append (EfiFile) if len(BinaryInput) > 0: - Cmd += ["-b"] + Cmd.append("-b") for BinFile in BinaryInput: - Cmd += [BinFile] + Cmd.append(BinFile) InputList.append (BinFile) # Check List @@ -672,15 +669,15 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, InputList)) if ClassCode is not None: - Cmd += ["-l", ClassCode] + Cmd += ("-l", ClassCode) if Revision is not None: - Cmd += ["-r", Revision] + Cmd += ("-r", Revision) if DeviceId is not None: - Cmd += ["-i", DeviceId] + Cmd += ("-i", DeviceId) if VendorId is not None: - Cmd += ["-f", VendorId] + Cmd += ("-f", VendorId) - Cmd += ["-o", Output] + Cmd += ("-o", Output) if IsMakefile: if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList: GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip()) @@ -695,7 +692,7 @@ class GenFdsGlobalVariable: Cmd = [ToolPath, ] Cmd += Options.split(' ') - Cmd += ["-o", Output] + Cmd += ("-o", Output) Cmd += Input if IsMakefile: if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList: