X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FUPT%2FPomAdapter%2FInfPomAlignment.py;h=d01481727b9e7d5033a40de607c5663867558df6;hp=e37a0b6c3be7191cca043ea9172c0fa1d39d11c8;hb=fb0b35e05f772bd415fe264267bbbcde2e0accda;hpb=4231a8193ec0d52df7e0a101d96c51b1a2b7a996 diff --git a/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py b/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py index e37a0b6c3b..d01481727b 100644 --- a/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py +++ b/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py @@ -1,11 +1,11 @@ ## @file InfPomAlignment.py # This file contained the adapter for convert INF parser object to POM Object # -# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at +# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php # # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, @@ -20,10 +20,10 @@ InfPomAlignment import os.path from Logger import StringTable as ST import Logger.Log as Logger -from Library.String import FORMAT_INVALID -from Library.String import PARSER_ERROR -from Library.String import NormPath -from Library.String import GetSplitValueList +from Library.StringUtils import FORMAT_INVALID +from Library.StringUtils import PARSER_ERROR +from Library.StringUtils import NormPath +from Library.StringUtils import GetSplitValueList from Library.Misc import ConvertVersionToDecimal from Library.Misc import GetHelpStringByRemoveHashKey from Library.Misc import ConvertArchList @@ -59,8 +59,8 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws # class InfPomAlignment(ModuleObject): ## Construct of InfPomAlignment - # Skip means that UPT don't care the syntax of INF, this may be the not - # distributed INF files during creation or the INF files checked for + # Skip means that UPT don't care the syntax of INF, this may be the not + # distributed INF files during creation or the INF files checked for # dependency rule during remove. # def __init__(self, FileName, WorkSpace=None, PackagePath='', Skip=False): @@ -90,12 +90,12 @@ class InfPomAlignment(ModuleObject): self._GenInfPomObjects(Skip) ## - # Generate all POM objects, the original input comes + # Generate all POM objects, the original input comes # from INF parser's output # def _GenInfPomObjects(self, Skip): # - # Call INF Parser to get information from INF file + # Call INF Parser to get information from INF file # self.Parser = InfParser.InfParser(self.FileName, self.WorkSpace) self.FullPath = self.Parser.FullPath @@ -133,7 +133,7 @@ class InfPomAlignment(ModuleObject): # # Should only have one ArchString Item. # - ArchString = RecordSet.keys()[0] + ArchString = list(RecordSet.keys())[0] ArchList = GetSplitValueList(ArchString, ' ') ArchList = ConvertArchList(ArchList) HasCalledFlag = False @@ -144,8 +144,8 @@ class InfPomAlignment(ModuleObject): self.SetFileName(self.FileName) self.SetFullPath(self.FullPath) # - # The INF's filename (without the directory path or the extension) - # must be used for the value of the + # The INF's filename (without the directory path or the extension) + # must be used for the value of the # ModuleSurfaceArea.Header.Name element # self.SetName(os.path.splitext(os.path.basename(self.FileName))[0]) @@ -184,7 +184,7 @@ class InfPomAlignment(ModuleObject): # # must exist items in INF define section - # MODULE_TYPE/BASE_NAME/INF_VERSION/FILE_GUID/VERSION_STRING + # MODULE_TYPE/BASE_NAME/INF_VERSION/FILE_GUID/VERSION_STRING # if DefineObj.GetModuleType() is None: Logger.Error("InfParser", FORMAT_INVALID, @@ -194,7 +194,7 @@ class InfPomAlignment(ModuleObject): ModuleType = DefineObj.GetModuleType().GetValue() if ModuleType: # - # Drivers and applications are not allowed to have a MODULE_TYPE of "BASE". Only + # Drivers and applications are not allowed to have a MODULE_TYPE of "BASE". Only # libraries are permitted to a have a MODULE_TYPE of "BASE". # if len(DefineObj.LibraryClass) == 0 and ModuleType == 'BASE': @@ -248,7 +248,7 @@ class InfPomAlignment(ModuleObject): Logger.Error("Parser", PARSER_ERROR, ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF, ExtraData=self.FullPath, RaiseError=Logger.IS_RAISE_ERROR) # - # if there is Shadow, Should judge the MODULE_TYPE in + # if there is Shadow, Should judge the MODULE_TYPE in # SEC, PEI_CORE and PEIM # if DefineObj.GetShadow(): @@ -283,7 +283,7 @@ class InfPomAlignment(ModuleObject): self._GenSpecialComments() # # put all define statement into user-extension sections - # + # DefinesDictNew = GenModuleHeaderUserExt(DefineObj, ArchString) if DefinesDictNew: UserExtension = CommonObject.UserExtensionObject() @@ -293,7 +293,7 @@ class InfPomAlignment(ModuleObject): self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension]) # # Get all meta-file header information - # the record is list of items formated: + # the record is list of items formatted: # [LineValue, Arch, StartLine, ID, Third] # InfHeaderObj = self.Parser.InfHeader @@ -356,13 +356,13 @@ class InfPomAlignment(ModuleObject): self.SetExternList(self.GetExternList() + [Image]) # # UNLOAD_IMAGE - # + # UnloadImageList = DefineObj.GetUnloadImages() for UnloadImage in UnloadImageList: Image = ExternObject() # # Future enhancement - # + # Image.SetUnloadImage(UnloadImage.GetCName()) self.SetExternList(self.GetExternList() + [Image]) # @@ -373,7 +373,7 @@ class InfPomAlignment(ModuleObject): Image = ExternObject() # # Future enhancement - # + # Image.SetConstructor(ConstructorItem.GetCName()) self.SetExternList(self.GetExternList() + [Image]) # @@ -384,7 +384,7 @@ class InfPomAlignment(ModuleObject): Image = ExternObject() # # Future enhancement - # + # Image.SetDestructor(DestructorItem.GetCName()) self.SetExternList(self.GetExternList() + [Image]) @@ -486,10 +486,7 @@ class InfPomAlignment(ModuleObject): # # Get all LibraryClasses # - LibClassObj = self.Parser.InfLibraryClassSection.LibraryClasses - Keys = LibClassObj.keys() - for Key in Keys: - LibraryClassData = LibClassObj[Key] + for LibraryClassData in self.Parser.InfLibraryClassSection.LibraryClasses.values(): for Item in LibraryClassData: LibraryClass = CommonObject.LibraryClassObject() LibraryClass.SetUsage(DT.USAGE_ITEM_CONSUMES) @@ -614,8 +611,7 @@ class InfPomAlignment(ModuleObject): SourceFile = Item.GetSourceFileName() Family = Item.GetFamily() FeatureFlag = Item.GetFeatureFlagExp() - SupArchList = ConvertArchList(Item.GetSupArchList()) - SupArchList.sort() + SupArchList = sorted(ConvertArchList(Item.GetSupArchList())) Source = SourceFileObject() Source.SetSourceFile(SourceFile) Source.SetFamily(Family) @@ -643,7 +639,7 @@ class InfPomAlignment(ModuleObject): UserExtension = CommonObject.UserExtensionObject() UserId = UserExtensionDataObj.GetUserId() if UserId.startswith('"') and UserId.endswith('"'): - UserId = UserId[1:-1] + UserId = UserId[1:-1] UserExtension.SetUserID(UserId) Identifier = UserExtensionDataObj.GetIdString() if Identifier.startswith('"') and Identifier.endswith('"'): @@ -657,11 +653,11 @@ class InfPomAlignment(ModuleObject): UserExtension.SetStatement(UserExtensionDataObj.GetContent()) UserExtension.SetSupArchList(ConvertArchList(UserExtensionDataObj.GetSupArchList())) self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension]) - + # # Gen UserExtensions of TianoCore."BinaryHeader" # - + #Get Binary header from INF file BinaryAbstractList = self.BinaryHeaderAbstractList BinaryDescriptionList = self.BinaryHeaderDescriptionList @@ -688,7 +684,7 @@ class InfPomAlignment(ModuleObject): BinaryUserExtension.SetIdentifier(DT.TAB_BINARY_HEADER_IDENTIFIER) BinaryUserExtension.SetUserID(DT.TAB_BINARY_HEADER_USERID) self.SetUserExtensionList(self.GetUserExtensionList() + [BinaryUserExtension]) - + def _GenDepexesList(self, SmmDepexList, DxeDepexList, PeiDepexList): if SmmDepexList: self.SetSmmDepex(SmmDepexList) @@ -806,7 +802,7 @@ class InfPomAlignment(ModuleObject): BinaryData = BinaryObj.keys() # - # If the INF file does not contain a [Sources] section, and the INF file does contain a [Binaries] section, + # If the INF file does not contain a [Sources] section, and the INF file does contain a [Binaries] section, # then the ModuleSurfaceArea.BinaryModule attribute must be set to true. Otherwise, do not use the attribute # if BinaryObj and not self.Parser.InfSourcesSection.GetSources(): @@ -831,7 +827,7 @@ class InfPomAlignment(ModuleObject): # # BuildOption AsBuild Info - # + # for BuildOptionItem in self.Parser.InfBuildOptionSection.GetBuildOptions(): AsBuildBuildOptionList.append(BuildOptionItem) AsBuildIns.SetBuildFlagsList(AsBuildBuildOptionList) @@ -853,14 +849,14 @@ class InfPomAlignment(ModuleObject): TempPath = ModulePath ModulePath = os.path.dirname(ModulePath) PackageName = TempPath - DecFilePath = os.path.normpath(os.path.join(WorkSpace, PackageName)) + DecFilePath = os.path.normpath(os.path.join(WorkSpace, PackageName)) if DecFilePath: for File in os.listdir(DecFilePath): if File.upper().endswith('.DEC'): DecFileFullPath = os.path.normpath(os.path.join(DecFilePath, File)) DecObjList.append(DecPomAlignment(DecFileFullPath, self.WorkSpace)) - - + + BinariesDict, AsBuildIns, BinaryFileObjectList = GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, @@ -868,7 +864,7 @@ class InfPomAlignment(ModuleObject): self.GetSupArchList(), self.BinaryModule, DecObjList) - + BinariesDict2 = {} for Key in BinariesDict: ValueList = BinariesDict[Key] @@ -876,7 +872,7 @@ class InfPomAlignment(ModuleObject): BinariesDict2[Key] = ValueList else: # - # if there is no TagName, ToolCode, HelpStr, + # if there is no TagName, ToolCode, HelpStr, # then do not need to put them into userextension # (Target, Family, TagName, HelpStr) = ValueList[0] @@ -1004,7 +1000,7 @@ class InfPomAlignment(ModuleObject): HelpTxtTailObj.SetLang(DT.TAB_LANGUAGE_EN_X) HelpTxtTailObj.SetString(HelpString) ListObject.SetHelpTextList([HelpTxtTailObj]) - + GuidProtocolPpiList.append(ListObject) elif Type == DT.TAB_PROTOCOLS: ProtocolData = ProtocolObj.keys() @@ -1072,10 +1068,10 @@ class InfPomAlignment(ModuleObject): FileObj.SetURI(FileName) MiscFileObj.SetFileList(MiscFileObj.GetFileList()+[FileObj]) else: - Logger.Error("InfParser", + Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Line), File=GlobalData.gINF_MODULE_NAME, - ExtraData=Line) - self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj]) - + ExtraData=Line) + self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj]) +