From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 A22D6207E637F for ; Thu, 17 May 2018 17:06:55 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 May 2018 17:06:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,413,1520924400"; d="scan'208";a="56905109" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga001.jf.intel.com with ESMTP; 17 May 2018 17:06:54 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Liming Gao , Yonghong Zhu Date: Thu, 17 May 2018 17:06:52 -0700 Message-Id: <659ea4a0cdeebe126604a1ee4fe4226770d03183.1526601941.git.jaben.carsey@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [PATCH v1 2/2] BaseTools: Cleanup unneeded code 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: Fri, 18 May 2018 00:06:55 -0000 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/AutoGen.py | 335 +++++++++----------- BaseTools/Source/Python/AutoGen/GenC.py | 2 +- BaseTools/Source/Python/AutoGen/GenMake.py | 4 +- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 14 +- BaseTools/Source/Python/AutoGen/GenVar.py | 2 +- BaseTools/Source/Python/AutoGen/StrGather.py | 8 +- BaseTools/Source/Python/Common/Misc.py | 2 +- BaseTools/Source/Python/Common/String.py | 2 +- BaseTools/Source/Python/Common/VpdInfoFile.py | 2 +- BaseTools/Source/Python/GenFds/FdfParser.py | 8 +- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 119 ++++--- BaseTools/Source/Python/build/BuildReport.py | 26 +- BaseTools/Source/Python/build/build.py | 6 +- 13 files changed, 246 insertions(+), 284 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index d1801bff9c83..a0f57903a40e 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -50,6 +50,7 @@ import hashlib from GenVar import VariableMgr,var_info from collections import OrderedDict from collections import defaultdict +from Workspace.WorkspaceCommon import OrderedListDict ## Regular expression for splitting Dependency Expression string into tokens gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)") @@ -463,7 +464,7 @@ class WorkspaceAutoGen(AutoGen): 'build', FORMAT_INVALID, "Building modules from source INFs, following PCD use %s and %s access method. It must be corrected to use only one access method." % (i, j), - ExtraData="%s" % '\n\t'.join(str(P[1]+'.'+P[0]) for P in Intersections) + ExtraData='\n\t'.join(str(P[1]+'.'+P[0]) for P in Intersections) ) # @@ -705,10 +706,9 @@ class WorkspaceAutoGen(AutoGen): # if self.FdfFile: AllWorkSpaceMetaFiles.add (self.FdfFile.Path) - if self.FdfFile: - FdfFiles = GlobalData.gFdfParser.GetAllIncludedFile() - for f in FdfFiles: - AllWorkSpaceMetaFiles.add (f.FileName) + for f in GlobalData.gFdfParser.GetAllIncludedFile(): + AllWorkSpaceMetaFiles.add (f.FileName) + # # add dsc # @@ -729,19 +729,16 @@ class WorkspaceAutoGen(AutoGen): AllWorkSpaceMetaFiles.add(os.path.join(self.BuildDir, 'PcdTokenNumber')) for Arch in self.ArchList: - Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain] - PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch) - # # add dec # - for Package in PGen.PackageList: + for Package in PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch).PackageList: AllWorkSpaceMetaFiles.add(Package.MetaFile.Path) # # add included dsc # - for filePath in Platform._RawData.IncludedFiles: + for filePath in self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]._RawData.IncludedFiles: AllWorkSpaceMetaFiles.add(filePath.Path) return AllWorkSpaceMetaFiles @@ -872,12 +869,11 @@ class WorkspaceAutoGen(AutoGen): def _CheckPcdDefineAndType(self): - PcdTypeList = [ - TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG, - TAB_PCDS_DYNAMIC, #TAB_PCDS_DYNAMIC_HII, TAB_PCDS_DYNAMIC_VPD, - TAB_PCDS_DYNAMIC_EX, # TAB_PCDS_DYNAMIC_EX_HII, TAB_PCDS_DYNAMIC_EX_VPD - ] - + PcdTypeSet = {TAB_PCDS_FIXED_AT_BUILD, + TAB_PCDS_PATCHABLE_IN_MODULE, + TAB_PCDS_FEATURE_FLAG, + TAB_PCDS_DYNAMIC, + TAB_PCDS_DYNAMIC_EX} # This dict store PCDs which are not used by any modules with specified arches UnusedPcd = OrderedDict() for Pa in self.AutoGenObjectList: @@ -899,7 +895,7 @@ class WorkspaceAutoGen(AutoGen): # Key of DEC's Pcds dictionary is PcdCName, TokenSpaceGuid, PcdType if (Pcd[0], Pcd[1], PcdType) in Package.Pcds: break - for Type in PcdTypeList: + for Type in PcdTypeSet: if (Pcd[0], Pcd[1], Type) in Package.Pcds: EdkLogger.error( 'build', @@ -1057,9 +1053,10 @@ class WorkspaceAutoGen(AutoGen): # modules will be created as well # def CreateMakeFile(self, CreateDepsMakeFile=False): - if CreateDepsMakeFile: - for Pa in self.AutoGenObjectList: - Pa.CreateMakeFile(CreateDepsMakeFile) + if not CreateDepsMakeFile: + return + for Pa in self.AutoGenObjectList: + Pa.CreateMakeFile(True) ## Create autogen code for platform and modules # @@ -1073,7 +1070,7 @@ class WorkspaceAutoGen(AutoGen): if not CreateDepsCodeFile: return for Pa in self.AutoGenObjectList: - Pa.CreateCodeFile(CreateDepsCodeFile) + Pa.CreateCodeFile(True) ## Create AsBuilt INF file the platform # @@ -1378,11 +1375,7 @@ class PlatformAutoGen(AutoGen): del self.Platform.Pcds[key] self.Platform.Pcds[newkey] = Value break - else: - pass break - else: - pass # for gathering error information NoDatumTypePcdList = set() @@ -1567,8 +1560,7 @@ class PlatformAutoGen(AutoGen): PcdNvStoreDfBuffer.SkuInfoList[skuname].DefaultValue = vardump PcdNvStoreDfBuffer.MaxDatumSize = str(len(vardump.split(","))) - PlatformPcds = self._PlatformPcds.keys() - PlatformPcds.sort() + PlatformPcds = sorted(self._PlatformPcds.keys()) # # Add VPD type PCD into VpdFile and determine whether the VPD PCD need to be fixed up. # @@ -1874,7 +1866,7 @@ class PlatformAutoGen(AutoGen): if Flags.startswith('='): self._BuildCommand = [self._BuildCommand[0]] + [Flags[1:]] else: - self._BuildCommand += [Flags] + self._BuildCommand.append(Flags) return self._BuildCommand ## Get tool chain definition @@ -2069,32 +2061,28 @@ class PlatformAutoGen(AutoGen): # TokeNumber 11 ~ 20 # for Pcd in self.DynamicPcdList: - if Pcd.Phase == "PEI": - if Pcd.Type in PCD_DYNAMIC_TYPE_SET: - EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) - self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber - TokenNumber += 1 + if Pcd.Phase == "PEI" and Pcd.Type in PCD_DYNAMIC_TYPE_SET: + EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) + self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber + TokenNumber += 1 for Pcd in self.DynamicPcdList: - if Pcd.Phase == "PEI": - if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: - EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) - self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber - TokenNumber += 1 + if Pcd.Phase == "PEI" and Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: + EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) + self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber + TokenNumber += 1 for Pcd in self.DynamicPcdList: - if Pcd.Phase == "DXE": - if Pcd.Type in PCD_DYNAMIC_TYPE_SET: - EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) - self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber - TokenNumber += 1 + if Pcd.Phase == "DXE" and Pcd.Type in PCD_DYNAMIC_TYPE_SET: + EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) + self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber + TokenNumber += 1 for Pcd in self.DynamicPcdList: - if Pcd.Phase == "DXE": - if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: - EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) - self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber - TokenNumber += 1 + if Pcd.Phase == "DXE" and Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: + EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) + self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber + TokenNumber += 1 for Pcd in self.NonDynamicPcdList: self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber @@ -2185,8 +2173,8 @@ class PlatformAutoGen(AutoGen): if FromPcd is not None: if ToPcd.Pending and FromPcd.Type: ToPcd.Type = FromPcd.Type - elif (ToPcd.Type) and (FromPcd.Type)\ - and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type): + elif ToPcd.Type and FromPcd.Type\ + and ToPcd.Type != FromPcd.Type and ToPcd.Type in FromPcd.Type: if ToPcd.Type.strip() == TAB_PCDS_DYNAMIC_EX: ToPcd.Type = FromPcd.Type elif ToPcd.Type and FromPcd.Type \ @@ -2397,13 +2385,14 @@ class PlatformAutoGen(AutoGen): if (Key[0] == self.BuildRuleFamily and (ModuleStyle is None or len(Key) < 3 or (len(Key) > 2 and Key[2] == ModuleStyle))): Target, ToolChain, Arch, CommandType, Attr = Key[1].split('_') - if Target == self.BuildTarget or Target == "*": - if ToolChain == self.ToolChain or ToolChain == "*": - if Arch == self.Arch or Arch == "*": - if Options[Key].startswith("="): - if OverrideList.get(Key[1]) is not None: - OverrideList.pop(Key[1]) - OverrideList[Key[1]] = Options[Key] + if (Target == self.BuildTarget or Target == "*") and\ + (ToolChain == self.ToolChain or ToolChain == "*") and\ + (Arch == self.Arch or Arch == "*") and\ + Options[Key].startswith("="): + + if OverrideList.get(Key[1]) is not None: + OverrideList.pop(Key[1]) + OverrideList[Key[1]] = Options[Key] # # Use the highest priority value. @@ -2419,17 +2408,18 @@ class PlatformAutoGen(AutoGen): # Compare two Key, if one is included by another, choose the higher priority one # Target2, ToolChain2, Arch2, CommandType2, Attr2 = NextKey.split("_") - if Target1 == Target2 or Target1 == "*" or Target2 == "*": - if ToolChain1 == ToolChain2 or ToolChain1 == "*" or ToolChain2 == "*": - if Arch1 == Arch2 or Arch1 == "*" or Arch2 == "*": - if CommandType1 == CommandType2 or CommandType1 == "*" or CommandType2 == "*": - if Attr1 == Attr2 or Attr1 == "*" or Attr2 == "*": - if self.CalculatePriorityValue(NowKey) > self.CalculatePriorityValue(NextKey): - if Options.get((self.BuildRuleFamily, NextKey)) is not None: - Options.pop((self.BuildRuleFamily, NextKey)) - else: - if Options.get((self.BuildRuleFamily, NowKey)) is not None: - Options.pop((self.BuildRuleFamily, NowKey)) + if (Target1 == Target2 or Target1 == "*" or Target2 == "*") and\ + (ToolChain1 == ToolChain2 or ToolChain1 == "*" or ToolChain2 == "*") and\ + (Arch1 == Arch2 or Arch1 == "*" or Arch2 == "*") and\ + (CommandType1 == CommandType2 or CommandType1 == "*" or CommandType2 == "*") and\ + (Attr1 == Attr2 or Attr1 == "*" or Attr2 == "*"): + + if self.CalculatePriorityValue(NowKey) > self.CalculatePriorityValue(NextKey): + if Options.get((self.BuildRuleFamily, NextKey)) is not None: + Options.pop((self.BuildRuleFamily, NextKey)) + else: + if Options.get((self.BuildRuleFamily, NowKey)) is not None: + Options.pop((self.BuildRuleFamily, NowKey)) for Key in Options: if ModuleStyle is not None and len (Key) > 2: @@ -2591,6 +2581,14 @@ class PlatformAutoGen(AutoGen): LibraryAutoGenList = property(_GetLibraryAutoGenList) GenFdsCommand = property(_GenFdsCommand) +# +# extend lists contained in a dictionary with lists stored in another dictionary +# if CopyToDict is not derived from DefaultDict(list) then this may raise exception +# +def ExtendCopyDictionaryLists(CopyToDict, CopyFromDict): + for Key in CopyFromDict: + CopyToDict[Key].extend(CopyFromDict[Key]) + ## ModuleAutoGen class # # This class encapsules the AutoGen behaviors for the build tools. In addition to @@ -2681,7 +2679,6 @@ class ModuleAutoGen(AutoGen): self._MakeFileDir = None self._IncludePathList = None - self._IncludePathLength = 0 self._AutoGenFileList = None self._UnicodeFileList = None self._VfrFileList = None @@ -2696,16 +2693,16 @@ class ModuleAutoGen(AutoGen): self._DerivedPackageList = None self._ModulePcdList = None self._LibraryPcdList = None - self._PcdComments = OrderedDict() + self._PcdComments = OrderedListDict() self._GuidList = None self._GuidsUsedByPcd = None - self._GuidComments = OrderedDict() + self._GuidComments = OrderedListDict() self._ProtocolList = None - self._ProtocolComments = OrderedDict() + self._ProtocolComments = OrderedListDict() self._PpiList = None - self._PpiComments = OrderedDict() - self._DepexList = None - self._DepexExpressionList = None + self._PpiComments = OrderedListDict() + self._DepexDict = None + self._DepexExpressionDict = None self._BuildOption = None self._BuildOptionIncPathList = None self._BuildTargets = None @@ -2727,7 +2724,6 @@ class ModuleAutoGen(AutoGen): # self._FixedAtBuildPcds = [] self.ConstPcd = {} - return True def __repr__(self): return "%s [%s]" % (self.MetaFile, self.Arch) @@ -2855,10 +2851,7 @@ class ModuleAutoGen(AutoGen): ## Check if the module is library or not def _IsLibrary(self): if self._LibraryFlag is None: - if self.Module.LibraryClass is not None and self.Module.LibraryClass != []: - self._LibraryFlag = True - else: - self._LibraryFlag = False + self._LibraryFlag = True if self.Module.LibraryClass else False return self._LibraryFlag ## Check if the module is binary module or not @@ -3010,15 +3003,15 @@ class ModuleAutoGen(AutoGen): # @retval list The token list of the dependency expression after parsed # def _GetDepexTokenList(self): - if self._DepexList is None: - self._DepexList = {} + if self._DepexDict is None: + self._DepexDict = {} if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes: - return self._DepexList + return self._DepexDict - self._DepexList[self.ModuleType] = [] + self._DepexDict[self.ModuleType] = [] - for ModuleType in self._DepexList: - DepexList = self._DepexList[ModuleType] + for ModuleType in self._DepexDict: + DepexList = self._DepexDict[ModuleType] # # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion # @@ -3039,43 +3032,43 @@ class ModuleAutoGen(AutoGen): break if len(DepexList) > 0: EdkLogger.verbose('') - return self._DepexList + return self._DepexDict ## Merge dependency expression # # @retval list The token list of the dependency expression after parsed # def _GetDepexExpressionTokenList(self): - if self._DepexExpressionList is None: - self._DepexExpressionList = {} + if self._DepexExpressionDict is None: + self._DepexExpressionDict = {} if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes: - return self._DepexExpressionList + return self._DepexExpressionDict - self._DepexExpressionList[self.ModuleType] = '' + self._DepexExpressionDict[self.ModuleType] = '' - for ModuleType in self._DepexExpressionList: - DepexExpressionList = self._DepexExpressionList[ModuleType] + for ModuleType in self._DepexExpressionDict: + DepexExpressionString = self._DepexExpressionDict[ModuleType] # # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion # for M in [self.Module] + self.DependentLibraryList: Inherited = False for D in M.DepexExpression[self.Arch, ModuleType]: - if DepexExpressionList != '': - DepexExpressionList += ' AND ' - DepexExpressionList += '(' - DepexExpressionList += D - DepexExpressionList = DepexExpressionList.rstrip('END').strip() - DepexExpressionList += ')' + if DepexExpressionString != '': + DepexExpressionString += ' AND ' + DepexExpressionString += '(' + DepexExpressionString += D + DepexExpressionString = DepexExpressionString.rstrip('END').strip() + DepexExpressionString += ')' Inherited = True if Inherited: - EdkLogger.verbose("DEPEX[%s] (+%s) = %s" % (self.Name, M.BaseName, DepexExpressionList)) - if 'BEFORE' in DepexExpressionList or 'AFTER' in DepexExpressionList: + EdkLogger.verbose("DEPEX[%s] (+%s) = %s" % (self.Name, M.BaseName, DepexExpressionString)) + if 'BEFORE' in DepexExpressionString or 'AFTER' in DepexExpressionString: break - if len(DepexExpressionList) > 0: + if len(DepexExpressionString) > 0: EdkLogger.verbose('') - self._DepexExpressionList[ModuleType] = DepexExpressionList - return self._DepexExpressionList + self._DepexExpressionDict[ModuleType] = DepexExpressionString + return self._DepexExpressionDict # Get the tiano core user extension, it is contain dependent library. # @retval: a list contain tiano core userextension. @@ -3143,9 +3136,8 @@ class ModuleAutoGen(AutoGen): BuildOptionIncPathList = [] for Tool in ('CC', 'PP', 'VFRPP', 'ASLPP', 'ASLCC', 'APP', 'ASM'): - Attr = 'FLAGS' try: - FlagOption = self.BuildOption[Tool][Attr] + FlagOption = self.BuildOption[Tool]['FLAGS'] except KeyError: FlagOption = '' @@ -3158,13 +3150,13 @@ class ModuleAutoGen(AutoGen): IncPathList = [] for Path in BuildOptIncludeRegEx.findall(FlagOption): PathList = GetSplitList(Path, TAB_COMMA_SPLIT) - IncPathList += [NormPath(PathEntry, self.Macros) for PathEntry in PathList] + IncPathList.extend(NormPath(PathEntry, self.Macros) for PathEntry in PathList) # # EDK II modules must not reference header files outside of the packages they depend on or # within the module's directory tree. Report error if violation. # - if self.AutoGenVersion >= 0x00010005 and len(IncPathList) > 0: + if self.AutoGenVersion >= 0x00010005: for Path in IncPathList: if (Path not in self.IncludePathList) and (CommonPath([Path, self.MetaFile.Dir]) != self.MetaFile.Dir): ErrMsg = "The include directory for the EDK II module in this line is invalid %s specified in %s FLAGS '%s'" % (Path, Tool, FlagOption) @@ -3318,7 +3310,7 @@ class ModuleAutoGen(AutoGen): if not os.path.exists(SubDirectory): CreateDirectory(SubDirectory) LastTarget = None - RuleChain = [] + RuleChain = set() SourceList = [File] Index = 0 # @@ -3375,7 +3367,7 @@ class ModuleAutoGen(AutoGen): if FileType in RuleChain: break - RuleChain.append(FileType) + RuleChain.add(FileType) SourceList.extend(Target.Outputs) LastTarget = Target FileType = TAB_UNKNOWN_FILE @@ -3484,12 +3476,6 @@ class ModuleAutoGen(AutoGen): self._DependentLibraryList = self.PlatformInfo.ApplyLibraryInstance(self.Module) return self._DependentLibraryList - @staticmethod - def UpdateComments(Recver, Src): - for Key in Src: - if Key not in Recver: - Recver[Key] = [] - Recver[Key].extend(Src[Key]) ## Get the list of PCDs from current module # # @retval list The list of PCD @@ -3498,7 +3484,7 @@ class ModuleAutoGen(AutoGen): if self._ModulePcdList is None: # apply PCD settings from platform self._ModulePcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, self.Module.Pcds) - self.UpdateComments(self._PcdComments, self.Module.PcdComments) + ExtendCopyDictionaryLists(self._PcdComments, self.Module.PcdComments) return self._ModulePcdList ## Get the list of PCDs from dependent libraries @@ -3511,7 +3497,7 @@ class ModuleAutoGen(AutoGen): if not self.IsLibrary: # get PCDs from dependent libraries for Library in self.DependentLibraryList: - self.UpdateComments(self._PcdComments, Library.PcdComments) + ExtendCopyDictionaryLists(self._PcdComments, Library.PcdComments) for Key in Library.Pcds: # skip duplicated PCDs if Key in self.Module.Pcds or Key in Pcds: @@ -3533,8 +3519,8 @@ class ModuleAutoGen(AutoGen): self._GuidList.update(self.Module.Guids) for Library in self.DependentLibraryList: self._GuidList.update(Library.Guids) - self.UpdateComments(self._GuidComments, Library.GuidComments) - self.UpdateComments(self._GuidComments, self.Module.GuidComments) + ExtendCopyDictionaryLists(self._GuidComments, Library.GuidComments) + ExtendCopyDictionaryLists(self._GuidComments, self.Module.GuidComments) return self._GuidList def GetGuidsUsedByPcd(self): @@ -3554,8 +3540,8 @@ class ModuleAutoGen(AutoGen): self._ProtocolList.update(self.Module.Protocols) for Library in self.DependentLibraryList: self._ProtocolList.update(Library.Protocols) - self.UpdateComments(self._ProtocolComments, Library.ProtocolComments) - self.UpdateComments(self._ProtocolComments, self.Module.ProtocolComments) + ExtendCopyDictionaryLists(self._ProtocolComments, Library.ProtocolComments) + ExtendCopyDictionaryLists(self._ProtocolComments, self.Module.ProtocolComments) return self._ProtocolList ## Get the PPI value mapping @@ -3568,8 +3554,8 @@ class ModuleAutoGen(AutoGen): self._PpiList.update(self.Module.Ppis) for Library in self.DependentLibraryList: self._PpiList.update(Library.Ppis) - self.UpdateComments(self._PpiComments, Library.PpiComments) - self.UpdateComments(self._PpiComments, self.Module.PpiComments) + ExtendCopyDictionaryLists(self._PpiComments, Library.PpiComments) + ExtendCopyDictionaryLists(self._PpiComments, self.Module.PpiComments) return self._PpiList ## Get the list of include search path @@ -3607,11 +3593,7 @@ class ModuleAutoGen(AutoGen): return self._IncludePathList def _GetIncludePathLength(self): - self._IncludePathLength = 0 - if self._IncludePathList: - for inc in self._IncludePathList: - self._IncludePathLength += len(' ' + inc) - return self._IncludePathLength + return sum(len(inc)+1 for inc in self._IncludePathList) ## Get HII EX PCDs which maybe used by VFR # @@ -3665,12 +3647,11 @@ class ModuleAutoGen(AutoGen): for Pcd in self.PlatformInfo.Platform.Pcds.values(): if Pcd.Type != TAB_PCDS_DYNAMIC_EX_HII: continue - for SkuName in Pcd.SkuInfoList: - SkuInfo = Pcd.SkuInfoList[SkuName] - Name = ConvertStringToByteArray(SkuInfo.VariableName) + for SkuInfo in Pcd.SkuInfoList.values(): Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList, self.MetaFile.Path) if not Value: continue + Name = ConvertStringToByteArray(SkuInfo.VariableName) Guid = GuidStructureStringToGuidString(Value) if (Name, Guid) in NameGuids and Pcd not in HiiExPcds: HiiExPcds.append(Pcd) @@ -3686,13 +3667,13 @@ class ModuleAutoGen(AutoGen): # search the .map file to find the offset of vfr binary in the PE32+/TE file. # VfrUniBaseName[SourceFile.BaseName] = (SourceFile.BaseName + "Bin") - if SourceFile.Type.upper() == ".UNI" : + elif SourceFile.Type.upper() == ".UNI" : # # search the .map file to find the offset of Uni strings binary in the PE32+/TE file. # VfrUniBaseName["UniOffsetName"] = (self.Name + "Strings") - if len(VfrUniBaseName) == 0: + if not VfrUniBaseName: return None MapFileName = os.path.join(self.OutputDir, self.Name + ".map") EfiFileName = os.path.join(self.OutputDir, self.Name + ".efi") @@ -3751,10 +3732,9 @@ class ModuleAutoGen(AutoGen): # def CreateAsBuiltInf(self, IsOnlyCopy = False): self.OutputFile = set() - if IsOnlyCopy: - if GlobalData.gBinCacheDest: - self.CopyModuleToCache() - return + if IsOnlyCopy and GlobalData.gBinCacheDest: + self.CopyModuleToCache() + return if self.IsAsBuiltInfCreated: return @@ -3786,11 +3766,11 @@ class ModuleAutoGen(AutoGen): PcdTokenSpaceList = [] for Pcd in self.ModulePcdList + self.LibraryPcdList: if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE: - PatchablePcds += [Pcd] + PatchablePcds.append(Pcd) PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_PATCHABLE_IN_MODULE)) elif Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: if Pcd not in Pcds: - Pcds += [Pcd] + Pcds.append(Pcd) PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC_EX)) PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC)) PcdTokenSpaceList.append(Pcd.TokenSpaceGuidCName) @@ -3810,10 +3790,11 @@ class ModuleAutoGen(AutoGen): for Index in range(len(BeChecked)): for Item in CheckList[Index]: if Item in BeChecked[Index]: - Packages += [Package] + Packages.append(Package) Found = True break - if Found: break + if Found: + break VfrPcds = self._GetPcdsMaybeUsedByVfr() for Pkg in self.PlatformInfo.PackageList: @@ -3822,17 +3803,11 @@ class ModuleAutoGen(AutoGen): for VfrPcd in VfrPcds: if ((VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC_EX) in Pkg.Pcds or (VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC) in Pkg.Pcds): - Packages += [Pkg] + Packages.append(Pkg) break - ModuleType = self.ModuleType - if ModuleType == SUP_MODULE_UEFI_DRIVER and self.DepexGenerated: - ModuleType = SUP_MODULE_DXE_DRIVER - - DriverType = '' - if self.PcdIsDriver != '': - DriverType = self.PcdIsDriver - + ModuleType = SUP_MODULE_DXE_DRIVER if self.ModuleType == SUP_MODULE_UEFI_DRIVER and self.DepexGenerated else self.ModuleType + DriverType = self.PcdIsDriver if self.PcdIsDriver else '' Guid = self.Guid MDefs = self.Module.Defines @@ -3858,7 +3833,7 @@ class ModuleAutoGen(AutoGen): 'module_uefi_hii_resource_section' : [MDefs['UEFI_HII_RESOURCE_SECTION']] if 'UEFI_HII_RESOURCE_SECTION' in MDefs else [], 'module_uni_file' : [MDefs['MODULE_UNI_FILE']] if 'MODULE_UNI_FILE' in MDefs else [], 'module_arch' : self.Arch, - 'package_item' : ['%s' % (Package.MetaFile.File.replace('\\', '/')) for Package in Packages], + 'package_item' : [Package.MetaFile.File.replace('\\', '/') for Package in Packages], 'binary_item' : [], 'patchablepcd_item' : [], 'pcd_item' : [], @@ -3880,12 +3855,12 @@ class ModuleAutoGen(AutoGen): AsBuiltInfDict['module_inf_version'] = gInfSpecVersion if DriverType: - AsBuiltInfDict['pcd_is_driver_string'] += [DriverType] + AsBuiltInfDict['pcd_is_driver_string'].append(DriverType) if 'UEFI_SPECIFICATION_VERSION' in self.Specification: - AsBuiltInfDict['module_uefi_specification_version'] += [self.Specification['UEFI_SPECIFICATION_VERSION']] + AsBuiltInfDict['module_uefi_specification_version'].append(self.Specification['UEFI_SPECIFICATION_VERSION']) if 'PI_SPECIFICATION_VERSION' in self.Specification: - AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']] + AsBuiltInfDict['module_pi_specification_version'].append(self.Specification['PI_SPECIFICATION_VERSION']) OutputDir = self.OutputDir.replace('\\', '/').strip('/') DebugDir = self.DebugDir.replace('\\', '/').strip('/') @@ -3895,31 +3870,31 @@ class ModuleAutoGen(AutoGen): if os.path.isabs(File): File = File.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/') if Item.Target.Ext.lower() == '.aml': - AsBuiltInfDict['binary_item'] += ['ASL|' + File] + AsBuiltInfDict['binary_item'].append('ASL|' + File) elif Item.Target.Ext.lower() == '.acpi': - AsBuiltInfDict['binary_item'] += ['ACPI|' + File] + AsBuiltInfDict['binary_item'].append('ACPI|' + File) elif Item.Target.Ext.lower() == '.efi': - AsBuiltInfDict['binary_item'] += ['PE32|' + self.Name + '.efi'] + AsBuiltInfDict['binary_item'].append('PE32|' + self.Name + '.efi') else: - AsBuiltInfDict['binary_item'] += ['BIN|' + File] + AsBuiltInfDict['binary_item'].append('BIN|' + File) if self.DepexGenerated: self.OutputFile.add(self.Name + '.depex') if self.ModuleType in [SUP_MODULE_PEIM]: - AsBuiltInfDict['binary_item'] += ['PEI_DEPEX|' + self.Name + '.depex'] - if self.ModuleType in [SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER]: - AsBuiltInfDict['binary_item'] += ['DXE_DEPEX|' + self.Name + '.depex'] - if self.ModuleType in [SUP_MODULE_DXE_SMM_DRIVER]: - AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex'] + AsBuiltInfDict['binary_item'].append('PEI_DEPEX|' + self.Name + '.depex') + elif self.ModuleType in [SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER]: + AsBuiltInfDict['binary_item'].append('DXE_DEPEX|' + self.Name + '.depex') + elif self.ModuleType in [SUP_MODULE_DXE_SMM_DRIVER]: + AsBuiltInfDict['binary_item'].append('SMM_DEPEX|' + self.Name + '.depex') Bin = self._GenOffsetBin() if Bin: - AsBuiltInfDict['binary_item'] += ['BIN|%s' % Bin] + AsBuiltInfDict['binary_item'].append('BIN|%s' % Bin) self.OutputFile.add(Bin) for Root, Dirs, Files in os.walk(OutputDir): for File in Files: if File.lower().endswith('.pdb'): - AsBuiltInfDict['binary_item'] += ['DISPOSABLE|' + File] + AsBuiltInfDict['binary_item'].append('DISPOSABLE|' + File) self.OutputFile.add(File) HeaderComments = self.Module.HeaderComments StartPos = 0 @@ -3938,12 +3913,8 @@ class ModuleAutoGen(AutoGen): ] for Item in GenList: for CName in Item[0]: - Comments = '' - if CName in Item[1]: - Comments = '\n '.join(Item[1][CName]) - Entry = CName - if Comments: - Entry = Comments + '\n ' + CName + Comments = '\n '.join(Item[1][CName]) if CName in Item[1] else '' + Entry = Comments + '\n ' + CName if Comments else CName AsBuiltInfDict[Item[2]].append(Entry) PatchList = parsePcdInfoFromMapFile( os.path.join(self.OutputDir, self.Name + '.map'), @@ -4034,7 +4005,6 @@ class ModuleAutoGen(AutoGen): HiiPcds = set() for Pcd in Pcds + VfrPcds: - PcdComments = '' PcdCommentList = [] HiiInfo = '' SkuId = '' @@ -4075,14 +4045,14 @@ class ModuleAutoGen(AutoGen): PcdEntry = Pcd.TokenSpaceGuidCName + '.' + TokenCName if PcdComments: PcdEntry = PcdComments + '\n ' + PcdEntry - AsBuiltInfDict['pcd_item'] += [PcdEntry] + AsBuiltInfDict['pcd_item'].append(PcdEntry) for Item in self.BuildOption: if 'FLAGS' in self.BuildOption[Item]: - AsBuiltInfDict['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())] + AsBuiltInfDict['flags_item'].append('%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())) # Generated LibraryClasses section in comments. for Library in self.LibraryAutoGenList: - AsBuiltInfDict['libraryclasses_item'] += [Library.MetaFile.File.replace('\\', '/')] + AsBuiltInfDict['libraryclasses_item'].append(Library.MetaFile.File.replace('\\', '/')) # Generated UserExtensions TianoCore section. # All tianocore user extensions are copied. @@ -4095,10 +4065,8 @@ class ModuleAutoGen(AutoGen): AsBuiltInfDict['userextension_tianocore_item'] = UserExtStr # Generated depex expression section in comments. - AsBuiltInfDict['depexsection_item'] = '' DepexExpresion = self._GetDepexExpresionString() - if DepexExpresion: - AsBuiltInfDict['depexsection_item'] = DepexExpresion + AsBuiltInfDict['depexsection_item'] = DepexExpresion if DepexExpresion else '' AsBuiltInf = TemplateString() AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict)) @@ -4317,8 +4285,7 @@ class ModuleAutoGen(AutoGen): if self.Name not in GlobalData.gModuleHash[self.Arch]: GlobalData.gModuleHash[self.Arch][self.Name] = m.hexdigest() if GlobalData.gBinCacheSource: - CacheValid = self.AttemptModuleCacheCopy() - if CacheValid: + if self.AttemptModuleCacheCopy(): return False return SaveFileOnChange(ModuleHashFile, m.hexdigest(), True) @@ -4357,9 +4324,7 @@ class ModuleAutoGen(AutoGen): return self._TimeStampPath def CreateTimeStamp(self, Makefile): - FileSet = set() - - FileSet.add (self.MetaFile.Path) + FileSet = {self.MetaFile.Path} for SourceFile in self.Module.Sources: FileSet.add (SourceFile.Path) @@ -4423,7 +4388,7 @@ class ModuleAutoGen(AutoGen): PpiList = property(_GetPpiList) DepexList = property(_GetDepexTokenList) DxsFile = property(_GetDxsFile) - DepexExpressionList = property(_GetDepexExpressionTokenList) + DepexExpressionDict = property(_GetDepexExpressionTokenList) BuildOption = property(_GetModuleBuildOption) BuildOptionIncPathList = property(_GetBuildOptionIncPathList) BuildCommand = property(_GetBuildCommand) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 40a343ca1057..af8bfe7bba59 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1655,7 +1655,7 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH): TokenSpaceList = [] for Pcd in Info.ModulePcdList: if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenSpaceGuidCName not in TokenSpaceList: - TokenSpaceList += [Pcd.TokenSpaceGuidCName] + TokenSpaceList.append(Pcd.TokenSpaceGuidCName) SkuMgr = Info.Workspace.Platform.SkuIdMgr AutoGenH.Append("\n// Definition of SkuId Array\n") diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index a37350742240..e0e2ab57dd29 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -698,7 +698,7 @@ cleanlib: Src = self.ReplaceMacro(Src) Dst = self.ReplaceMacro(Dst) if Dst not in self.ResultFileList: - self.ResultFileList.append('%s' % Dst) + self.ResultFileList.append(Dst) if '%s :' %(Dst) not in self.BuildTargetList: self.BuildTargetList.append("%s :" %(Dst)) self.BuildTargetList.append('\t' + self._CP_TEMPLATE_[self._FileType] %{'Src': Src, 'Dst': Dst}) @@ -716,7 +716,7 @@ cleanlib: if DepsFileString == '': continue OutputFile = self.ReplaceMacro(OutputFile) - self.ResultFileList.append('%s' % OutputFile) + self.ResultFileList.append(OutputFile) DepsFileString = self.ReplaceMacro(DepsFileString) self.BuildTargetList.append('%s : %s' % (OutputFile, DepsFileString)) CmdString = ' '.join(FfsCmdList).strip() diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index d2d42fe9d08e..759f9df8d9c0 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -1115,7 +1115,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): TokenSpaceGuid = GuidStructureStringToGuidValueName(TokenSpaceGuidStructure) if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: if TokenSpaceGuid not in GuidList: - GuidList += [TokenSpaceGuid] + GuidList.append(TokenSpaceGuid) Dict['GUID_STRUCTURE'].append(TokenSpaceGuidStructure) NumberOfExTokens += 1 @@ -1140,7 +1140,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): Pcd.TokenTypeList = ['PCD_DATUM_TYPE_' + Pcd.DatumType] if len(Pcd.SkuInfoList) > 1: -# Pcd.TokenTypeList += ['PCD_TYPE_SKU_ENABLED'] + NumberOfSkuEnabledPcd += 1 SkuIdIndex = 1 @@ -1178,7 +1178,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): else: EdkLogger.error("build", PCD_VALIDATION_INFO_ERROR, "The PCD '%s.%s' Validation information defined in DEC file has incorrect format." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)) - Pcd.TokenTypeList += ['PCD_TYPE_HII'] + Pcd.TokenTypeList.append('PCD_TYPE_HII') Pcd.InitString = 'INIT' # Store all variable names of one HII PCD under different SKU to stringTable # and calculate the VariableHeadStringIndex @@ -1209,7 +1209,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): # store VariableGuid to GuidTable and get the VariableHeadGuidIndex if VariableGuid not in GuidList: - GuidList += [VariableGuid] + GuidList.append(VariableGuid) Dict['GUID_STRUCTURE'].append(VariableGuidStructure) VariableHeadGuidIndex = GuidList.index(VariableGuid) @@ -1261,7 +1261,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): VariableDbValueList.append([VariableHeadGuidIndex, VariableHeadStringIndex, Sku.VariableOffset, VariableOffset, VariableRefTable, Sku.VariableAttribute]) elif Sku.VpdOffset != '': - Pcd.TokenTypeList += ['PCD_TYPE_VPD'] + Pcd.TokenTypeList.append('PCD_TYPE_VPD') Pcd.InitString = 'INIT' VpdHeadOffsetList.append(str(Sku.VpdOffset) + 'U') VpdDbOffsetList.append(Sku.VpdOffset) @@ -1273,7 +1273,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): continue if Pcd.DatumType == TAB_VOID: - Pcd.TokenTypeList += ['PCD_TYPE_STRING'] + Pcd.TokenTypeList.append('PCD_TYPE_STRING') Pcd.InitString = 'INIT' if Sku.HiiDefaultValue != '' and Sku.DefaultValue == '': Sku.DefaultValue = Sku.HiiDefaultValue @@ -1322,7 +1322,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): StringTableSize += (StringTabLen) else: if "PCD_TYPE_HII" not in Pcd.TokenTypeList: - Pcd.TokenTypeList += ['PCD_TYPE_DATA'] + Pcd.TokenTypeList.append('PCD_TYPE_DATA') if Sku.DefaultValue == 'TRUE': Pcd.InitString = 'INIT' else: diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index 2eab278d6876..3675be8de994 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -75,7 +75,7 @@ class VariableMgr(object): data = value_list[0] value_list = [] for data_byte in pack(data_flag,int(data,16) if data.upper().startswith('0X') else int(data)): - value_list += [hex(unpack("B",data_byte)[0])] + value_list.append(hex(unpack("B",data_byte)[0])) newvalue[int(item.var_offset,16) if item.var_offset.upper().startswith("0X") else int(item.var_offset)] = value_list try: newvaluestr = "{" + ",".join(VariableMgr.assemble_variable(newvalue)) +"}" diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py index 73af1214eb0a..ce8866f480d5 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -258,7 +258,7 @@ def GetFilteredLanguage(UniLanguageList, LanguageFilterList): # first check for exact match if Language in UniLanguageList: if Language not in UniLanguageListFiltered: - UniLanguageListFiltered += [Language] + UniLanguageListFiltered.append(Language) # find the first one with the same/equivalent primary tag else: if Language.find('-') != -1: @@ -280,7 +280,7 @@ def GetFilteredLanguage(UniLanguageList, LanguageFilterList): if PrimaryTag == UniLanguagePrimaryTag: if UniLanguage not in UniLanguageListFiltered: - UniLanguageListFiltered += [UniLanguage] + UniLanguageListFiltered.append(UniLanguage) break else: # Here is rule 3 for "get best language" @@ -292,10 +292,10 @@ def GetFilteredLanguage(UniLanguageList, LanguageFilterList): for UniLanguage in UniLanguageList: if UniLanguage.startswith('en-') or UniLanguage.startswith('eng-'): if UniLanguage not in UniLanguageListFiltered: - UniLanguageListFiltered += [UniLanguage] + UniLanguageListFiltered.append(UniLanguage) break else: - UniLanguageListFiltered += [DefaultTag] + UniLanguageListFiltered.append(DefaultTag) return UniLanguageListFiltered diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 90350f863826..24706ebe500f 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1328,7 +1328,7 @@ def ParseFieldValue (Value): try: Value = "'" + uuid.UUID(Value).get_bytes_le() + "'" except ValueError, Message: - raise BadExpression('%s' % Message) + raise BadExpression(Message) Value, Size = ParseFieldValue(Value) return Value, 16 if Value.startswith('L"') and Value.endswith('"'): diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py index 34361ecdd58c..2292a263b985 100644 --- a/BaseTools/Source/Python/Common/String.py +++ b/BaseTools/Source/Python/Common/String.py @@ -447,7 +447,7 @@ def GetMultipleValuesOfKeyFromLines(Lines, Key, KeyValues, CommentCharacter): for Line in LineList: Line = CleanString(Line, CommentCharacter) if Line != '' and Line[0] != CommentCharacter: - KeyValues += [Line] + KeyValues.append(Line) return True diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index 32895deb5d0c..2b447772eafe 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -246,7 +246,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName): stderr= subprocess.PIPE, shell=True) except Exception, X: - EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData="%s" % (str(X))) + EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData=str(X)) (out, error) = PopenObject.communicate() print out while PopenObject.returncode is None : diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 8a9296c49d1d..3dec57fe163a 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -2329,7 +2329,7 @@ class FdfParser: if not self.__GetNextHexNumber() and not self.__GetNextDecimalNumber(): raise Warning("expected Hex FV extension entry type value At Line ", self.FileName, self.CurrentLineNumber) - FvObj.FvExtEntryTypeValue += [self.__Token] + FvObj.FvExtEntryTypeValue.append(self.__Token) if not self.__IsToken( "{"): raise Warning("expected '{'", self.FileName, self.CurrentLineNumber) @@ -2337,7 +2337,7 @@ class FdfParser: if not self.__IsKeyword ("FILE") and not self.__IsKeyword ("DATA"): raise Warning("expected 'FILE' or 'DATA'", self.FileName, self.CurrentLineNumber) - FvObj.FvExtEntryType += [self.__Token] + FvObj.FvExtEntryType.append(self.__Token) if self.__Token == 'DATA': @@ -2371,7 +2371,7 @@ class FdfParser: raise Warning("expected '}'", self.FileName, self.CurrentLineNumber) DataString = DataString.rstrip(",") - FvObj.FvExtEntryData += [DataString] + FvObj.FvExtEntryData.append(DataString) if self.__Token == 'FILE': @@ -2381,7 +2381,7 @@ class FdfParser: if not self.__GetNextToken(): raise Warning("expected FV Extension Entry file path At Line ", self.FileName, self.CurrentLineNumber) - FvObj.FvExtEntryData += [self.__Token] + FvObj.FvExtEntryData.append(self.__Token) if not self.__IsToken( "}"): raise Warning("expected '}'", self.FileName, self.CurrentLineNumber) diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index 6cf82526efd2..c2e82de891d3 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -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: - Cmd += ["-s", Type] + Cmd += ("-s", Type) if CompressionType: - Cmd += ["-c", CompressionType] + Cmd += ("-c", CompressionType) if Guid is not None: - Cmd += ["-g", Guid] + Cmd += ("-g", Guid) if DummyFile is not None: - Cmd += ["--dummy", DummyFile] + Cmd += ("--dummy", DummyFile) if GuidHdrLen: - 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 += ("-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: - #Cmd += ["-n", '"' + 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: @@ -481,10 +478,10 @@ class GenFdsGlobalVariable: SaveFileOnChange(Output, SectionData.tostring()) elif Ver: - Cmd += ["-n", 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,9 +523,9 @@ 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"] + Cmd.append("-s") if Align: if Align not in mFfsValidAlign: Align = GenFdsGlobalVariable.GetAlignment (Align) @@ -536,9 +533,9 @@ class GenFdsGlobalVariable: 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 and SectionAlign[I]: @@ -567,26 +564,26 @@ class GenFdsGlobalVariable: Cmd = ["GenFv"] if BaseAddress: - Cmd += ["-r", 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"] + Cmd.append("-p") if AddressFile: - Cmd += ["-a", AddressFile] + Cmd += ("-a", AddressFile) if MapFile: - Cmd += ["-m", 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") @@ -600,10 +597,10 @@ class GenFdsGlobalVariable: 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"] + Cmd.append("-t") if SubType: - Cmd += ["-e", SubType] + Cmd += ("-e", SubType) if TimeStamp: - Cmd += ["-s", TimeStamp] + Cmd += ("-s", TimeStamp) if Align: - Cmd += ["-a", Align] + Cmd += ("-a", Align) if Padding: - Cmd += ["-p", 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: diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index cf45ef173498..4bcdea726cd3 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -420,7 +420,7 @@ class DepexReport(object): self.Source = "DXS" break else: - self.Depex = M.DepexExpressionList.get(M.ModuleType, "") + self.Depex = M.DepexExpressionDict.get(M.ModuleType, "") self.ModuleDepex = " ".join(M.Module.DepexExpression[M.Arch, M.ModuleType]) if not self.ModuleDepex: self.ModuleDepex = "(None)" @@ -461,12 +461,12 @@ class DepexReport(object): FileWrite(File, "Dependency Expression (DEPEX) from %s" % self.Source) if self.Source == "INF": - FileWrite(File, "%s" % self.Depex, True) + FileWrite(File, self.Depex, True) FileWrite(File, gSubSectionSep) FileWrite(File, "From Module INF: %s" % self.ModuleDepex, True) FileWrite(File, "From Library INF: %s" % self.LibraryDepex, True) else: - FileWrite(File, "%s" % self.Depex) + FileWrite(File, self.Depex) FileWrite(File, gSubSectionEnd) ## @@ -1108,7 +1108,7 @@ class PcdReport(object): if IsByteArray: FileWrite(File, ' *M %-*s = %s' % (self.MaxLen + 19, ModulePath, '{')) for Array in ArrayList: - FileWrite(File, '%s' % (Array)) + FileWrite(File, Array) else: FileWrite(File, ' *M %-*s = %s' % (self.MaxLen + 19, ModulePath, ModuleDefault.strip())) @@ -1134,7 +1134,7 @@ class PcdReport(object): if IsByteArray: FileWrite(File, ' %*s = %s' % (self.MaxLen + 19, 'DSC DEFAULT', "{")) for Array in ArrayList: - FileWrite(File, '%s' % (Array)) + FileWrite(File, Array) else: FileWrite(File, ' %*s = %s' % (self.MaxLen + 19, 'DSC DEFAULT', Value)) if not InfMatch and InfDefaultValue is not None: @@ -1143,7 +1143,7 @@ class PcdReport(object): if IsByteArray: FileWrite(File, ' %*s = %s' % (self.MaxLen + 19, 'INF DEFAULT', "{")) for Array in ArrayList: - FileWrite(File, '%s' % (Array)) + FileWrite(File, Array) else: FileWrite(File, ' %*s = %s' % (self.MaxLen + 19, 'INF DEFAULT', Value)) @@ -1153,7 +1153,7 @@ class PcdReport(object): if IsByteArray: FileWrite(File, ' %*s = %s' % (self.MaxLen + 19, 'DEC DEFAULT', "{")) for Array in ArrayList: - FileWrite(File, '%s' % (Array)) + FileWrite(File, Array) else: FileWrite(File, ' %*s = %s' % (self.MaxLen + 19, 'DEC DEFAULT', Value)) if IsStructure: @@ -1168,7 +1168,7 @@ class PcdReport(object): if IsByteArray: FileWrite(File, ' %-*s : %6s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '{')) for Array in ArrayList: - FileWrite(File, '%s' % (Array)) + FileWrite(File, Array) else: FileWrite(File, ' %-*s : %6s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value)) if IsStructure: @@ -1204,7 +1204,7 @@ class PcdReport(object): else: FileWrite(File, ' %-*s : %6s %10s %10s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', '(' + DefaultStore + ')', '{')) for Array in ArrayList: - FileWrite(File, '%s' % (Array)) + FileWrite(File, Array) else: if self.DefaultStoreSingle and self.SkuSingle: FileWrite(File, ' %-*s : %6s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value)) @@ -1225,7 +1225,7 @@ class PcdReport(object): else: FileWrite(File, ' %-*s : %6s %10s %10s %10s = %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', '(' + DefaultStore + ')', '{')) for Array in ArrayList: - FileWrite(File, '%s' % (Array)) + FileWrite(File, Array) else: if self.DefaultStoreSingle and self.SkuSingle: FileWrite(File, ' %-*s : %6s %10s = %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', Value)) @@ -1252,7 +1252,7 @@ class PcdReport(object): else: FileWrite(File, ' %-*s : %6s %10s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', "{")) for Array in ArrayList: - FileWrite(File, '%s' % (Array)) + FileWrite(File, Array) else: if self.SkuSingle: FileWrite(File, ' %-*s : %6s %10s = %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value)) @@ -1265,7 +1265,7 @@ class PcdReport(object): else: FileWrite(File, ' %-*s : %6s %10s %10s = %s' % (self.MaxLen, ' ' , TypeName, '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', "{")) for Array in ArrayList: - FileWrite(File, '%s' % (Array)) + FileWrite(File, Array) else: if self.SkuSingle: FileWrite(File, ' %-*s : %6s %10s = %s' % (self.MaxLen, ' ' , TypeName, '(' + Pcd.DatumType + ')', Value)) @@ -1932,7 +1932,7 @@ class FdReport(object): ValueList[-1] = ' {' FileWrite(File, '|'.join(ValueList)) for Array in ArrayList: - FileWrite(File, '%s' % (Array)) + FileWrite(File, Array) else: FileWrite(File, item) FileWrite(File, gSubSectionEnd) diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index 1ef2dc5bfe70..c16e810fed71 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -105,7 +105,7 @@ def CheckEnvVariable(): WorkspaceDir = os.path.normcase(os.path.normpath(os.environ["WORKSPACE"])) if not os.path.exists(WorkspaceDir): - EdkLogger.error("build", FILE_NOT_FOUND, "WORKSPACE doesn't exist", ExtraData="%s" % WorkspaceDir) + EdkLogger.error("build", FILE_NOT_FOUND, "WORKSPACE doesn't exist", ExtraData=WorkspaceDir) elif ' ' in WorkspaceDir: EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "No space is allowed in WORKSPACE path", ExtraData=WorkspaceDir) @@ -117,7 +117,7 @@ def CheckEnvVariable(): if mws.PACKAGES_PATH: for Path in mws.PACKAGES_PATH: if not os.path.exists(Path): - EdkLogger.error("build", FILE_NOT_FOUND, "One Path in PACKAGES_PATH doesn't exist", ExtraData="%s" % Path) + EdkLogger.error("build", FILE_NOT_FOUND, "One Path in PACKAGES_PATH doesn't exist", ExtraData=Path) elif ' ' in Path: EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "No space is allowed in PACKAGES_PATH", ExtraData=Path) @@ -1543,7 +1543,7 @@ class Build(): GuidString = MatchGuid.group() if GuidString.upper() in ModuleList: Line = Line.replace(GuidString, ModuleList[GuidString.upper()].Name) - MapBuffer.write('%s' % (Line)) + MapBuffer.write(Line) # # Add the debug image full path. # -- 2.16.2.windows.1