X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FUPT%2FPomAdapter%2FInfPomAlignment.py;h=9c406e5f49e32c9f09eb8a31085c1c00457ad1ea;hb=e812a812c1a0800c49e11507cb46222351520cc7;hp=fa5f5af0e2126e74bc795f2dd5425e63564900e9;hpb=421ccda3079077dd613308526e02d797f5cc356a;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py b/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
index fa5f5af0e2..9c406e5f49 100644
--- a/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
+++ b/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
@@ -1,15 +1,9 @@
## @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
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
#
'''
InfPomAlignment
@@ -20,10 +14,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
@@ -51,7 +45,7 @@ from PomAdapter.InfPomAlignmentMisc import GenModuleHeaderUserExt
from PomAdapter.InfPomAlignmentMisc import GenBinaryData
from Parser import InfParser
from PomAdapter.DecPomAlignment import DecPomAlignment
-
+from Common.MultipleWorkspace import MultipleWorkspace as mws
## InfPomAlignment
#
@@ -59,8 +53,8 @@ from PomAdapter.DecPomAlignment import DecPomAlignment
#
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 +84,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 +127,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 +138,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])
@@ -167,11 +161,11 @@ class InfPomAlignment(ModuleObject):
#
# Convert UEFI/PI version to decimal number
#
- if DefineObj.GetUefiSpecificationVersion() != None:
+ if DefineObj.GetUefiSpecificationVersion() is not None:
__UefiVersion = DefineObj.GetUefiSpecificationVersion().GetValue()
__UefiVersion = ConvertVersionToDecimal(__UefiVersion)
self.SetUefiSpecificationVersion(str(__UefiVersion))
- if DefineObj.GetPiSpecificationVersion() != None:
+ if DefineObj.GetPiSpecificationVersion() is not None:
__PiVersion = DefineObj.GetPiSpecificationVersion().GetValue()
__PiVersion = ConvertVersionToDecimal(__PiVersion)
@@ -184,9 +178,9 @@ 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() == None:
+ if DefineObj.GetModuleType() is None:
Logger.Error("InfParser", FORMAT_INVALID,
ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("MODULE_TYPE"), File=self.FullPath)
else:
@@ -194,7 +188,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':
@@ -205,7 +199,7 @@ class InfPomAlignment(ModuleObject):
Line=DefineObj.ModuleType.CurrentLine.LineNo,
ExtraData=DefineObj.ModuleType.CurrentLine.LineString)
self.LibModuleTypeList.append(ModuleType)
- if DefineObj.GetBaseName() == None:
+ if DefineObj.GetBaseName() is None:
Logger.Error("InfParser", FORMAT_INVALID,
ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("BASE_NAME"), File=self.FullPath)
else:
@@ -214,17 +208,17 @@ class InfPomAlignment(ModuleObject):
self.UniFileClassObject = UniFileClassObject([PathClass(DefineObj.GetModuleUniFileName())])
else:
self.UniFileClassObject = None
- if DefineObj.GetInfVersion() == None:
+ if DefineObj.GetInfVersion() is None:
Logger.Error("InfParser", FORMAT_INVALID,
ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("INF_VERSION"), File=self.FullPath)
else:
self.SetVersion(DefineObj.GetInfVersion().GetValue())
- if DefineObj.GetFileGuid() == None:
+ if DefineObj.GetFileGuid() is None:
Logger.Error("InfParser", FORMAT_INVALID,
ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("FILE_GUID"), File=self.FullPath)
else:
self.SetGuid(DefineObj.GetFileGuid().GetValue())
- if DefineObj.GetVersionString() == None:
+ if DefineObj.GetVersionString() is None:
#
# VERSION_STRING is missing from the [Defines] section, tools must assume that the module's version is 0.
#
@@ -248,7 +242,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():
@@ -256,7 +250,7 @@ class InfPomAlignment(ModuleObject):
if not (ModuleTypeValue == 'SEC' or ModuleTypeValue == 'PEI_CORE' or ModuleTypeValue == 'PEIM'):
Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SHADOW_INVALID, File=self.FullPath)
- if DefineObj.GetPcdIsDriver() != None:
+ if DefineObj.GetPcdIsDriver() is not None:
self.SetPcdIsDriver(DefineObj.GetPcdIsDriver().GetValue())
#
# LIBRARY_CLASS
@@ -283,7 +277,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 +287,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 +350,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 +367,7 @@ class InfPomAlignment(ModuleObject):
Image = ExternObject()
#
# Future enhancement
- #
+ #
Image.SetConstructor(ConstructorItem.GetCName())
self.SetExternList(self.GetExternList() + [Image])
#
@@ -384,7 +378,7 @@ class InfPomAlignment(ModuleObject):
Image = ExternObject()
#
# Future enhancement
- #
+ #
Image.SetDestructor(DestructorItem.GetCName())
self.SetExternList(self.GetExternList() + [Image])
@@ -486,10 +480,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)
@@ -499,7 +490,7 @@ class InfPomAlignment(ModuleObject):
LibraryClass.SetSupArchList(ConvertArchList(Item.GetSupArchList()))
LibraryClass.SetSupModuleList(Item.GetSupModuleList())
HelpStringObj = Item.GetHelpString()
- if HelpStringObj != None:
+ if HelpStringObj is not None:
CommentString = GetHelpStringByRemoveHashKey(HelpStringObj.HeaderComments +
HelpStringObj.TailComments)
HelpTextHeaderObj = CommonObject.TextObject()
@@ -534,8 +525,7 @@ class InfPomAlignment(ModuleObject):
PackageDependency.SetSupArchList(ConvertArchList(PackageItemObj.GetSupArchList()))
PackageDependency.SetFeatureFlag(PackageItemObj.GetFeatureFlagExp())
- PkgInfo = GetPkgInfoFromDec(os.path.normpath(os.path.join(self.WorkSpace,
- NormPath(PackageItemObj.GetPackageName()))))
+ PkgInfo = GetPkgInfoFromDec(mws.join(self.WorkSpace, NormPath(PackageItemObj.GetPackageName())))
if PkgInfo[1] and PkgInfo[2]:
PackageDependency.SetGuid(PkgInfo[1])
PackageDependency.SetVersion(PkgInfo[2])
@@ -615,8 +605,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)
@@ -644,7 +633,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('"'):
@@ -658,11 +647,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
@@ -689,7 +678,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)
@@ -807,7 +796,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():
@@ -832,7 +821,7 @@ class InfPomAlignment(ModuleObject):
#
# BuildOption AsBuild Info
- #
+ #
for BuildOptionItem in self.Parser.InfBuildOptionSection.GetBuildOptions():
AsBuildBuildOptionList.append(BuildOptionItem)
AsBuildIns.SetBuildFlagsList(AsBuildBuildOptionList)
@@ -854,14 +843,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,
@@ -869,7 +858,7 @@ class InfPomAlignment(ModuleObject):
self.GetSupArchList(),
self.BinaryModule,
DecObjList)
-
+
BinariesDict2 = {}
for Key in BinariesDict:
ValueList = BinariesDict[Key]
@@ -877,7 +866,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]
@@ -940,7 +929,7 @@ class InfPomAlignment(ModuleObject):
HelpTextObj.SetString(CommentItem.GetHelpStringItem())
Pcd.SetHelpTextList(Pcd.GetHelpTextList() + [HelpTextObj])
AsBuildPatchPcdList.append(Pcd)
- else:
+ elif PcdItem[0].upper() == DT.TAB_INF_PCD_EX.upper():
PcdItemObj = PcdItem[1]
Pcd = CommonObject.PcdObject()
Pcd.SetTokenSpaceGuidValue(PcdItemObj.GetTokenSpaceGuidValue())
@@ -1005,7 +994,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()
@@ -1073,10 +1062,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])
+