summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/UPT/Object
diff options
context:
space:
mode:
authorkx <kx@radix.pro>2024-06-04 06:43:08 +0300
committerkx <kx@radix.pro>2024-06-04 06:43:08 +0300
commit7e2ccccace24636f29ddc210b94606abd4c7e42b (patch)
tree545d43ea12671048956cafeb12303e84d601e571 /BaseTools/Source/Python/UPT/Object
parent27b044605cd5f6b33a3d231576003850b3fe305b (diff)
downloadedk2-trunk.tar.xz
Renormalized end-of-lines from master@27b044605cd5f6b33a3d231576003850b3fe305btrunk
Diffstat (limited to 'BaseTools/Source/Python/UPT/Object')
-rw-r--r--BaseTools/Source/Python/UPT/Object/POM/CommonObject.py1906
-rw-r--r--BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py1308
-rw-r--r--BaseTools/Source/Python/UPT/Object/POM/PackageObject.py384
-rw-r--r--BaseTools/Source/Python/UPT/Object/POM/__init__.py28
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/DecObject.py1210
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py1372
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py174
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfCommonObject.py312
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfDefineCommonObject.py166
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py2004
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfDepexObject.py320
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py694
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfHeaderObject.py226
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py494
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py284
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py362
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py1338
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py674
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py610
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py466
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py254
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/__init__.py28
-rw-r--r--BaseTools/Source/Python/UPT/Object/__init__.py28
23 files changed, 7321 insertions, 7321 deletions
diff --git a/BaseTools/Source/Python/UPT/Object/POM/CommonObject.py b/BaseTools/Source/Python/UPT/Object/POM/CommonObject.py
index ae8fe8306d..0cd33ef0f0 100644
--- a/BaseTools/Source/Python/UPT/Object/POM/CommonObject.py
+++ b/BaseTools/Source/Python/UPT/Object/POM/CommonObject.py
@@ -1,953 +1,953 @@
-## @file
-# This file is used to define common items of class object
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-Common Object
-'''
-from Library.DataType import TAB_LANGUAGE_EN_US
-
-## HelpTextObject
-#
-# @param object: Inherited from object class
-#
-class HelpTextObject(object):
- def __init__(self):
- self.HelpText = TextObject()
-
- def SetHelpText(self, HelpText):
- self.HelpText = HelpText
-
- def GetHelpText(self):
- return self.HelpText
-
-## HelpTextListObject
-#
-# @param object: Inherited from object class
-#
-class HelpTextListObject(object):
- def __init__(self):
- self.HelpTextList = []
-
- def SetHelpTextList(self, HelpTextList):
- self.HelpTextList = HelpTextList
-
- def GetHelpTextList(self):
- return self.HelpTextList
-
-## PromptListObject
-#
-# @param object: Inherited from object class
-#
-class PromptListObject(object):
- def __init__(self):
- self.PromptList = []
-
- def SetPromptList(self, PromptList):
- self.PromptList = PromptList
-
- def GetPromptList(self):
- return self.PromptList
-
-## CommonPropertiesObject
-#
-# This class defined common attribution used in Module/Platform/Package files
-#
-# @param object: Inherited from object class
-# @param Usage: Input value for Usage, default is []
-# @param FeatureFlag: Input value for FeatureFalg, default is ''
-# @param SupArchList: Input value for SupArchList, default is []
-# @param HelpText: Input value for HelpText, default is ''
-# @param HelpTextList: Input value for HelpTextList, default is []
-#
-class CommonPropertiesObject(HelpTextObject, HelpTextListObject):
- def __init__(self):
- self.Usage = []
- self.FeatureFlag = ''
- self.SupArchList = []
- self.GuidValue = ''
- HelpTextObject.__init__(self)
- HelpTextListObject.__init__(self)
-
- def SetUsage(self, Usage):
- self.Usage = Usage
-
- def GetUsage(self):
- return self.Usage
-
- def SetFeatureFlag(self, FeatureFlag):
- self.FeatureFlag = FeatureFlag
-
- def GetFeatureFlag(self):
- return self.FeatureFlag
-
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
-
- def GetSupArchList(self):
- return self.SupArchList
-
- def SetGuidValue(self, GuidValue):
- self.GuidValue = GuidValue
-
- def GetGuidValue(self):
- return self.GuidValue
-
-## CommonHeaderObject
-#
-# This class defined common header items used in Module/Platform/Package files
-#
-# @param object: Inherited from object class
-#
-class CommonHeaderObject(object):
- def __init__(self):
- self.AbstractList = []
- self.DescriptionList = []
- self.CopyrightList = []
- self.LicenseList = []
-
- def SetAbstract(self, Abstract):
- if isinstance(Abstract, list):
- self.AbstractList = Abstract
- else:
- self.AbstractList.append(Abstract)
-
- def GetAbstract(self):
- return self.AbstractList
-
- def SetDescription(self, Description):
- if isinstance(Description, list):
- self.DescriptionList = Description
- else:
- self.DescriptionList.append(Description)
-
- def GetDescription(self):
- return self.DescriptionList
-
- def SetCopyright(self, Copyright):
- if isinstance(Copyright, list):
- self.CopyrightList = Copyright
- else:
- self.CopyrightList.append(Copyright)
-
- def GetCopyright(self):
- return self.CopyrightList
-
- def SetLicense(self, License):
- if isinstance(License, list):
- self.LicenseList = License
- else:
- self.LicenseList.append(License)
-
- def GetLicense(self):
- return self.LicenseList
-
-## BinaryHeaderObject
-#
-# This class defined Binary header items used in Module/Platform/Package files
-#
-# @param object: Inherited from object class
-#
-class BinaryHeaderObject(object):
- def __init__(self):
- self.BinaryHeaderAbstractList = []
- self.BinaryHeaderDescriptionList = []
- self.BinaryHeaderCopyrightList = []
- self.BinaryHeaderLicenseList = []
-
- def SetBinaryHeaderAbstract(self, Abstract):
- if isinstance(Abstract, list) and Abstract:
- self.BinaryHeaderAbstractList = Abstract
- elif isinstance(Abstract, tuple) and Abstract[1]:
- self.BinaryHeaderAbstractList.append(Abstract)
-
- def GetBinaryHeaderAbstract(self):
- return self.BinaryHeaderAbstractList
-
- def SetBinaryHeaderDescription(self, Description):
- if isinstance(Description, list) and Description:
- self.BinaryHeaderDescriptionList = Description
- elif isinstance(Description, tuple) and Description[1]:
- self.BinaryHeaderDescriptionList.append(Description)
-
- def GetBinaryHeaderDescription(self):
- return self.BinaryHeaderDescriptionList
-
- def SetBinaryHeaderCopyright(self, Copyright):
- if isinstance(Copyright, list) and Copyright:
- self.BinaryHeaderCopyrightList = Copyright
- elif isinstance(Copyright, tuple) and Copyright[1]:
- self.BinaryHeaderCopyrightList.append(Copyright)
-
- def GetBinaryHeaderCopyright(self):
- return self.BinaryHeaderCopyrightList
-
- def SetBinaryHeaderLicense(self, License):
- if isinstance(License, list) and License:
- self.BinaryHeaderLicenseList = License
- elif isinstance(License, tuple) and License[1]:
- self.BinaryHeaderLicenseList.append(License)
-
- def GetBinaryHeaderLicense(self):
- return self.BinaryHeaderLicenseList
-
-## ClonedRecordObject
-#
-# This class defined ClonedRecord items used in Module/Platform/Package files
-#
-# @param object: Inherited from object class
-#
-class ClonedRecordObject(object):
- def __init__(self):
- self.IdNum = 0
- self.FarGuid = ''
- self.PackageGuid = ''
- self.PackageVersion = ''
- self.ModuleGuid = ''
- self.ModuleVersion = ''
-
- def SetId(self, IdNo):
- self.IdNum = IdNo
-
- def GetId(self):
- return self.IdNum
-
- def SetFarGuid(self, FarGuid):
- self.FarGuid = FarGuid
-
- def GetFarGuid(self):
- return self.FarGuid
-
- def SetPackageGuid(self, PackageGuid):
- self.PackageGuid = PackageGuid
-
- def GetPackageGuid(self):
- return self.PackageGuid
-
- def SetPackageVersion(self, PackageVersion):
- self.PackageVersion = PackageVersion
-
- def GetPackageVersion(self):
- return self.PackageVersion
-
- def SetModuleGuid(self, ModuleGuid):
- self.ModuleGuid = ModuleGuid
-
- def GetModuleGuid(self):
- return self.ModuleGuid
-
- def SetModuleVersion(self, ModuleVersion):
- self.ModuleVersion = ModuleVersion
-
- def GetModuleVersion(self):
- return self.ModuleVersion
-
-## TextObject
-#
-# This class defined Text item used in PKG file
-#
-# @param object: Inherited from object class
-#
-class TextObject(object):
- def __init__(self):
- self.Lang = TAB_LANGUAGE_EN_US
- self.String = ''
-
- def SetLang(self, Lang):
- self.Lang = Lang
-
- def GetLang(self):
- return self.Lang
-
- def SetString(self, String):
- self.String = String
-
- def GetString(self):
- return self.String
-
-## FileNameObject
-#
-# This class defined File item used in module, for binary files
-#
-# @param CommonPropertiesObject: Inherited from CommonPropertiesObject class
-#
-class FileNameObject(CommonPropertiesObject):
- def __init__(self):
- self.FileType = ''
- self.Filename = ''
- CommonPropertiesObject.__init__(self)
-
- def SetFileType(self, FileType):
- self.FileType = FileType
-
- def GetFileType(self):
- return self.FileType
-
- def SetFilename(self, Filename):
- self.Filename = Filename
-
- def GetFilename(self):
- return self.Filename
-
-## FileObject
-#
-# This class defined File item used in PKG file
-#
-# @param object: Inherited from object class
-#
-class FileObject(object):
- def __init__(self):
- self.Executable = ''
- self.Uri = ''
- self.OsType = ''
-
- def SetExecutable(self, Executable):
- self.Executable = Executable
-
- def GetExecutable(self):
- return self.Executable
-
- def SetURI(self, URI):
- self.Uri = URI
-
- def GetURI(self):
- return self.Uri
-
- def SetOS(self, OsType):
- self.OsType = OsType
-
- def GetOS(self):
- return self.OsType
-
-##
-# MiscFileObject is used for xml
-#
-# @param CommonHeaderObject: Inherited from CommonHeaderObject class
-#
-class MiscFileObject(CommonHeaderObject):
- def __init__(self):
- self.Name = ''
- self.FileList = []
- CommonHeaderObject.__init__(self)
-
- def SetName(self, Name):
- self.Name = Name
-
- def GetName(self):
- return self.Name
-
- def SetFileList(self, FileList):
- self.FileList = FileList
-
- def GetFileList(self):
- return self.FileList
-
-##
-# ToolsObject
-#
-class ToolsObject(MiscFileObject):
- pass
-
-## GuidVersionObject
-#
-# This class defined GUID/Version items used in PKG file
-#
-# @param object: Inherited from object class
-#
-class GuidVersionObject(object):
- def __init__(self):
- self.Guid = ''
- self.Version = ''
-
- def SetGuid(self, Guid):
- self.Guid = Guid
-
- def GetGuid(self):
- return self.Guid
-
- def SetVersion(self, Version):
- self.Version = Version
-
- def GetVersion(self):
- return self.Version
-
-## IdentificationObject
-#
-# This class defined Identification items used in Module/Platform/Package files
-#
-# @param object: Inherited from object class
-#
-class IdentificationObject(GuidVersionObject):
- def __init__(self):
- self.Name = ''
- self.BaseName = ''
- self.FileName = ''
- self.FullPath = ''
- self.RelaPath = ''
- self.PackagePath = ''
- self.ModulePath = ''
- self.CombinePath = ''
- GuidVersionObject.__init__(self)
-
- def SetName(self, Name):
- self.Name = Name
-
- def GetName(self):
- return self.Name
-
- def SetBaseName(self, BaseName):
- self.BaseName = BaseName
-
- def GetBaseName(self):
- return self.BaseName
-
- def SetFileName(self, FileName):
- self.FileName = FileName
-
- def GetFileName(self):
- return self.FileName
-
- def SetFullPath(self, FullPath):
- self.FullPath = FullPath
-
- def GetFullPath(self):
- return self.FullPath
-
- def SetRelaPath(self, RelaPath):
- self.RelaPath = RelaPath
-
- def GetRelaPath(self):
- return self.RelaPath
-
- def SetPackagePath(self, PackagePath):
- self.PackagePath = PackagePath
-
- def GetPackagePath(self):
- return self.PackagePath
-
- def SetModulePath(self, ModulePath):
- self.ModulePath = ModulePath
-
- def GetModulePath(self):
- return self.ModulePath
-
- def SetCombinePath(self, CombinePath):
- self.CombinePath = CombinePath
-
- def GetCombinePath(self):
- return self.CombinePath
-
-## GuidProtocolPpiCommonObject
-#
-# This class defined Guid, Protocol and Ppi like items used in
-# Module/Platform/Package files
-#
-# @param CommonPropertiesObject: Inherited from CommonPropertiesObject class
-#
-class GuidProtocolPpiCommonObject(CommonPropertiesObject):
- def __init__(self):
- self.Name = ''
- self.CName = ''
- self.Guid = ''
- self.SupModuleList = []
- CommonPropertiesObject.__init__(self)
-
- def SetName(self, Name):
- self.Name = Name
-
- def GetName(self):
- return self.Name
-
- def SetCName(self, CName):
- self.CName = CName
-
- def GetCName(self):
- return self.CName
-
- def SetGuid(self, Guid):
- self.Guid = Guid
-
- def GetGuid(self):
- return self.Guid
-
- def SetSupModuleList(self, SupModuleList):
- self.SupModuleList = SupModuleList
-
- def GetSupModuleList(self):
- return self.SupModuleList
-
-## GuidObject
-#
-# This class defined Guid item used in Module/Platform/Package files
-#
-# @param GuidProtocolPpiCommonObject: GuidProtocolPpiCommonObject
-#
-class GuidObject(GuidProtocolPpiCommonObject):
- def __init__(self):
- self.VariableName = ''
- self.GuidTypeList = []
- GuidProtocolPpiCommonObject.__init__(self)
- def SetVariableName(self, VariableName):
- self.VariableName = VariableName
-
- def GetVariableName(self):
- return self.VariableName
-
- def SetGuidTypeList(self, GuidTypeList):
- self.GuidTypeList = GuidTypeList
-
- def GetGuidTypeList(self):
- return self.GuidTypeList
-
-## ProtocolObject
-#
-# This class defined Protocol item used in Module/Platform/Package files
-#
-# @param GuidProtocolPpiCommonObject: Inherited from
-# GuidProtocolPpiCommonObject
-#
-class ProtocolObject(GuidProtocolPpiCommonObject):
- def __init__(self):
- self.Notify = False
- GuidProtocolPpiCommonObject.__init__(self)
- def SetNotify(self, Notify):
- self.Notify = Notify
-
- def GetNotify(self):
- return self.Notify
-
-## PpiObject
-#
-# This class defined Ppi item used in Module/Platform/Package files
-#
-# @param GuidProtocolPpiCommonObject: Inherited from
-# GuidProtocolPpiCommonObject
-#
-class PpiObject(GuidProtocolPpiCommonObject):
- def __init__(self):
- self.Notify = False
- GuidProtocolPpiCommonObject.__init__(self)
- def SetNotify(self, Notify):
- self.Notify = Notify
-
- def GetNotify(self):
- return self.Notify
-
-## DefineObject
-#
-# This class defined item DEFINE used in Module/Platform/Package files
-#
-# @param object: Inherited from object class
-#
-class DefineClass(object):
- def __init__(self):
- self.Define = {}
-
-## UserExtensionObject
-#
-# @param object: Inherited from object class
-#
-class UserExtensionObject(object):
- def __init__(self):
- self.UserID = ''
- self.Identifier = ''
- self.BinaryAbstractList = []
- self.BinaryDescriptionList = []
- self.BinaryCopyrightList = []
- self.BinaryLicenseList = []
- self.UniLangDefsList = []
- #
- # { Statement : Arch , ... }
- #
- self.DefinesDict = {}
- #
- # { Arch : Statement , ... }
- #
- self.BuildOptionDict = {}
- self.IncludesDict = {}
- self.SourcesDict = {}
- self.BinariesDict = {}
- #
- # UserExtension statement from meta-data file [UserExtension] section
- #
- self.Statement = ''
- self.SupArchList = []
-
- def SetStatement(self, Statement):
- self.Statement = Statement
-
- def GetStatement(self):
- return self.Statement
-
- def SetSupArchList(self, ArchList):
- self.SupArchList = ArchList
-
- def GetSupArchList(self):
- return self.SupArchList
-
- def SetUserID(self, UserID):
- self.UserID = UserID
-
- def GetUserID(self):
- return self.UserID
-
- def SetIdentifier(self, Identifier):
- self.Identifier = Identifier
-
- def GetIdentifier(self):
- return self.Identifier
-
- def SetUniLangDefsList(self, UniLangDefsList):
- self.UniLangDefsList = UniLangDefsList
-
- def GetUniLangDefsList(self):
- return self.UniLangDefsList
-
- def SetBinaryAbstract(self, BinaryAbstractList):
- self.BinaryAbstractList = BinaryAbstractList
-
- def GetBinaryAbstract(self, Lang=None):
- if Lang:
- for (Key, Value) in self.BinaryAbstractList:
- if Key == Lang:
- return Value
- return None
- else:
- return self.BinaryAbstractList
-
- def SetBinaryDescription(self, BinaryDescriptionList):
- self.BinaryDescriptionList = BinaryDescriptionList
-
- def GetBinaryDescription(self, Lang=None):
- if Lang:
- for (Key, Value) in self.BinaryDescriptionList:
- if Key == Lang:
- return Value
- return None
- else:
- return self.BinaryDescriptionList
-
- def SetBinaryCopyright(self, BinaryCopyrightList):
- self.BinaryCopyrightList = BinaryCopyrightList
-
- def GetBinaryCopyright(self, Lang=None):
- if Lang:
- for (Key, Value) in self.BinaryCopyrightList:
- if Key == Lang:
- return Value
- return None
- else:
- return self.BinaryCopyrightList
-
- def SetBinaryLicense(self, BinaryLicenseList):
- self.BinaryLicenseList = BinaryLicenseList
-
- def GetBinaryLicense(self, Lang=None):
- if Lang:
- for (Key, Value) in self.BinaryLicenseList:
- if Key == Lang:
- return Value
- return None
- else:
- return self.BinaryLicenseList
-
- def SetDefinesDict(self, DefinesDict):
- self.DefinesDict = DefinesDict
-
- def GetDefinesDict(self):
- return self.DefinesDict
-
- def SetBuildOptionDict(self, BuildOptionDict):
- self.BuildOptionDict = BuildOptionDict
-
- def GetBuildOptionDict(self):
- return self.BuildOptionDict
-
- def SetIncludesDict(self, IncludesDict):
- self.IncludesDict = IncludesDict
-
- def GetIncludesDict(self):
- return self.IncludesDict
-
- def SetSourcesDict(self, SourcesDict):
- self.SourcesDict = SourcesDict
-
- def GetSourcesDict(self):
- return self.SourcesDict
-
- def SetBinariesDict(self, BinariesDict):
- self.BinariesDict = BinariesDict
-
- def GetBinariesDict(self):
- return self.BinariesDict
-
-## LibraryClassObject
-#
-# This class defined Library item used in Module/Platform/Package files
-#
-# @param CommonPropertiesObject: Inherited from CommonPropertiesObject class
-#
-class LibraryClassObject(CommonPropertiesObject):
- def __init__(self):
- self.LibraryClass = ''
- self.IncludeHeader = ''
- self.SupModuleList = []
- self.RecommendedInstance = GuidVersionObject()
- CommonPropertiesObject.__init__(self)
-
- def SetLibraryClass(self, LibraryClass):
- self.LibraryClass = LibraryClass
-
- def GetLibraryClass(self):
- return self.LibraryClass
-
- def SetSupModuleList(self, SupModuleList):
- self.SupModuleList = SupModuleList
-
- def GetSupModuleList(self):
- return self.SupModuleList
-
- def SetIncludeHeader(self, IncludeHeader):
- self.IncludeHeader = IncludeHeader
-
- def GetIncludeHeader(self):
- return self.IncludeHeader
-
- def SetRecommendedInstance(self, RecommendedInstance):
- self.RecommendedInstance = RecommendedInstance
-
- def GetRecommendedInstance(self):
- return self.RecommendedInstance
-
-
-## PcdErrorObject
-#
-# @param object: Inherited from object class
-#
-class PcdErrorObject(object):
- def __init__(self):
- self.ValidValue = ''
- self.ValidValueLang = ''
- self.ValidValueRange = ''
- self.Expression = ''
- self.ErrorNumber = ''
- self.ErrorMessageList = []
- self.TokenSpaceGuidCName = ''
- self.CName = ''
- self.FileLine = ''
- self.LineNum = 0
-
- def SetValidValue(self, ValidValue):
- self.ValidValue = ValidValue
-
- def GetValidValue(self):
- return self.ValidValue
-
- def SetValidValueLang(self, ValidValueLang):
- self.ValidValueLang = ValidValueLang
-
- def GetValidValueLang(self):
- return self.ValidValueLang
-
- def SetValidValueRange(self, ValidValueRange):
- self.ValidValueRange = ValidValueRange
-
- def GetValidValueRange(self):
- return self.ValidValueRange
-
- def SetExpression(self, Expression):
- self.Expression = Expression
-
- def GetExpression(self):
- return self.Expression
-
- def SetErrorNumber(self, ErrorNumber):
- self.ErrorNumber = ErrorNumber
-
- def GetErrorNumber(self):
- return self.ErrorNumber
-
- def SetErrorMessageList(self, ErrorMessageList):
- self.ErrorMessageList = ErrorMessageList
-
- def GetErrorMessageList(self):
- return self.ErrorMessageList
-
- def SetTokenSpaceGuidCName(self, TokenSpaceGuidCName):
- self.TokenSpaceGuidCName = TokenSpaceGuidCName
-
- def GetTokenSpaceGuidCName(self):
- return self.TokenSpaceGuidCName
-
- def SetCName(self, CName):
- self.CName = CName
-
- def GetCName(self):
- return self.CName
-
- def SetFileLine(self, FileLine):
- self.FileLine = FileLine
-
- def GetFileLine(self):
- return self.FileLine
-
- def SetLineNum(self, LineNum):
- self.LineNum = LineNum
-
- def GetLineNum(self):
- return self.LineNum
-
-
-## IncludeObject
-#
-# This class defined Include item used in Module/Platform/Package files
-#
-# @param CommonPropertiesObject: Inherited from CommonPropertiesObject class
-#
-class IncludeObject(CommonPropertiesObject):
- def __init__(self):
- self.FilePath = ''
- self.ModuleType = ''
- self.SupModuleList = []
- self.Comment = ''
- CommonPropertiesObject.__init__(self)
-
- def SetFilePath(self, FilePath):
- self.FilePath = FilePath
-
- def GetFilePath(self):
- return self.FilePath
-
- def SetModuleType(self, ModuleType):
- self.ModuleType = ModuleType
-
- def GetModuleType(self):
- return self.ModuleType
-
- def SetSupModuleList(self, SupModuleList):
- self.SupModuleList = SupModuleList
-
- def GetSupModuleList(self):
- return self.SupModuleList
-
- def SetComment(self, Comment):
- self.Comment = Comment
-
- def GetComment(self):
- return self.Comment
-
-## PcdObject
-#
-# This class defined Pcd item used in Module/Platform/Package files
-#
-# @param CName: Input value for CName, default is ''
-# @param Token: Input value for Token, default is ''
-# @param TokenSpaceGuidCName: Input value for TokenSpaceGuidCName, default is
-# ''
-# @param DatumType: Input value for DatumType, default is ''
-# @param MaxDatumSize: Input value for MaxDatumSize, default is ''
-# @param DefaultValue: Input value for DefaultValue, default is ''
-# @param ItemType: Input value for ItemType, default is ''
-# @param ValidUsage: Input value for ValidUsage, default is []
-# @param SkuInfoList: Input value for SkuInfoList, default is {}
-# @param SupModuleList: Input value for SupModuleList, default is []
-#
-class PcdObject(CommonPropertiesObject, HelpTextListObject, PromptListObject):
- def __init__(self):
- self.PcdCName = ''
- self.CName = ''
- self.Token = ''
- self.TokenSpaceGuidCName = ''
- self.TokenSpaceGuidValue = ''
- self.DatumType = ''
- self.MaxDatumSize = ''
- self.DefaultValue = ''
- self.Offset = ''
- self.ValidUsage = ''
- self.ItemType = ''
- self.PcdErrorsList = []
- self.SupModuleList = []
- CommonPropertiesObject.__init__(self)
- HelpTextListObject.__init__(self)
- PromptListObject.__init__(self)
-
- def SetPcdCName(self, PcdCName):
- self.PcdCName = PcdCName
-
- def GetPcdCName(self):
- return self.PcdCName
-
- def SetCName(self, CName):
- self.CName = CName
-
- def GetCName(self):
- return self.CName
-
- def SetToken(self, Token):
- self.Token = Token
-
- def GetOffset(self):
- return self.Offset
-
- def SetOffset(self, Offset):
- self.Offset = Offset
-
- def GetToken(self):
- return self.Token
-
- def SetTokenSpaceGuidCName(self, TokenSpaceGuidCName):
- self.TokenSpaceGuidCName = TokenSpaceGuidCName
-
- def GetTokenSpaceGuidCName(self):
- return self.TokenSpaceGuidCName
-
- def SetTokenSpaceGuidValue(self, TokenSpaceGuidValue):
- self.TokenSpaceGuidValue = TokenSpaceGuidValue
-
- def GetTokenSpaceGuidValue(self):
- return self.TokenSpaceGuidValue
-
- def SetDatumType(self, DatumType):
- self.DatumType = DatumType
-
- def GetDatumType(self):
- return self.DatumType
-
- def SetMaxDatumSize(self, MaxDatumSize):
- self.MaxDatumSize = MaxDatumSize
-
- def GetMaxDatumSize(self):
- return self.MaxDatumSize
-
- def SetDefaultValue(self, DefaultValue):
- self.DefaultValue = DefaultValue
-
- def GetDefaultValue(self):
- return self.DefaultValue
-
- def SetValidUsage(self, ValidUsage):
- self.ValidUsage = ValidUsage
-
- def GetValidUsage(self):
- return self.ValidUsage
-
- def SetPcdErrorsList(self, PcdErrorsList):
- self.PcdErrorsList = PcdErrorsList
-
- def GetPcdErrorsList(self):
- return self.PcdErrorsList
-
- def SetItemType(self, ItemType):
- self.ItemType = ItemType
-
- def GetItemType(self):
- return self.ItemType
-
- def SetSupModuleList(self, SupModuleList):
- self.SupModuleList = SupModuleList
-
- def GetSupModuleList(self):
- return self.SupModuleList
+## @file
+# This file is used to define common items of class object
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+Common Object
+'''
+from Library.DataType import TAB_LANGUAGE_EN_US
+
+## HelpTextObject
+#
+# @param object: Inherited from object class
+#
+class HelpTextObject(object):
+ def __init__(self):
+ self.HelpText = TextObject()
+
+ def SetHelpText(self, HelpText):
+ self.HelpText = HelpText
+
+ def GetHelpText(self):
+ return self.HelpText
+
+## HelpTextListObject
+#
+# @param object: Inherited from object class
+#
+class HelpTextListObject(object):
+ def __init__(self):
+ self.HelpTextList = []
+
+ def SetHelpTextList(self, HelpTextList):
+ self.HelpTextList = HelpTextList
+
+ def GetHelpTextList(self):
+ return self.HelpTextList
+
+## PromptListObject
+#
+# @param object: Inherited from object class
+#
+class PromptListObject(object):
+ def __init__(self):
+ self.PromptList = []
+
+ def SetPromptList(self, PromptList):
+ self.PromptList = PromptList
+
+ def GetPromptList(self):
+ return self.PromptList
+
+## CommonPropertiesObject
+#
+# This class defined common attribution used in Module/Platform/Package files
+#
+# @param object: Inherited from object class
+# @param Usage: Input value for Usage, default is []
+# @param FeatureFlag: Input value for FeatureFalg, default is ''
+# @param SupArchList: Input value for SupArchList, default is []
+# @param HelpText: Input value for HelpText, default is ''
+# @param HelpTextList: Input value for HelpTextList, default is []
+#
+class CommonPropertiesObject(HelpTextObject, HelpTextListObject):
+ def __init__(self):
+ self.Usage = []
+ self.FeatureFlag = ''
+ self.SupArchList = []
+ self.GuidValue = ''
+ HelpTextObject.__init__(self)
+ HelpTextListObject.__init__(self)
+
+ def SetUsage(self, Usage):
+ self.Usage = Usage
+
+ def GetUsage(self):
+ return self.Usage
+
+ def SetFeatureFlag(self, FeatureFlag):
+ self.FeatureFlag = FeatureFlag
+
+ def GetFeatureFlag(self):
+ return self.FeatureFlag
+
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+
+ def GetSupArchList(self):
+ return self.SupArchList
+
+ def SetGuidValue(self, GuidValue):
+ self.GuidValue = GuidValue
+
+ def GetGuidValue(self):
+ return self.GuidValue
+
+## CommonHeaderObject
+#
+# This class defined common header items used in Module/Platform/Package files
+#
+# @param object: Inherited from object class
+#
+class CommonHeaderObject(object):
+ def __init__(self):
+ self.AbstractList = []
+ self.DescriptionList = []
+ self.CopyrightList = []
+ self.LicenseList = []
+
+ def SetAbstract(self, Abstract):
+ if isinstance(Abstract, list):
+ self.AbstractList = Abstract
+ else:
+ self.AbstractList.append(Abstract)
+
+ def GetAbstract(self):
+ return self.AbstractList
+
+ def SetDescription(self, Description):
+ if isinstance(Description, list):
+ self.DescriptionList = Description
+ else:
+ self.DescriptionList.append(Description)
+
+ def GetDescription(self):
+ return self.DescriptionList
+
+ def SetCopyright(self, Copyright):
+ if isinstance(Copyright, list):
+ self.CopyrightList = Copyright
+ else:
+ self.CopyrightList.append(Copyright)
+
+ def GetCopyright(self):
+ return self.CopyrightList
+
+ def SetLicense(self, License):
+ if isinstance(License, list):
+ self.LicenseList = License
+ else:
+ self.LicenseList.append(License)
+
+ def GetLicense(self):
+ return self.LicenseList
+
+## BinaryHeaderObject
+#
+# This class defined Binary header items used in Module/Platform/Package files
+#
+# @param object: Inherited from object class
+#
+class BinaryHeaderObject(object):
+ def __init__(self):
+ self.BinaryHeaderAbstractList = []
+ self.BinaryHeaderDescriptionList = []
+ self.BinaryHeaderCopyrightList = []
+ self.BinaryHeaderLicenseList = []
+
+ def SetBinaryHeaderAbstract(self, Abstract):
+ if isinstance(Abstract, list) and Abstract:
+ self.BinaryHeaderAbstractList = Abstract
+ elif isinstance(Abstract, tuple) and Abstract[1]:
+ self.BinaryHeaderAbstractList.append(Abstract)
+
+ def GetBinaryHeaderAbstract(self):
+ return self.BinaryHeaderAbstractList
+
+ def SetBinaryHeaderDescription(self, Description):
+ if isinstance(Description, list) and Description:
+ self.BinaryHeaderDescriptionList = Description
+ elif isinstance(Description, tuple) and Description[1]:
+ self.BinaryHeaderDescriptionList.append(Description)
+
+ def GetBinaryHeaderDescription(self):
+ return self.BinaryHeaderDescriptionList
+
+ def SetBinaryHeaderCopyright(self, Copyright):
+ if isinstance(Copyright, list) and Copyright:
+ self.BinaryHeaderCopyrightList = Copyright
+ elif isinstance(Copyright, tuple) and Copyright[1]:
+ self.BinaryHeaderCopyrightList.append(Copyright)
+
+ def GetBinaryHeaderCopyright(self):
+ return self.BinaryHeaderCopyrightList
+
+ def SetBinaryHeaderLicense(self, License):
+ if isinstance(License, list) and License:
+ self.BinaryHeaderLicenseList = License
+ elif isinstance(License, tuple) and License[1]:
+ self.BinaryHeaderLicenseList.append(License)
+
+ def GetBinaryHeaderLicense(self):
+ return self.BinaryHeaderLicenseList
+
+## ClonedRecordObject
+#
+# This class defined ClonedRecord items used in Module/Platform/Package files
+#
+# @param object: Inherited from object class
+#
+class ClonedRecordObject(object):
+ def __init__(self):
+ self.IdNum = 0
+ self.FarGuid = ''
+ self.PackageGuid = ''
+ self.PackageVersion = ''
+ self.ModuleGuid = ''
+ self.ModuleVersion = ''
+
+ def SetId(self, IdNo):
+ self.IdNum = IdNo
+
+ def GetId(self):
+ return self.IdNum
+
+ def SetFarGuid(self, FarGuid):
+ self.FarGuid = FarGuid
+
+ def GetFarGuid(self):
+ return self.FarGuid
+
+ def SetPackageGuid(self, PackageGuid):
+ self.PackageGuid = PackageGuid
+
+ def GetPackageGuid(self):
+ return self.PackageGuid
+
+ def SetPackageVersion(self, PackageVersion):
+ self.PackageVersion = PackageVersion
+
+ def GetPackageVersion(self):
+ return self.PackageVersion
+
+ def SetModuleGuid(self, ModuleGuid):
+ self.ModuleGuid = ModuleGuid
+
+ def GetModuleGuid(self):
+ return self.ModuleGuid
+
+ def SetModuleVersion(self, ModuleVersion):
+ self.ModuleVersion = ModuleVersion
+
+ def GetModuleVersion(self):
+ return self.ModuleVersion
+
+## TextObject
+#
+# This class defined Text item used in PKG file
+#
+# @param object: Inherited from object class
+#
+class TextObject(object):
+ def __init__(self):
+ self.Lang = TAB_LANGUAGE_EN_US
+ self.String = ''
+
+ def SetLang(self, Lang):
+ self.Lang = Lang
+
+ def GetLang(self):
+ return self.Lang
+
+ def SetString(self, String):
+ self.String = String
+
+ def GetString(self):
+ return self.String
+
+## FileNameObject
+#
+# This class defined File item used in module, for binary files
+#
+# @param CommonPropertiesObject: Inherited from CommonPropertiesObject class
+#
+class FileNameObject(CommonPropertiesObject):
+ def __init__(self):
+ self.FileType = ''
+ self.Filename = ''
+ CommonPropertiesObject.__init__(self)
+
+ def SetFileType(self, FileType):
+ self.FileType = FileType
+
+ def GetFileType(self):
+ return self.FileType
+
+ def SetFilename(self, Filename):
+ self.Filename = Filename
+
+ def GetFilename(self):
+ return self.Filename
+
+## FileObject
+#
+# This class defined File item used in PKG file
+#
+# @param object: Inherited from object class
+#
+class FileObject(object):
+ def __init__(self):
+ self.Executable = ''
+ self.Uri = ''
+ self.OsType = ''
+
+ def SetExecutable(self, Executable):
+ self.Executable = Executable
+
+ def GetExecutable(self):
+ return self.Executable
+
+ def SetURI(self, URI):
+ self.Uri = URI
+
+ def GetURI(self):
+ return self.Uri
+
+ def SetOS(self, OsType):
+ self.OsType = OsType
+
+ def GetOS(self):
+ return self.OsType
+
+##
+# MiscFileObject is used for xml
+#
+# @param CommonHeaderObject: Inherited from CommonHeaderObject class
+#
+class MiscFileObject(CommonHeaderObject):
+ def __init__(self):
+ self.Name = ''
+ self.FileList = []
+ CommonHeaderObject.__init__(self)
+
+ def SetName(self, Name):
+ self.Name = Name
+
+ def GetName(self):
+ return self.Name
+
+ def SetFileList(self, FileList):
+ self.FileList = FileList
+
+ def GetFileList(self):
+ return self.FileList
+
+##
+# ToolsObject
+#
+class ToolsObject(MiscFileObject):
+ pass
+
+## GuidVersionObject
+#
+# This class defined GUID/Version items used in PKG file
+#
+# @param object: Inherited from object class
+#
+class GuidVersionObject(object):
+ def __init__(self):
+ self.Guid = ''
+ self.Version = ''
+
+ def SetGuid(self, Guid):
+ self.Guid = Guid
+
+ def GetGuid(self):
+ return self.Guid
+
+ def SetVersion(self, Version):
+ self.Version = Version
+
+ def GetVersion(self):
+ return self.Version
+
+## IdentificationObject
+#
+# This class defined Identification items used in Module/Platform/Package files
+#
+# @param object: Inherited from object class
+#
+class IdentificationObject(GuidVersionObject):
+ def __init__(self):
+ self.Name = ''
+ self.BaseName = ''
+ self.FileName = ''
+ self.FullPath = ''
+ self.RelaPath = ''
+ self.PackagePath = ''
+ self.ModulePath = ''
+ self.CombinePath = ''
+ GuidVersionObject.__init__(self)
+
+ def SetName(self, Name):
+ self.Name = Name
+
+ def GetName(self):
+ return self.Name
+
+ def SetBaseName(self, BaseName):
+ self.BaseName = BaseName
+
+ def GetBaseName(self):
+ return self.BaseName
+
+ def SetFileName(self, FileName):
+ self.FileName = FileName
+
+ def GetFileName(self):
+ return self.FileName
+
+ def SetFullPath(self, FullPath):
+ self.FullPath = FullPath
+
+ def GetFullPath(self):
+ return self.FullPath
+
+ def SetRelaPath(self, RelaPath):
+ self.RelaPath = RelaPath
+
+ def GetRelaPath(self):
+ return self.RelaPath
+
+ def SetPackagePath(self, PackagePath):
+ self.PackagePath = PackagePath
+
+ def GetPackagePath(self):
+ return self.PackagePath
+
+ def SetModulePath(self, ModulePath):
+ self.ModulePath = ModulePath
+
+ def GetModulePath(self):
+ return self.ModulePath
+
+ def SetCombinePath(self, CombinePath):
+ self.CombinePath = CombinePath
+
+ def GetCombinePath(self):
+ return self.CombinePath
+
+## GuidProtocolPpiCommonObject
+#
+# This class defined Guid, Protocol and Ppi like items used in
+# Module/Platform/Package files
+#
+# @param CommonPropertiesObject: Inherited from CommonPropertiesObject class
+#
+class GuidProtocolPpiCommonObject(CommonPropertiesObject):
+ def __init__(self):
+ self.Name = ''
+ self.CName = ''
+ self.Guid = ''
+ self.SupModuleList = []
+ CommonPropertiesObject.__init__(self)
+
+ def SetName(self, Name):
+ self.Name = Name
+
+ def GetName(self):
+ return self.Name
+
+ def SetCName(self, CName):
+ self.CName = CName
+
+ def GetCName(self):
+ return self.CName
+
+ def SetGuid(self, Guid):
+ self.Guid = Guid
+
+ def GetGuid(self):
+ return self.Guid
+
+ def SetSupModuleList(self, SupModuleList):
+ self.SupModuleList = SupModuleList
+
+ def GetSupModuleList(self):
+ return self.SupModuleList
+
+## GuidObject
+#
+# This class defined Guid item used in Module/Platform/Package files
+#
+# @param GuidProtocolPpiCommonObject: GuidProtocolPpiCommonObject
+#
+class GuidObject(GuidProtocolPpiCommonObject):
+ def __init__(self):
+ self.VariableName = ''
+ self.GuidTypeList = []
+ GuidProtocolPpiCommonObject.__init__(self)
+ def SetVariableName(self, VariableName):
+ self.VariableName = VariableName
+
+ def GetVariableName(self):
+ return self.VariableName
+
+ def SetGuidTypeList(self, GuidTypeList):
+ self.GuidTypeList = GuidTypeList
+
+ def GetGuidTypeList(self):
+ return self.GuidTypeList
+
+## ProtocolObject
+#
+# This class defined Protocol item used in Module/Platform/Package files
+#
+# @param GuidProtocolPpiCommonObject: Inherited from
+# GuidProtocolPpiCommonObject
+#
+class ProtocolObject(GuidProtocolPpiCommonObject):
+ def __init__(self):
+ self.Notify = False
+ GuidProtocolPpiCommonObject.__init__(self)
+ def SetNotify(self, Notify):
+ self.Notify = Notify
+
+ def GetNotify(self):
+ return self.Notify
+
+## PpiObject
+#
+# This class defined Ppi item used in Module/Platform/Package files
+#
+# @param GuidProtocolPpiCommonObject: Inherited from
+# GuidProtocolPpiCommonObject
+#
+class PpiObject(GuidProtocolPpiCommonObject):
+ def __init__(self):
+ self.Notify = False
+ GuidProtocolPpiCommonObject.__init__(self)
+ def SetNotify(self, Notify):
+ self.Notify = Notify
+
+ def GetNotify(self):
+ return self.Notify
+
+## DefineObject
+#
+# This class defined item DEFINE used in Module/Platform/Package files
+#
+# @param object: Inherited from object class
+#
+class DefineClass(object):
+ def __init__(self):
+ self.Define = {}
+
+## UserExtensionObject
+#
+# @param object: Inherited from object class
+#
+class UserExtensionObject(object):
+ def __init__(self):
+ self.UserID = ''
+ self.Identifier = ''
+ self.BinaryAbstractList = []
+ self.BinaryDescriptionList = []
+ self.BinaryCopyrightList = []
+ self.BinaryLicenseList = []
+ self.UniLangDefsList = []
+ #
+ # { Statement : Arch , ... }
+ #
+ self.DefinesDict = {}
+ #
+ # { Arch : Statement , ... }
+ #
+ self.BuildOptionDict = {}
+ self.IncludesDict = {}
+ self.SourcesDict = {}
+ self.BinariesDict = {}
+ #
+ # UserExtension statement from meta-data file [UserExtension] section
+ #
+ self.Statement = ''
+ self.SupArchList = []
+
+ def SetStatement(self, Statement):
+ self.Statement = Statement
+
+ def GetStatement(self):
+ return self.Statement
+
+ def SetSupArchList(self, ArchList):
+ self.SupArchList = ArchList
+
+ def GetSupArchList(self):
+ return self.SupArchList
+
+ def SetUserID(self, UserID):
+ self.UserID = UserID
+
+ def GetUserID(self):
+ return self.UserID
+
+ def SetIdentifier(self, Identifier):
+ self.Identifier = Identifier
+
+ def GetIdentifier(self):
+ return self.Identifier
+
+ def SetUniLangDefsList(self, UniLangDefsList):
+ self.UniLangDefsList = UniLangDefsList
+
+ def GetUniLangDefsList(self):
+ return self.UniLangDefsList
+
+ def SetBinaryAbstract(self, BinaryAbstractList):
+ self.BinaryAbstractList = BinaryAbstractList
+
+ def GetBinaryAbstract(self, Lang=None):
+ if Lang:
+ for (Key, Value) in self.BinaryAbstractList:
+ if Key == Lang:
+ return Value
+ return None
+ else:
+ return self.BinaryAbstractList
+
+ def SetBinaryDescription(self, BinaryDescriptionList):
+ self.BinaryDescriptionList = BinaryDescriptionList
+
+ def GetBinaryDescription(self, Lang=None):
+ if Lang:
+ for (Key, Value) in self.BinaryDescriptionList:
+ if Key == Lang:
+ return Value
+ return None
+ else:
+ return self.BinaryDescriptionList
+
+ def SetBinaryCopyright(self, BinaryCopyrightList):
+ self.BinaryCopyrightList = BinaryCopyrightList
+
+ def GetBinaryCopyright(self, Lang=None):
+ if Lang:
+ for (Key, Value) in self.BinaryCopyrightList:
+ if Key == Lang:
+ return Value
+ return None
+ else:
+ return self.BinaryCopyrightList
+
+ def SetBinaryLicense(self, BinaryLicenseList):
+ self.BinaryLicenseList = BinaryLicenseList
+
+ def GetBinaryLicense(self, Lang=None):
+ if Lang:
+ for (Key, Value) in self.BinaryLicenseList:
+ if Key == Lang:
+ return Value
+ return None
+ else:
+ return self.BinaryLicenseList
+
+ def SetDefinesDict(self, DefinesDict):
+ self.DefinesDict = DefinesDict
+
+ def GetDefinesDict(self):
+ return self.DefinesDict
+
+ def SetBuildOptionDict(self, BuildOptionDict):
+ self.BuildOptionDict = BuildOptionDict
+
+ def GetBuildOptionDict(self):
+ return self.BuildOptionDict
+
+ def SetIncludesDict(self, IncludesDict):
+ self.IncludesDict = IncludesDict
+
+ def GetIncludesDict(self):
+ return self.IncludesDict
+
+ def SetSourcesDict(self, SourcesDict):
+ self.SourcesDict = SourcesDict
+
+ def GetSourcesDict(self):
+ return self.SourcesDict
+
+ def SetBinariesDict(self, BinariesDict):
+ self.BinariesDict = BinariesDict
+
+ def GetBinariesDict(self):
+ return self.BinariesDict
+
+## LibraryClassObject
+#
+# This class defined Library item used in Module/Platform/Package files
+#
+# @param CommonPropertiesObject: Inherited from CommonPropertiesObject class
+#
+class LibraryClassObject(CommonPropertiesObject):
+ def __init__(self):
+ self.LibraryClass = ''
+ self.IncludeHeader = ''
+ self.SupModuleList = []
+ self.RecommendedInstance = GuidVersionObject()
+ CommonPropertiesObject.__init__(self)
+
+ def SetLibraryClass(self, LibraryClass):
+ self.LibraryClass = LibraryClass
+
+ def GetLibraryClass(self):
+ return self.LibraryClass
+
+ def SetSupModuleList(self, SupModuleList):
+ self.SupModuleList = SupModuleList
+
+ def GetSupModuleList(self):
+ return self.SupModuleList
+
+ def SetIncludeHeader(self, IncludeHeader):
+ self.IncludeHeader = IncludeHeader
+
+ def GetIncludeHeader(self):
+ return self.IncludeHeader
+
+ def SetRecommendedInstance(self, RecommendedInstance):
+ self.RecommendedInstance = RecommendedInstance
+
+ def GetRecommendedInstance(self):
+ return self.RecommendedInstance
+
+
+## PcdErrorObject
+#
+# @param object: Inherited from object class
+#
+class PcdErrorObject(object):
+ def __init__(self):
+ self.ValidValue = ''
+ self.ValidValueLang = ''
+ self.ValidValueRange = ''
+ self.Expression = ''
+ self.ErrorNumber = ''
+ self.ErrorMessageList = []
+ self.TokenSpaceGuidCName = ''
+ self.CName = ''
+ self.FileLine = ''
+ self.LineNum = 0
+
+ def SetValidValue(self, ValidValue):
+ self.ValidValue = ValidValue
+
+ def GetValidValue(self):
+ return self.ValidValue
+
+ def SetValidValueLang(self, ValidValueLang):
+ self.ValidValueLang = ValidValueLang
+
+ def GetValidValueLang(self):
+ return self.ValidValueLang
+
+ def SetValidValueRange(self, ValidValueRange):
+ self.ValidValueRange = ValidValueRange
+
+ def GetValidValueRange(self):
+ return self.ValidValueRange
+
+ def SetExpression(self, Expression):
+ self.Expression = Expression
+
+ def GetExpression(self):
+ return self.Expression
+
+ def SetErrorNumber(self, ErrorNumber):
+ self.ErrorNumber = ErrorNumber
+
+ def GetErrorNumber(self):
+ return self.ErrorNumber
+
+ def SetErrorMessageList(self, ErrorMessageList):
+ self.ErrorMessageList = ErrorMessageList
+
+ def GetErrorMessageList(self):
+ return self.ErrorMessageList
+
+ def SetTokenSpaceGuidCName(self, TokenSpaceGuidCName):
+ self.TokenSpaceGuidCName = TokenSpaceGuidCName
+
+ def GetTokenSpaceGuidCName(self):
+ return self.TokenSpaceGuidCName
+
+ def SetCName(self, CName):
+ self.CName = CName
+
+ def GetCName(self):
+ return self.CName
+
+ def SetFileLine(self, FileLine):
+ self.FileLine = FileLine
+
+ def GetFileLine(self):
+ return self.FileLine
+
+ def SetLineNum(self, LineNum):
+ self.LineNum = LineNum
+
+ def GetLineNum(self):
+ return self.LineNum
+
+
+## IncludeObject
+#
+# This class defined Include item used in Module/Platform/Package files
+#
+# @param CommonPropertiesObject: Inherited from CommonPropertiesObject class
+#
+class IncludeObject(CommonPropertiesObject):
+ def __init__(self):
+ self.FilePath = ''
+ self.ModuleType = ''
+ self.SupModuleList = []
+ self.Comment = ''
+ CommonPropertiesObject.__init__(self)
+
+ def SetFilePath(self, FilePath):
+ self.FilePath = FilePath
+
+ def GetFilePath(self):
+ return self.FilePath
+
+ def SetModuleType(self, ModuleType):
+ self.ModuleType = ModuleType
+
+ def GetModuleType(self):
+ return self.ModuleType
+
+ def SetSupModuleList(self, SupModuleList):
+ self.SupModuleList = SupModuleList
+
+ def GetSupModuleList(self):
+ return self.SupModuleList
+
+ def SetComment(self, Comment):
+ self.Comment = Comment
+
+ def GetComment(self):
+ return self.Comment
+
+## PcdObject
+#
+# This class defined Pcd item used in Module/Platform/Package files
+#
+# @param CName: Input value for CName, default is ''
+# @param Token: Input value for Token, default is ''
+# @param TokenSpaceGuidCName: Input value for TokenSpaceGuidCName, default is
+# ''
+# @param DatumType: Input value for DatumType, default is ''
+# @param MaxDatumSize: Input value for MaxDatumSize, default is ''
+# @param DefaultValue: Input value for DefaultValue, default is ''
+# @param ItemType: Input value for ItemType, default is ''
+# @param ValidUsage: Input value for ValidUsage, default is []
+# @param SkuInfoList: Input value for SkuInfoList, default is {}
+# @param SupModuleList: Input value for SupModuleList, default is []
+#
+class PcdObject(CommonPropertiesObject, HelpTextListObject, PromptListObject):
+ def __init__(self):
+ self.PcdCName = ''
+ self.CName = ''
+ self.Token = ''
+ self.TokenSpaceGuidCName = ''
+ self.TokenSpaceGuidValue = ''
+ self.DatumType = ''
+ self.MaxDatumSize = ''
+ self.DefaultValue = ''
+ self.Offset = ''
+ self.ValidUsage = ''
+ self.ItemType = ''
+ self.PcdErrorsList = []
+ self.SupModuleList = []
+ CommonPropertiesObject.__init__(self)
+ HelpTextListObject.__init__(self)
+ PromptListObject.__init__(self)
+
+ def SetPcdCName(self, PcdCName):
+ self.PcdCName = PcdCName
+
+ def GetPcdCName(self):
+ return self.PcdCName
+
+ def SetCName(self, CName):
+ self.CName = CName
+
+ def GetCName(self):
+ return self.CName
+
+ def SetToken(self, Token):
+ self.Token = Token
+
+ def GetOffset(self):
+ return self.Offset
+
+ def SetOffset(self, Offset):
+ self.Offset = Offset
+
+ def GetToken(self):
+ return self.Token
+
+ def SetTokenSpaceGuidCName(self, TokenSpaceGuidCName):
+ self.TokenSpaceGuidCName = TokenSpaceGuidCName
+
+ def GetTokenSpaceGuidCName(self):
+ return self.TokenSpaceGuidCName
+
+ def SetTokenSpaceGuidValue(self, TokenSpaceGuidValue):
+ self.TokenSpaceGuidValue = TokenSpaceGuidValue
+
+ def GetTokenSpaceGuidValue(self):
+ return self.TokenSpaceGuidValue
+
+ def SetDatumType(self, DatumType):
+ self.DatumType = DatumType
+
+ def GetDatumType(self):
+ return self.DatumType
+
+ def SetMaxDatumSize(self, MaxDatumSize):
+ self.MaxDatumSize = MaxDatumSize
+
+ def GetMaxDatumSize(self):
+ return self.MaxDatumSize
+
+ def SetDefaultValue(self, DefaultValue):
+ self.DefaultValue = DefaultValue
+
+ def GetDefaultValue(self):
+ return self.DefaultValue
+
+ def SetValidUsage(self, ValidUsage):
+ self.ValidUsage = ValidUsage
+
+ def GetValidUsage(self):
+ return self.ValidUsage
+
+ def SetPcdErrorsList(self, PcdErrorsList):
+ self.PcdErrorsList = PcdErrorsList
+
+ def GetPcdErrorsList(self):
+ return self.PcdErrorsList
+
+ def SetItemType(self, ItemType):
+ self.ItemType = ItemType
+
+ def GetItemType(self):
+ return self.ItemType
+
+ def SetSupModuleList(self, SupModuleList):
+ self.SupModuleList = SupModuleList
+
+ def GetSupModuleList(self):
+ return self.SupModuleList
diff --git a/BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py b/BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py
index 6e515a2c3f..de2d29bcca 100644
--- a/BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py
+++ b/BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py
@@ -1,654 +1,654 @@
-## @file
-# This file is used to define a class object to describe a module
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-ModuleObject
-'''
-
-##
-# Import Modules
-#
-from Object.POM.CommonObject import CommonPropertiesObject
-from Object.POM.CommonObject import IdentificationObject
-from Object.POM.CommonObject import CommonHeaderObject
-from Object.POM.CommonObject import BinaryHeaderObject
-from Object.POM.CommonObject import HelpTextListObject
-from Object.POM.CommonObject import GuidVersionObject
-
-
-##
-# BootModeObject
-#
-class BootModeObject(CommonPropertiesObject, HelpTextListObject):
- def __init__(self):
- self.SupportedBootModes = ''
- CommonPropertiesObject.__init__(self)
- HelpTextListObject.__init__(self)
-
- def SetSupportedBootModes(self, SupportedBootModes):
- self.SupportedBootModes = SupportedBootModes
-
- def GetSupportedBootModes(self):
- return self.SupportedBootModes
-
-##
-# EventObject
-#
-class EventObject(CommonPropertiesObject, HelpTextListObject):
- def __init__(self):
- self.EventType = ''
- CommonPropertiesObject.__init__(self)
- HelpTextListObject.__init__(self)
-
- def SetEventType(self, EventType):
- self.EventType = EventType
-
- def GetEventType(self):
- return self.EventType
-
-##
-# HobObject
-#
-class HobObject(CommonPropertiesObject, HelpTextListObject):
- def __init__(self):
- self.HobType = ''
- CommonPropertiesObject.__init__(self)
- HelpTextListObject.__init__(self)
-
- def SetHobType(self, HobType):
- self.HobType = HobType
-
- def GetHobType(self):
- return self.HobType
-
-##
-# SpecObject
-#
-class SpecObject(object):
- def __init__(self):
- self.Spec = ''
- self.Version = ''
-
- def SetSpec(self, Spec):
- self.Spec = Spec
-
- def GetSpec(self):
- return self.Spec
-
- def SetVersion(self, Version):
- self.Version = Version
-
- def GetVersion(self):
- return self.Version
-
-## ModuleHeaderObject
-#
-# This class defined header items used in Module file
-#
-class ModuleHeaderObject(IdentificationObject, CommonHeaderObject, BinaryHeaderObject):
- def __init__(self):
- self.IsLibrary = False
- self.IsLibraryModList = []
- self.ModuleType = ''
- self.BinaryModule = False
- self.PcdIsDriver = ''
- self.PiSpecificationVersion = ''
- self.UefiSpecificationVersion = ''
- self.UNIFlag = False
- self.ModuleUniFile = ''
- #
- # SpecObject
- #
- self.SpecList = []
- #
- # BootModeObject
- #
- self.BootModeList = []
- #
- # EventObject
- #
- self.EventList = []
- #
- # HobObject
- #
- self.HobList = []
- #
- # LibraryClassObject
- #
- self.LibraryClassList = []
- self.SupArchList = []
- IdentificationObject.__init__(self)
- CommonHeaderObject.__init__(self)
- BinaryHeaderObject.__init__(self)
-
- def SetIsLibrary(self, IsLibrary):
- self.IsLibrary = IsLibrary
-
- def GetIsLibrary(self):
- return self.IsLibrary
-
- def SetIsLibraryModList(self, IsLibraryModList):
- self.IsLibraryModList = IsLibraryModList
-
- def GetIsLibraryModList(self):
- return self.IsLibraryModList
-
- def SetModuleType(self, ModuleType):
- self.ModuleType = ModuleType
-
- def GetModuleType(self):
- return self.ModuleType
-
- def SetBinaryModule(self, BinaryModule):
- self.BinaryModule = BinaryModule
-
- def GetBinaryModule(self):
- return self.BinaryModule
-
- def SetPcdIsDriver(self, PcdIsDriver):
- self.PcdIsDriver = PcdIsDriver
-
- def GetPcdIsDriver(self):
- return self.PcdIsDriver
-
- def SetPiSpecificationVersion(self, PiSpecificationVersion):
- self.PiSpecificationVersion = PiSpecificationVersion
-
- def GetPiSpecificationVersion(self):
- return self.PiSpecificationVersion
-
- def SetUefiSpecificationVersion(self, UefiSpecificationVersion):
- self.UefiSpecificationVersion = UefiSpecificationVersion
-
- def GetUefiSpecificationVersion(self):
- return self.UefiSpecificationVersion
-
- def SetSpecList(self, SpecList):
- self.SpecList = SpecList
-
- def GetSpecList(self):
- return self.SpecList
-
- def SetBootModeList(self, BootModeList):
- self.BootModeList = BootModeList
-
- def GetBootModeList(self):
- return self.BootModeList
-
- def SetEventList(self, EventList):
- self.EventList = EventList
-
- def GetEventList(self):
- return self.EventList
-
- def SetHobList(self, HobList):
- self.HobList = HobList
-
- def GetHobList(self):
- return self.HobList
-
- def SetLibraryClassList(self, LibraryClassList):
- self.LibraryClassList = LibraryClassList
-
- def GetLibraryClassList(self):
- return self.LibraryClassList
-
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
-
- def GetSupArchList(self):
- return self.SupArchList
-
- def SetModuleUniFile(self, ModuleUniFile):
- self.ModuleUniFile = ModuleUniFile
-
- def GetModuleUniFile(self):
- return self.ModuleUniFile
-##
-# SourceFileObject
-#
-class SourceFileObject(CommonPropertiesObject):
- def __init__(self):
- CommonPropertiesObject.__init__(self)
- self.SourceFile = ''
- self.TagName = ''
- self.ToolCode = ''
- self.Family = ''
- self.FileType = ''
-
- def SetSourceFile(self, SourceFile):
- self.SourceFile = SourceFile
-
- def GetSourceFile(self):
- return self.SourceFile
-
- def SetTagName(self, TagName):
- self.TagName = TagName
-
- def GetTagName(self):
- return self.TagName
-
- def SetToolCode(self, ToolCode):
- self.ToolCode = ToolCode
-
- def GetToolCode(self):
- return self.ToolCode
-
- def SetFamily(self, Family):
- self.Family = Family
-
- def GetFamily(self):
- return self.Family
-
- def SetFileType(self, FileType):
- self.FileType = FileType
-
- def GetFileType(self):
- return self.FileType
-
-
-##
-# BinaryFileObject
-#
-class BinaryFileObject(CommonPropertiesObject):
- def __init__(self):
- self.FileNamList = []
- self.AsBuiltList = []
- CommonPropertiesObject.__init__(self)
-
- def SetFileNameList(self, FileNamList):
- self.FileNamList = FileNamList
-
- def GetFileNameList(self):
- return self.FileNamList
-
- def SetAsBuiltList(self, AsBuiltList):
- self.AsBuiltList = AsBuiltList
-
- def GetAsBuiltList(self):
- return self.AsBuiltList
-
-
-##
-# AsBuildLibraryClassObject
-#
-class AsBuildLibraryClassObject(object):
- def __init__(self):
- self.LibGuid = ''
- self.LibVersion = ''
- self.SupArchList = []
-
- def SetLibGuid(self, LibGuid):
- self.LibGuid = LibGuid
- def GetLibGuid(self):
- return self.LibGuid
-
- def SetLibVersion(self, LibVersion):
- self.LibVersion = LibVersion
- def GetLibVersion(self):
- return self.LibVersion
-
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
- def GetSupArchList(self):
- return self.SupArchList
-
-##
-# AsBuiltObject
-#
-class AsBuiltObject(object):
- def __init__(self):
- #
- # list of PcdObject
- #
- self.PatchPcdList = []
- #
- # list of PcdObject
- #
- self.PcdExValueList = []
- #
- # list of GuidVersionObject
- #
- self.LibraryInstancesList = []
- #
- # List of BinaryBuildFlag object
- #
- self.BinaryBuildFlagList = []
-
- def SetPatchPcdList(self, PatchPcdList):
- self.PatchPcdList = PatchPcdList
-
- def GetPatchPcdList(self):
- return self.PatchPcdList
-
- def SetPcdExList(self, PcdExValueList):
- self.PcdExValueList = PcdExValueList
-
- def GetPcdExList(self):
- return self.PcdExValueList
-
- def SetLibraryInstancesList(self, LibraryInstancesList):
- self.LibraryInstancesList = LibraryInstancesList
-
- def GetLibraryInstancesList(self):
- return self.LibraryInstancesList
-
- def SetBuildFlagsList(self, BinaryBuildFlagList):
- self.BinaryBuildFlagList = BinaryBuildFlagList
-
- def GetBuildFlagsList(self):
- return self.BinaryBuildFlagList
-
-##
-# BinaryBuildFlag, this object will include those fields that are not
-# covered by the UPT Spec BinaryFile field
-#
-class BinaryBuildFlagObject(object):
- def __init__(self):
- self.Target = ''
- self.TagName = ''
- self.Family = ''
- self.AsBuiltOptionFlags = ''
-
- def SetTarget(self, Target):
- self.Target = Target
-
- def GetTarget(self):
- return self.Target
-
- def SetTagName(self, TagName):
- self.TagName = TagName
-
- def GetTagName(self):
- return self.TagName
-
- def SetFamily(self, Family):
- self.Family = Family
-
- def GetFamily(self):
- return self.Family
-
- def SetAsBuiltOptionFlags(self, AsBuiltOptionFlags):
- self.AsBuiltOptionFlags = AsBuiltOptionFlags
- def GetAsBuiltOptionFlags(self):
- return self.AsBuiltOptionFlags
-
-##
-# ExternObject
-#
-class ExternObject(CommonPropertiesObject):
- def __init__(self):
- self.EntryPoint = ''
- self.UnloadImage = ''
- self.Constructor = ''
- self.Destructor = ''
- self.SupModList = []
- CommonPropertiesObject.__init__(self)
-
- def SetEntryPoint(self, EntryPoint):
- self.EntryPoint = EntryPoint
-
- def GetEntryPoint(self):
- return self.EntryPoint
-
- def SetUnloadImage(self, UnloadImage):
- self.UnloadImage = UnloadImage
-
- def GetUnloadImage(self):
- return self.UnloadImage
-
- def SetConstructor(self, Constructor):
- self.Constructor = Constructor
-
- def GetConstructor(self):
- return self.Constructor
-
- def SetDestructor(self, Destructor):
- self.Destructor = Destructor
-
- def GetDestructor(self):
- return self.Destructor
-
- def SetSupModList(self, SupModList):
- self.SupModList = SupModList
- def GetSupModList(self):
- return self.SupModList
-
-##
-# DepexObject
-#
-class DepexObject(CommonPropertiesObject):
- def __init__(self):
- self.Depex = ''
- self.ModuelType = ''
- CommonPropertiesObject.__init__(self)
-
- def SetDepex(self, Depex):
- self.Depex = Depex
-
- def GetDepex(self):
- return self.Depex
-
- def SetModuleType(self, ModuleType):
- self.ModuelType = ModuleType
-
- def GetModuleType(self):
- return self.ModuelType
-
-##
-# PackageDependencyObject
-#
-class PackageDependencyObject(GuidVersionObject, CommonPropertiesObject):
- def __init__(self):
- self.Package = ''
- self.PackageFilePath = ''
- GuidVersionObject.__init__(self)
- CommonPropertiesObject.__init__(self)
-
- def SetPackageFilePath(self, PackageFilePath):
- self.PackageFilePath = PackageFilePath
-
- def GetPackageFilePath(self):
- return self.PackageFilePath
-
- def SetPackage(self, Package):
- self.Package = Package
-
- def GetPackage(self):
- return self.Package
-
-##
-# BuildOptionObject
-#
-class BuildOptionObject(CommonPropertiesObject):
- def __init__(self):
- CommonPropertiesObject.__init__(self)
- self.BuildOption = ''
-
- def SetBuildOption(self, BuildOption):
- self.BuildOption = BuildOption
-
- def GetBuildOption(self):
- return self.BuildOption
-
-##
-# ModuleObject
-#
-class ModuleObject(ModuleHeaderObject):
- def __init__(self):
- #
- # {Arch : ModuleHeaderObject}
- #
- self.HeaderDict = {}
- #
- # LibraryClassObject
- #
- self.LibraryClassList = []
- #
- # SourceFileObject
- #
- self.SourceFileList = []
- #
- # BinaryFileObject
- #
- self.BinaryFileList = []
- #
- # PackageDependencyObject
- #
- self.PackageDependencyList = []
- #
- # DepexObject
- #
- self.PeiDepex = []
- #
- # DepexObject
- #
- self.DxeDepex = []
- #
- # DepexObject
- #
- self.SmmDepex = []
- #
- # ProtocolObject
- #
- self.ProtocolList = []
- #
- # PpiObject
- #
- self.PpiList = []
- #
- # GuidObject
- #
- self.GuidList = []
- #
- # PcdObject
- #
- self.PcdList = []
- #
- # ExternObject
- #
- self.ExternList = []
- #
- # BuildOptionObject
- #
- self.BuildOptionList = []
- #
- # UserExtensionObject
- #
- self.UserExtensionList = []
- #
- # MiscFileObject
- #
- self.MiscFileList = []
- #
- # ClonedFromObject
- #
- self.ClonedFrom = None
-
- ModuleHeaderObject.__init__(self)
-
- def SetHeaderDict(self, HeaderDict):
- self.HeaderDict = HeaderDict
-
- def GetHeaderDict(self):
- return self.HeaderDict
-
- def SetLibraryClassList(self, LibraryClassList):
- self.LibraryClassList = LibraryClassList
-
- def GetLibraryClassList(self):
- return self.LibraryClassList
-
- def SetSourceFileList(self, SourceFileList):
- self.SourceFileList = SourceFileList
-
- def GetSourceFileList(self):
- return self.SourceFileList
-
- def SetBinaryFileList(self, BinaryFileList):
- self.BinaryFileList = BinaryFileList
-
- def GetBinaryFileList(self):
- return self.BinaryFileList
-
- def SetPackageDependencyList(self, PackageDependencyList):
- self.PackageDependencyList = PackageDependencyList
-
- def GetPackageDependencyList(self):
- return self.PackageDependencyList
-
- def SetPeiDepex(self, PeiDepex):
- self.PeiDepex = PeiDepex
-
- def GetPeiDepex(self):
- return self.PeiDepex
-
- def SetDxeDepex(self, DxeDepex):
- self.DxeDepex = DxeDepex
-
- def GetDxeDepex(self):
- return self.DxeDepex
-
- def SetSmmDepex(self, SmmDepex):
- self.SmmDepex = SmmDepex
-
- def GetSmmDepex(self):
- return self.SmmDepex
-
- def SetPpiList(self, PpiList):
- self.PpiList = PpiList
-
- def GetPpiList(self):
- return self.PpiList
-
- def SetProtocolList(self, ProtocolList):
- self.ProtocolList = ProtocolList
-
- def GetProtocolList(self):
- return self.ProtocolList
-
- def SetPcdList(self, PcdList):
- self.PcdList = PcdList
-
- def GetPcdList(self):
- return self.PcdList
-
- def SetGuidList(self, GuidList):
- self.GuidList = GuidList
-
- def GetGuidList(self):
- return self.GuidList
-
- def SetExternList(self, ExternList):
- self.ExternList = ExternList
-
- def GetExternList(self):
- return self.ExternList
-
- def SetBuildOptionList(self, BuildOptionList):
- self.BuildOptionList = BuildOptionList
-
- def GetBuildOptionList(self):
- return self.BuildOptionList
-
- def SetUserExtensionList(self, UserExtensionList):
- self.UserExtensionList = UserExtensionList
-
- def GetUserExtensionList(self):
- return self.UserExtensionList
-
- def SetMiscFileList(self, MiscFileList):
- self.MiscFileList = MiscFileList
-
- def GetMiscFileList(self):
- return self.MiscFileList
-
- def SetClonedFrom(self, ClonedFrom):
- self.ClonedFrom = ClonedFrom
-
- def GetClonedFrom(self):
- return self.ClonedFrom
+## @file
+# This file is used to define a class object to describe a module
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+ModuleObject
+'''
+
+##
+# Import Modules
+#
+from Object.POM.CommonObject import CommonPropertiesObject
+from Object.POM.CommonObject import IdentificationObject
+from Object.POM.CommonObject import CommonHeaderObject
+from Object.POM.CommonObject import BinaryHeaderObject
+from Object.POM.CommonObject import HelpTextListObject
+from Object.POM.CommonObject import GuidVersionObject
+
+
+##
+# BootModeObject
+#
+class BootModeObject(CommonPropertiesObject, HelpTextListObject):
+ def __init__(self):
+ self.SupportedBootModes = ''
+ CommonPropertiesObject.__init__(self)
+ HelpTextListObject.__init__(self)
+
+ def SetSupportedBootModes(self, SupportedBootModes):
+ self.SupportedBootModes = SupportedBootModes
+
+ def GetSupportedBootModes(self):
+ return self.SupportedBootModes
+
+##
+# EventObject
+#
+class EventObject(CommonPropertiesObject, HelpTextListObject):
+ def __init__(self):
+ self.EventType = ''
+ CommonPropertiesObject.__init__(self)
+ HelpTextListObject.__init__(self)
+
+ def SetEventType(self, EventType):
+ self.EventType = EventType
+
+ def GetEventType(self):
+ return self.EventType
+
+##
+# HobObject
+#
+class HobObject(CommonPropertiesObject, HelpTextListObject):
+ def __init__(self):
+ self.HobType = ''
+ CommonPropertiesObject.__init__(self)
+ HelpTextListObject.__init__(self)
+
+ def SetHobType(self, HobType):
+ self.HobType = HobType
+
+ def GetHobType(self):
+ return self.HobType
+
+##
+# SpecObject
+#
+class SpecObject(object):
+ def __init__(self):
+ self.Spec = ''
+ self.Version = ''
+
+ def SetSpec(self, Spec):
+ self.Spec = Spec
+
+ def GetSpec(self):
+ return self.Spec
+
+ def SetVersion(self, Version):
+ self.Version = Version
+
+ def GetVersion(self):
+ return self.Version
+
+## ModuleHeaderObject
+#
+# This class defined header items used in Module file
+#
+class ModuleHeaderObject(IdentificationObject, CommonHeaderObject, BinaryHeaderObject):
+ def __init__(self):
+ self.IsLibrary = False
+ self.IsLibraryModList = []
+ self.ModuleType = ''
+ self.BinaryModule = False
+ self.PcdIsDriver = ''
+ self.PiSpecificationVersion = ''
+ self.UefiSpecificationVersion = ''
+ self.UNIFlag = False
+ self.ModuleUniFile = ''
+ #
+ # SpecObject
+ #
+ self.SpecList = []
+ #
+ # BootModeObject
+ #
+ self.BootModeList = []
+ #
+ # EventObject
+ #
+ self.EventList = []
+ #
+ # HobObject
+ #
+ self.HobList = []
+ #
+ # LibraryClassObject
+ #
+ self.LibraryClassList = []
+ self.SupArchList = []
+ IdentificationObject.__init__(self)
+ CommonHeaderObject.__init__(self)
+ BinaryHeaderObject.__init__(self)
+
+ def SetIsLibrary(self, IsLibrary):
+ self.IsLibrary = IsLibrary
+
+ def GetIsLibrary(self):
+ return self.IsLibrary
+
+ def SetIsLibraryModList(self, IsLibraryModList):
+ self.IsLibraryModList = IsLibraryModList
+
+ def GetIsLibraryModList(self):
+ return self.IsLibraryModList
+
+ def SetModuleType(self, ModuleType):
+ self.ModuleType = ModuleType
+
+ def GetModuleType(self):
+ return self.ModuleType
+
+ def SetBinaryModule(self, BinaryModule):
+ self.BinaryModule = BinaryModule
+
+ def GetBinaryModule(self):
+ return self.BinaryModule
+
+ def SetPcdIsDriver(self, PcdIsDriver):
+ self.PcdIsDriver = PcdIsDriver
+
+ def GetPcdIsDriver(self):
+ return self.PcdIsDriver
+
+ def SetPiSpecificationVersion(self, PiSpecificationVersion):
+ self.PiSpecificationVersion = PiSpecificationVersion
+
+ def GetPiSpecificationVersion(self):
+ return self.PiSpecificationVersion
+
+ def SetUefiSpecificationVersion(self, UefiSpecificationVersion):
+ self.UefiSpecificationVersion = UefiSpecificationVersion
+
+ def GetUefiSpecificationVersion(self):
+ return self.UefiSpecificationVersion
+
+ def SetSpecList(self, SpecList):
+ self.SpecList = SpecList
+
+ def GetSpecList(self):
+ return self.SpecList
+
+ def SetBootModeList(self, BootModeList):
+ self.BootModeList = BootModeList
+
+ def GetBootModeList(self):
+ return self.BootModeList
+
+ def SetEventList(self, EventList):
+ self.EventList = EventList
+
+ def GetEventList(self):
+ return self.EventList
+
+ def SetHobList(self, HobList):
+ self.HobList = HobList
+
+ def GetHobList(self):
+ return self.HobList
+
+ def SetLibraryClassList(self, LibraryClassList):
+ self.LibraryClassList = LibraryClassList
+
+ def GetLibraryClassList(self):
+ return self.LibraryClassList
+
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+
+ def GetSupArchList(self):
+ return self.SupArchList
+
+ def SetModuleUniFile(self, ModuleUniFile):
+ self.ModuleUniFile = ModuleUniFile
+
+ def GetModuleUniFile(self):
+ return self.ModuleUniFile
+##
+# SourceFileObject
+#
+class SourceFileObject(CommonPropertiesObject):
+ def __init__(self):
+ CommonPropertiesObject.__init__(self)
+ self.SourceFile = ''
+ self.TagName = ''
+ self.ToolCode = ''
+ self.Family = ''
+ self.FileType = ''
+
+ def SetSourceFile(self, SourceFile):
+ self.SourceFile = SourceFile
+
+ def GetSourceFile(self):
+ return self.SourceFile
+
+ def SetTagName(self, TagName):
+ self.TagName = TagName
+
+ def GetTagName(self):
+ return self.TagName
+
+ def SetToolCode(self, ToolCode):
+ self.ToolCode = ToolCode
+
+ def GetToolCode(self):
+ return self.ToolCode
+
+ def SetFamily(self, Family):
+ self.Family = Family
+
+ def GetFamily(self):
+ return self.Family
+
+ def SetFileType(self, FileType):
+ self.FileType = FileType
+
+ def GetFileType(self):
+ return self.FileType
+
+
+##
+# BinaryFileObject
+#
+class BinaryFileObject(CommonPropertiesObject):
+ def __init__(self):
+ self.FileNamList = []
+ self.AsBuiltList = []
+ CommonPropertiesObject.__init__(self)
+
+ def SetFileNameList(self, FileNamList):
+ self.FileNamList = FileNamList
+
+ def GetFileNameList(self):
+ return self.FileNamList
+
+ def SetAsBuiltList(self, AsBuiltList):
+ self.AsBuiltList = AsBuiltList
+
+ def GetAsBuiltList(self):
+ return self.AsBuiltList
+
+
+##
+# AsBuildLibraryClassObject
+#
+class AsBuildLibraryClassObject(object):
+ def __init__(self):
+ self.LibGuid = ''
+ self.LibVersion = ''
+ self.SupArchList = []
+
+ def SetLibGuid(self, LibGuid):
+ self.LibGuid = LibGuid
+ def GetLibGuid(self):
+ return self.LibGuid
+
+ def SetLibVersion(self, LibVersion):
+ self.LibVersion = LibVersion
+ def GetLibVersion(self):
+ return self.LibVersion
+
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+
+##
+# AsBuiltObject
+#
+class AsBuiltObject(object):
+ def __init__(self):
+ #
+ # list of PcdObject
+ #
+ self.PatchPcdList = []
+ #
+ # list of PcdObject
+ #
+ self.PcdExValueList = []
+ #
+ # list of GuidVersionObject
+ #
+ self.LibraryInstancesList = []
+ #
+ # List of BinaryBuildFlag object
+ #
+ self.BinaryBuildFlagList = []
+
+ def SetPatchPcdList(self, PatchPcdList):
+ self.PatchPcdList = PatchPcdList
+
+ def GetPatchPcdList(self):
+ return self.PatchPcdList
+
+ def SetPcdExList(self, PcdExValueList):
+ self.PcdExValueList = PcdExValueList
+
+ def GetPcdExList(self):
+ return self.PcdExValueList
+
+ def SetLibraryInstancesList(self, LibraryInstancesList):
+ self.LibraryInstancesList = LibraryInstancesList
+
+ def GetLibraryInstancesList(self):
+ return self.LibraryInstancesList
+
+ def SetBuildFlagsList(self, BinaryBuildFlagList):
+ self.BinaryBuildFlagList = BinaryBuildFlagList
+
+ def GetBuildFlagsList(self):
+ return self.BinaryBuildFlagList
+
+##
+# BinaryBuildFlag, this object will include those fields that are not
+# covered by the UPT Spec BinaryFile field
+#
+class BinaryBuildFlagObject(object):
+ def __init__(self):
+ self.Target = ''
+ self.TagName = ''
+ self.Family = ''
+ self.AsBuiltOptionFlags = ''
+
+ def SetTarget(self, Target):
+ self.Target = Target
+
+ def GetTarget(self):
+ return self.Target
+
+ def SetTagName(self, TagName):
+ self.TagName = TagName
+
+ def GetTagName(self):
+ return self.TagName
+
+ def SetFamily(self, Family):
+ self.Family = Family
+
+ def GetFamily(self):
+ return self.Family
+
+ def SetAsBuiltOptionFlags(self, AsBuiltOptionFlags):
+ self.AsBuiltOptionFlags = AsBuiltOptionFlags
+ def GetAsBuiltOptionFlags(self):
+ return self.AsBuiltOptionFlags
+
+##
+# ExternObject
+#
+class ExternObject(CommonPropertiesObject):
+ def __init__(self):
+ self.EntryPoint = ''
+ self.UnloadImage = ''
+ self.Constructor = ''
+ self.Destructor = ''
+ self.SupModList = []
+ CommonPropertiesObject.__init__(self)
+
+ def SetEntryPoint(self, EntryPoint):
+ self.EntryPoint = EntryPoint
+
+ def GetEntryPoint(self):
+ return self.EntryPoint
+
+ def SetUnloadImage(self, UnloadImage):
+ self.UnloadImage = UnloadImage
+
+ def GetUnloadImage(self):
+ return self.UnloadImage
+
+ def SetConstructor(self, Constructor):
+ self.Constructor = Constructor
+
+ def GetConstructor(self):
+ return self.Constructor
+
+ def SetDestructor(self, Destructor):
+ self.Destructor = Destructor
+
+ def GetDestructor(self):
+ return self.Destructor
+
+ def SetSupModList(self, SupModList):
+ self.SupModList = SupModList
+ def GetSupModList(self):
+ return self.SupModList
+
+##
+# DepexObject
+#
+class DepexObject(CommonPropertiesObject):
+ def __init__(self):
+ self.Depex = ''
+ self.ModuelType = ''
+ CommonPropertiesObject.__init__(self)
+
+ def SetDepex(self, Depex):
+ self.Depex = Depex
+
+ def GetDepex(self):
+ return self.Depex
+
+ def SetModuleType(self, ModuleType):
+ self.ModuelType = ModuleType
+
+ def GetModuleType(self):
+ return self.ModuelType
+
+##
+# PackageDependencyObject
+#
+class PackageDependencyObject(GuidVersionObject, CommonPropertiesObject):
+ def __init__(self):
+ self.Package = ''
+ self.PackageFilePath = ''
+ GuidVersionObject.__init__(self)
+ CommonPropertiesObject.__init__(self)
+
+ def SetPackageFilePath(self, PackageFilePath):
+ self.PackageFilePath = PackageFilePath
+
+ def GetPackageFilePath(self):
+ return self.PackageFilePath
+
+ def SetPackage(self, Package):
+ self.Package = Package
+
+ def GetPackage(self):
+ return self.Package
+
+##
+# BuildOptionObject
+#
+class BuildOptionObject(CommonPropertiesObject):
+ def __init__(self):
+ CommonPropertiesObject.__init__(self)
+ self.BuildOption = ''
+
+ def SetBuildOption(self, BuildOption):
+ self.BuildOption = BuildOption
+
+ def GetBuildOption(self):
+ return self.BuildOption
+
+##
+# ModuleObject
+#
+class ModuleObject(ModuleHeaderObject):
+ def __init__(self):
+ #
+ # {Arch : ModuleHeaderObject}
+ #
+ self.HeaderDict = {}
+ #
+ # LibraryClassObject
+ #
+ self.LibraryClassList = []
+ #
+ # SourceFileObject
+ #
+ self.SourceFileList = []
+ #
+ # BinaryFileObject
+ #
+ self.BinaryFileList = []
+ #
+ # PackageDependencyObject
+ #
+ self.PackageDependencyList = []
+ #
+ # DepexObject
+ #
+ self.PeiDepex = []
+ #
+ # DepexObject
+ #
+ self.DxeDepex = []
+ #
+ # DepexObject
+ #
+ self.SmmDepex = []
+ #
+ # ProtocolObject
+ #
+ self.ProtocolList = []
+ #
+ # PpiObject
+ #
+ self.PpiList = []
+ #
+ # GuidObject
+ #
+ self.GuidList = []
+ #
+ # PcdObject
+ #
+ self.PcdList = []
+ #
+ # ExternObject
+ #
+ self.ExternList = []
+ #
+ # BuildOptionObject
+ #
+ self.BuildOptionList = []
+ #
+ # UserExtensionObject
+ #
+ self.UserExtensionList = []
+ #
+ # MiscFileObject
+ #
+ self.MiscFileList = []
+ #
+ # ClonedFromObject
+ #
+ self.ClonedFrom = None
+
+ ModuleHeaderObject.__init__(self)
+
+ def SetHeaderDict(self, HeaderDict):
+ self.HeaderDict = HeaderDict
+
+ def GetHeaderDict(self):
+ return self.HeaderDict
+
+ def SetLibraryClassList(self, LibraryClassList):
+ self.LibraryClassList = LibraryClassList
+
+ def GetLibraryClassList(self):
+ return self.LibraryClassList
+
+ def SetSourceFileList(self, SourceFileList):
+ self.SourceFileList = SourceFileList
+
+ def GetSourceFileList(self):
+ return self.SourceFileList
+
+ def SetBinaryFileList(self, BinaryFileList):
+ self.BinaryFileList = BinaryFileList
+
+ def GetBinaryFileList(self):
+ return self.BinaryFileList
+
+ def SetPackageDependencyList(self, PackageDependencyList):
+ self.PackageDependencyList = PackageDependencyList
+
+ def GetPackageDependencyList(self):
+ return self.PackageDependencyList
+
+ def SetPeiDepex(self, PeiDepex):
+ self.PeiDepex = PeiDepex
+
+ def GetPeiDepex(self):
+ return self.PeiDepex
+
+ def SetDxeDepex(self, DxeDepex):
+ self.DxeDepex = DxeDepex
+
+ def GetDxeDepex(self):
+ return self.DxeDepex
+
+ def SetSmmDepex(self, SmmDepex):
+ self.SmmDepex = SmmDepex
+
+ def GetSmmDepex(self):
+ return self.SmmDepex
+
+ def SetPpiList(self, PpiList):
+ self.PpiList = PpiList
+
+ def GetPpiList(self):
+ return self.PpiList
+
+ def SetProtocolList(self, ProtocolList):
+ self.ProtocolList = ProtocolList
+
+ def GetProtocolList(self):
+ return self.ProtocolList
+
+ def SetPcdList(self, PcdList):
+ self.PcdList = PcdList
+
+ def GetPcdList(self):
+ return self.PcdList
+
+ def SetGuidList(self, GuidList):
+ self.GuidList = GuidList
+
+ def GetGuidList(self):
+ return self.GuidList
+
+ def SetExternList(self, ExternList):
+ self.ExternList = ExternList
+
+ def GetExternList(self):
+ return self.ExternList
+
+ def SetBuildOptionList(self, BuildOptionList):
+ self.BuildOptionList = BuildOptionList
+
+ def GetBuildOptionList(self):
+ return self.BuildOptionList
+
+ def SetUserExtensionList(self, UserExtensionList):
+ self.UserExtensionList = UserExtensionList
+
+ def GetUserExtensionList(self):
+ return self.UserExtensionList
+
+ def SetMiscFileList(self, MiscFileList):
+ self.MiscFileList = MiscFileList
+
+ def GetMiscFileList(self):
+ return self.MiscFileList
+
+ def SetClonedFrom(self, ClonedFrom):
+ self.ClonedFrom = ClonedFrom
+
+ def GetClonedFrom(self):
+ return self.ClonedFrom
diff --git a/BaseTools/Source/Python/UPT/Object/POM/PackageObject.py b/BaseTools/Source/Python/UPT/Object/POM/PackageObject.py
index fcc2a3bea9..9d2db3399a 100644
--- a/BaseTools/Source/Python/UPT/Object/POM/PackageObject.py
+++ b/BaseTools/Source/Python/UPT/Object/POM/PackageObject.py
@@ -1,192 +1,192 @@
-## @file
-# This file is used to define a class object to describe a package
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-PackageObject
-'''
-
-##
-# Import Modules
-#
-from Object.POM.CommonObject import CommonPropertiesObject
-from Object.POM.CommonObject import IdentificationObject
-from Object.POM.CommonObject import CommonHeaderObject
-from Object.POM.CommonObject import BinaryHeaderObject
-from Library.Misc import Sdict
-
-## StandardIncludeFileObject
-#
-class StandardIncludeFileObject(CommonPropertiesObject):
- def __init__(self):
- CommonPropertiesObject.__init__(self)
- self.IncludeFile = ''
-
- def SetIncludeFile(self, IncludeFile):
- self.IncludeFile = IncludeFile
-
- def GetIncludeFile(self):
- return self.IncludeFile
-
-## PackageIncludeFileObject
-#
-class PackageIncludeFileObject(StandardIncludeFileObject):
- pass
-
-##
-# PackageObject
-#
-class PackageObject(IdentificationObject, CommonHeaderObject, BinaryHeaderObject):
- def __init__(self):
- IdentificationObject.__init__(self)
- CommonHeaderObject.__init__(self)
- BinaryHeaderObject.__init__(self)
- #
- # LibraryClassObject
- #
- self.LibraryClassList = []
- #
- # FileObject
- #
- self.IncludePathList = []
- #
- # StandardIncludeFileObject
- #
- self.StandardIncludeFileList = []
- #
- # PackageIncludeFileObject
- #
- self.PackageIncludeFileList = []
- #
- # Include and Arch List, item is (IncludePath, SupArchList-List of Arch), used during install package
- #
- self.IncludeArchList = []
- #
- # ProtocolObject
- #
- self.ProtocolList = []
- #
- # PpiObject
- #
- self.PpiList = []
- #
- # GuidObject
- #
- self.GuidList = []
- #
- # (PcdObject, PcdErrorObject)
- #
- self.PcdList = []
- #
- # {(PcdTokenSpaceGuidCName, PcdErrroNumber): PcdErrorMessageList}
- #
- self.PcdErrorCommentDict = {}
- #
- # UserExtensionObject
- #
- self.UserExtensionList = []
- #
- # MiscFileObject
- #
- self.MiscFileList = []
- self.ModuleDict = Sdict()
- #
- # ClonedRecordObject
- #
- self.ClonedFromList = []
- #
- # string object
- #
- self.ModuleFileList = []
-
- self.PcdChecks = []
-
- self.UNIFlag = False
-
- def SetLibraryClassList(self, LibraryClassList):
- self.LibraryClassList = LibraryClassList
-
- def GetLibraryClassList(self):
- return self.LibraryClassList
-
- def SetIncludePathList(self, IncludePathList):
- self.IncludePathList = IncludePathList
-
- def GetIncludePathList(self):
- return self.IncludePathList
-
- def SetIncludeArchList(self, IncludeArchList):
- self.IncludeArchList = IncludeArchList
-
- def GetIncludeArchList(self):
- return self.IncludeArchList
-
- def SetStandardIncludeFileList(self, StandardIncludeFileList):
- self.StandardIncludeFileList = StandardIncludeFileList
-
- def GetStandardIncludeFileList(self):
- return self.StandardIncludeFileList
-
- def SetPackageIncludeFileList(self, PackageIncludeFileList):
- self.PackageIncludeFileList = PackageIncludeFileList
-
- def GetPackageIncludeFileList(self):
- return self.PackageIncludeFileList
-
- def SetProtocolList(self, ProtocolList):
- self.ProtocolList = ProtocolList
-
- def GetProtocolList(self):
- return self.ProtocolList
-
- def SetPpiList(self, PpiList):
- self.PpiList = PpiList
-
- def GetPpiList(self):
- return self.PpiList
-
- def SetGuidList(self, GuidList):
- self.GuidList = GuidList
-
- def GetGuidList(self):
- return self.GuidList
-
- def SetPcdList(self, PcdList):
- self.PcdList = PcdList
-
- def GetPcdList(self):
- return self.PcdList
-
- def SetUserExtensionList(self, UserExtensionList):
- self.UserExtensionList = UserExtensionList
-
- def GetUserExtensionList(self):
- return self.UserExtensionList
-
- def SetMiscFileList(self, MiscFileList):
- self.MiscFileList = MiscFileList
-
- def GetMiscFileList(self):
- return self.MiscFileList
-
- def SetModuleDict(self, ModuleDict):
- self.ModuleDict = ModuleDict
-
- def GetModuleDict(self):
- return self.ModuleDict
-
- def SetClonedFromList(self, ClonedFromList):
- self.ClonedFromList = ClonedFromList
-
- def GetClonedFromList(self):
- return self.ClonedFromList
-
- def SetModuleFileList(self, ModuleFileList):
- self.ModuleFileList = ModuleFileList
-
- def GetModuleFileList(self):
- return self.ModuleFileList
-
+## @file
+# This file is used to define a class object to describe a package
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+PackageObject
+'''
+
+##
+# Import Modules
+#
+from Object.POM.CommonObject import CommonPropertiesObject
+from Object.POM.CommonObject import IdentificationObject
+from Object.POM.CommonObject import CommonHeaderObject
+from Object.POM.CommonObject import BinaryHeaderObject
+from Library.Misc import Sdict
+
+## StandardIncludeFileObject
+#
+class StandardIncludeFileObject(CommonPropertiesObject):
+ def __init__(self):
+ CommonPropertiesObject.__init__(self)
+ self.IncludeFile = ''
+
+ def SetIncludeFile(self, IncludeFile):
+ self.IncludeFile = IncludeFile
+
+ def GetIncludeFile(self):
+ return self.IncludeFile
+
+## PackageIncludeFileObject
+#
+class PackageIncludeFileObject(StandardIncludeFileObject):
+ pass
+
+##
+# PackageObject
+#
+class PackageObject(IdentificationObject, CommonHeaderObject, BinaryHeaderObject):
+ def __init__(self):
+ IdentificationObject.__init__(self)
+ CommonHeaderObject.__init__(self)
+ BinaryHeaderObject.__init__(self)
+ #
+ # LibraryClassObject
+ #
+ self.LibraryClassList = []
+ #
+ # FileObject
+ #
+ self.IncludePathList = []
+ #
+ # StandardIncludeFileObject
+ #
+ self.StandardIncludeFileList = []
+ #
+ # PackageIncludeFileObject
+ #
+ self.PackageIncludeFileList = []
+ #
+ # Include and Arch List, item is (IncludePath, SupArchList-List of Arch), used during install package
+ #
+ self.IncludeArchList = []
+ #
+ # ProtocolObject
+ #
+ self.ProtocolList = []
+ #
+ # PpiObject
+ #
+ self.PpiList = []
+ #
+ # GuidObject
+ #
+ self.GuidList = []
+ #
+ # (PcdObject, PcdErrorObject)
+ #
+ self.PcdList = []
+ #
+ # {(PcdTokenSpaceGuidCName, PcdErrroNumber): PcdErrorMessageList}
+ #
+ self.PcdErrorCommentDict = {}
+ #
+ # UserExtensionObject
+ #
+ self.UserExtensionList = []
+ #
+ # MiscFileObject
+ #
+ self.MiscFileList = []
+ self.ModuleDict = Sdict()
+ #
+ # ClonedRecordObject
+ #
+ self.ClonedFromList = []
+ #
+ # string object
+ #
+ self.ModuleFileList = []
+
+ self.PcdChecks = []
+
+ self.UNIFlag = False
+
+ def SetLibraryClassList(self, LibraryClassList):
+ self.LibraryClassList = LibraryClassList
+
+ def GetLibraryClassList(self):
+ return self.LibraryClassList
+
+ def SetIncludePathList(self, IncludePathList):
+ self.IncludePathList = IncludePathList
+
+ def GetIncludePathList(self):
+ return self.IncludePathList
+
+ def SetIncludeArchList(self, IncludeArchList):
+ self.IncludeArchList = IncludeArchList
+
+ def GetIncludeArchList(self):
+ return self.IncludeArchList
+
+ def SetStandardIncludeFileList(self, StandardIncludeFileList):
+ self.StandardIncludeFileList = StandardIncludeFileList
+
+ def GetStandardIncludeFileList(self):
+ return self.StandardIncludeFileList
+
+ def SetPackageIncludeFileList(self, PackageIncludeFileList):
+ self.PackageIncludeFileList = PackageIncludeFileList
+
+ def GetPackageIncludeFileList(self):
+ return self.PackageIncludeFileList
+
+ def SetProtocolList(self, ProtocolList):
+ self.ProtocolList = ProtocolList
+
+ def GetProtocolList(self):
+ return self.ProtocolList
+
+ def SetPpiList(self, PpiList):
+ self.PpiList = PpiList
+
+ def GetPpiList(self):
+ return self.PpiList
+
+ def SetGuidList(self, GuidList):
+ self.GuidList = GuidList
+
+ def GetGuidList(self):
+ return self.GuidList
+
+ def SetPcdList(self, PcdList):
+ self.PcdList = PcdList
+
+ def GetPcdList(self):
+ return self.PcdList
+
+ def SetUserExtensionList(self, UserExtensionList):
+ self.UserExtensionList = UserExtensionList
+
+ def GetUserExtensionList(self):
+ return self.UserExtensionList
+
+ def SetMiscFileList(self, MiscFileList):
+ self.MiscFileList = MiscFileList
+
+ def GetMiscFileList(self):
+ return self.MiscFileList
+
+ def SetModuleDict(self, ModuleDict):
+ self.ModuleDict = ModuleDict
+
+ def GetModuleDict(self):
+ return self.ModuleDict
+
+ def SetClonedFromList(self, ClonedFromList):
+ self.ClonedFromList = ClonedFromList
+
+ def GetClonedFromList(self):
+ return self.ClonedFromList
+
+ def SetModuleFileList(self, ModuleFileList):
+ self.ModuleFileList = ModuleFileList
+
+ def GetModuleFileList(self):
+ return self.ModuleFileList
+
diff --git a/BaseTools/Source/Python/UPT/Object/POM/__init__.py b/BaseTools/Source/Python/UPT/Object/POM/__init__.py
index b36e7f6585..7f07f89fd1 100644
--- a/BaseTools/Source/Python/UPT/Object/POM/__init__.py
+++ b/BaseTools/Source/Python/UPT/Object/POM/__init__.py
@@ -1,14 +1,14 @@
-## @file
-# Python 'Object' package initialization file.
-#
-# This file is required to make Python interpreter treat the directory
-# as containing package.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-
-'''
-POM
-'''
+## @file
+# Python 'Object' package initialization file.
+#
+# This file is required to make Python interpreter treat the directory
+# as containing package.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+'''
+POM
+'''
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/DecObject.py b/BaseTools/Source/Python/UPT/Object/Parser/DecObject.py
index 2a7fcf1697..3e2919bb3d 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/DecObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/DecObject.py
@@ -1,605 +1,605 @@
-## @file
-# This file is used to define class objects for DEC file. It will consumed by
-#DecParser
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-DecObject
-'''
-
-## Import modules
-#
-import os.path
-
-from Library.Misc import Sdict
-from Library.DataType import TAB_GUIDS
-from Library.DataType import TAB_PPIS
-from Library.DataType import TAB_PROTOCOLS
-from Library.DataType import TAB_DEC_DEFINES
-from Library.DataType import TAB_INCLUDES
-from Library.DataType import TAB_LIBRARY_CLASSES
-from Library.DataType import TAB_USER_EXTENSIONS
-from Library.DataType import TAB_PCDS
-from Library.DataType import TAB_ARCH_COMMON
-
-## _DecComments
-#
-# Base class for all data objects which have head and tail comments
-#
-class _DecComments:
-
- ##constructor
- #
- def __init__(self):
- self._HeadComment = []
- self._TailComment = []
-
- ## GetComments
- #
- def GetComments(self):
- return self._HeadComment, self._TailComment
-
- ## GetHeadComment
- #
- def GetHeadComment(self):
- return self._HeadComment
-
- ## SetHeadComment
- #
- # @param Comment: comment content
- #
- def SetHeadComment(self, Comment):
- self._HeadComment = Comment
-
- ## GetTailComment
- #
- def GetTailComment(self):
- return self._TailComment
-
- ## SetTailComment
- #
- # @param Comment: comment content
- #
- def SetTailComment(self, Comment):
- self._TailComment = Comment
-
-## _DecBaseObject
-#
-# Base class that hold common info
-#
-class _DecBaseObject(_DecComments):
- def __init__(self, PkgFullName):
- _DecComments.__init__(self)
- #
- # Key is combined with (Arch, SectionType)
- # Default is common
- #
- self.ValueDict = Sdict()
- self._PkgFullName = PkgFullName
- self._PackagePath, self._FileName = os.path.split(PkgFullName)
- self._SecName = ''
-
- ## GetSectionName
- #
- def GetSectionName(self):
- return self._SecName
-
- ## GetPackagePath
- #
- def GetPackagePath(self):
- return self._PackagePath
-
- ## GetPackageFile
- #
- def GetPackageFile(self):
- return self._FileName
-
- ## GetPackageFullName
- #
- def GetPackageFullName(self):
- return self._PkgFullName
-
- ## AddItem
- # Add sub-item to current object, sub-class should override it if needed
- #
- # @param Item: Sub-item to be added
- # @param Scope: A list store section name and arch info
- #
- def AddItem(self, Item, Scope):
- if not Scope:
- return
- if not Item:
- return
- ArchModule = []
- for Ele in Scope:
- if Ele[1] in self.ValueDict:
- self.ValueDict[Ele[1]].append(Item)
- else:
- self.ValueDict[Ele[1]] = [Item]
- ArchModule.append(Ele[1])
- Item.ArchAndModuleType = ArchModule
-
- ## _GetItemByArch
- # Helper class used by sub-class
- # @param Arch: arch
- #
- def _GetItemByArch(self, Arch):
- Arch = Arch.upper()
- if Arch not in self.ValueDict:
- return []
- return self.ValueDict[Arch]
-
- ## _GetAllItems
- # Get all items, union all arches, items in returned list are unique
- #
- def _GetAllItems(self):
- Retlst = []
- for Arch in self.ValueDict:
- for Item in self.ValueDict[Arch]:
- if Item not in Retlst:
- Retlst.append(Item)
- return Retlst
-
-## _DecItemBaseObject
-#
-# Module type and arch the item belongs to
-#
-class _DecItemBaseObject(_DecComments):
- def __init__(self):
- _DecComments.__init__(self)
- #
- # Item's arch, if PCD, also include PCD type
- #
- self.ArchAndModuleType = []
-
- ## GetArchList
- #
- def GetArchList(self):
- ArchSet = set()
- for Arch in self.ArchAndModuleType:
- ArchSet.add(Arch)
- return list(ArchSet)
-
-## DecDefineObject
-#
-# Class to hold define section information
-#
-class DecDefineObject(_DecBaseObject):
- def __init__(self, PkgFullName):
- _DecBaseObject.__init__(self, PkgFullName)
- self._SecName = TAB_DEC_DEFINES.upper()
- self._DecSpec = ''
- self._PkgName = ''
- self._PkgGuid = ''
- self._PkgVersion = ''
- self._PkgUniFile = ''
-
- ## GetPackageSpecification
- #
- def GetPackageSpecification(self):
- return self._DecSpec
-
- def SetPackageSpecification(self, DecSpec):
- self._DecSpec = DecSpec
-
- ## GetPackageName
- #
- def GetPackageName(self):
- return self._PkgName
-
- def SetPackageName(self, PkgName):
- self._PkgName = PkgName
-
- ## GetPackageGuid
- #
- def GetPackageGuid(self):
- return self._PkgGuid
-
- def SetPackageGuid(self, PkgGuid):
- self._PkgGuid = PkgGuid
-
- ## GetPackageVersion
- #
- def GetPackageVersion(self):
- return self._PkgVersion
-
- def SetPackageVersion(self, PkgVersion):
- self._PkgVersion = PkgVersion
-
- ## GetPackageUniFile
- #
- def GetPackageUniFile(self):
- return self._PkgUniFile
-
- def SetPackageUniFile(self, PkgUniFile):
- self._PkgUniFile = PkgUniFile
-
- ## GetDefines
- #
- def GetDefines(self):
- return self._GetItemByArch(TAB_ARCH_COMMON)
-
- ## GetAllDefines
- #
- def GetAllDefines(self):
- return self._GetAllItems()
-
-## DecDefineItemObject
-#
-# Each item of define section
-#
-class DecDefineItemObject(_DecItemBaseObject):
- def __init__(self):
- _DecItemBaseObject.__init__(self)
- self.Key = ''
- self.Value = ''
-
- ## __hash__
- #
- def __hash__(self):
- return hash(self.Key + self.Value)
-
- ## __eq__
- #
- def __eq__(self, Other):
- return id(self) == id(Other)
-
- ## __str__
- #
- def __str__(self):
- return str(self.ArchAndModuleType) + '\n' + self.Key + \
- ' = ' + self.Value
-
-## DecIncludeObject
-#
-# Class to hold include section info
-#
-class DecIncludeObject(_DecBaseObject):
- def __init__(self, PkgFullName):
- _DecBaseObject.__init__(self, PkgFullName)
- self._SecName = TAB_INCLUDES.upper()
-
- ## GetIncludes
- #
- def GetIncludes(self, Arch=TAB_ARCH_COMMON):
- return self._GetItemByArch(Arch)
-
- ## GetAllIncludes
- #
- def GetAllIncludes(self):
- return self._GetAllItems()
-
-## DecIncludeItemObject
-#
-# Item of include section
-#
-class DecIncludeItemObject(_DecItemBaseObject):
- def __init__(self, File, Root):
- self.File = File
- self.Root = Root
- _DecItemBaseObject.__init__(self)
-
- ## __hash__
- #
- def __hash__(self):
- return hash(self.File)
-
- ## __eq__
- #
- def __eq__(self, Other):
- return id(self) == id(Other)
-
- ## __str__
- #
- def __str__(self):
- return self.File
-
-## DecLibraryclassObject
-#
-# Class to hold library class section info
-#
-class DecLibraryclassObject(_DecBaseObject):
- def __init__(self, PkgFullName):
- _DecBaseObject.__init__(self, PkgFullName)
- self._PackagePath, self._FileName = os.path.split(PkgFullName)
- self._SecName = TAB_LIBRARY_CLASSES.upper()
-
- ## GetLibraryclasses
- #
- def GetLibraryclasses(self, Arch=TAB_ARCH_COMMON):
- return self._GetItemByArch(Arch)
-
- ## GetAllLibraryclasses
- #
- def GetAllLibraryclasses(self):
- return self._GetAllItems()
-
-## DecLibraryclassItemObject
-# Item of library class section
-#
-class DecLibraryclassItemObject(_DecItemBaseObject):
- def __init__(self, Libraryclass, File, Root):
- _DecItemBaseObject.__init__(self)
- self.File = File
- self.Root = Root
- self.Libraryclass = Libraryclass
-
- ## __hash__
- #
- def __hash__(self):
- return hash(self.Libraryclass + self.File)
-
- ## __eq__
- #
- def __eq__(self, Other):
- return id(self) == id(Other)
-
- ## __str__
- #
- def __str__(self):
- return self.Libraryclass + '|' + self.File
-
-## DecPcdObject
-# Class to hold PCD section
-#
-class DecPcdObject(_DecBaseObject):
- def __init__(self, PkgFullName):
- _DecBaseObject.__init__(self, PkgFullName)
- self._SecName = TAB_PCDS.upper()
-
- ## AddItem
- #
- # Diff from base class
- #
- # @param Item: Item
- # @param Scope: Scope
- #
- def AddItem(self, Item, Scope):
- if not Scope:
- return
- if not Item:
- return
- ArchModule = []
- for Type, Arch in Scope:
- if (Type, Arch) in self.ValueDict:
- self.ValueDict[Type, Arch].append(Item)
- else:
- self.ValueDict[Type, Arch] = [Item]
- ArchModule.append([Type, Arch])
- Item.ArchAndModuleType = ArchModule
-
- ## GetPcds
- #
- # @param PcdType: PcdType
- # @param Arch: Arch
- #
- def GetPcds(self, PcdType, Arch=TAB_ARCH_COMMON):
- PcdType = PcdType.upper()
- Arch = Arch.upper()
- if (PcdType, Arch) not in self.ValueDict:
- return []
- return self.ValueDict[PcdType, Arch]
-
- ## GetPcdsByType
- #
- # @param PcdType: PcdType
- #
- def GetPcdsByType(self, PcdType):
- PcdType = PcdType.upper()
- Retlst = []
- for TypeInDict, Arch in self.ValueDict:
- if TypeInDict != PcdType:
- continue
- for Item in self.ValueDict[PcdType, Arch]:
- if Item not in Retlst:
- Retlst.append(Item)
- return Retlst
-
-## DecPcdItemObject
-#
-# Item of PCD section
-#
-# @param _DecItemBaseObject: _DecItemBaseObject object
-#
-class DecPcdItemObject(_DecItemBaseObject):
- def __init__(self, Guid, Name, Value, DatumType,
- Token, MaxDatumSize=''):
- _DecItemBaseObject.__init__(self)
- self.TokenCName = Name
- self.TokenSpaceGuidCName = Guid
- self.DatumType = DatumType
- self.DefaultValue = Value
- self.TokenValue = Token
- self.MaxDatumSize = MaxDatumSize
-
- ## __hash__
- #
- def __hash__(self):
- return hash(self.TokenSpaceGuidCName + self.TokenCName)
-
- ## __eq__
- #
- def __eq__(self, Other):
- return id(self) == id(Other)
-
- ## GetArchListOfType
- #
- # @param PcdType: PcdType
- #
- def GetArchListOfType(self, PcdType):
- ItemSet = set()
- PcdType = PcdType.upper()
- for Type, Arch in self.ArchAndModuleType:
- if Type != PcdType:
- continue
- ItemSet.add(Arch)
- return list(ItemSet)
-
-## DecGuidObjectBase
-#
-# Base class for PPI, Protocol, and GUID.
-# Hold same data but has different method for clarification in sub-class
-#
-# @param _DecBaseObject: Dec Base Object
-#
-class DecGuidObjectBase(_DecBaseObject):
- def __init__(self, PkgFullName):
- _DecBaseObject.__init__(self, PkgFullName)
-
- ## GetGuidStyleItems
- #
- # @param Arch: Arch
- #
- def GetGuidStyleItems(self, Arch=TAB_ARCH_COMMON):
- return self._GetItemByArch(Arch)
-
- ## GetGuidStyleAllItems
- #
- def GetGuidStyleAllItems(self):
- return self._GetAllItems()
-
-## DecGuidItemObject
-#
-# Item of GUID, PPI and Protocol section
-#
-# @param _DecItemBaseObject: Dec Item Base Object
-#
-class DecGuidItemObject(_DecItemBaseObject):
- def __init__(self, CName, GuidCValue, GuidString):
- _DecItemBaseObject.__init__(self)
- self.GuidCName = CName
- self.GuidCValue = GuidCValue
- self.GuidString = GuidString
-
- ## __hash__
- #
- def __hash__(self):
- return hash(self.GuidCName)
-
- ## __eq__
- #
- def __eq__(self, Other):
- return id(self) == id(Other)
-
- ## __str__
- #
- def __str__(self):
- return self.GuidCName + ' = ' + self.GuidCValue
-
-## DecGuidObject
-#
-# Class for GUID section
-#
-# @param DecGuidObjectBase: Dec Guid Object Base
-#
-class DecGuidObject(DecGuidObjectBase):
- def __init__(self, PkgFullName):
- DecGuidObjectBase.__init__(self, PkgFullName)
- self._SecName = TAB_GUIDS.upper()
-
- ## GetGuids
- #
- # @param Arch: Arch
- #
- def GetGuids(self, Arch=TAB_ARCH_COMMON):
- return self._GetItemByArch(Arch)
-
- ## GetAllGuids
- #
- def GetAllGuids(self):
- return self._GetAllItems()
-
-## DecPpiObject
-#
-# Class for PPI section
-#
-# @param DecGuidObjectBase: Dec Guid Object Base
-#
-class DecPpiObject(DecGuidObjectBase):
- def __init__(self, PkgFullName):
- DecGuidObjectBase.__init__(self, PkgFullName)
- self._SecName = TAB_PPIS.upper()
-
- ## GetPpis
- #
- # @param Arch: Arch
- #
- def GetPpis(self, Arch=TAB_ARCH_COMMON):
- return self._GetItemByArch(Arch)
-
- ## GetAllPpis
- #
- def GetAllPpis(self):
- return self._GetAllItems()
-
-## DecProtocolObject
-#
-# Class for protocol section
-#
-# @param DecGuidObjectBase: Dec Guid Object Base
-#
-class DecProtocolObject(DecGuidObjectBase):
- def __init__(self, PkgFullName):
- DecGuidObjectBase.__init__(self, PkgFullName)
- self._SecName = TAB_PROTOCOLS.upper()
-
- ## GetProtocols
- #
- # @param Arch: Arch
- #
- def GetProtocols(self, Arch=TAB_ARCH_COMMON):
- return self._GetItemByArch(Arch)
-
- ## GetAllProtocols
- #
- def GetAllProtocols(self):
- return self._GetAllItems()
-
-## DecUserExtensionObject
-#
-# Class for user extension section
-#
-# @param _DecBaseObject: Dec Guid Object Base
-#
-class DecUserExtensionObject(_DecBaseObject):
- def __init__(self, PkgFullName):
- _DecBaseObject.__init__(self, PkgFullName)
- self._SecName = TAB_USER_EXTENSIONS.upper()
- self.ItemList = []
-
- ## GetProtocols
- #
- # @param Item: Item
- # @param Scope: Scope
- #
- def AddItem(self, Item, Scope):
- if not Scope:
- pass
- if not Item:
- return
- self.ItemList.append(Item)
-
- ## GetAllUserExtensions
- #
- def GetAllUserExtensions(self):
- return self.ItemList
-
-
-## DecUserExtensionItemObject
-# Item for user extension section
-#
-# @param _DecItemBaseObject: Dec Item Base Object
-#
-class DecUserExtensionItemObject(_DecItemBaseObject):
- def __init__(self):
- _DecItemBaseObject.__init__(self)
- self.UserString = ''
- self.UserId = ''
- self.IdString = ''
-
-
-
-
+## @file
+# This file is used to define class objects for DEC file. It will consumed by
+#DecParser
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+DecObject
+'''
+
+## Import modules
+#
+import os.path
+
+from Library.Misc import Sdict
+from Library.DataType import TAB_GUIDS
+from Library.DataType import TAB_PPIS
+from Library.DataType import TAB_PROTOCOLS
+from Library.DataType import TAB_DEC_DEFINES
+from Library.DataType import TAB_INCLUDES
+from Library.DataType import TAB_LIBRARY_CLASSES
+from Library.DataType import TAB_USER_EXTENSIONS
+from Library.DataType import TAB_PCDS
+from Library.DataType import TAB_ARCH_COMMON
+
+## _DecComments
+#
+# Base class for all data objects which have head and tail comments
+#
+class _DecComments:
+
+ ##constructor
+ #
+ def __init__(self):
+ self._HeadComment = []
+ self._TailComment = []
+
+ ## GetComments
+ #
+ def GetComments(self):
+ return self._HeadComment, self._TailComment
+
+ ## GetHeadComment
+ #
+ def GetHeadComment(self):
+ return self._HeadComment
+
+ ## SetHeadComment
+ #
+ # @param Comment: comment content
+ #
+ def SetHeadComment(self, Comment):
+ self._HeadComment = Comment
+
+ ## GetTailComment
+ #
+ def GetTailComment(self):
+ return self._TailComment
+
+ ## SetTailComment
+ #
+ # @param Comment: comment content
+ #
+ def SetTailComment(self, Comment):
+ self._TailComment = Comment
+
+## _DecBaseObject
+#
+# Base class that hold common info
+#
+class _DecBaseObject(_DecComments):
+ def __init__(self, PkgFullName):
+ _DecComments.__init__(self)
+ #
+ # Key is combined with (Arch, SectionType)
+ # Default is common
+ #
+ self.ValueDict = Sdict()
+ self._PkgFullName = PkgFullName
+ self._PackagePath, self._FileName = os.path.split(PkgFullName)
+ self._SecName = ''
+
+ ## GetSectionName
+ #
+ def GetSectionName(self):
+ return self._SecName
+
+ ## GetPackagePath
+ #
+ def GetPackagePath(self):
+ return self._PackagePath
+
+ ## GetPackageFile
+ #
+ def GetPackageFile(self):
+ return self._FileName
+
+ ## GetPackageFullName
+ #
+ def GetPackageFullName(self):
+ return self._PkgFullName
+
+ ## AddItem
+ # Add sub-item to current object, sub-class should override it if needed
+ #
+ # @param Item: Sub-item to be added
+ # @param Scope: A list store section name and arch info
+ #
+ def AddItem(self, Item, Scope):
+ if not Scope:
+ return
+ if not Item:
+ return
+ ArchModule = []
+ for Ele in Scope:
+ if Ele[1] in self.ValueDict:
+ self.ValueDict[Ele[1]].append(Item)
+ else:
+ self.ValueDict[Ele[1]] = [Item]
+ ArchModule.append(Ele[1])
+ Item.ArchAndModuleType = ArchModule
+
+ ## _GetItemByArch
+ # Helper class used by sub-class
+ # @param Arch: arch
+ #
+ def _GetItemByArch(self, Arch):
+ Arch = Arch.upper()
+ if Arch not in self.ValueDict:
+ return []
+ return self.ValueDict[Arch]
+
+ ## _GetAllItems
+ # Get all items, union all arches, items in returned list are unique
+ #
+ def _GetAllItems(self):
+ Retlst = []
+ for Arch in self.ValueDict:
+ for Item in self.ValueDict[Arch]:
+ if Item not in Retlst:
+ Retlst.append(Item)
+ return Retlst
+
+## _DecItemBaseObject
+#
+# Module type and arch the item belongs to
+#
+class _DecItemBaseObject(_DecComments):
+ def __init__(self):
+ _DecComments.__init__(self)
+ #
+ # Item's arch, if PCD, also include PCD type
+ #
+ self.ArchAndModuleType = []
+
+ ## GetArchList
+ #
+ def GetArchList(self):
+ ArchSet = set()
+ for Arch in self.ArchAndModuleType:
+ ArchSet.add(Arch)
+ return list(ArchSet)
+
+## DecDefineObject
+#
+# Class to hold define section information
+#
+class DecDefineObject(_DecBaseObject):
+ def __init__(self, PkgFullName):
+ _DecBaseObject.__init__(self, PkgFullName)
+ self._SecName = TAB_DEC_DEFINES.upper()
+ self._DecSpec = ''
+ self._PkgName = ''
+ self._PkgGuid = ''
+ self._PkgVersion = ''
+ self._PkgUniFile = ''
+
+ ## GetPackageSpecification
+ #
+ def GetPackageSpecification(self):
+ return self._DecSpec
+
+ def SetPackageSpecification(self, DecSpec):
+ self._DecSpec = DecSpec
+
+ ## GetPackageName
+ #
+ def GetPackageName(self):
+ return self._PkgName
+
+ def SetPackageName(self, PkgName):
+ self._PkgName = PkgName
+
+ ## GetPackageGuid
+ #
+ def GetPackageGuid(self):
+ return self._PkgGuid
+
+ def SetPackageGuid(self, PkgGuid):
+ self._PkgGuid = PkgGuid
+
+ ## GetPackageVersion
+ #
+ def GetPackageVersion(self):
+ return self._PkgVersion
+
+ def SetPackageVersion(self, PkgVersion):
+ self._PkgVersion = PkgVersion
+
+ ## GetPackageUniFile
+ #
+ def GetPackageUniFile(self):
+ return self._PkgUniFile
+
+ def SetPackageUniFile(self, PkgUniFile):
+ self._PkgUniFile = PkgUniFile
+
+ ## GetDefines
+ #
+ def GetDefines(self):
+ return self._GetItemByArch(TAB_ARCH_COMMON)
+
+ ## GetAllDefines
+ #
+ def GetAllDefines(self):
+ return self._GetAllItems()
+
+## DecDefineItemObject
+#
+# Each item of define section
+#
+class DecDefineItemObject(_DecItemBaseObject):
+ def __init__(self):
+ _DecItemBaseObject.__init__(self)
+ self.Key = ''
+ self.Value = ''
+
+ ## __hash__
+ #
+ def __hash__(self):
+ return hash(self.Key + self.Value)
+
+ ## __eq__
+ #
+ def __eq__(self, Other):
+ return id(self) == id(Other)
+
+ ## __str__
+ #
+ def __str__(self):
+ return str(self.ArchAndModuleType) + '\n' + self.Key + \
+ ' = ' + self.Value
+
+## DecIncludeObject
+#
+# Class to hold include section info
+#
+class DecIncludeObject(_DecBaseObject):
+ def __init__(self, PkgFullName):
+ _DecBaseObject.__init__(self, PkgFullName)
+ self._SecName = TAB_INCLUDES.upper()
+
+ ## GetIncludes
+ #
+ def GetIncludes(self, Arch=TAB_ARCH_COMMON):
+ return self._GetItemByArch(Arch)
+
+ ## GetAllIncludes
+ #
+ def GetAllIncludes(self):
+ return self._GetAllItems()
+
+## DecIncludeItemObject
+#
+# Item of include section
+#
+class DecIncludeItemObject(_DecItemBaseObject):
+ def __init__(self, File, Root):
+ self.File = File
+ self.Root = Root
+ _DecItemBaseObject.__init__(self)
+
+ ## __hash__
+ #
+ def __hash__(self):
+ return hash(self.File)
+
+ ## __eq__
+ #
+ def __eq__(self, Other):
+ return id(self) == id(Other)
+
+ ## __str__
+ #
+ def __str__(self):
+ return self.File
+
+## DecLibraryclassObject
+#
+# Class to hold library class section info
+#
+class DecLibraryclassObject(_DecBaseObject):
+ def __init__(self, PkgFullName):
+ _DecBaseObject.__init__(self, PkgFullName)
+ self._PackagePath, self._FileName = os.path.split(PkgFullName)
+ self._SecName = TAB_LIBRARY_CLASSES.upper()
+
+ ## GetLibraryclasses
+ #
+ def GetLibraryclasses(self, Arch=TAB_ARCH_COMMON):
+ return self._GetItemByArch(Arch)
+
+ ## GetAllLibraryclasses
+ #
+ def GetAllLibraryclasses(self):
+ return self._GetAllItems()
+
+## DecLibraryclassItemObject
+# Item of library class section
+#
+class DecLibraryclassItemObject(_DecItemBaseObject):
+ def __init__(self, Libraryclass, File, Root):
+ _DecItemBaseObject.__init__(self)
+ self.File = File
+ self.Root = Root
+ self.Libraryclass = Libraryclass
+
+ ## __hash__
+ #
+ def __hash__(self):
+ return hash(self.Libraryclass + self.File)
+
+ ## __eq__
+ #
+ def __eq__(self, Other):
+ return id(self) == id(Other)
+
+ ## __str__
+ #
+ def __str__(self):
+ return self.Libraryclass + '|' + self.File
+
+## DecPcdObject
+# Class to hold PCD section
+#
+class DecPcdObject(_DecBaseObject):
+ def __init__(self, PkgFullName):
+ _DecBaseObject.__init__(self, PkgFullName)
+ self._SecName = TAB_PCDS.upper()
+
+ ## AddItem
+ #
+ # Diff from base class
+ #
+ # @param Item: Item
+ # @param Scope: Scope
+ #
+ def AddItem(self, Item, Scope):
+ if not Scope:
+ return
+ if not Item:
+ return
+ ArchModule = []
+ for Type, Arch in Scope:
+ if (Type, Arch) in self.ValueDict:
+ self.ValueDict[Type, Arch].append(Item)
+ else:
+ self.ValueDict[Type, Arch] = [Item]
+ ArchModule.append([Type, Arch])
+ Item.ArchAndModuleType = ArchModule
+
+ ## GetPcds
+ #
+ # @param PcdType: PcdType
+ # @param Arch: Arch
+ #
+ def GetPcds(self, PcdType, Arch=TAB_ARCH_COMMON):
+ PcdType = PcdType.upper()
+ Arch = Arch.upper()
+ if (PcdType, Arch) not in self.ValueDict:
+ return []
+ return self.ValueDict[PcdType, Arch]
+
+ ## GetPcdsByType
+ #
+ # @param PcdType: PcdType
+ #
+ def GetPcdsByType(self, PcdType):
+ PcdType = PcdType.upper()
+ Retlst = []
+ for TypeInDict, Arch in self.ValueDict:
+ if TypeInDict != PcdType:
+ continue
+ for Item in self.ValueDict[PcdType, Arch]:
+ if Item not in Retlst:
+ Retlst.append(Item)
+ return Retlst
+
+## DecPcdItemObject
+#
+# Item of PCD section
+#
+# @param _DecItemBaseObject: _DecItemBaseObject object
+#
+class DecPcdItemObject(_DecItemBaseObject):
+ def __init__(self, Guid, Name, Value, DatumType,
+ Token, MaxDatumSize=''):
+ _DecItemBaseObject.__init__(self)
+ self.TokenCName = Name
+ self.TokenSpaceGuidCName = Guid
+ self.DatumType = DatumType
+ self.DefaultValue = Value
+ self.TokenValue = Token
+ self.MaxDatumSize = MaxDatumSize
+
+ ## __hash__
+ #
+ def __hash__(self):
+ return hash(self.TokenSpaceGuidCName + self.TokenCName)
+
+ ## __eq__
+ #
+ def __eq__(self, Other):
+ return id(self) == id(Other)
+
+ ## GetArchListOfType
+ #
+ # @param PcdType: PcdType
+ #
+ def GetArchListOfType(self, PcdType):
+ ItemSet = set()
+ PcdType = PcdType.upper()
+ for Type, Arch in self.ArchAndModuleType:
+ if Type != PcdType:
+ continue
+ ItemSet.add(Arch)
+ return list(ItemSet)
+
+## DecGuidObjectBase
+#
+# Base class for PPI, Protocol, and GUID.
+# Hold same data but has different method for clarification in sub-class
+#
+# @param _DecBaseObject: Dec Base Object
+#
+class DecGuidObjectBase(_DecBaseObject):
+ def __init__(self, PkgFullName):
+ _DecBaseObject.__init__(self, PkgFullName)
+
+ ## GetGuidStyleItems
+ #
+ # @param Arch: Arch
+ #
+ def GetGuidStyleItems(self, Arch=TAB_ARCH_COMMON):
+ return self._GetItemByArch(Arch)
+
+ ## GetGuidStyleAllItems
+ #
+ def GetGuidStyleAllItems(self):
+ return self._GetAllItems()
+
+## DecGuidItemObject
+#
+# Item of GUID, PPI and Protocol section
+#
+# @param _DecItemBaseObject: Dec Item Base Object
+#
+class DecGuidItemObject(_DecItemBaseObject):
+ def __init__(self, CName, GuidCValue, GuidString):
+ _DecItemBaseObject.__init__(self)
+ self.GuidCName = CName
+ self.GuidCValue = GuidCValue
+ self.GuidString = GuidString
+
+ ## __hash__
+ #
+ def __hash__(self):
+ return hash(self.GuidCName)
+
+ ## __eq__
+ #
+ def __eq__(self, Other):
+ return id(self) == id(Other)
+
+ ## __str__
+ #
+ def __str__(self):
+ return self.GuidCName + ' = ' + self.GuidCValue
+
+## DecGuidObject
+#
+# Class for GUID section
+#
+# @param DecGuidObjectBase: Dec Guid Object Base
+#
+class DecGuidObject(DecGuidObjectBase):
+ def __init__(self, PkgFullName):
+ DecGuidObjectBase.__init__(self, PkgFullName)
+ self._SecName = TAB_GUIDS.upper()
+
+ ## GetGuids
+ #
+ # @param Arch: Arch
+ #
+ def GetGuids(self, Arch=TAB_ARCH_COMMON):
+ return self._GetItemByArch(Arch)
+
+ ## GetAllGuids
+ #
+ def GetAllGuids(self):
+ return self._GetAllItems()
+
+## DecPpiObject
+#
+# Class for PPI section
+#
+# @param DecGuidObjectBase: Dec Guid Object Base
+#
+class DecPpiObject(DecGuidObjectBase):
+ def __init__(self, PkgFullName):
+ DecGuidObjectBase.__init__(self, PkgFullName)
+ self._SecName = TAB_PPIS.upper()
+
+ ## GetPpis
+ #
+ # @param Arch: Arch
+ #
+ def GetPpis(self, Arch=TAB_ARCH_COMMON):
+ return self._GetItemByArch(Arch)
+
+ ## GetAllPpis
+ #
+ def GetAllPpis(self):
+ return self._GetAllItems()
+
+## DecProtocolObject
+#
+# Class for protocol section
+#
+# @param DecGuidObjectBase: Dec Guid Object Base
+#
+class DecProtocolObject(DecGuidObjectBase):
+ def __init__(self, PkgFullName):
+ DecGuidObjectBase.__init__(self, PkgFullName)
+ self._SecName = TAB_PROTOCOLS.upper()
+
+ ## GetProtocols
+ #
+ # @param Arch: Arch
+ #
+ def GetProtocols(self, Arch=TAB_ARCH_COMMON):
+ return self._GetItemByArch(Arch)
+
+ ## GetAllProtocols
+ #
+ def GetAllProtocols(self):
+ return self._GetAllItems()
+
+## DecUserExtensionObject
+#
+# Class for user extension section
+#
+# @param _DecBaseObject: Dec Guid Object Base
+#
+class DecUserExtensionObject(_DecBaseObject):
+ def __init__(self, PkgFullName):
+ _DecBaseObject.__init__(self, PkgFullName)
+ self._SecName = TAB_USER_EXTENSIONS.upper()
+ self.ItemList = []
+
+ ## GetProtocols
+ #
+ # @param Item: Item
+ # @param Scope: Scope
+ #
+ def AddItem(self, Item, Scope):
+ if not Scope:
+ pass
+ if not Item:
+ return
+ self.ItemList.append(Item)
+
+ ## GetAllUserExtensions
+ #
+ def GetAllUserExtensions(self):
+ return self.ItemList
+
+
+## DecUserExtensionItemObject
+# Item for user extension section
+#
+# @param _DecItemBaseObject: Dec Item Base Object
+#
+class DecUserExtensionItemObject(_DecItemBaseObject):
+ def __init__(self):
+ _DecItemBaseObject.__init__(self)
+ self.UserString = ''
+ self.UserId = ''
+ self.IdString = ''
+
+
+
+
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py
index 6b55d01ab2..70cbc54cee 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py
@@ -1,686 +1,686 @@
-## @file
-# This file is used to define class objects of INF file [Binaries] section.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfBinaryObject
-'''
-
-import os
-
-from copy import deepcopy
-from Library import DataType as DT
-from Library import GlobalData
-import Logger.Log as Logger
-from Logger import ToolError
-from Logger import StringTable as ST
-from Library.Misc import Sdict
-
-from Object.Parser.InfCommonObject import InfSectionCommonDef
-from Object.Parser.InfCommonObject import CurrentLine
-from Library.Misc import ConvPathFromAbsToRel
-from Library.ExpressionValidate import IsValidFeatureFlagExp
-from Library.Misc import ValidFile
-from Library.ParserValidate import IsValidPath
-
-
-class InfBianryItem():
- def __init__(self):
- self.FileName = ''
- self.Target = ''
- self.FeatureFlagExp = ''
- self.HelpString = ''
- self.Type = ''
- self.SupArchList = []
-
- def SetFileName(self, FileName):
- self.FileName = FileName
- def GetFileName(self):
- return self.FileName
-
- def SetTarget(self, Target):
- self.Target = Target
- def GetTarget(self):
- return self.Target
-
- def SetFeatureFlagExp(self, FeatureFlagExp):
- self.FeatureFlagExp = FeatureFlagExp
- def GetFeatureFlagExp(self):
- return self.FeatureFlagExp
-
- def SetHelpString(self, HelpString):
- self.HelpString = HelpString
- def GetHelpString(self):
- return self.HelpString
-
- def SetType(self, Type):
- self.Type = Type
- def GetType(self):
- return self.Type
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
- def GetSupArchList(self):
- return self.SupArchList
-
-class InfBianryVerItem(InfBianryItem, CurrentLine):
- def __init__(self):
- InfBianryItem.__init__(self)
- CurrentLine.__init__(self)
- self.VerTypeName = ''
-
- def SetVerTypeName(self, VerTypeName):
- self.VerTypeName = VerTypeName
- def GetVerTypeName(self):
- return self.VerTypeName
-
-class InfBianryUiItem(InfBianryItem, CurrentLine):
- def __init__(self):
- InfBianryItem.__init__(self)
- CurrentLine.__init__(self)
- self.UiTypeName = ''
-
- def SetUiTypeName(self, UiTypeName):
- self.UiTypeName = UiTypeName
- def GetVerTypeName(self):
- return self.UiTypeName
-
-class InfBianryCommonItem(InfBianryItem, CurrentLine):
- def __init__(self):
- self.CommonType = ''
- self.TagName = ''
- self.Family = ''
- self.GuidValue = ''
- InfBianryItem.__init__(self)
- CurrentLine.__init__(self)
-
- def SetCommonType(self, CommonType):
- self.CommonType = CommonType
- def GetCommonType(self):
- return self.CommonType
-
- def SetTagName(self, TagName):
- self.TagName = TagName
- def GetTagName(self):
- return self.TagName
-
- def SetFamily(self, Family):
- self.Family = Family
- def GetFamily(self):
- return self.Family
-
- def SetGuidValue(self, GuidValue):
- self.GuidValue = GuidValue
- def GetGuidValue(self):
- return self.GuidValue
-
-##
-#
-#
-#
-class InfBinariesObject(InfSectionCommonDef):
- def __init__(self):
- self.Binaries = Sdict()
- #
- # Macro defined in this section should be only used in this section.
- #
- self.Macros = {}
- InfSectionCommonDef.__init__(self)
-
- ## CheckVer
- #
- #
- def CheckVer(self, Ver, __SupArchList):
- #
- # Check Ver
- #
- for VerItem in Ver:
- IsValidFileFlag = False
- VerContent = VerItem[0]
- VerComment = VerItem[1]
- VerCurrentLine = VerItem[2]
- GlobalData.gINF_CURRENT_LINE = VerCurrentLine
- InfBianryVerItemObj = None
- #
- # Should not less than 2 elements
- #
- if len(VerContent) < 2:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (VerContent[0], 2),
- File=VerCurrentLine.GetFileName(),
- Line=VerCurrentLine.GetLineNo(),
- ExtraData=VerCurrentLine.GetLineString())
- return False
- if len(VerContent) > 4:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (VerContent[0], 4),
- File=VerCurrentLine.GetFileName(),
- Line=VerCurrentLine.GetLineNo(),
- ExtraData=VerCurrentLine.GetLineString())
- return False
- if len(VerContent) >= 2:
- #
- # Create a Ver Object.
- #
- InfBianryVerItemObj = InfBianryVerItem()
-
- if VerContent[0] != DT.BINARY_FILE_TYPE_VER:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_VER_TYPE % DT.BINARY_FILE_TYPE_VER,
- File=VerCurrentLine.GetFileName(),
- Line=VerCurrentLine.GetLineNo(),
- ExtraData=VerCurrentLine.GetLineString())
-
- InfBianryVerItemObj.SetVerTypeName(VerContent[0])
- InfBianryVerItemObj.SetType(VerContent[0])
- #
- # Verify File exist or not
- #
- FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,
- VerContent[1])))
- if not (ValidFile(FullFileName) or ValidFile(VerContent[1])):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (VerContent[1]),
- File=VerCurrentLine.GetFileName(),
- Line=VerCurrentLine.GetLineNo(),
- ExtraData=VerCurrentLine.GetLineString())
- #
- # Validate file exist/format.
- #
- if IsValidPath(VerContent[1], GlobalData.gINF_MODULE_DIR):
- IsValidFileFlag = True
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (VerContent[1]),
- File=VerCurrentLine.GetFileName(),
- Line=VerCurrentLine.GetLineNo(),
- ExtraData=VerCurrentLine.GetLineString())
- return False
- if IsValidFileFlag:
- VerContent[0] = ConvPathFromAbsToRel(VerContent[0],
- GlobalData.gINF_MODULE_DIR)
- InfBianryVerItemObj.SetFileName(VerContent[1])
- if len(VerContent) >= 3:
- #
- # Add Target information
- #
- InfBianryVerItemObj.SetTarget(VerContent[2])
- if len(VerContent) == 4:
- if VerContent[3].strip() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- File=VerCurrentLine.GetFileName(),
- Line=VerCurrentLine.GetLineNo(),
- ExtraData=VerCurrentLine.GetLineString())
- #
- # Validate Feature Flag Express
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(VerContent[3].\
- strip())
- if not FeatureFlagRtv[0]:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
- File=VerCurrentLine.GetFileName(),
- Line=VerCurrentLine.GetLineNo(),
- ExtraData=VerCurrentLine.GetLineString())
- InfBianryVerItemObj.SetFeatureFlagExp(VerContent[3])
-
- InfBianryVerItemObj.SetSupArchList(__SupArchList)
-
- #
- # Determine binary file name duplicate. Follow below rule:
- #
- # A binary filename must not be duplicated within
- # a [Binaries] section. A binary filename may appear in
- # multiple architectural [Binaries] sections. A binary
- # filename listed in an architectural [Binaries] section
- # must not be listed in the common architectural
- # [Binaries] section.
- #
- # NOTE: This check will not report error now.
- #
- for Item in self.Binaries:
- if Item.GetFileName() == InfBianryVerItemObj.GetFileName():
- ItemSupArchList = Item.GetSupArchList()
- for ItemArch in ItemSupArchList:
- for VerItemObjArch in __SupArchList:
- if ItemArch == VerItemObjArch:
- #
- # ST.ERR_INF_PARSER_ITEM_DUPLICATE
- #
- pass
- if ItemArch.upper() == 'COMMON' or VerItemObjArch.upper() == 'COMMON':
- #
- # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
- #
- pass
-
- if InfBianryVerItemObj is not None:
- if (InfBianryVerItemObj) in self.Binaries:
- BinariesList = self.Binaries[InfBianryVerItemObj]
- BinariesList.append((InfBianryVerItemObj, VerComment))
- self.Binaries[InfBianryVerItemObj] = BinariesList
- else:
- BinariesList = []
- BinariesList.append((InfBianryVerItemObj, VerComment))
- self.Binaries[InfBianryVerItemObj] = BinariesList
-
- ## ParseCommonBinary
- #
- # ParseCommonBinary
- #
- def ParseCommonBinary(self, CommonBinary, __SupArchList):
- #
- # Check common binary definitions
- # Type | FileName | Target | Family | TagName | FeatureFlagExp
- #
- for Item in CommonBinary:
- IsValidFileFlag = False
- ItemContent = Item[0]
- ItemComment = Item[1]
- CurrentLineOfItem = Item[2]
- GlobalData.gINF_CURRENT_LINE = CurrentLineOfItem
- InfBianryCommonItemObj = None
- if ItemContent[0] == 'SUBTYPE_GUID':
- if len(ItemContent) < 3:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (ItemContent[0], 3),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- return False
- else:
- if len(ItemContent) < 2:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (ItemContent[0], 2),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- return False
-
- if len(ItemContent) > 7:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (ItemContent[0], 7),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- return False
- if len(ItemContent) >= 2:
- #
- # Create a Common Object.
- #
- InfBianryCommonItemObj = InfBianryCommonItem()
- #
- # Convert Binary type.
- #
- BinaryFileType = ItemContent[0].strip()
- if BinaryFileType == 'RAW' or BinaryFileType == 'ACPI' or BinaryFileType == 'ASL':
- BinaryFileType = 'BIN'
-
- if BinaryFileType not in DT.BINARY_FILE_TYPE_LIST:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FILETYPE % \
- (DT.BINARY_FILE_TYPE_LIST.__str__()),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
-
- if BinaryFileType == 'SUBTYPE_GUID':
- BinaryFileType = 'FREEFORM'
-
- if BinaryFileType == 'LIB' or BinaryFileType == 'UEFI_APP':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FILETYPE % \
- (DT.BINARY_FILE_TYPE_LIST.__str__()),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
-
- InfBianryCommonItemObj.SetType(BinaryFileType)
- InfBianryCommonItemObj.SetCommonType(ItemContent[0])
- FileName = ''
- if BinaryFileType == 'FREEFORM':
- InfBianryCommonItemObj.SetGuidValue(ItemContent[1])
- if len(ItemContent) >= 3:
- FileName = ItemContent[2]
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FILENAME_NOT_EXIST,
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- else:
- FileName = ItemContent[1]
- #
- # Verify File exist or not
- #
- FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,
- FileName)))
- if not (ValidFile(FullFileName) or ValidFile(FileName)):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (FileName),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- #
- # Validate file exist/format.
- #
- if IsValidPath(FileName, GlobalData.gINF_MODULE_DIR):
- IsValidFileFlag = True
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (FileName),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- return False
- if IsValidFileFlag:
- ItemContent[0] = ConvPathFromAbsToRel(ItemContent[0], GlobalData.gINF_MODULE_DIR)
- InfBianryCommonItemObj.SetFileName(FileName)
- if len(ItemContent) >= 3:
- #
- # Add Target information
- #
- if BinaryFileType != 'FREEFORM':
- InfBianryCommonItemObj.SetTarget(ItemContent[2])
-
- if len(ItemContent) >= 4:
- #
- # Add Family information
- #
- if BinaryFileType != 'FREEFORM':
- InfBianryCommonItemObj.SetFamily(ItemContent[3])
- else:
- InfBianryCommonItemObj.SetTarget(ItemContent[3])
-
- if len(ItemContent) >= 5:
- #
- # TagName entries are build system specific. If there
- # is content in the entry, the tool must exit
- # gracefully with an error message that indicates build
- # system specific content cannot be distributed using
- # the UDP
- #
- if BinaryFileType != 'FREEFORM':
- if ItemContent[4].strip() != '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED % (ItemContent[4]),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- else:
- InfBianryCommonItemObj.SetFamily(ItemContent[4])
-
- if len(ItemContent) >= 6:
- #
- # Add FeatureFlagExp
- #
- if BinaryFileType != 'FREEFORM':
- if ItemContent[5].strip() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- #
- # Validate Feature Flag Express
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(ItemContent[5].strip())
- if not FeatureFlagRtv[0]:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- InfBianryCommonItemObj.SetFeatureFlagExp(ItemContent[5])
- else:
- if ItemContent[5].strip() != '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED % (ItemContent[5]),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
-
- if len(ItemContent) == 7:
- if ItemContent[6].strip() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- #
- # Validate Feature Flag Express
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(ItemContent[6].strip())
- if not FeatureFlagRtv[0]:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- InfBianryCommonItemObj.SetFeatureFlagExp(ItemContent[6])
-
- InfBianryCommonItemObj.SetSupArchList(__SupArchList)
-
- #
- # Determine binary file name duplicate. Follow below rule:
- #
- # A binary filename must not be duplicated within
- # a [Binaries] section. A binary filename may appear in
- # multiple architectural [Binaries] sections. A binary
- # filename listed in an architectural [Binaries] section
- # must not be listed in the common architectural
- # [Binaries] section.
- #
- # NOTE: This check will not report error now.
- #
-# for Item in self.Binaries:
-# if Item.GetFileName() == InfBianryCommonItemObj.GetFileName():
-# ItemSupArchList = Item.GetSupArchList()
-# for ItemArch in ItemSupArchList:
-# for ComItemObjArch in __SupArchList:
-# if ItemArch == ComItemObjArch:
-# #
-# # ST.ERR_INF_PARSER_ITEM_DUPLICATE
-# #
-# pass
-#
-# if ItemArch.upper() == 'COMMON' or ComItemObjArch.upper() == 'COMMON':
-# #
-# # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
-# #
-# pass
-
- if InfBianryCommonItemObj is not None:
- if (InfBianryCommonItemObj) in self.Binaries:
- BinariesList = self.Binaries[InfBianryCommonItemObj]
- BinariesList.append((InfBianryCommonItemObj, ItemComment))
- self.Binaries[InfBianryCommonItemObj] = BinariesList
- else:
- BinariesList = []
- BinariesList.append((InfBianryCommonItemObj, ItemComment))
- self.Binaries[InfBianryCommonItemObj] = BinariesList
-
- def SetBinary(self, UiInf=None, Ver=None, CommonBinary=None, ArchList=None):
-
- __SupArchList = []
- for ArchItem in ArchList:
- #
- # Validate Arch
- #
- if (ArchItem == '' or ArchItem is None):
- ArchItem = 'COMMON'
- __SupArchList.append(ArchItem)
-
- if UiInf is not None:
- if len(UiInf) > 0:
- #
- # Check UI
- #
- for UiItem in UiInf:
- IsValidFileFlag = False
- InfBianryUiItemObj = None
- UiContent = UiItem[0]
- UiComment = UiItem[1]
- UiCurrentLine = UiItem[2]
- GlobalData.gINF_CURRENT_LINE = deepcopy(UiItem[2])
- #
- # Should not less than 2 elements
- #
- if len(UiContent) < 2:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (UiContent[0], 2),
- File=UiCurrentLine.GetFileName(),
- Line=UiCurrentLine.GetLineNo(),
- ExtraData=UiCurrentLine.GetLineString())
- return False
-
- if len(UiContent) > 4:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (UiContent[0], 4),
- File=UiCurrentLine.GetFileName(),
- Line=UiCurrentLine.GetLineNo(),
- ExtraData=UiCurrentLine.GetLineString())
- return False
- if len(UiContent) >= 2:
- #
- # Create an Ui Object.
- #
- InfBianryUiItemObj = InfBianryUiItem()
- if UiContent[0] != 'UI':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_VER_TYPE % ('UI'),
- File=UiCurrentLine.GetFileName(),
- Line=UiCurrentLine.GetLineNo(),
- ExtraData=UiCurrentLine.GetLineString())
- InfBianryUiItemObj.SetUiTypeName(UiContent[0])
- InfBianryUiItemObj.SetType(UiContent[0])
- #
- # Verify File exist or not
- #
- FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,
- UiContent[1])))
- if not (ValidFile(FullFileName) or ValidFile(UiContent[1])):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (UiContent[1]),
- File=UiCurrentLine.GetFileName(),
- Line=UiCurrentLine.GetLineNo(),
- ExtraData=UiCurrentLine.GetLineString())
- #
- # Validate file exist/format.
- #
- if IsValidPath(UiContent[1], GlobalData.gINF_MODULE_DIR):
- IsValidFileFlag = True
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (UiContent[1]),
- File=UiCurrentLine.GetFileName(),
- Line=UiCurrentLine.GetLineNo(),
- ExtraData=UiCurrentLine.GetLineString())
- return False
- if IsValidFileFlag:
- UiContent[0] = ConvPathFromAbsToRel(UiContent[0], GlobalData.gINF_MODULE_DIR)
- InfBianryUiItemObj.SetFileName(UiContent[1])
- if len(UiContent) >= 3:
- #
- # Add Target information
- #
- InfBianryUiItemObj.SetTarget(UiContent[2])
- if len(UiContent) == 4:
- if UiContent[3].strip() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- File=UiCurrentLine.GetFileName(),
- Line=UiCurrentLine.GetLineNo(),
- ExtraData=UiCurrentLine.GetLineString())
- #
- # Validate Feature Flag Express
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(UiContent[3].strip())
- if not FeatureFlagRtv[0]:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
- File=UiCurrentLine.GetFileName(),
- Line=UiCurrentLine.GetLineNo(),
- ExtraData=UiCurrentLine.GetLineString())
- InfBianryUiItemObj.SetFeatureFlagExp(UiContent[3])
-
- InfBianryUiItemObj.SetSupArchList(__SupArchList)
-
- #
- # Determine binary file name duplicate. Follow below rule:
- #
- # A binary filename must not be duplicated within
- # a [Binaries] section. A binary filename may appear in
- # multiple architectural [Binaries] sections. A binary
- # filename listed in an architectural [Binaries] section
- # must not be listed in the common architectural
- # [Binaries] section.
- #
- # NOTE: This check will not report error now.
- #
-# for Item in self.Binaries:
-# if Item.GetFileName() == InfBianryUiItemObj.GetFileName():
-# ItemSupArchList = Item.GetSupArchList()
-# for ItemArch in ItemSupArchList:
-# for UiItemObjArch in __SupArchList:
-# if ItemArch == UiItemObjArch:
-# #
-# # ST.ERR_INF_PARSER_ITEM_DUPLICATE
-# #
-# pass
-# if ItemArch.upper() == 'COMMON' or UiItemObjArch.upper() == 'COMMON':
-# #
-# # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
-# #
-# pass
-
- if InfBianryUiItemObj is not None:
- if (InfBianryUiItemObj) in self.Binaries:
- BinariesList = self.Binaries[InfBianryUiItemObj]
- BinariesList.append((InfBianryUiItemObj, UiComment))
- self.Binaries[InfBianryUiItemObj] = BinariesList
- else:
- BinariesList = []
- BinariesList.append((InfBianryUiItemObj, UiComment))
- self.Binaries[InfBianryUiItemObj] = BinariesList
- if Ver is not None and len(Ver) > 0:
- self.CheckVer(Ver, __SupArchList)
- if CommonBinary and len(CommonBinary) > 0:
- self.ParseCommonBinary(CommonBinary, __SupArchList)
-
- return True
-
- def GetBinary(self):
- return self.Binaries
+## @file
+# This file is used to define class objects of INF file [Binaries] section.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfBinaryObject
+'''
+
+import os
+
+from copy import deepcopy
+from Library import DataType as DT
+from Library import GlobalData
+import Logger.Log as Logger
+from Logger import ToolError
+from Logger import StringTable as ST
+from Library.Misc import Sdict
+
+from Object.Parser.InfCommonObject import InfSectionCommonDef
+from Object.Parser.InfCommonObject import CurrentLine
+from Library.Misc import ConvPathFromAbsToRel
+from Library.ExpressionValidate import IsValidFeatureFlagExp
+from Library.Misc import ValidFile
+from Library.ParserValidate import IsValidPath
+
+
+class InfBianryItem():
+ def __init__(self):
+ self.FileName = ''
+ self.Target = ''
+ self.FeatureFlagExp = ''
+ self.HelpString = ''
+ self.Type = ''
+ self.SupArchList = []
+
+ def SetFileName(self, FileName):
+ self.FileName = FileName
+ def GetFileName(self):
+ return self.FileName
+
+ def SetTarget(self, Target):
+ self.Target = Target
+ def GetTarget(self):
+ return self.Target
+
+ def SetFeatureFlagExp(self, FeatureFlagExp):
+ self.FeatureFlagExp = FeatureFlagExp
+ def GetFeatureFlagExp(self):
+ return self.FeatureFlagExp
+
+ def SetHelpString(self, HelpString):
+ self.HelpString = HelpString
+ def GetHelpString(self):
+ return self.HelpString
+
+ def SetType(self, Type):
+ self.Type = Type
+ def GetType(self):
+ return self.Type
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+
+class InfBianryVerItem(InfBianryItem, CurrentLine):
+ def __init__(self):
+ InfBianryItem.__init__(self)
+ CurrentLine.__init__(self)
+ self.VerTypeName = ''
+
+ def SetVerTypeName(self, VerTypeName):
+ self.VerTypeName = VerTypeName
+ def GetVerTypeName(self):
+ return self.VerTypeName
+
+class InfBianryUiItem(InfBianryItem, CurrentLine):
+ def __init__(self):
+ InfBianryItem.__init__(self)
+ CurrentLine.__init__(self)
+ self.UiTypeName = ''
+
+ def SetUiTypeName(self, UiTypeName):
+ self.UiTypeName = UiTypeName
+ def GetVerTypeName(self):
+ return self.UiTypeName
+
+class InfBianryCommonItem(InfBianryItem, CurrentLine):
+ def __init__(self):
+ self.CommonType = ''
+ self.TagName = ''
+ self.Family = ''
+ self.GuidValue = ''
+ InfBianryItem.__init__(self)
+ CurrentLine.__init__(self)
+
+ def SetCommonType(self, CommonType):
+ self.CommonType = CommonType
+ def GetCommonType(self):
+ return self.CommonType
+
+ def SetTagName(self, TagName):
+ self.TagName = TagName
+ def GetTagName(self):
+ return self.TagName
+
+ def SetFamily(self, Family):
+ self.Family = Family
+ def GetFamily(self):
+ return self.Family
+
+ def SetGuidValue(self, GuidValue):
+ self.GuidValue = GuidValue
+ def GetGuidValue(self):
+ return self.GuidValue
+
+##
+#
+#
+#
+class InfBinariesObject(InfSectionCommonDef):
+ def __init__(self):
+ self.Binaries = Sdict()
+ #
+ # Macro defined in this section should be only used in this section.
+ #
+ self.Macros = {}
+ InfSectionCommonDef.__init__(self)
+
+ ## CheckVer
+ #
+ #
+ def CheckVer(self, Ver, __SupArchList):
+ #
+ # Check Ver
+ #
+ for VerItem in Ver:
+ IsValidFileFlag = False
+ VerContent = VerItem[0]
+ VerComment = VerItem[1]
+ VerCurrentLine = VerItem[2]
+ GlobalData.gINF_CURRENT_LINE = VerCurrentLine
+ InfBianryVerItemObj = None
+ #
+ # Should not less than 2 elements
+ #
+ if len(VerContent) < 2:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (VerContent[0], 2),
+ File=VerCurrentLine.GetFileName(),
+ Line=VerCurrentLine.GetLineNo(),
+ ExtraData=VerCurrentLine.GetLineString())
+ return False
+ if len(VerContent) > 4:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (VerContent[0], 4),
+ File=VerCurrentLine.GetFileName(),
+ Line=VerCurrentLine.GetLineNo(),
+ ExtraData=VerCurrentLine.GetLineString())
+ return False
+ if len(VerContent) >= 2:
+ #
+ # Create a Ver Object.
+ #
+ InfBianryVerItemObj = InfBianryVerItem()
+
+ if VerContent[0] != DT.BINARY_FILE_TYPE_VER:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_VER_TYPE % DT.BINARY_FILE_TYPE_VER,
+ File=VerCurrentLine.GetFileName(),
+ Line=VerCurrentLine.GetLineNo(),
+ ExtraData=VerCurrentLine.GetLineString())
+
+ InfBianryVerItemObj.SetVerTypeName(VerContent[0])
+ InfBianryVerItemObj.SetType(VerContent[0])
+ #
+ # Verify File exist or not
+ #
+ FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,
+ VerContent[1])))
+ if not (ValidFile(FullFileName) or ValidFile(VerContent[1])):
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (VerContent[1]),
+ File=VerCurrentLine.GetFileName(),
+ Line=VerCurrentLine.GetLineNo(),
+ ExtraData=VerCurrentLine.GetLineString())
+ #
+ # Validate file exist/format.
+ #
+ if IsValidPath(VerContent[1], GlobalData.gINF_MODULE_DIR):
+ IsValidFileFlag = True
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (VerContent[1]),
+ File=VerCurrentLine.GetFileName(),
+ Line=VerCurrentLine.GetLineNo(),
+ ExtraData=VerCurrentLine.GetLineString())
+ return False
+ if IsValidFileFlag:
+ VerContent[0] = ConvPathFromAbsToRel(VerContent[0],
+ GlobalData.gINF_MODULE_DIR)
+ InfBianryVerItemObj.SetFileName(VerContent[1])
+ if len(VerContent) >= 3:
+ #
+ # Add Target information
+ #
+ InfBianryVerItemObj.SetTarget(VerContent[2])
+ if len(VerContent) == 4:
+ if VerContent[3].strip() == '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
+ File=VerCurrentLine.GetFileName(),
+ Line=VerCurrentLine.GetLineNo(),
+ ExtraData=VerCurrentLine.GetLineString())
+ #
+ # Validate Feature Flag Express
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(VerContent[3].\
+ strip())
+ if not FeatureFlagRtv[0]:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
+ File=VerCurrentLine.GetFileName(),
+ Line=VerCurrentLine.GetLineNo(),
+ ExtraData=VerCurrentLine.GetLineString())
+ InfBianryVerItemObj.SetFeatureFlagExp(VerContent[3])
+
+ InfBianryVerItemObj.SetSupArchList(__SupArchList)
+
+ #
+ # Determine binary file name duplicate. Follow below rule:
+ #
+ # A binary filename must not be duplicated within
+ # a [Binaries] section. A binary filename may appear in
+ # multiple architectural [Binaries] sections. A binary
+ # filename listed in an architectural [Binaries] section
+ # must not be listed in the common architectural
+ # [Binaries] section.
+ #
+ # NOTE: This check will not report error now.
+ #
+ for Item in self.Binaries:
+ if Item.GetFileName() == InfBianryVerItemObj.GetFileName():
+ ItemSupArchList = Item.GetSupArchList()
+ for ItemArch in ItemSupArchList:
+ for VerItemObjArch in __SupArchList:
+ if ItemArch == VerItemObjArch:
+ #
+ # ST.ERR_INF_PARSER_ITEM_DUPLICATE
+ #
+ pass
+ if ItemArch.upper() == 'COMMON' or VerItemObjArch.upper() == 'COMMON':
+ #
+ # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
+ #
+ pass
+
+ if InfBianryVerItemObj is not None:
+ if (InfBianryVerItemObj) in self.Binaries:
+ BinariesList = self.Binaries[InfBianryVerItemObj]
+ BinariesList.append((InfBianryVerItemObj, VerComment))
+ self.Binaries[InfBianryVerItemObj] = BinariesList
+ else:
+ BinariesList = []
+ BinariesList.append((InfBianryVerItemObj, VerComment))
+ self.Binaries[InfBianryVerItemObj] = BinariesList
+
+ ## ParseCommonBinary
+ #
+ # ParseCommonBinary
+ #
+ def ParseCommonBinary(self, CommonBinary, __SupArchList):
+ #
+ # Check common binary definitions
+ # Type | FileName | Target | Family | TagName | FeatureFlagExp
+ #
+ for Item in CommonBinary:
+ IsValidFileFlag = False
+ ItemContent = Item[0]
+ ItemComment = Item[1]
+ CurrentLineOfItem = Item[2]
+ GlobalData.gINF_CURRENT_LINE = CurrentLineOfItem
+ InfBianryCommonItemObj = None
+ if ItemContent[0] == 'SUBTYPE_GUID':
+ if len(ItemContent) < 3:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (ItemContent[0], 3),
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+ return False
+ else:
+ if len(ItemContent) < 2:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (ItemContent[0], 2),
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+ return False
+
+ if len(ItemContent) > 7:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (ItemContent[0], 7),
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+ return False
+ if len(ItemContent) >= 2:
+ #
+ # Create a Common Object.
+ #
+ InfBianryCommonItemObj = InfBianryCommonItem()
+ #
+ # Convert Binary type.
+ #
+ BinaryFileType = ItemContent[0].strip()
+ if BinaryFileType == 'RAW' or BinaryFileType == 'ACPI' or BinaryFileType == 'ASL':
+ BinaryFileType = 'BIN'
+
+ if BinaryFileType not in DT.BINARY_FILE_TYPE_LIST:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FILETYPE % \
+ (DT.BINARY_FILE_TYPE_LIST.__str__()),
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+
+ if BinaryFileType == 'SUBTYPE_GUID':
+ BinaryFileType = 'FREEFORM'
+
+ if BinaryFileType == 'LIB' or BinaryFileType == 'UEFI_APP':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FILETYPE % \
+ (DT.BINARY_FILE_TYPE_LIST.__str__()),
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+
+ InfBianryCommonItemObj.SetType(BinaryFileType)
+ InfBianryCommonItemObj.SetCommonType(ItemContent[0])
+ FileName = ''
+ if BinaryFileType == 'FREEFORM':
+ InfBianryCommonItemObj.SetGuidValue(ItemContent[1])
+ if len(ItemContent) >= 3:
+ FileName = ItemContent[2]
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_FILENAME_NOT_EXIST,
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+ else:
+ FileName = ItemContent[1]
+ #
+ # Verify File exist or not
+ #
+ FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,
+ FileName)))
+ if not (ValidFile(FullFileName) or ValidFile(FileName)):
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (FileName),
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+ #
+ # Validate file exist/format.
+ #
+ if IsValidPath(FileName, GlobalData.gINF_MODULE_DIR):
+ IsValidFileFlag = True
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (FileName),
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+ return False
+ if IsValidFileFlag:
+ ItemContent[0] = ConvPathFromAbsToRel(ItemContent[0], GlobalData.gINF_MODULE_DIR)
+ InfBianryCommonItemObj.SetFileName(FileName)
+ if len(ItemContent) >= 3:
+ #
+ # Add Target information
+ #
+ if BinaryFileType != 'FREEFORM':
+ InfBianryCommonItemObj.SetTarget(ItemContent[2])
+
+ if len(ItemContent) >= 4:
+ #
+ # Add Family information
+ #
+ if BinaryFileType != 'FREEFORM':
+ InfBianryCommonItemObj.SetFamily(ItemContent[3])
+ else:
+ InfBianryCommonItemObj.SetTarget(ItemContent[3])
+
+ if len(ItemContent) >= 5:
+ #
+ # TagName entries are build system specific. If there
+ # is content in the entry, the tool must exit
+ # gracefully with an error message that indicates build
+ # system specific content cannot be distributed using
+ # the UDP
+ #
+ if BinaryFileType != 'FREEFORM':
+ if ItemContent[4].strip() != '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED % (ItemContent[4]),
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+ else:
+ InfBianryCommonItemObj.SetFamily(ItemContent[4])
+
+ if len(ItemContent) >= 6:
+ #
+ # Add FeatureFlagExp
+ #
+ if BinaryFileType != 'FREEFORM':
+ if ItemContent[5].strip() == '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+ #
+ # Validate Feature Flag Express
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(ItemContent[5].strip())
+ if not FeatureFlagRtv[0]:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+ InfBianryCommonItemObj.SetFeatureFlagExp(ItemContent[5])
+ else:
+ if ItemContent[5].strip() != '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED % (ItemContent[5]),
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+
+ if len(ItemContent) == 7:
+ if ItemContent[6].strip() == '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+ #
+ # Validate Feature Flag Express
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(ItemContent[6].strip())
+ if not FeatureFlagRtv[0]:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
+ File=CurrentLineOfItem.GetFileName(),
+ Line=CurrentLineOfItem.GetLineNo(),
+ ExtraData=CurrentLineOfItem.GetLineString())
+ InfBianryCommonItemObj.SetFeatureFlagExp(ItemContent[6])
+
+ InfBianryCommonItemObj.SetSupArchList(__SupArchList)
+
+ #
+ # Determine binary file name duplicate. Follow below rule:
+ #
+ # A binary filename must not be duplicated within
+ # a [Binaries] section. A binary filename may appear in
+ # multiple architectural [Binaries] sections. A binary
+ # filename listed in an architectural [Binaries] section
+ # must not be listed in the common architectural
+ # [Binaries] section.
+ #
+ # NOTE: This check will not report error now.
+ #
+# for Item in self.Binaries:
+# if Item.GetFileName() == InfBianryCommonItemObj.GetFileName():
+# ItemSupArchList = Item.GetSupArchList()
+# for ItemArch in ItemSupArchList:
+# for ComItemObjArch in __SupArchList:
+# if ItemArch == ComItemObjArch:
+# #
+# # ST.ERR_INF_PARSER_ITEM_DUPLICATE
+# #
+# pass
+#
+# if ItemArch.upper() == 'COMMON' or ComItemObjArch.upper() == 'COMMON':
+# #
+# # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
+# #
+# pass
+
+ if InfBianryCommonItemObj is not None:
+ if (InfBianryCommonItemObj) in self.Binaries:
+ BinariesList = self.Binaries[InfBianryCommonItemObj]
+ BinariesList.append((InfBianryCommonItemObj, ItemComment))
+ self.Binaries[InfBianryCommonItemObj] = BinariesList
+ else:
+ BinariesList = []
+ BinariesList.append((InfBianryCommonItemObj, ItemComment))
+ self.Binaries[InfBianryCommonItemObj] = BinariesList
+
+ def SetBinary(self, UiInf=None, Ver=None, CommonBinary=None, ArchList=None):
+
+ __SupArchList = []
+ for ArchItem in ArchList:
+ #
+ # Validate Arch
+ #
+ if (ArchItem == '' or ArchItem is None):
+ ArchItem = 'COMMON'
+ __SupArchList.append(ArchItem)
+
+ if UiInf is not None:
+ if len(UiInf) > 0:
+ #
+ # Check UI
+ #
+ for UiItem in UiInf:
+ IsValidFileFlag = False
+ InfBianryUiItemObj = None
+ UiContent = UiItem[0]
+ UiComment = UiItem[1]
+ UiCurrentLine = UiItem[2]
+ GlobalData.gINF_CURRENT_LINE = deepcopy(UiItem[2])
+ #
+ # Should not less than 2 elements
+ #
+ if len(UiContent) < 2:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (UiContent[0], 2),
+ File=UiCurrentLine.GetFileName(),
+ Line=UiCurrentLine.GetLineNo(),
+ ExtraData=UiCurrentLine.GetLineString())
+ return False
+
+ if len(UiContent) > 4:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (UiContent[0], 4),
+ File=UiCurrentLine.GetFileName(),
+ Line=UiCurrentLine.GetLineNo(),
+ ExtraData=UiCurrentLine.GetLineString())
+ return False
+ if len(UiContent) >= 2:
+ #
+ # Create an Ui Object.
+ #
+ InfBianryUiItemObj = InfBianryUiItem()
+ if UiContent[0] != 'UI':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_VER_TYPE % ('UI'),
+ File=UiCurrentLine.GetFileName(),
+ Line=UiCurrentLine.GetLineNo(),
+ ExtraData=UiCurrentLine.GetLineString())
+ InfBianryUiItemObj.SetUiTypeName(UiContent[0])
+ InfBianryUiItemObj.SetType(UiContent[0])
+ #
+ # Verify File exist or not
+ #
+ FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,
+ UiContent[1])))
+ if not (ValidFile(FullFileName) or ValidFile(UiContent[1])):
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (UiContent[1]),
+ File=UiCurrentLine.GetFileName(),
+ Line=UiCurrentLine.GetLineNo(),
+ ExtraData=UiCurrentLine.GetLineString())
+ #
+ # Validate file exist/format.
+ #
+ if IsValidPath(UiContent[1], GlobalData.gINF_MODULE_DIR):
+ IsValidFileFlag = True
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (UiContent[1]),
+ File=UiCurrentLine.GetFileName(),
+ Line=UiCurrentLine.GetLineNo(),
+ ExtraData=UiCurrentLine.GetLineString())
+ return False
+ if IsValidFileFlag:
+ UiContent[0] = ConvPathFromAbsToRel(UiContent[0], GlobalData.gINF_MODULE_DIR)
+ InfBianryUiItemObj.SetFileName(UiContent[1])
+ if len(UiContent) >= 3:
+ #
+ # Add Target information
+ #
+ InfBianryUiItemObj.SetTarget(UiContent[2])
+ if len(UiContent) == 4:
+ if UiContent[3].strip() == '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
+ File=UiCurrentLine.GetFileName(),
+ Line=UiCurrentLine.GetLineNo(),
+ ExtraData=UiCurrentLine.GetLineString())
+ #
+ # Validate Feature Flag Express
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(UiContent[3].strip())
+ if not FeatureFlagRtv[0]:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
+ File=UiCurrentLine.GetFileName(),
+ Line=UiCurrentLine.GetLineNo(),
+ ExtraData=UiCurrentLine.GetLineString())
+ InfBianryUiItemObj.SetFeatureFlagExp(UiContent[3])
+
+ InfBianryUiItemObj.SetSupArchList(__SupArchList)
+
+ #
+ # Determine binary file name duplicate. Follow below rule:
+ #
+ # A binary filename must not be duplicated within
+ # a [Binaries] section. A binary filename may appear in
+ # multiple architectural [Binaries] sections. A binary
+ # filename listed in an architectural [Binaries] section
+ # must not be listed in the common architectural
+ # [Binaries] section.
+ #
+ # NOTE: This check will not report error now.
+ #
+# for Item in self.Binaries:
+# if Item.GetFileName() == InfBianryUiItemObj.GetFileName():
+# ItemSupArchList = Item.GetSupArchList()
+# for ItemArch in ItemSupArchList:
+# for UiItemObjArch in __SupArchList:
+# if ItemArch == UiItemObjArch:
+# #
+# # ST.ERR_INF_PARSER_ITEM_DUPLICATE
+# #
+# pass
+# if ItemArch.upper() == 'COMMON' or UiItemObjArch.upper() == 'COMMON':
+# #
+# # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
+# #
+# pass
+
+ if InfBianryUiItemObj is not None:
+ if (InfBianryUiItemObj) in self.Binaries:
+ BinariesList = self.Binaries[InfBianryUiItemObj]
+ BinariesList.append((InfBianryUiItemObj, UiComment))
+ self.Binaries[InfBianryUiItemObj] = BinariesList
+ else:
+ BinariesList = []
+ BinariesList.append((InfBianryUiItemObj, UiComment))
+ self.Binaries[InfBianryUiItemObj] = BinariesList
+ if Ver is not None and len(Ver) > 0:
+ self.CheckVer(Ver, __SupArchList)
+ if CommonBinary and len(CommonBinary) > 0:
+ self.ParseCommonBinary(CommonBinary, __SupArchList)
+
+ return True
+
+ def GetBinary(self):
+ return self.Binaries
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py
index fdba5db983..1638e5336a 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py
@@ -1,87 +1,87 @@
-## @file
-# This file is used to define class objects of INF file [BuildOptions] section.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfBuildOptionObject
-'''
-
-from Library import GlobalData
-
-from Object.Parser.InfCommonObject import InfSectionCommonDef
-
-class InfBuildOptionItem():
- def __init__(self):
- self.Content = ''
- self.SupArchList = []
- self.AsBuildList = []
-
- def SetContent(self, Content):
- self.Content = Content
- def GetContent(self):
- return self.Content
-
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
- def GetSupArchList(self):
- return self.SupArchList
-
- #
- # AsBuild Information
- #
- def SetAsBuildList(self, AsBuildList):
- self.AsBuildList = AsBuildList
- def GetAsBuildList(self):
- return self.AsBuildList
-
-
-## INF BuildOption section
-# Macro define is not permitted for this section.
-#
-#
-class InfBuildOptionsObject(InfSectionCommonDef):
- def __init__(self):
- self.BuildOptions = []
- InfSectionCommonDef.__init__(self)
- ## SetBuildOptions function
- #
- # For BuildOptionName, need to validate its format
- # For BuildOptionValue, just ignore it.
- #
- # @param Arch Indicated which arch of build options belong to.
- # @param BuildOptCont A list contain BuildOption related information.
- # The element in the list contain 3 members.
- # BuildOptionName, BuildOptionValue and IsReplace
- # flag.
- #
- # @return True Build options set/validate successfully
- # @return False Build options set/validate failed
- #
- def SetBuildOptions(self, BuildOptCont, ArchList = None, SectionContent = ''):
-
- if not GlobalData.gIS_BINARY_INF:
-
- if SectionContent.strip() != '':
- InfBuildOptionItemObj = InfBuildOptionItem()
- InfBuildOptionItemObj.SetContent(SectionContent)
- InfBuildOptionItemObj.SetSupArchList(ArchList)
-
- self.BuildOptions.append(InfBuildOptionItemObj)
- else:
- #
- # For AsBuild INF file
- #
- if len(BuildOptCont) >= 1:
- InfBuildOptionItemObj = InfBuildOptionItem()
- InfBuildOptionItemObj.SetAsBuildList(BuildOptCont)
- InfBuildOptionItemObj.SetSupArchList(ArchList)
- self.BuildOptions.append(InfBuildOptionItemObj)
-
- return True
-
- def GetBuildOptions(self):
- return self.BuildOptions
+## @file
+# This file is used to define class objects of INF file [BuildOptions] section.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfBuildOptionObject
+'''
+
+from Library import GlobalData
+
+from Object.Parser.InfCommonObject import InfSectionCommonDef
+
+class InfBuildOptionItem():
+ def __init__(self):
+ self.Content = ''
+ self.SupArchList = []
+ self.AsBuildList = []
+
+ def SetContent(self, Content):
+ self.Content = Content
+ def GetContent(self):
+ return self.Content
+
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+
+ #
+ # AsBuild Information
+ #
+ def SetAsBuildList(self, AsBuildList):
+ self.AsBuildList = AsBuildList
+ def GetAsBuildList(self):
+ return self.AsBuildList
+
+
+## INF BuildOption section
+# Macro define is not permitted for this section.
+#
+#
+class InfBuildOptionsObject(InfSectionCommonDef):
+ def __init__(self):
+ self.BuildOptions = []
+ InfSectionCommonDef.__init__(self)
+ ## SetBuildOptions function
+ #
+ # For BuildOptionName, need to validate its format
+ # For BuildOptionValue, just ignore it.
+ #
+ # @param Arch Indicated which arch of build options belong to.
+ # @param BuildOptCont A list contain BuildOption related information.
+ # The element in the list contain 3 members.
+ # BuildOptionName, BuildOptionValue and IsReplace
+ # flag.
+ #
+ # @return True Build options set/validate successfully
+ # @return False Build options set/validate failed
+ #
+ def SetBuildOptions(self, BuildOptCont, ArchList = None, SectionContent = ''):
+
+ if not GlobalData.gIS_BINARY_INF:
+
+ if SectionContent.strip() != '':
+ InfBuildOptionItemObj = InfBuildOptionItem()
+ InfBuildOptionItemObj.SetContent(SectionContent)
+ InfBuildOptionItemObj.SetSupArchList(ArchList)
+
+ self.BuildOptions.append(InfBuildOptionItemObj)
+ else:
+ #
+ # For AsBuild INF file
+ #
+ if len(BuildOptCont) >= 1:
+ InfBuildOptionItemObj = InfBuildOptionItem()
+ InfBuildOptionItemObj.SetAsBuildList(BuildOptCont)
+ InfBuildOptionItemObj.SetSupArchList(ArchList)
+ self.BuildOptions.append(InfBuildOptionItemObj)
+
+ return True
+
+ def GetBuildOptions(self):
+ return self.BuildOptions
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfCommonObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfCommonObject.py
index aa23d08788..4e6c6f7ad7 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfCommonObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfCommonObject.py
@@ -1,156 +1,156 @@
-## @file
-# This file is used to define common class objects for INF file.
-# It will consumed by InfParser
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfCommonObject
-'''
-
-## InfLineCommentObject
-#
-# Comment Object for any line in the INF file
-#
-# #
-# # HeaderComment
-# #
-# Line # TailComment
-#
-class InfLineCommentObject():
- def __init__(self):
- self.HeaderComments = ''
- self.TailComments = ''
-
- def SetHeaderComments(self, HeaderComments):
- self.HeaderComments = HeaderComments
-
- def GetHeaderComments(self):
- return self.HeaderComments
-
- def SetTailComments(self, TailComments):
- self.TailComments = TailComments
-
- def GetTailComments(self):
- return self.TailComments
-
-## CurrentLine
-#
-class CurrentLine():
- def __init__(self):
- self.LineNo = ''
- self.LineString = ''
- self.FileName = ''
-
- ## SetLineNo
- #
- # @param LineNo: LineNo
- #
- def SetLineNo(self, LineNo):
- self.LineNo = LineNo
-
- ## GetLineNo
- #
- def GetLineNo(self):
- return self.LineNo
-
- ## SetLineString
- #
- # @param LineString: Line String content
- #
- def SetLineString(self, LineString):
- self.LineString = LineString
-
- ## GetLineString
- #
- def GetLineString(self):
- return self.LineString
-
- ## SetFileName
- #
- # @param FileName: File Name
- #
- def SetFileName(self, FileName):
- self.FileName = FileName
-
- ## GetFileName
- #
- def GetFileName(self):
- return self.FileName
-
-##
-# Inf Section common data
-#
-class InfSectionCommonDef():
- def __init__(self):
- #
- # #
- # # HeaderComments at here
- # #
- # [xxSection] TailComments at here
- # data
- #
- self.HeaderComments = ''
- self.TailComments = ''
- #
- # The support arch list of this section
- #
- self.SupArchList = []
-
- #
- # Store all section content
- # Key is supported Arch
- #
- self.AllContent = {}
-
- ## SetHeaderComments
- #
- # @param HeaderComments: HeaderComments
- #
- def SetHeaderComments(self, HeaderComments):
- self.HeaderComments = HeaderComments
-
- ## GetHeaderComments
- #
- def GetHeaderComments(self):
- return self.HeaderComments
-
- ## SetTailComments
- #
- # @param TailComments: TailComments
- #
- def SetTailComments(self, TailComments):
- self.TailComments = TailComments
-
- ## GetTailComments
- #
- def GetTailComments(self):
- return self.TailComments
-
- ## SetSupArchList
- #
- # @param Arch: Arch
- #
- def SetSupArchList(self, Arch):
- if Arch not in self.SupArchList:
- self.SupArchList.append(Arch)
-
- ## GetSupArchList
- #
- def GetSupArchList(self):
- return self.SupArchList
-
- ## SetAllContent
- #
- # @param ArchList: ArchList
- # @param Content: Content
- #
- def SetAllContent(self, Content):
- self.AllContent = Content
-
- ## GetAllContent
- #
- def GetAllContent(self):
- return self.AllContent
+## @file
+# This file is used to define common class objects for INF file.
+# It will consumed by InfParser
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfCommonObject
+'''
+
+## InfLineCommentObject
+#
+# Comment Object for any line in the INF file
+#
+# #
+# # HeaderComment
+# #
+# Line # TailComment
+#
+class InfLineCommentObject():
+ def __init__(self):
+ self.HeaderComments = ''
+ self.TailComments = ''
+
+ def SetHeaderComments(self, HeaderComments):
+ self.HeaderComments = HeaderComments
+
+ def GetHeaderComments(self):
+ return self.HeaderComments
+
+ def SetTailComments(self, TailComments):
+ self.TailComments = TailComments
+
+ def GetTailComments(self):
+ return self.TailComments
+
+## CurrentLine
+#
+class CurrentLine():
+ def __init__(self):
+ self.LineNo = ''
+ self.LineString = ''
+ self.FileName = ''
+
+ ## SetLineNo
+ #
+ # @param LineNo: LineNo
+ #
+ def SetLineNo(self, LineNo):
+ self.LineNo = LineNo
+
+ ## GetLineNo
+ #
+ def GetLineNo(self):
+ return self.LineNo
+
+ ## SetLineString
+ #
+ # @param LineString: Line String content
+ #
+ def SetLineString(self, LineString):
+ self.LineString = LineString
+
+ ## GetLineString
+ #
+ def GetLineString(self):
+ return self.LineString
+
+ ## SetFileName
+ #
+ # @param FileName: File Name
+ #
+ def SetFileName(self, FileName):
+ self.FileName = FileName
+
+ ## GetFileName
+ #
+ def GetFileName(self):
+ return self.FileName
+
+##
+# Inf Section common data
+#
+class InfSectionCommonDef():
+ def __init__(self):
+ #
+ # #
+ # # HeaderComments at here
+ # #
+ # [xxSection] TailComments at here
+ # data
+ #
+ self.HeaderComments = ''
+ self.TailComments = ''
+ #
+ # The support arch list of this section
+ #
+ self.SupArchList = []
+
+ #
+ # Store all section content
+ # Key is supported Arch
+ #
+ self.AllContent = {}
+
+ ## SetHeaderComments
+ #
+ # @param HeaderComments: HeaderComments
+ #
+ def SetHeaderComments(self, HeaderComments):
+ self.HeaderComments = HeaderComments
+
+ ## GetHeaderComments
+ #
+ def GetHeaderComments(self):
+ return self.HeaderComments
+
+ ## SetTailComments
+ #
+ # @param TailComments: TailComments
+ #
+ def SetTailComments(self, TailComments):
+ self.TailComments = TailComments
+
+ ## GetTailComments
+ #
+ def GetTailComments(self):
+ return self.TailComments
+
+ ## SetSupArchList
+ #
+ # @param Arch: Arch
+ #
+ def SetSupArchList(self, Arch):
+ if Arch not in self.SupArchList:
+ self.SupArchList.append(Arch)
+
+ ## GetSupArchList
+ #
+ def GetSupArchList(self):
+ return self.SupArchList
+
+ ## SetAllContent
+ #
+ # @param ArchList: ArchList
+ # @param Content: Content
+ #
+ def SetAllContent(self, Content):
+ self.AllContent = Content
+
+ ## GetAllContent
+ #
+ def GetAllContent(self):
+ return self.AllContent
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineCommonObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfDefineCommonObject.py
index 738a4c2dbf..05844834e8 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineCommonObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfDefineCommonObject.py
@@ -1,83 +1,83 @@
-## @file
-# This file is used to define common class objects of [Defines] section for INF file.
-# It will consumed by InfParser
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfDefineCommonObject
-'''
-
-from Object.Parser.InfCommonObject import InfLineCommentObject
-
-## InfDefineImageExeParamItem
-#
-class InfDefineImageExeParamItem():
- def __init__(self):
- self.CName = ''
- self.FeatureFlagExp = ''
- self.Comments = InfLineCommentObject()
-
- def SetCName(self, CName):
- self.CName = CName
- def GetCName(self):
- return self.CName
- def SetFeatureFlagExp(self, FeatureFlagExp):
- self.FeatureFlagExp = FeatureFlagExp
- def GetFeatureFlagExp(self):
- return self.FeatureFlagExp
-
-## InfDefineEntryPointItem
-#
-class InfDefineEntryPointItem(InfDefineImageExeParamItem):
- def __init__(self):
- InfDefineImageExeParamItem.__init__(self)
-
-## InfDefineUnloadImageItem
-#
-class InfDefineUnloadImageItem(InfDefineImageExeParamItem):
- def __init__(self):
- InfDefineImageExeParamItem.__init__(self)
-
-## InfDefineConstructorItem
-#
-class InfDefineConstructorItem(InfDefineImageExeParamItem):
- def __init__(self):
- InfDefineImageExeParamItem.__init__(self)
- self.SupModList = []
-
- def SetSupModList(self, SupModList):
- self.SupModList = SupModList
- def GetSupModList(self):
- return self.SupModList
-
-## InfDefineDestructorItem
-#
-class InfDefineDestructorItem(InfDefineImageExeParamItem):
- def __init__(self):
- InfDefineImageExeParamItem.__init__(self)
- self.SupModList = []
-
- def SetSupModList(self, SupModList):
- self.SupModList = SupModList
- def GetSupModList(self):
- return self.SupModList
-
-## InfDefineLibraryItem
-#
-class InfDefineLibraryItem():
- def __init__(self):
- self.LibraryName = ''
- self.Types = []
- self.Comments = InfLineCommentObject()
-
- def SetLibraryName(self, Name):
- self.LibraryName = Name
- def GetLibraryName(self):
- return self.LibraryName
- def SetTypes(self, Type):
- self.Types = Type
- def GetTypes(self):
- return self.Types
+## @file
+# This file is used to define common class objects of [Defines] section for INF file.
+# It will consumed by InfParser
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfDefineCommonObject
+'''
+
+from Object.Parser.InfCommonObject import InfLineCommentObject
+
+## InfDefineImageExeParamItem
+#
+class InfDefineImageExeParamItem():
+ def __init__(self):
+ self.CName = ''
+ self.FeatureFlagExp = ''
+ self.Comments = InfLineCommentObject()
+
+ def SetCName(self, CName):
+ self.CName = CName
+ def GetCName(self):
+ return self.CName
+ def SetFeatureFlagExp(self, FeatureFlagExp):
+ self.FeatureFlagExp = FeatureFlagExp
+ def GetFeatureFlagExp(self):
+ return self.FeatureFlagExp
+
+## InfDefineEntryPointItem
+#
+class InfDefineEntryPointItem(InfDefineImageExeParamItem):
+ def __init__(self):
+ InfDefineImageExeParamItem.__init__(self)
+
+## InfDefineUnloadImageItem
+#
+class InfDefineUnloadImageItem(InfDefineImageExeParamItem):
+ def __init__(self):
+ InfDefineImageExeParamItem.__init__(self)
+
+## InfDefineConstructorItem
+#
+class InfDefineConstructorItem(InfDefineImageExeParamItem):
+ def __init__(self):
+ InfDefineImageExeParamItem.__init__(self)
+ self.SupModList = []
+
+ def SetSupModList(self, SupModList):
+ self.SupModList = SupModList
+ def GetSupModList(self):
+ return self.SupModList
+
+## InfDefineDestructorItem
+#
+class InfDefineDestructorItem(InfDefineImageExeParamItem):
+ def __init__(self):
+ InfDefineImageExeParamItem.__init__(self)
+ self.SupModList = []
+
+ def SetSupModList(self, SupModList):
+ self.SupModList = SupModList
+ def GetSupModList(self):
+ return self.SupModList
+
+## InfDefineLibraryItem
+#
+class InfDefineLibraryItem():
+ def __init__(self):
+ self.LibraryName = ''
+ self.Types = []
+ self.Comments = InfLineCommentObject()
+
+ def SetLibraryName(self, Name):
+ self.LibraryName = Name
+ def GetLibraryName(self):
+ return self.LibraryName
+ def SetTypes(self, Type):
+ self.Types = Type
+ def GetTypes(self):
+ return self.Types
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py
index a1b691ff03..bd3e06e4fa 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py
@@ -1,1002 +1,1002 @@
-## @file
-# This file is used to define class objects of [Defines] section for INF file.
-# It will consumed by InfParser
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfDefineObject
-'''
-
-import os
-import re
-
-from Logger import StringTable as ST
-from Logger import ToolError
-from Library import GlobalData
-from Library import DataType as DT
-from Library.StringUtils import GetSplitValueList
-from Library.Misc import CheckGuidRegFormat
-from Library.Misc import Sdict
-from Library.Misc import ConvPathFromAbsToRel
-from Library.Misc import ValidateUNIFilePath
-from Library.ExpressionValidate import IsValidFeatureFlagExp
-from Library.ParserValidate import IsValidWord
-from Library.ParserValidate import IsValidInfMoudleType
-from Library.ParserValidate import IsValidHex
-from Library.ParserValidate import IsValidHexVersion
-from Library.ParserValidate import IsValidDecVersion
-from Library.ParserValidate import IsValidCVariableName
-from Library.ParserValidate import IsValidBoolType
-from Library.ParserValidate import IsValidPath
-from Library.ParserValidate import IsValidFamily
-from Library.ParserValidate import IsValidIdentifier
-from Library.ParserValidate import IsValidDecVersionVal
-from Object.Parser.InfCommonObject import InfLineCommentObject
-from Object.Parser.InfCommonObject import CurrentLine
-from Object.Parser.InfCommonObject import InfSectionCommonDef
-from Object.Parser.InfMisc import ErrorInInf
-from Object.Parser.InfDefineCommonObject import InfDefineLibraryItem
-from Object.Parser.InfDefineCommonObject import InfDefineEntryPointItem
-from Object.Parser.InfDefineCommonObject import InfDefineUnloadImageItem
-from Object.Parser.InfDefineCommonObject import InfDefineConstructorItem
-from Object.Parser.InfDefineCommonObject import InfDefineDestructorItem
-
-class InfDefSectionOptionRomInfo():
- def __init__(self):
- self.PciVendorId = None
- self.PciDeviceId = None
- self.PciClassCode = None
- self.PciRevision = None
- self.PciCompress = None
- self.CurrentLine = ['', -1, '']
- def SetPciVendorId(self, PciVendorId, Comments):
- #
- # Value has been set before.
- #
- if self.PciVendorId is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_VENDOR_ID),
- LineInfo=self.CurrentLine)
- return False
- #
- # The PciVendorId should be hex string.
- #
- if (IsValidHex(PciVendorId)):
- self.PciVendorId = InfDefMember()
- self.PciVendorId.SetValue(PciVendorId)
- self.PciVendorId.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciVendorId),
- LineInfo=self.CurrentLine)
- return False
-
- def GetPciVendorId(self):
- return self.PciVendorId
-
- def SetPciDeviceId(self, PciDeviceId, Comments):
- #
- # Value has been set before.
- #
- if self.PciDeviceId is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_DEVICE_ID),
- LineInfo=self.CurrentLine)
- return False
- #
- # The PciDeviceId should be hex string.
- #
- if (IsValidHex(PciDeviceId)):
- self.PciDeviceId = InfDefMember()
- self.PciDeviceId.SetValue(PciDeviceId)
- self.PciDeviceId.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciDeviceId),
- LineInfo=self.CurrentLine)
- return False
-
- def GetPciDeviceId(self):
- return self.PciDeviceId
-
- def SetPciClassCode(self, PciClassCode, Comments):
- #
- # Value has been set before.
- #
- if self.PciClassCode is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_CLASS_CODE),
- LineInfo=self.CurrentLine)
- return False
- #
- # The PciClassCode should be 4 bytes hex string.
- #
- if (IsValidHex(PciClassCode)):
- self.PciClassCode = InfDefMember()
- self.PciClassCode.SetValue(PciClassCode)
- self.PciClassCode.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%\
- (PciClassCode),
- LineInfo=self.CurrentLine)
- return False
-
- def GetPciClassCode(self):
- return self.PciClassCode
-
- def SetPciRevision(self, PciRevision, Comments):
- #
- # Value has been set before.
- #
- if self.PciRevision is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_REVISION),
- LineInfo=self.CurrentLine)
- return False
- #
- # The PciRevision should be 4 bytes hex string.
- #
- if (IsValidHex(PciRevision)):
- self.PciRevision = InfDefMember()
- self.PciRevision.SetValue(PciRevision)
- self.PciRevision.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciRevision),
- LineInfo=self.CurrentLine)
- return False
-
- def GetPciRevision(self):
- return self.PciRevision
-
- def SetPciCompress(self, PciCompress, Comments):
- #
- # Value has been set before.
- #
- if self.PciCompress is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_COMPRESS),
- LineInfo=self.CurrentLine)
- return False
-
- #
- # The PciCompress should be 'TRUE' or 'FALSE'.
- #
- if (PciCompress == 'TRUE' or PciCompress == 'FALSE'):
- self.PciCompress = InfDefMember()
- self.PciCompress.SetValue(PciCompress)
- self.PciCompress.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciCompress),
- LineInfo=self.CurrentLine)
- return False
- def GetPciCompress(self):
- return self.PciCompress
-##
-# INF [Define] section Object
-#
-class InfDefSection(InfDefSectionOptionRomInfo):
- def __init__(self):
- self.BaseName = None
- self.FileGuid = None
- self.ModuleType = None
- self.ModuleUniFileName = None
- self.InfVersion = None
- self.EdkReleaseVersion = None
- self.UefiSpecificationVersion = None
- self.PiSpecificationVersion = None
- self.LibraryClass = []
- self.Package = None
- self.VersionString = None
- self.PcdIsDriver = None
- self.EntryPoint = []
- self.UnloadImages = []
- self.Constructor = []
- self.Destructor = []
- self.Shadow = None
- self.CustomMakefile = []
- self.Specification = []
- self.UefiHiiResourceSection = None
- self.DpxSource = []
- self.CurrentLine = ['', -1, '']
- InfDefSectionOptionRomInfo.__init__(self)
-
- ## SetHeadComment
- #
- # @param BaseName: BaseName
- #
- def SetBaseName(self, BaseName, Comments):
- #
- # Value has been set before.
- #
- if self.BaseName is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_BASE_NAME),
- LineInfo=self.CurrentLine)
- return False
- if not (BaseName == '' or BaseName is None):
- if IsValidWord(BaseName) and not BaseName.startswith("_"):
- self.BaseName = InfDefMember()
- self.BaseName.SetValue(BaseName)
- self.BaseName.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_NAME_INVALID%(BaseName),
- LineInfo=self.CurrentLine)
- return False
-
- ## GetBaseName
- #
- def GetBaseName(self):
- return self.BaseName
-
- ## SetFileGuid
- #
- # @param FileGuid: FileGuid
- #
- def SetFileGuid(self, FileGuid, Comments):
- #
- # Value has been set before.
- #
- if self.FileGuid is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
- %(DT.TAB_INF_DEFINES_FILE_GUID),
- LineInfo=self.CurrentLine)
- return False
- #
- # Do verification of GUID content/format
- #
- if (CheckGuidRegFormat(FileGuid)):
- self.FileGuid = InfDefMember()
- self.FileGuid.SetValue(FileGuid)
- self.FileGuid.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_GUID_INVALID%(FileGuid),
- LineInfo=self.CurrentLine)
- return False
-
- ## GetFileGuid
- #
- def GetFileGuid(self):
- return self.FileGuid
-
- ## SetModuleType
- #
- # @param ModuleType: ModuleType
- #
- def SetModuleType(self, ModuleType, Comments):
- #
- # Value has been set before.
- #
- if self.ModuleType is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
- %(DT.TAB_INF_DEFINES_MODULE_TYPE),
- LineInfo=self.CurrentLine)
- return False
- #
- # Valid Module Type or not
- #
- if (IsValidInfMoudleType(ModuleType)):
- self.ModuleType = InfDefMember()
- self.ModuleType.SetValue(ModuleType)
- self.ModuleType.CurrentLine = CurrentLine()
- self.ModuleType.CurrentLine.SetLineNo(self.CurrentLine[1])
- self.ModuleType.CurrentLine.SetLineString(self.CurrentLine[2])
- self.ModuleType.CurrentLine.SetFileName(self.CurrentLine[0])
- self.ModuleType.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID%\
- (ModuleType),
- LineInfo=self.CurrentLine)
- return False
-
- ## GetModuleType
- #
- def GetModuleType(self):
- return self.ModuleType
-
- ## SetModuleUniFileName
- #
- # @param ModuleUniFileName: ModuleUniFileName
- #
- def SetModuleUniFileName(self, ModuleUniFileName, Comments):
- if Comments:
- pass
- if self.ModuleUniFileName is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_MODULE_UNI_FILE),
- LineInfo=self.CurrentLine)
- self.ModuleUniFileName = ModuleUniFileName
-
- ## GetModuleType
- #
- def GetModuleUniFileName(self):
- return self.ModuleUniFileName
-
- ## SetInfVersion
- #
- # @param InfVersion: InfVersion
- #
- def SetInfVersion(self, InfVersion, Comments):
- #
- # Value has been set before.
- #
- if self.InfVersion is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
- %(DT.TAB_INF_DEFINES_INF_VERSION),
- LineInfo=self.CurrentLine)
- return False
- #
- # The InfVersion should be 4 bytes hex string.
- #
- if (IsValidHex(InfVersion)):
- if (InfVersion < '0x00010005'):
- ErrorInInf(ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF,
- ErrorCode=ToolError.EDK1_INF_ERROR,
- LineInfo=self.CurrentLine)
- elif IsValidDecVersionVal(InfVersion):
- if (InfVersion < 65541):
- ErrorInInf(ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF,
- ErrorCode=ToolError.EDK1_INF_ERROR,
- LineInfo=self.CurrentLine)
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(InfVersion),
- LineInfo=self.CurrentLine)
- return False
-
- self.InfVersion = InfDefMember()
- self.InfVersion.SetValue(InfVersion)
- self.InfVersion.Comments = Comments
- return True
-
- ## GetInfVersion
- #
- def GetInfVersion(self):
- return self.InfVersion
-
- ## SetEdkReleaseVersion
- #
- # @param EdkReleaseVersion: EdkReleaseVersion
- #
- def SetEdkReleaseVersion(self, EdkReleaseVersion, Comments):
- #
- # Value has been set before.
- #
- if self.EdkReleaseVersion is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
- %(DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION),
- LineInfo=self.CurrentLine)
- return False
- #
- # The EdkReleaseVersion should be 4 bytes hex string.
- #
- if IsValidHexVersion(EdkReleaseVersion) or \
- IsValidDecVersionVal(EdkReleaseVersion):
- self.EdkReleaseVersion = InfDefMember()
- self.EdkReleaseVersion.SetValue(EdkReleaseVersion)
- self.EdkReleaseVersion.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\
- %(EdkReleaseVersion),
- LineInfo=self.CurrentLine)
- return False
-
- ## GetEdkReleaseVersion
- #
- def GetEdkReleaseVersion(self):
- return self.EdkReleaseVersion
-
- ## SetUefiSpecificationVersion
- #
- # @param UefiSpecificationVersion: UefiSpecificationVersion
- #
- def SetUefiSpecificationVersion(self, UefiSpecificationVersion, Comments):
- #
- # Value has been set before.
- #
- if self.UefiSpecificationVersion is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
- %(DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION),
- LineInfo=self.CurrentLine)
- return False
- #
- # The EdkReleaseVersion should be 4 bytes hex string.
- #
- if IsValidHexVersion(UefiSpecificationVersion) or \
- IsValidDecVersionVal(UefiSpecificationVersion):
- self.UefiSpecificationVersion = InfDefMember()
- self.UefiSpecificationVersion.SetValue(UefiSpecificationVersion)
- self.UefiSpecificationVersion.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\
- %(UefiSpecificationVersion),
- LineInfo=self.CurrentLine)
- return False
-
- ## GetUefiSpecificationVersion
- #
- def GetUefiSpecificationVersion(self):
- return self.UefiSpecificationVersion
-
- ## SetPiSpecificationVersion
- #
- # @param PiSpecificationVersion: PiSpecificationVersion
- #
- def SetPiSpecificationVersion(self, PiSpecificationVersion, Comments):
- #
- # Value has been set before.
- #
- if self.PiSpecificationVersion is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
- %(DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION),
- LineInfo=self.CurrentLine)
- return False
- #
- # The EdkReleaseVersion should be 4 bytes hex string.
- #
- if IsValidHexVersion(PiSpecificationVersion) or \
- IsValidDecVersionVal(PiSpecificationVersion):
- self.PiSpecificationVersion = InfDefMember()
- self.PiSpecificationVersion.SetValue(PiSpecificationVersion)
- self.PiSpecificationVersion.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\
- %(PiSpecificationVersion),
- LineInfo=self.CurrentLine)
- return False
-
- ## GetPiSpecificationVersion
- #
- def GetPiSpecificationVersion(self):
- return self.PiSpecificationVersion
-
- ## SetLibraryClass
- #
- # @param LibraryClass: LibraryClass
- #
- def SetLibraryClass(self, LibraryClass, Comments):
- ValueList = GetSplitValueList(LibraryClass)
- Name = ValueList[0]
- if IsValidWord(Name):
- InfDefineLibraryItemObj = InfDefineLibraryItem()
- InfDefineLibraryItemObj.SetLibraryName(Name)
- InfDefineLibraryItemObj.Comments = Comments
- if len(ValueList) == 2:
- Type = ValueList[1]
- TypeList = GetSplitValueList(Type, ' ')
- TypeList = [Type for Type in TypeList if Type != '']
- for Item in TypeList:
- if Item not in DT.MODULE_LIST:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Item),
- LineInfo=self.CurrentLine)
- return False
- InfDefineLibraryItemObj.SetTypes(TypeList)
- self.LibraryClass.append(InfDefineLibraryItemObj)
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Name),
- LineInfo=self.CurrentLine)
- return False
-
- return True
-
- def GetLibraryClass(self):
- return self.LibraryClass
-
- def SetVersionString(self, VersionString, Comments):
- #
- # Value has been set before.
- #
- if self.VersionString is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
- %(DT.TAB_INF_DEFINES_VERSION_STRING),
- LineInfo=self.CurrentLine)
- return False
- if not IsValidDecVersion(VersionString):
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\
- %(VersionString),
- LineInfo=self.CurrentLine)
- self.VersionString = InfDefMember()
- self.VersionString.SetValue(VersionString)
- self.VersionString.Comments = Comments
- return True
-
-
- def GetVersionString(self):
- return self.VersionString
-
- def SetPcdIsDriver(self, PcdIsDriver, Comments):
- #
- # Value has been set before.
- #
- if self.PcdIsDriver is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
- %(DT.TAB_INF_DEFINES_PCD_IS_DRIVER),
- LineInfo=self.CurrentLine)
- return False
- if PcdIsDriver == 'PEI_PCD_DRIVER' or PcdIsDriver == 'DXE_PCD_DRIVER':
- self.PcdIsDriver = InfDefMember()
- self.PcdIsDriver.SetValue(PcdIsDriver)
- self.PcdIsDriver.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PcdIsDriver),
- LineInfo=self.CurrentLine)
- return False
-
- def GetPcdIsDriver(self):
- return self.PcdIsDriver
-
- #
- # SetEntryPoint
- #
- def SetEntryPoint(self, EntryPoint, Comments):
- #
- # It can be a list
- #
- ValueList = []
- TokenList = GetSplitValueList(EntryPoint, DT.TAB_VALUE_SPLIT)
- ValueList[0:len(TokenList)] = TokenList
- InfDefineEntryPointItemObj = InfDefineEntryPointItem()
- if not IsValidCVariableName(ValueList[0]):
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%\
- (ValueList[0]),
- LineInfo=self.CurrentLine)
- InfDefineEntryPointItemObj.SetCName(ValueList[0])
- if len(ValueList) == 2:
- if ValueList[1].strip() == '':
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%\
- (ValueList[1]),
- LineInfo=self.CurrentLine)
- #
- # Validate FFE
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[1].strip())
- if not FeatureFlagRtv[0]:
- ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%\
- (FeatureFlagRtv[1]),
- LineInfo=self.CurrentLine)
- InfDefineEntryPointItemObj.SetFeatureFlagExp(ValueList[1])
- if len(ValueList) > 2:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(EntryPoint),
- LineInfo=self.CurrentLine)
- InfDefineEntryPointItemObj.Comments = Comments
- self.EntryPoint.append(InfDefineEntryPointItemObj)
-
- def GetEntryPoint(self):
- return self.EntryPoint
-
- #
- # SetUnloadImages
- #
- def SetUnloadImages(self, UnloadImages, Comments):
- #
- # It can be a list
- #
- ValueList = []
- TokenList = GetSplitValueList(UnloadImages, DT.TAB_VALUE_SPLIT)
- ValueList[0:len(TokenList)] = TokenList
- InfDefineUnloadImageItemObj = InfDefineUnloadImageItem()
- if not IsValidCVariableName(ValueList[0]):
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[0]),
- LineInfo=self.CurrentLine)
- InfDefineUnloadImageItemObj.SetCName(ValueList[0])
- if len(ValueList) == 2:
- if ValueList[1].strip() == '':
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[1]),
- LineInfo=self.CurrentLine)
- #
- # Validate FFE
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[1].strip())
- if not FeatureFlagRtv[0]:
- ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
- LineInfo=self.CurrentLine)
- InfDefineUnloadImageItemObj.SetFeatureFlagExp(ValueList[1])
-
- if len(ValueList) > 2:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(UnloadImages),
- LineInfo=self.CurrentLine)
- InfDefineUnloadImageItemObj.Comments = Comments
- self.UnloadImages.append(InfDefineUnloadImageItemObj)
-
- def GetUnloadImages(self):
- return self.UnloadImages
-
- #
- # SetConstructor
- #
- def SetConstructor(self, Constructor, Comments):
- #
- # It can be a list
- #
- ValueList = []
- TokenList = GetSplitValueList(Constructor, DT.TAB_VALUE_SPLIT)
- ValueList[0:len(TokenList)] = TokenList
- InfDefineConstructorItemObj = InfDefineConstructorItem()
- if not IsValidCVariableName(ValueList[0]):
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[0]),
- LineInfo=self.CurrentLine)
- InfDefineConstructorItemObj.SetCName(ValueList[0])
- if len(ValueList) >= 2:
- ModList = GetSplitValueList(ValueList[1], ' ')
- if ValueList[1].strip() == '':
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[1]),
- LineInfo=self.CurrentLine)
- for ModItem in ModList:
- if ModItem not in DT.MODULE_LIST:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID%(ModItem),
- LineInfo=self.CurrentLine)
- InfDefineConstructorItemObj.SetSupModList(ModList)
- if len(ValueList) == 3:
- if ValueList[2].strip() == '':
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[2]),
- LineInfo=self.CurrentLine)
- #
- # Validate FFE
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[2].strip())
- if not FeatureFlagRtv[0]:
- ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[2]),
- LineInfo=self.CurrentLine)
- InfDefineConstructorItemObj.SetFeatureFlagExp(ValueList[2])
-
- if len(ValueList) > 3:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Constructor),
- LineInfo=self.CurrentLine)
- InfDefineConstructorItemObj.Comments = Comments
- self.Constructor.append(InfDefineConstructorItemObj)
-
- def GetConstructor(self):
- return self.Constructor
-
- #
- # SetDestructor
- #
- def SetDestructor(self, Destructor, Comments):
- #
- # It can be a list and only 1 set to TRUE
- #
- ValueList = []
- TokenList = GetSplitValueList(Destructor, DT.TAB_VALUE_SPLIT)
- ValueList[0:len(TokenList)] = TokenList
- InfDefineDestructorItemObj = InfDefineDestructorItem()
- if not IsValidCVariableName(ValueList[0]):
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[0]),
- LineInfo=self.CurrentLine)
- InfDefineDestructorItemObj.SetCName(ValueList[0])
- if len(ValueList) >= 2:
- ModList = GetSplitValueList(ValueList[1].strip(), ' ')
- if ValueList[1].strip() == '':
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[1]),
- LineInfo=self.CurrentLine)
- for ModItem in ModList:
- if ModItem not in DT.MODULE_LIST:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID%(ModItem),
- LineInfo=self.CurrentLine)
- InfDefineDestructorItemObj.SetSupModList(ModList)
- if len(ValueList) == 3:
- if ValueList[2].strip() == '':
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[2]),
- LineInfo=self.CurrentLine)
- #
- # Validate FFE
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[2].strip())
- if not FeatureFlagRtv[0]:
- ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
- LineInfo=self.CurrentLine)
- InfDefineDestructorItemObj.SetFeatureFlagExp(ValueList[2])
-
- if len(ValueList) > 3:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Destructor),
- LineInfo=self.CurrentLine)
-
- InfDefineDestructorItemObj.Comments = Comments
- self.Destructor.append(InfDefineDestructorItemObj)
-
- def GetDestructor(self):
- return self.Destructor
-
- def SetShadow(self, Shadow, Comments):
- #
- # Value has been set before.
- #
- if self.Shadow is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_SHADOW),
- LineInfo=self.CurrentLine)
- return False
- if (IsValidBoolType(Shadow)):
- self.Shadow = InfDefMember()
- self.Shadow.SetValue(Shadow)
- self.Shadow.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Shadow),
- LineInfo=self.CurrentLine)
- return False
- def GetShadow(self):
- return self.Shadow
-
- #
- # <Family> ::= {"MSFT"} {"GCC"}
- # <CustomMake> ::= [<Family> "|"] <Filename>
- #
- def SetCustomMakefile(self, CustomMakefile, Comments):
- if not (CustomMakefile == '' or CustomMakefile is None):
- ValueList = GetSplitValueList(CustomMakefile)
- if len(ValueList) == 1:
- FileName = ValueList[0]
- Family = ''
- else:
- Family = ValueList[0]
- FileName = ValueList[1]
- Family = Family.strip()
- if Family != '':
- if not IsValidFamily(Family):
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Family),
- LineInfo=self.CurrentLine)
- return False
- #
- # The MakefileName specified file should exist
- #
- IsValidFileFlag = False
- ModulePath = os.path.split(self.CurrentLine[0])[0]
- if IsValidPath(FileName, ModulePath):
- IsValidFileFlag = True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(FileName),
- LineInfo=self.CurrentLine)
- return False
- if IsValidFileFlag:
- FileName = ConvPathFromAbsToRel(FileName, GlobalData.gINF_MODULE_DIR)
- self.CustomMakefile.append((Family, FileName, Comments))
- IsValidFileFlag = False
- return True
- else:
- return False
-
- def GetCustomMakefile(self):
- return self.CustomMakefile
-
- #
- # ["SPEC" <Spec> <EOL>]*{0,}
- # <Spec> ::= <Word> "=" <VersionVal>
- # <VersionVal> ::= {<HexVersion>] {<DecVersion>}
- # <HexNumber> ::= "0x" [<HexDigit>]{1,}
- # <DecVersion> ::= (0-9){1,} ["." (0-9){1,2}]
- #
- def SetSpecification(self, Specification, Comments):
- #
- # Valid the value of Specification
- #
- __ValueList = []
- TokenList = GetSplitValueList(Specification, DT.TAB_EQUAL_SPLIT, 1)
- __ValueList[0:len(TokenList)] = TokenList
- if len(__ValueList) != 2:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_NO_NAME + ' Or ' + ST.ERR_INF_PARSER_DEFINE_ITEM_NO_VALUE,
- LineInfo=self.CurrentLine)
- Name = __ValueList[0].strip()
- Version = __ValueList[1].strip()
- if IsValidIdentifier(Name):
- if IsValidDecVersion(Version):
- self.Specification.append((Name, Version, Comments))
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Version),
- LineInfo=self.CurrentLine)
- return False
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Name),
- LineInfo=self.CurrentLine)
- return False
- return True
-
- def GetSpecification(self):
- return self.Specification
-
- #
- # [<UefiHiiResource> <EOL>]{0,1}
- # <UefiHiiResource> ::= "UEFI_HII_RESOURCE_SECTION" "=" <BoolType>
- #
- def SetUefiHiiResourceSection(self, UefiHiiResourceSection, Comments):
- #
- # Value has been set before.
- #
- if self.UefiHiiResourceSection is not None:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND
- %(DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION),
- LineInfo=self.CurrentLine)
- return False
- if not (UefiHiiResourceSection == '' or UefiHiiResourceSection is None):
- if (IsValidBoolType(UefiHiiResourceSection)):
- self.UefiHiiResourceSection = InfDefMember()
- self.UefiHiiResourceSection.SetValue(UefiHiiResourceSection)
- self.UefiHiiResourceSection.Comments = Comments
- return True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(UefiHiiResourceSection),
- LineInfo=self.CurrentLine)
- return False
- else:
- return False
-
- def GetUefiHiiResourceSection(self):
- return self.UefiHiiResourceSection
-
- def SetDpxSource(self, DpxSource, Comments):
- #
- # The MakefileName specified file should exist
- #
- IsValidFileFlag = False
- ModulePath = os.path.split(self.CurrentLine[0])[0]
- if IsValidPath(DpxSource, ModulePath):
- IsValidFileFlag = True
- else:
- ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(DpxSource),
- LineInfo=self.CurrentLine)
- return False
- if IsValidFileFlag:
- DpxSource = ConvPathFromAbsToRel(DpxSource,
- GlobalData.gINF_MODULE_DIR)
- self.DpxSource.append((DpxSource, Comments))
- IsValidFileFlag = False
- return True
-
- def GetDpxSource(self):
- return self.DpxSource
-
-gFUNCTION_MAPPING_FOR_DEFINE_SECTION = {
- #
- # Required Fields
- #
- DT.TAB_INF_DEFINES_BASE_NAME : InfDefSection.SetBaseName,
- DT.TAB_INF_DEFINES_FILE_GUID : InfDefSection.SetFileGuid,
- DT.TAB_INF_DEFINES_MODULE_TYPE : InfDefSection.SetModuleType,
- #
- # Required by EDKII style INF file
- #
- DT.TAB_INF_DEFINES_INF_VERSION : InfDefSection.SetInfVersion,
- #
- # Optional Fields
- #
- DT.TAB_INF_DEFINES_MODULE_UNI_FILE : InfDefSection.SetModuleUniFileName,
- DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION : InfDefSection.SetEdkReleaseVersion,
- DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION : InfDefSection.SetUefiSpecificationVersion,
- DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION : InfDefSection.SetPiSpecificationVersion,
- DT.TAB_INF_DEFINES_LIBRARY_CLASS : InfDefSection.SetLibraryClass,
- DT.TAB_INF_DEFINES_VERSION_STRING : InfDefSection.SetVersionString,
- DT.TAB_INF_DEFINES_PCD_IS_DRIVER : InfDefSection.SetPcdIsDriver,
- DT.TAB_INF_DEFINES_ENTRY_POINT : InfDefSection.SetEntryPoint,
- DT.TAB_INF_DEFINES_UNLOAD_IMAGE : InfDefSection.SetUnloadImages,
- DT.TAB_INF_DEFINES_CONSTRUCTOR : InfDefSection.SetConstructor,
- DT.TAB_INF_DEFINES_DESTRUCTOR : InfDefSection.SetDestructor,
- DT.TAB_INF_DEFINES_SHADOW : InfDefSection.SetShadow,
- DT.TAB_INF_DEFINES_PCI_VENDOR_ID : InfDefSection.SetPciVendorId,
- DT.TAB_INF_DEFINES_PCI_DEVICE_ID : InfDefSection.SetPciDeviceId,
- DT.TAB_INF_DEFINES_PCI_CLASS_CODE : InfDefSection.SetPciClassCode,
- DT.TAB_INF_DEFINES_PCI_REVISION : InfDefSection.SetPciRevision,
- DT.TAB_INF_DEFINES_PCI_COMPRESS : InfDefSection.SetPciCompress,
- DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE : InfDefSection.SetCustomMakefile,
- DT.TAB_INF_DEFINES_SPEC : InfDefSection.SetSpecification,
- DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION : InfDefSection.SetUefiHiiResourceSection,
- DT.TAB_INF_DEFINES_DPX_SOURCE : InfDefSection.SetDpxSource
-}
-
-## InfDefMember
-#
-#
-class InfDefMember():
- def __init__(self, Name='', Value=''):
- self.Comments = InfLineCommentObject()
- self.Name = Name
- self.Value = Value
- self.CurrentLine = CurrentLine()
- def GetName(self):
- return self.Name
- def SetName(self, Name):
- self.Name = Name
- def GetValue(self):
- return self.Value
- def SetValue(self, Value):
- self.Value = Value
-
-## InfDefObject
-#
-#
-class InfDefObject(InfSectionCommonDef):
- def __init__(self):
- self.Defines = Sdict()
- InfSectionCommonDef.__init__(self)
- def SetDefines(self, DefineContent, Arch = None):
- #
- # Validate Arch
- #
- HasFoundInfVersionFalg = False
- LineInfo = ['', -1, '']
- ArchListString = ' '.join(Arch)
- #
- # Parse Define items.
- #
- for InfDefMemberObj in DefineContent:
- ProcessFunc = None
- Name = InfDefMemberObj.GetName()
- Value = InfDefMemberObj.GetValue()
- if Name == DT.TAB_INF_DEFINES_MODULE_UNI_FILE:
- ValidateUNIFilePath(Value)
- Value = os.path.join(os.path.dirname(InfDefMemberObj.CurrentLine.FileName), Value)
- if not os.path.isfile(Value) or not os.path.exists(Value):
- LineInfo[0] = InfDefMemberObj.CurrentLine.GetFileName()
- LineInfo[1] = InfDefMemberObj.CurrentLine.GetLineNo()
- LineInfo[2] = InfDefMemberObj.CurrentLine.GetLineString()
- ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Name),
- LineInfo=LineInfo)
- InfLineCommentObj = InfLineCommentObject()
- InfLineCommentObj.SetHeaderComments(InfDefMemberObj.Comments.GetHeaderComments())
- InfLineCommentObj.SetTailComments(InfDefMemberObj.Comments.GetTailComments())
- if Name == 'COMPONENT_TYPE':
- ErrorInInf(ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF,
- ErrorCode=ToolError.EDK1_INF_ERROR,
- RaiseError=True)
- if Name == DT.TAB_INF_DEFINES_INF_VERSION:
- HasFoundInfVersionFalg = True
- if not (Name == '' or Name is None):
- #
- # Process "SPEC" Keyword definition.
- #
- ReName = re.compile(r"SPEC ", re.DOTALL)
- if ReName.match(Name):
- SpecValue = Name[Name.find("SPEC") + len("SPEC"):].strip()
- Name = "SPEC"
- Value = SpecValue + " = " + Value
- if ArchListString in self.Defines:
- DefineList = self.Defines[ArchListString]
- LineInfo[0] = InfDefMemberObj.CurrentLine.GetFileName()
- LineInfo[1] = InfDefMemberObj.CurrentLine.GetLineNo()
- LineInfo[2] = InfDefMemberObj.CurrentLine.GetLineString()
- DefineList.CurrentLine = LineInfo
- #
- # Found the process function from mapping table.
- #
- if Name not in gFUNCTION_MAPPING_FOR_DEFINE_SECTION.keys():
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_SECTION_KEYWORD_INVALID%(Name),
- LineInfo=LineInfo)
- else:
- ProcessFunc = gFUNCTION_MAPPING_FOR_DEFINE_SECTION[Name]
- if (ProcessFunc is not None):
- ProcessFunc(DefineList, Value, InfLineCommentObj)
- self.Defines[ArchListString] = DefineList
- else:
- DefineList = InfDefSection()
- LineInfo[0] = InfDefMemberObj.CurrentLine.GetFileName()
- LineInfo[1] = InfDefMemberObj.CurrentLine.GetLineNo()
- LineInfo[2] = InfDefMemberObj.CurrentLine.GetLineString()
- DefineList.CurrentLine = LineInfo
- #
- # Found the process function from mapping table.
- #
- if Name not in gFUNCTION_MAPPING_FOR_DEFINE_SECTION.keys():
- ErrorInInf(ST.ERR_INF_PARSER_DEFINE_SECTION_KEYWORD_INVALID%(Name),
- LineInfo=LineInfo)
- #
- # Found the process function from mapping table.
- #
- else:
- ProcessFunc = gFUNCTION_MAPPING_FOR_DEFINE_SECTION[Name]
- if (ProcessFunc is not None):
- ProcessFunc(DefineList, Value, InfLineCommentObj)
- self.Defines[ArchListString] = DefineList
- #
- # After set, check whether INF_VERSION defined.
- #
- if not HasFoundInfVersionFalg:
- ErrorInInf(ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF,
- ErrorCode=ToolError.EDK1_INF_ERROR,
- RaiseError=True)
- return True
-
- def GetDefines(self):
- return self.Defines
-
+## @file
+# This file is used to define class objects of [Defines] section for INF file.
+# It will consumed by InfParser
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfDefineObject
+'''
+
+import os
+import re
+
+from Logger import StringTable as ST
+from Logger import ToolError
+from Library import GlobalData
+from Library import DataType as DT
+from Library.StringUtils import GetSplitValueList
+from Library.Misc import CheckGuidRegFormat
+from Library.Misc import Sdict
+from Library.Misc import ConvPathFromAbsToRel
+from Library.Misc import ValidateUNIFilePath
+from Library.ExpressionValidate import IsValidFeatureFlagExp
+from Library.ParserValidate import IsValidWord
+from Library.ParserValidate import IsValidInfMoudleType
+from Library.ParserValidate import IsValidHex
+from Library.ParserValidate import IsValidHexVersion
+from Library.ParserValidate import IsValidDecVersion
+from Library.ParserValidate import IsValidCVariableName
+from Library.ParserValidate import IsValidBoolType
+from Library.ParserValidate import IsValidPath
+from Library.ParserValidate import IsValidFamily
+from Library.ParserValidate import IsValidIdentifier
+from Library.ParserValidate import IsValidDecVersionVal
+from Object.Parser.InfCommonObject import InfLineCommentObject
+from Object.Parser.InfCommonObject import CurrentLine
+from Object.Parser.InfCommonObject import InfSectionCommonDef
+from Object.Parser.InfMisc import ErrorInInf
+from Object.Parser.InfDefineCommonObject import InfDefineLibraryItem
+from Object.Parser.InfDefineCommonObject import InfDefineEntryPointItem
+from Object.Parser.InfDefineCommonObject import InfDefineUnloadImageItem
+from Object.Parser.InfDefineCommonObject import InfDefineConstructorItem
+from Object.Parser.InfDefineCommonObject import InfDefineDestructorItem
+
+class InfDefSectionOptionRomInfo():
+ def __init__(self):
+ self.PciVendorId = None
+ self.PciDeviceId = None
+ self.PciClassCode = None
+ self.PciRevision = None
+ self.PciCompress = None
+ self.CurrentLine = ['', -1, '']
+ def SetPciVendorId(self, PciVendorId, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.PciVendorId is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_VENDOR_ID),
+ LineInfo=self.CurrentLine)
+ return False
+ #
+ # The PciVendorId should be hex string.
+ #
+ if (IsValidHex(PciVendorId)):
+ self.PciVendorId = InfDefMember()
+ self.PciVendorId.SetValue(PciVendorId)
+ self.PciVendorId.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciVendorId),
+ LineInfo=self.CurrentLine)
+ return False
+
+ def GetPciVendorId(self):
+ return self.PciVendorId
+
+ def SetPciDeviceId(self, PciDeviceId, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.PciDeviceId is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_DEVICE_ID),
+ LineInfo=self.CurrentLine)
+ return False
+ #
+ # The PciDeviceId should be hex string.
+ #
+ if (IsValidHex(PciDeviceId)):
+ self.PciDeviceId = InfDefMember()
+ self.PciDeviceId.SetValue(PciDeviceId)
+ self.PciDeviceId.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciDeviceId),
+ LineInfo=self.CurrentLine)
+ return False
+
+ def GetPciDeviceId(self):
+ return self.PciDeviceId
+
+ def SetPciClassCode(self, PciClassCode, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.PciClassCode is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_CLASS_CODE),
+ LineInfo=self.CurrentLine)
+ return False
+ #
+ # The PciClassCode should be 4 bytes hex string.
+ #
+ if (IsValidHex(PciClassCode)):
+ self.PciClassCode = InfDefMember()
+ self.PciClassCode.SetValue(PciClassCode)
+ self.PciClassCode.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%\
+ (PciClassCode),
+ LineInfo=self.CurrentLine)
+ return False
+
+ def GetPciClassCode(self):
+ return self.PciClassCode
+
+ def SetPciRevision(self, PciRevision, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.PciRevision is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_REVISION),
+ LineInfo=self.CurrentLine)
+ return False
+ #
+ # The PciRevision should be 4 bytes hex string.
+ #
+ if (IsValidHex(PciRevision)):
+ self.PciRevision = InfDefMember()
+ self.PciRevision.SetValue(PciRevision)
+ self.PciRevision.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciRevision),
+ LineInfo=self.CurrentLine)
+ return False
+
+ def GetPciRevision(self):
+ return self.PciRevision
+
+ def SetPciCompress(self, PciCompress, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.PciCompress is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_COMPRESS),
+ LineInfo=self.CurrentLine)
+ return False
+
+ #
+ # The PciCompress should be 'TRUE' or 'FALSE'.
+ #
+ if (PciCompress == 'TRUE' or PciCompress == 'FALSE'):
+ self.PciCompress = InfDefMember()
+ self.PciCompress.SetValue(PciCompress)
+ self.PciCompress.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciCompress),
+ LineInfo=self.CurrentLine)
+ return False
+ def GetPciCompress(self):
+ return self.PciCompress
+##
+# INF [Define] section Object
+#
+class InfDefSection(InfDefSectionOptionRomInfo):
+ def __init__(self):
+ self.BaseName = None
+ self.FileGuid = None
+ self.ModuleType = None
+ self.ModuleUniFileName = None
+ self.InfVersion = None
+ self.EdkReleaseVersion = None
+ self.UefiSpecificationVersion = None
+ self.PiSpecificationVersion = None
+ self.LibraryClass = []
+ self.Package = None
+ self.VersionString = None
+ self.PcdIsDriver = None
+ self.EntryPoint = []
+ self.UnloadImages = []
+ self.Constructor = []
+ self.Destructor = []
+ self.Shadow = None
+ self.CustomMakefile = []
+ self.Specification = []
+ self.UefiHiiResourceSection = None
+ self.DpxSource = []
+ self.CurrentLine = ['', -1, '']
+ InfDefSectionOptionRomInfo.__init__(self)
+
+ ## SetHeadComment
+ #
+ # @param BaseName: BaseName
+ #
+ def SetBaseName(self, BaseName, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.BaseName is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_BASE_NAME),
+ LineInfo=self.CurrentLine)
+ return False
+ if not (BaseName == '' or BaseName is None):
+ if IsValidWord(BaseName) and not BaseName.startswith("_"):
+ self.BaseName = InfDefMember()
+ self.BaseName.SetValue(BaseName)
+ self.BaseName.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_NAME_INVALID%(BaseName),
+ LineInfo=self.CurrentLine)
+ return False
+
+ ## GetBaseName
+ #
+ def GetBaseName(self):
+ return self.BaseName
+
+ ## SetFileGuid
+ #
+ # @param FileGuid: FileGuid
+ #
+ def SetFileGuid(self, FileGuid, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.FileGuid is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
+ %(DT.TAB_INF_DEFINES_FILE_GUID),
+ LineInfo=self.CurrentLine)
+ return False
+ #
+ # Do verification of GUID content/format
+ #
+ if (CheckGuidRegFormat(FileGuid)):
+ self.FileGuid = InfDefMember()
+ self.FileGuid.SetValue(FileGuid)
+ self.FileGuid.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_GUID_INVALID%(FileGuid),
+ LineInfo=self.CurrentLine)
+ return False
+
+ ## GetFileGuid
+ #
+ def GetFileGuid(self):
+ return self.FileGuid
+
+ ## SetModuleType
+ #
+ # @param ModuleType: ModuleType
+ #
+ def SetModuleType(self, ModuleType, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.ModuleType is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
+ %(DT.TAB_INF_DEFINES_MODULE_TYPE),
+ LineInfo=self.CurrentLine)
+ return False
+ #
+ # Valid Module Type or not
+ #
+ if (IsValidInfMoudleType(ModuleType)):
+ self.ModuleType = InfDefMember()
+ self.ModuleType.SetValue(ModuleType)
+ self.ModuleType.CurrentLine = CurrentLine()
+ self.ModuleType.CurrentLine.SetLineNo(self.CurrentLine[1])
+ self.ModuleType.CurrentLine.SetLineString(self.CurrentLine[2])
+ self.ModuleType.CurrentLine.SetFileName(self.CurrentLine[0])
+ self.ModuleType.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID%\
+ (ModuleType),
+ LineInfo=self.CurrentLine)
+ return False
+
+ ## GetModuleType
+ #
+ def GetModuleType(self):
+ return self.ModuleType
+
+ ## SetModuleUniFileName
+ #
+ # @param ModuleUniFileName: ModuleUniFileName
+ #
+ def SetModuleUniFileName(self, ModuleUniFileName, Comments):
+ if Comments:
+ pass
+ if self.ModuleUniFileName is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_MODULE_UNI_FILE),
+ LineInfo=self.CurrentLine)
+ self.ModuleUniFileName = ModuleUniFileName
+
+ ## GetModuleType
+ #
+ def GetModuleUniFileName(self):
+ return self.ModuleUniFileName
+
+ ## SetInfVersion
+ #
+ # @param InfVersion: InfVersion
+ #
+ def SetInfVersion(self, InfVersion, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.InfVersion is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
+ %(DT.TAB_INF_DEFINES_INF_VERSION),
+ LineInfo=self.CurrentLine)
+ return False
+ #
+ # The InfVersion should be 4 bytes hex string.
+ #
+ if (IsValidHex(InfVersion)):
+ if (InfVersion < '0x00010005'):
+ ErrorInInf(ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF,
+ ErrorCode=ToolError.EDK1_INF_ERROR,
+ LineInfo=self.CurrentLine)
+ elif IsValidDecVersionVal(InfVersion):
+ if (InfVersion < 65541):
+ ErrorInInf(ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF,
+ ErrorCode=ToolError.EDK1_INF_ERROR,
+ LineInfo=self.CurrentLine)
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(InfVersion),
+ LineInfo=self.CurrentLine)
+ return False
+
+ self.InfVersion = InfDefMember()
+ self.InfVersion.SetValue(InfVersion)
+ self.InfVersion.Comments = Comments
+ return True
+
+ ## GetInfVersion
+ #
+ def GetInfVersion(self):
+ return self.InfVersion
+
+ ## SetEdkReleaseVersion
+ #
+ # @param EdkReleaseVersion: EdkReleaseVersion
+ #
+ def SetEdkReleaseVersion(self, EdkReleaseVersion, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.EdkReleaseVersion is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
+ %(DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION),
+ LineInfo=self.CurrentLine)
+ return False
+ #
+ # The EdkReleaseVersion should be 4 bytes hex string.
+ #
+ if IsValidHexVersion(EdkReleaseVersion) or \
+ IsValidDecVersionVal(EdkReleaseVersion):
+ self.EdkReleaseVersion = InfDefMember()
+ self.EdkReleaseVersion.SetValue(EdkReleaseVersion)
+ self.EdkReleaseVersion.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\
+ %(EdkReleaseVersion),
+ LineInfo=self.CurrentLine)
+ return False
+
+ ## GetEdkReleaseVersion
+ #
+ def GetEdkReleaseVersion(self):
+ return self.EdkReleaseVersion
+
+ ## SetUefiSpecificationVersion
+ #
+ # @param UefiSpecificationVersion: UefiSpecificationVersion
+ #
+ def SetUefiSpecificationVersion(self, UefiSpecificationVersion, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.UefiSpecificationVersion is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
+ %(DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION),
+ LineInfo=self.CurrentLine)
+ return False
+ #
+ # The EdkReleaseVersion should be 4 bytes hex string.
+ #
+ if IsValidHexVersion(UefiSpecificationVersion) or \
+ IsValidDecVersionVal(UefiSpecificationVersion):
+ self.UefiSpecificationVersion = InfDefMember()
+ self.UefiSpecificationVersion.SetValue(UefiSpecificationVersion)
+ self.UefiSpecificationVersion.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\
+ %(UefiSpecificationVersion),
+ LineInfo=self.CurrentLine)
+ return False
+
+ ## GetUefiSpecificationVersion
+ #
+ def GetUefiSpecificationVersion(self):
+ return self.UefiSpecificationVersion
+
+ ## SetPiSpecificationVersion
+ #
+ # @param PiSpecificationVersion: PiSpecificationVersion
+ #
+ def SetPiSpecificationVersion(self, PiSpecificationVersion, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.PiSpecificationVersion is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
+ %(DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION),
+ LineInfo=self.CurrentLine)
+ return False
+ #
+ # The EdkReleaseVersion should be 4 bytes hex string.
+ #
+ if IsValidHexVersion(PiSpecificationVersion) or \
+ IsValidDecVersionVal(PiSpecificationVersion):
+ self.PiSpecificationVersion = InfDefMember()
+ self.PiSpecificationVersion.SetValue(PiSpecificationVersion)
+ self.PiSpecificationVersion.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\
+ %(PiSpecificationVersion),
+ LineInfo=self.CurrentLine)
+ return False
+
+ ## GetPiSpecificationVersion
+ #
+ def GetPiSpecificationVersion(self):
+ return self.PiSpecificationVersion
+
+ ## SetLibraryClass
+ #
+ # @param LibraryClass: LibraryClass
+ #
+ def SetLibraryClass(self, LibraryClass, Comments):
+ ValueList = GetSplitValueList(LibraryClass)
+ Name = ValueList[0]
+ if IsValidWord(Name):
+ InfDefineLibraryItemObj = InfDefineLibraryItem()
+ InfDefineLibraryItemObj.SetLibraryName(Name)
+ InfDefineLibraryItemObj.Comments = Comments
+ if len(ValueList) == 2:
+ Type = ValueList[1]
+ TypeList = GetSplitValueList(Type, ' ')
+ TypeList = [Type for Type in TypeList if Type != '']
+ for Item in TypeList:
+ if Item not in DT.MODULE_LIST:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Item),
+ LineInfo=self.CurrentLine)
+ return False
+ InfDefineLibraryItemObj.SetTypes(TypeList)
+ self.LibraryClass.append(InfDefineLibraryItemObj)
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Name),
+ LineInfo=self.CurrentLine)
+ return False
+
+ return True
+
+ def GetLibraryClass(self):
+ return self.LibraryClass
+
+ def SetVersionString(self, VersionString, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.VersionString is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
+ %(DT.TAB_INF_DEFINES_VERSION_STRING),
+ LineInfo=self.CurrentLine)
+ return False
+ if not IsValidDecVersion(VersionString):
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\
+ %(VersionString),
+ LineInfo=self.CurrentLine)
+ self.VersionString = InfDefMember()
+ self.VersionString.SetValue(VersionString)
+ self.VersionString.Comments = Comments
+ return True
+
+
+ def GetVersionString(self):
+ return self.VersionString
+
+ def SetPcdIsDriver(self, PcdIsDriver, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.PcdIsDriver is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
+ %(DT.TAB_INF_DEFINES_PCD_IS_DRIVER),
+ LineInfo=self.CurrentLine)
+ return False
+ if PcdIsDriver == 'PEI_PCD_DRIVER' or PcdIsDriver == 'DXE_PCD_DRIVER':
+ self.PcdIsDriver = InfDefMember()
+ self.PcdIsDriver.SetValue(PcdIsDriver)
+ self.PcdIsDriver.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PcdIsDriver),
+ LineInfo=self.CurrentLine)
+ return False
+
+ def GetPcdIsDriver(self):
+ return self.PcdIsDriver
+
+ #
+ # SetEntryPoint
+ #
+ def SetEntryPoint(self, EntryPoint, Comments):
+ #
+ # It can be a list
+ #
+ ValueList = []
+ TokenList = GetSplitValueList(EntryPoint, DT.TAB_VALUE_SPLIT)
+ ValueList[0:len(TokenList)] = TokenList
+ InfDefineEntryPointItemObj = InfDefineEntryPointItem()
+ if not IsValidCVariableName(ValueList[0]):
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%\
+ (ValueList[0]),
+ LineInfo=self.CurrentLine)
+ InfDefineEntryPointItemObj.SetCName(ValueList[0])
+ if len(ValueList) == 2:
+ if ValueList[1].strip() == '':
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%\
+ (ValueList[1]),
+ LineInfo=self.CurrentLine)
+ #
+ # Validate FFE
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[1].strip())
+ if not FeatureFlagRtv[0]:
+ ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%\
+ (FeatureFlagRtv[1]),
+ LineInfo=self.CurrentLine)
+ InfDefineEntryPointItemObj.SetFeatureFlagExp(ValueList[1])
+ if len(ValueList) > 2:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(EntryPoint),
+ LineInfo=self.CurrentLine)
+ InfDefineEntryPointItemObj.Comments = Comments
+ self.EntryPoint.append(InfDefineEntryPointItemObj)
+
+ def GetEntryPoint(self):
+ return self.EntryPoint
+
+ #
+ # SetUnloadImages
+ #
+ def SetUnloadImages(self, UnloadImages, Comments):
+ #
+ # It can be a list
+ #
+ ValueList = []
+ TokenList = GetSplitValueList(UnloadImages, DT.TAB_VALUE_SPLIT)
+ ValueList[0:len(TokenList)] = TokenList
+ InfDefineUnloadImageItemObj = InfDefineUnloadImageItem()
+ if not IsValidCVariableName(ValueList[0]):
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[0]),
+ LineInfo=self.CurrentLine)
+ InfDefineUnloadImageItemObj.SetCName(ValueList[0])
+ if len(ValueList) == 2:
+ if ValueList[1].strip() == '':
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[1]),
+ LineInfo=self.CurrentLine)
+ #
+ # Validate FFE
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[1].strip())
+ if not FeatureFlagRtv[0]:
+ ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
+ LineInfo=self.CurrentLine)
+ InfDefineUnloadImageItemObj.SetFeatureFlagExp(ValueList[1])
+
+ if len(ValueList) > 2:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(UnloadImages),
+ LineInfo=self.CurrentLine)
+ InfDefineUnloadImageItemObj.Comments = Comments
+ self.UnloadImages.append(InfDefineUnloadImageItemObj)
+
+ def GetUnloadImages(self):
+ return self.UnloadImages
+
+ #
+ # SetConstructor
+ #
+ def SetConstructor(self, Constructor, Comments):
+ #
+ # It can be a list
+ #
+ ValueList = []
+ TokenList = GetSplitValueList(Constructor, DT.TAB_VALUE_SPLIT)
+ ValueList[0:len(TokenList)] = TokenList
+ InfDefineConstructorItemObj = InfDefineConstructorItem()
+ if not IsValidCVariableName(ValueList[0]):
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[0]),
+ LineInfo=self.CurrentLine)
+ InfDefineConstructorItemObj.SetCName(ValueList[0])
+ if len(ValueList) >= 2:
+ ModList = GetSplitValueList(ValueList[1], ' ')
+ if ValueList[1].strip() == '':
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[1]),
+ LineInfo=self.CurrentLine)
+ for ModItem in ModList:
+ if ModItem not in DT.MODULE_LIST:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID%(ModItem),
+ LineInfo=self.CurrentLine)
+ InfDefineConstructorItemObj.SetSupModList(ModList)
+ if len(ValueList) == 3:
+ if ValueList[2].strip() == '':
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[2]),
+ LineInfo=self.CurrentLine)
+ #
+ # Validate FFE
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[2].strip())
+ if not FeatureFlagRtv[0]:
+ ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[2]),
+ LineInfo=self.CurrentLine)
+ InfDefineConstructorItemObj.SetFeatureFlagExp(ValueList[2])
+
+ if len(ValueList) > 3:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Constructor),
+ LineInfo=self.CurrentLine)
+ InfDefineConstructorItemObj.Comments = Comments
+ self.Constructor.append(InfDefineConstructorItemObj)
+
+ def GetConstructor(self):
+ return self.Constructor
+
+ #
+ # SetDestructor
+ #
+ def SetDestructor(self, Destructor, Comments):
+ #
+ # It can be a list and only 1 set to TRUE
+ #
+ ValueList = []
+ TokenList = GetSplitValueList(Destructor, DT.TAB_VALUE_SPLIT)
+ ValueList[0:len(TokenList)] = TokenList
+ InfDefineDestructorItemObj = InfDefineDestructorItem()
+ if not IsValidCVariableName(ValueList[0]):
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[0]),
+ LineInfo=self.CurrentLine)
+ InfDefineDestructorItemObj.SetCName(ValueList[0])
+ if len(ValueList) >= 2:
+ ModList = GetSplitValueList(ValueList[1].strip(), ' ')
+ if ValueList[1].strip() == '':
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[1]),
+ LineInfo=self.CurrentLine)
+ for ModItem in ModList:
+ if ModItem not in DT.MODULE_LIST:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID%(ModItem),
+ LineInfo=self.CurrentLine)
+ InfDefineDestructorItemObj.SetSupModList(ModList)
+ if len(ValueList) == 3:
+ if ValueList[2].strip() == '':
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[2]),
+ LineInfo=self.CurrentLine)
+ #
+ # Validate FFE
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[2].strip())
+ if not FeatureFlagRtv[0]:
+ ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
+ LineInfo=self.CurrentLine)
+ InfDefineDestructorItemObj.SetFeatureFlagExp(ValueList[2])
+
+ if len(ValueList) > 3:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Destructor),
+ LineInfo=self.CurrentLine)
+
+ InfDefineDestructorItemObj.Comments = Comments
+ self.Destructor.append(InfDefineDestructorItemObj)
+
+ def GetDestructor(self):
+ return self.Destructor
+
+ def SetShadow(self, Shadow, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.Shadow is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_SHADOW),
+ LineInfo=self.CurrentLine)
+ return False
+ if (IsValidBoolType(Shadow)):
+ self.Shadow = InfDefMember()
+ self.Shadow.SetValue(Shadow)
+ self.Shadow.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Shadow),
+ LineInfo=self.CurrentLine)
+ return False
+ def GetShadow(self):
+ return self.Shadow
+
+ #
+ # <Family> ::= {"MSFT"} {"GCC"}
+ # <CustomMake> ::= [<Family> "|"] <Filename>
+ #
+ def SetCustomMakefile(self, CustomMakefile, Comments):
+ if not (CustomMakefile == '' or CustomMakefile is None):
+ ValueList = GetSplitValueList(CustomMakefile)
+ if len(ValueList) == 1:
+ FileName = ValueList[0]
+ Family = ''
+ else:
+ Family = ValueList[0]
+ FileName = ValueList[1]
+ Family = Family.strip()
+ if Family != '':
+ if not IsValidFamily(Family):
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Family),
+ LineInfo=self.CurrentLine)
+ return False
+ #
+ # The MakefileName specified file should exist
+ #
+ IsValidFileFlag = False
+ ModulePath = os.path.split(self.CurrentLine[0])[0]
+ if IsValidPath(FileName, ModulePath):
+ IsValidFileFlag = True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(FileName),
+ LineInfo=self.CurrentLine)
+ return False
+ if IsValidFileFlag:
+ FileName = ConvPathFromAbsToRel(FileName, GlobalData.gINF_MODULE_DIR)
+ self.CustomMakefile.append((Family, FileName, Comments))
+ IsValidFileFlag = False
+ return True
+ else:
+ return False
+
+ def GetCustomMakefile(self):
+ return self.CustomMakefile
+
+ #
+ # ["SPEC" <Spec> <EOL>]*{0,}
+ # <Spec> ::= <Word> "=" <VersionVal>
+ # <VersionVal> ::= {<HexVersion>] {<DecVersion>}
+ # <HexNumber> ::= "0x" [<HexDigit>]{1,}
+ # <DecVersion> ::= (0-9){1,} ["." (0-9){1,2}]
+ #
+ def SetSpecification(self, Specification, Comments):
+ #
+ # Valid the value of Specification
+ #
+ __ValueList = []
+ TokenList = GetSplitValueList(Specification, DT.TAB_EQUAL_SPLIT, 1)
+ __ValueList[0:len(TokenList)] = TokenList
+ if len(__ValueList) != 2:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_NO_NAME + ' Or ' + ST.ERR_INF_PARSER_DEFINE_ITEM_NO_VALUE,
+ LineInfo=self.CurrentLine)
+ Name = __ValueList[0].strip()
+ Version = __ValueList[1].strip()
+ if IsValidIdentifier(Name):
+ if IsValidDecVersion(Version):
+ self.Specification.append((Name, Version, Comments))
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Version),
+ LineInfo=self.CurrentLine)
+ return False
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Name),
+ LineInfo=self.CurrentLine)
+ return False
+ return True
+
+ def GetSpecification(self):
+ return self.Specification
+
+ #
+ # [<UefiHiiResource> <EOL>]{0,1}
+ # <UefiHiiResource> ::= "UEFI_HII_RESOURCE_SECTION" "=" <BoolType>
+ #
+ def SetUefiHiiResourceSection(self, UefiHiiResourceSection, Comments):
+ #
+ # Value has been set before.
+ #
+ if self.UefiHiiResourceSection is not None:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND
+ %(DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION),
+ LineInfo=self.CurrentLine)
+ return False
+ if not (UefiHiiResourceSection == '' or UefiHiiResourceSection is None):
+ if (IsValidBoolType(UefiHiiResourceSection)):
+ self.UefiHiiResourceSection = InfDefMember()
+ self.UefiHiiResourceSection.SetValue(UefiHiiResourceSection)
+ self.UefiHiiResourceSection.Comments = Comments
+ return True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(UefiHiiResourceSection),
+ LineInfo=self.CurrentLine)
+ return False
+ else:
+ return False
+
+ def GetUefiHiiResourceSection(self):
+ return self.UefiHiiResourceSection
+
+ def SetDpxSource(self, DpxSource, Comments):
+ #
+ # The MakefileName specified file should exist
+ #
+ IsValidFileFlag = False
+ ModulePath = os.path.split(self.CurrentLine[0])[0]
+ if IsValidPath(DpxSource, ModulePath):
+ IsValidFileFlag = True
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(DpxSource),
+ LineInfo=self.CurrentLine)
+ return False
+ if IsValidFileFlag:
+ DpxSource = ConvPathFromAbsToRel(DpxSource,
+ GlobalData.gINF_MODULE_DIR)
+ self.DpxSource.append((DpxSource, Comments))
+ IsValidFileFlag = False
+ return True
+
+ def GetDpxSource(self):
+ return self.DpxSource
+
+gFUNCTION_MAPPING_FOR_DEFINE_SECTION = {
+ #
+ # Required Fields
+ #
+ DT.TAB_INF_DEFINES_BASE_NAME : InfDefSection.SetBaseName,
+ DT.TAB_INF_DEFINES_FILE_GUID : InfDefSection.SetFileGuid,
+ DT.TAB_INF_DEFINES_MODULE_TYPE : InfDefSection.SetModuleType,
+ #
+ # Required by EDKII style INF file
+ #
+ DT.TAB_INF_DEFINES_INF_VERSION : InfDefSection.SetInfVersion,
+ #
+ # Optional Fields
+ #
+ DT.TAB_INF_DEFINES_MODULE_UNI_FILE : InfDefSection.SetModuleUniFileName,
+ DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION : InfDefSection.SetEdkReleaseVersion,
+ DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION : InfDefSection.SetUefiSpecificationVersion,
+ DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION : InfDefSection.SetPiSpecificationVersion,
+ DT.TAB_INF_DEFINES_LIBRARY_CLASS : InfDefSection.SetLibraryClass,
+ DT.TAB_INF_DEFINES_VERSION_STRING : InfDefSection.SetVersionString,
+ DT.TAB_INF_DEFINES_PCD_IS_DRIVER : InfDefSection.SetPcdIsDriver,
+ DT.TAB_INF_DEFINES_ENTRY_POINT : InfDefSection.SetEntryPoint,
+ DT.TAB_INF_DEFINES_UNLOAD_IMAGE : InfDefSection.SetUnloadImages,
+ DT.TAB_INF_DEFINES_CONSTRUCTOR : InfDefSection.SetConstructor,
+ DT.TAB_INF_DEFINES_DESTRUCTOR : InfDefSection.SetDestructor,
+ DT.TAB_INF_DEFINES_SHADOW : InfDefSection.SetShadow,
+ DT.TAB_INF_DEFINES_PCI_VENDOR_ID : InfDefSection.SetPciVendorId,
+ DT.TAB_INF_DEFINES_PCI_DEVICE_ID : InfDefSection.SetPciDeviceId,
+ DT.TAB_INF_DEFINES_PCI_CLASS_CODE : InfDefSection.SetPciClassCode,
+ DT.TAB_INF_DEFINES_PCI_REVISION : InfDefSection.SetPciRevision,
+ DT.TAB_INF_DEFINES_PCI_COMPRESS : InfDefSection.SetPciCompress,
+ DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE : InfDefSection.SetCustomMakefile,
+ DT.TAB_INF_DEFINES_SPEC : InfDefSection.SetSpecification,
+ DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION : InfDefSection.SetUefiHiiResourceSection,
+ DT.TAB_INF_DEFINES_DPX_SOURCE : InfDefSection.SetDpxSource
+}
+
+## InfDefMember
+#
+#
+class InfDefMember():
+ def __init__(self, Name='', Value=''):
+ self.Comments = InfLineCommentObject()
+ self.Name = Name
+ self.Value = Value
+ self.CurrentLine = CurrentLine()
+ def GetName(self):
+ return self.Name
+ def SetName(self, Name):
+ self.Name = Name
+ def GetValue(self):
+ return self.Value
+ def SetValue(self, Value):
+ self.Value = Value
+
+## InfDefObject
+#
+#
+class InfDefObject(InfSectionCommonDef):
+ def __init__(self):
+ self.Defines = Sdict()
+ InfSectionCommonDef.__init__(self)
+ def SetDefines(self, DefineContent, Arch = None):
+ #
+ # Validate Arch
+ #
+ HasFoundInfVersionFalg = False
+ LineInfo = ['', -1, '']
+ ArchListString = ' '.join(Arch)
+ #
+ # Parse Define items.
+ #
+ for InfDefMemberObj in DefineContent:
+ ProcessFunc = None
+ Name = InfDefMemberObj.GetName()
+ Value = InfDefMemberObj.GetValue()
+ if Name == DT.TAB_INF_DEFINES_MODULE_UNI_FILE:
+ ValidateUNIFilePath(Value)
+ Value = os.path.join(os.path.dirname(InfDefMemberObj.CurrentLine.FileName), Value)
+ if not os.path.isfile(Value) or not os.path.exists(Value):
+ LineInfo[0] = InfDefMemberObj.CurrentLine.GetFileName()
+ LineInfo[1] = InfDefMemberObj.CurrentLine.GetLineNo()
+ LineInfo[2] = InfDefMemberObj.CurrentLine.GetLineString()
+ ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Name),
+ LineInfo=LineInfo)
+ InfLineCommentObj = InfLineCommentObject()
+ InfLineCommentObj.SetHeaderComments(InfDefMemberObj.Comments.GetHeaderComments())
+ InfLineCommentObj.SetTailComments(InfDefMemberObj.Comments.GetTailComments())
+ if Name == 'COMPONENT_TYPE':
+ ErrorInInf(ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF,
+ ErrorCode=ToolError.EDK1_INF_ERROR,
+ RaiseError=True)
+ if Name == DT.TAB_INF_DEFINES_INF_VERSION:
+ HasFoundInfVersionFalg = True
+ if not (Name == '' or Name is None):
+ #
+ # Process "SPEC" Keyword definition.
+ #
+ ReName = re.compile(r"SPEC ", re.DOTALL)
+ if ReName.match(Name):
+ SpecValue = Name[Name.find("SPEC") + len("SPEC"):].strip()
+ Name = "SPEC"
+ Value = SpecValue + " = " + Value
+ if ArchListString in self.Defines:
+ DefineList = self.Defines[ArchListString]
+ LineInfo[0] = InfDefMemberObj.CurrentLine.GetFileName()
+ LineInfo[1] = InfDefMemberObj.CurrentLine.GetLineNo()
+ LineInfo[2] = InfDefMemberObj.CurrentLine.GetLineString()
+ DefineList.CurrentLine = LineInfo
+ #
+ # Found the process function from mapping table.
+ #
+ if Name not in gFUNCTION_MAPPING_FOR_DEFINE_SECTION.keys():
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_SECTION_KEYWORD_INVALID%(Name),
+ LineInfo=LineInfo)
+ else:
+ ProcessFunc = gFUNCTION_MAPPING_FOR_DEFINE_SECTION[Name]
+ if (ProcessFunc is not None):
+ ProcessFunc(DefineList, Value, InfLineCommentObj)
+ self.Defines[ArchListString] = DefineList
+ else:
+ DefineList = InfDefSection()
+ LineInfo[0] = InfDefMemberObj.CurrentLine.GetFileName()
+ LineInfo[1] = InfDefMemberObj.CurrentLine.GetLineNo()
+ LineInfo[2] = InfDefMemberObj.CurrentLine.GetLineString()
+ DefineList.CurrentLine = LineInfo
+ #
+ # Found the process function from mapping table.
+ #
+ if Name not in gFUNCTION_MAPPING_FOR_DEFINE_SECTION.keys():
+ ErrorInInf(ST.ERR_INF_PARSER_DEFINE_SECTION_KEYWORD_INVALID%(Name),
+ LineInfo=LineInfo)
+ #
+ # Found the process function from mapping table.
+ #
+ else:
+ ProcessFunc = gFUNCTION_MAPPING_FOR_DEFINE_SECTION[Name]
+ if (ProcessFunc is not None):
+ ProcessFunc(DefineList, Value, InfLineCommentObj)
+ self.Defines[ArchListString] = DefineList
+ #
+ # After set, check whether INF_VERSION defined.
+ #
+ if not HasFoundInfVersionFalg:
+ ErrorInInf(ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF,
+ ErrorCode=ToolError.EDK1_INF_ERROR,
+ RaiseError=True)
+ return True
+
+ def GetDefines(self):
+ return self.Defines
+
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfDepexObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfDepexObject.py
index 0de663291c..b0b1db687f 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfDepexObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfDepexObject.py
@@ -1,160 +1,160 @@
-## @file
-# This file is used to define class objects of INF file [Depex] section.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfDepexObject
-'''
-
-from Library import DataType as DT
-from Library import GlobalData
-import Logger.Log as Logger
-from Logger import ToolError
-from Logger import StringTable as ST
-
-from Object.Parser.InfCommonObject import InfSectionCommonDef
-from Library.ParserValidate import IsValidArch
-
-class InfDepexContentItem():
- def __init__(self):
- self.SectionType = ''
- self.SectionString = ''
-
- def SetSectionType(self, SectionType):
- self.SectionType = SectionType
- def GetSectionType(self):
- return self.SectionType
-
- def SetSectionString(self, SectionString):
- self.SectionString = SectionString
- def GetSectionString(self):
- return self.SectionString
-
-
-class InfDepexItem():
- def __init__(self):
- self.DepexContent = ''
- self.ModuleType = ''
- self.SupArch = ''
- self.HelpString = ''
- self.FeatureFlagExp = ''
- self.InfDepexContentItemList = []
-
- def SetFeatureFlagExp(self, FeatureFlagExp):
- self.FeatureFlagExp = FeatureFlagExp
- def GetFeatureFlagExp(self):
- return self.FeatureFlagExp
-
- def SetSupArch(self, Arch):
- self.SupArch = Arch
- def GetSupArch(self):
- return self.SupArch
-
- def SetHelpString(self, HelpString):
- self.HelpString = HelpString
- def GetHelpString(self):
- return self.HelpString
-
- def SetModuleType(self, Type):
- self.ModuleType = Type
- def GetModuleType(self):
- return self.ModuleType
-
- def SetDepexConent(self, Content):
- self.DepexContent = Content
- def GetDepexContent(self):
- return self.DepexContent
-
- def SetInfDepexContentItemList(self, InfDepexContentItemList):
- self.InfDepexContentItemList = InfDepexContentItemList
- def GetInfDepexContentItemList(self):
- return self.InfDepexContentItemList
-
-## InfDepexObject
-#
-#
-#
-class InfDepexObject(InfSectionCommonDef):
- def __init__(self):
- self.Depex = []
- self.AllContent = ''
- self.SectionContent = ''
- InfSectionCommonDef.__init__(self)
-
- def SetDepex(self, DepexContent, KeyList=None, CommentList=None):
- for KeyItem in KeyList:
- Arch = KeyItem[0]
- ModuleType = KeyItem[1]
- InfDepexItemIns = InfDepexItem()
-
- #
- # Validate Arch
- #
- if IsValidArch(Arch.strip().upper()):
- InfDepexItemIns.SetSupArch(Arch)
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_DEFINE_NAME_INVALID % (Arch),
- File=GlobalData.gINF_MODULE_NAME,
- Line=KeyItem[2])
-
- #
- # Validate Module Type
- #
- if ModuleType and ModuleType != 'COMMON':
- if ModuleType in DT.VALID_DEPEX_MODULE_TYPE_LIST:
- InfDepexItemIns.SetModuleType(ModuleType)
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TYPE_ERROR % (ModuleType),
- File=GlobalData.gINF_MODULE_NAME,
- Line=KeyItem[2])
-
- #
- # Parser content in [Depex] section.
- #
- DepexString = ''
- HelpString = ''
- #
- # Get Depex Expression
- #
- for Line in DepexContent:
- LineContent = Line[0].strip()
- if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1:
- LineContent = LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT)]
- if LineContent:
- DepexString = DepexString + LineContent + DT.END_OF_LINE
- continue
-
- if DepexString.endswith(DT.END_OF_LINE):
- DepexString = DepexString[:-1]
-
- if not DepexString.strip():
- continue
-
- #
- # Get Help Text
- #
- for HelpLine in CommentList:
- HelpString = HelpString + HelpLine + DT.END_OF_LINE
- if HelpString.endswith(DT.END_OF_LINE):
- HelpString = HelpString[:-1]
-
- InfDepexItemIns.SetDepexConent(DepexString)
- InfDepexItemIns.SetHelpString(HelpString)
-
- self.Depex.append(InfDepexItemIns)
-
- return True
-
- def GetDepex(self):
- return self.Depex
-
- def GetAllContent(self):
- return self.AllContent
+## @file
+# This file is used to define class objects of INF file [Depex] section.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfDepexObject
+'''
+
+from Library import DataType as DT
+from Library import GlobalData
+import Logger.Log as Logger
+from Logger import ToolError
+from Logger import StringTable as ST
+
+from Object.Parser.InfCommonObject import InfSectionCommonDef
+from Library.ParserValidate import IsValidArch
+
+class InfDepexContentItem():
+ def __init__(self):
+ self.SectionType = ''
+ self.SectionString = ''
+
+ def SetSectionType(self, SectionType):
+ self.SectionType = SectionType
+ def GetSectionType(self):
+ return self.SectionType
+
+ def SetSectionString(self, SectionString):
+ self.SectionString = SectionString
+ def GetSectionString(self):
+ return self.SectionString
+
+
+class InfDepexItem():
+ def __init__(self):
+ self.DepexContent = ''
+ self.ModuleType = ''
+ self.SupArch = ''
+ self.HelpString = ''
+ self.FeatureFlagExp = ''
+ self.InfDepexContentItemList = []
+
+ def SetFeatureFlagExp(self, FeatureFlagExp):
+ self.FeatureFlagExp = FeatureFlagExp
+ def GetFeatureFlagExp(self):
+ return self.FeatureFlagExp
+
+ def SetSupArch(self, Arch):
+ self.SupArch = Arch
+ def GetSupArch(self):
+ return self.SupArch
+
+ def SetHelpString(self, HelpString):
+ self.HelpString = HelpString
+ def GetHelpString(self):
+ return self.HelpString
+
+ def SetModuleType(self, Type):
+ self.ModuleType = Type
+ def GetModuleType(self):
+ return self.ModuleType
+
+ def SetDepexConent(self, Content):
+ self.DepexContent = Content
+ def GetDepexContent(self):
+ return self.DepexContent
+
+ def SetInfDepexContentItemList(self, InfDepexContentItemList):
+ self.InfDepexContentItemList = InfDepexContentItemList
+ def GetInfDepexContentItemList(self):
+ return self.InfDepexContentItemList
+
+## InfDepexObject
+#
+#
+#
+class InfDepexObject(InfSectionCommonDef):
+ def __init__(self):
+ self.Depex = []
+ self.AllContent = ''
+ self.SectionContent = ''
+ InfSectionCommonDef.__init__(self)
+
+ def SetDepex(self, DepexContent, KeyList=None, CommentList=None):
+ for KeyItem in KeyList:
+ Arch = KeyItem[0]
+ ModuleType = KeyItem[1]
+ InfDepexItemIns = InfDepexItem()
+
+ #
+ # Validate Arch
+ #
+ if IsValidArch(Arch.strip().upper()):
+ InfDepexItemIns.SetSupArch(Arch)
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_DEFINE_NAME_INVALID % (Arch),
+ File=GlobalData.gINF_MODULE_NAME,
+ Line=KeyItem[2])
+
+ #
+ # Validate Module Type
+ #
+ if ModuleType and ModuleType != 'COMMON':
+ if ModuleType in DT.VALID_DEPEX_MODULE_TYPE_LIST:
+ InfDepexItemIns.SetModuleType(ModuleType)
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TYPE_ERROR % (ModuleType),
+ File=GlobalData.gINF_MODULE_NAME,
+ Line=KeyItem[2])
+
+ #
+ # Parser content in [Depex] section.
+ #
+ DepexString = ''
+ HelpString = ''
+ #
+ # Get Depex Expression
+ #
+ for Line in DepexContent:
+ LineContent = Line[0].strip()
+ if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1:
+ LineContent = LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT)]
+ if LineContent:
+ DepexString = DepexString + LineContent + DT.END_OF_LINE
+ continue
+
+ if DepexString.endswith(DT.END_OF_LINE):
+ DepexString = DepexString[:-1]
+
+ if not DepexString.strip():
+ continue
+
+ #
+ # Get Help Text
+ #
+ for HelpLine in CommentList:
+ HelpString = HelpString + HelpLine + DT.END_OF_LINE
+ if HelpString.endswith(DT.END_OF_LINE):
+ HelpString = HelpString[:-1]
+
+ InfDepexItemIns.SetDepexConent(DepexString)
+ InfDepexItemIns.SetHelpString(HelpString)
+
+ self.Depex.append(InfDepexItemIns)
+
+ return True
+
+ def GetDepex(self):
+ return self.Depex
+
+ def GetAllContent(self):
+ return self.AllContent
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py
index 3e0bc80440..f0eff8bd0d 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py
@@ -1,347 +1,347 @@
-## @file
-# This file is used to define class objects of INF file [Guids] section.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfGuidObject
-'''
-
-from Library.ParserValidate import IsValidCVariableName
-from Library.CommentParsing import ParseComment
-from Library.ExpressionValidate import IsValidFeatureFlagExp
-
-from Library.Misc import Sdict
-from Library import DataType as DT
-import Logger.Log as Logger
-from Logger import ToolError
-from Logger import StringTable as ST
-
-class InfGuidItemCommentContent():
- def __init__(self):
- #
- # ## SOMETIMES_CONSUMES ## Variable:L"MemoryTypeInformation"
- # TailString.
- #
- #
- # SOMETIMES_CONSUMES
- #
- self.UsageItem = ''
- #
- # Variable
- #
- self.GuidTypeItem = ''
- #
- # MemoryTypeInformation
- #
- self.VariableNameItem = ''
- #
- # TailString
- #
- self.HelpStringItem = ''
-
- def SetUsageItem(self, UsageItem):
- self.UsageItem = UsageItem
- def GetUsageItem(self):
- return self.UsageItem
-
- def SetGuidTypeItem(self, GuidTypeItem):
- self.GuidTypeItem = GuidTypeItem
- def GetGuidTypeItem(self):
- return self.GuidTypeItem
-
- def SetVariableNameItem(self, VariableNameItem):
- self.VariableNameItem = VariableNameItem
- def GetVariableNameItem(self):
- return self.VariableNameItem
-
- def SetHelpStringItem(self, HelpStringItem):
- self.HelpStringItem = HelpStringItem
- def GetHelpStringItem(self):
- return self.HelpStringItem
-
-class InfGuidItem():
- def __init__(self):
- self.Name = ''
- self.FeatureFlagExp = ''
- #
- # A list contain instance of InfGuidItemCommentContent
- #
- self.CommentList = []
- self.SupArchList = []
-
- def SetName(self, Name):
- self.Name = Name
- def GetName(self):
- return self.Name
-
- def SetFeatureFlagExp(self, FeatureFlagExp):
- self.FeatureFlagExp = FeatureFlagExp
- def GetFeatureFlagExp(self):
- return self.FeatureFlagExp
-
- def SetCommentList(self, CommentList):
- self.CommentList = CommentList
- def GetCommentList(self):
- return self.CommentList
-
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
- def GetSupArchList(self):
- return self.SupArchList
-
-## ParseComment
-#
-# ParseComment
-#
-def ParseGuidComment(CommentsList, InfGuidItemObj):
- #
- # Get/Set Usage and HelpString
- #
- if CommentsList is not None and len(CommentsList) != 0 :
- CommentInsList = []
- PreUsage = None
- PreGuidType = None
- PreHelpText = ''
- BlockFlag = -1
- Count = 0
- for CommentItem in CommentsList:
- Count = Count + 1
- CommentItemUsage, \
- CommentItemGuidType, \
- CommentItemVarString, \
- CommentItemHelpText = \
- ParseComment(CommentItem,
- DT.ALL_USAGE_TOKENS,
- DT.GUID_TYPE_TOKENS,
- [],
- True)
-
- if CommentItemHelpText is None:
- CommentItemHelpText = ''
- if Count == len(CommentsList) and CommentItemUsage == CommentItemGuidType == DT.ITEM_UNDEFINED:
- CommentItemHelpText = DT.END_OF_LINE
-
- if Count == len(CommentsList):
- if BlockFlag == 1 or BlockFlag == 2:
- if CommentItemUsage == CommentItemGuidType == DT.ITEM_UNDEFINED:
- BlockFlag = 4
- else:
- BlockFlag = 3
- if BlockFlag == -1:
- BlockFlag = 4
- if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
- if CommentItemUsage == CommentItemGuidType == DT.ITEM_UNDEFINED:
- if BlockFlag == -1:
- BlockFlag = 1
- elif BlockFlag == 1:
- BlockFlag = 2
- else:
- if BlockFlag == 1 or BlockFlag == 2:
- BlockFlag = 3
- elif BlockFlag == -1:
- BlockFlag = 4
-
- #
- # Combine two comment line if they are generic comment
- #
- if CommentItemUsage == CommentItemGuidType == PreUsage == PreGuidType == DT.ITEM_UNDEFINED:
- CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
- PreHelpText = CommentItemHelpText
-
- if BlockFlag == 4:
- CommentItemIns = InfGuidItemCommentContent()
- CommentItemIns.SetUsageItem(CommentItemUsage)
- CommentItemIns.SetGuidTypeItem(CommentItemGuidType)
- CommentItemIns.SetVariableNameItem(CommentItemVarString)
- if CommentItemHelpText == '' or CommentItemHelpText.endswith(DT.END_OF_LINE):
- CommentItemHelpText = CommentItemHelpText.strip(DT.END_OF_LINE)
- CommentItemIns.SetHelpStringItem(CommentItemHelpText)
- CommentInsList.append(CommentItemIns)
-
- BlockFlag = -1
- PreUsage = None
- PreGuidType = None
- PreHelpText = ''
-
- elif BlockFlag == 3:
- #
- # Add previous help string
- #
- CommentItemIns = InfGuidItemCommentContent()
- CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
- CommentItemIns.SetGuidTypeItem(DT.ITEM_UNDEFINED)
- if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
- PreHelpText = PreHelpText.strip(DT.END_OF_LINE)
- CommentItemIns.SetHelpStringItem(PreHelpText)
- CommentInsList.append(CommentItemIns)
- #
- # Add Current help string
- #
- CommentItemIns = InfGuidItemCommentContent()
- CommentItemIns.SetUsageItem(CommentItemUsage)
- CommentItemIns.SetGuidTypeItem(CommentItemGuidType)
- CommentItemIns.SetVariableNameItem(CommentItemVarString)
- if CommentItemHelpText == '' or CommentItemHelpText.endswith(DT.END_OF_LINE):
- CommentItemHelpText = CommentItemHelpText.strip(DT.END_OF_LINE)
- CommentItemIns.SetHelpStringItem(CommentItemHelpText)
- CommentInsList.append(CommentItemIns)
-
- BlockFlag = -1
- PreUsage = None
- PreGuidType = None
- PreHelpText = ''
-
- else:
- PreUsage = CommentItemUsage
- PreGuidType = CommentItemGuidType
- PreHelpText = CommentItemHelpText
-
- InfGuidItemObj.SetCommentList(CommentInsList)
- else:
- #
- # Still need to set the USAGE/GUIDTYPE to undefined.
- #
- CommentItemIns = InfGuidItemCommentContent()
- CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
- CommentItemIns.SetGuidTypeItem(DT.ITEM_UNDEFINED)
- InfGuidItemObj.SetCommentList([CommentItemIns])
-
- return InfGuidItemObj
-
-## InfGuidObject
-#
-# InfGuidObject
-#
-class InfGuidObject():
- def __init__(self):
- self.Guids = Sdict()
- #
- # Macro defined in this section should be only used in this section.
- #
- self.Macros = {}
-
- def SetGuid(self, GuidList, Arch = None):
- __SupportArchList = []
- for ArchItem in Arch:
- #
- # Validate Arch
- #
- if (ArchItem == '' or ArchItem is None):
- ArchItem = 'COMMON'
-
- __SupportArchList.append(ArchItem)
-
- for Item in GuidList:
- #
- # Get Comment content of this protocol
- #
- CommentsList = None
- if len(Item) == 3:
- CommentsList = Item[1]
- CurrentLineOfItem = Item[2]
- Item = Item[0]
- InfGuidItemObj = InfGuidItem()
- if len(Item) >= 1 and len(Item) <= 2:
- #
- # Only GuildName contained
- #
- if not IsValidCVariableName(Item[0]):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]),
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- if (Item[0] != ''):
- InfGuidItemObj.SetName(Item[0])
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_CNAME_MISSING,
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- if len(Item) == 2:
- #
- # Contained CName and Feature Flag Express
- # <statements> ::= <CName> ["|" <FeatureFlagExpress>]
- # For GUID entry.
- #
- if Item[1].strip() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- #
- # Validate Feature Flag Express
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(Item[1].strip())
- if not FeatureFlagRtv[0]:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- InfGuidItemObj.SetFeatureFlagExp(Item[1])
- if len(Item) != 1 and len(Item) != 2:
- #
- # Invalid format of GUID statement
- #
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR,
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
-
- InfGuidItemObj = ParseGuidComment(CommentsList, InfGuidItemObj)
- InfGuidItemObj.SetSupArchList(__SupportArchList)
-
- #
- # Determine GUID name duplicate. Follow below rule:
- #
- # A GUID must not be duplicated within a [Guids] section.
- # A GUID may appear in multiple architectural [Guids]
- # sections. A GUID listed in an architectural [Guids]
- # section must not be listed in the common architectural
- # [Guids] section.
- #
- # NOTE: This check will not report error now.
- #
- for Item in self.Guids:
- if Item.GetName() == InfGuidItemObj.GetName():
- ItemSupArchList = Item.GetSupArchList()
- for ItemArch in ItemSupArchList:
- for GuidItemObjArch in __SupportArchList:
- if ItemArch == GuidItemObjArch:
- #
- # ST.ERR_INF_PARSER_ITEM_DUPLICATE
- #
- pass
-
- if ItemArch.upper() == 'COMMON' or GuidItemObjArch.upper() == 'COMMON':
- #
- # ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
- #
- pass
-
- if (InfGuidItemObj) in self.Guids:
- GuidList = self.Guids[InfGuidItemObj]
- GuidList.append(InfGuidItemObj)
- self.Guids[InfGuidItemObj] = GuidList
- else:
- GuidList = []
- GuidList.append(InfGuidItemObj)
- self.Guids[InfGuidItemObj] = GuidList
-
- return True
-
- def GetGuid(self):
- return self.Guids
+## @file
+# This file is used to define class objects of INF file [Guids] section.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfGuidObject
+'''
+
+from Library.ParserValidate import IsValidCVariableName
+from Library.CommentParsing import ParseComment
+from Library.ExpressionValidate import IsValidFeatureFlagExp
+
+from Library.Misc import Sdict
+from Library import DataType as DT
+import Logger.Log as Logger
+from Logger import ToolError
+from Logger import StringTable as ST
+
+class InfGuidItemCommentContent():
+ def __init__(self):
+ #
+ # ## SOMETIMES_CONSUMES ## Variable:L"MemoryTypeInformation"
+ # TailString.
+ #
+ #
+ # SOMETIMES_CONSUMES
+ #
+ self.UsageItem = ''
+ #
+ # Variable
+ #
+ self.GuidTypeItem = ''
+ #
+ # MemoryTypeInformation
+ #
+ self.VariableNameItem = ''
+ #
+ # TailString
+ #
+ self.HelpStringItem = ''
+
+ def SetUsageItem(self, UsageItem):
+ self.UsageItem = UsageItem
+ def GetUsageItem(self):
+ return self.UsageItem
+
+ def SetGuidTypeItem(self, GuidTypeItem):
+ self.GuidTypeItem = GuidTypeItem
+ def GetGuidTypeItem(self):
+ return self.GuidTypeItem
+
+ def SetVariableNameItem(self, VariableNameItem):
+ self.VariableNameItem = VariableNameItem
+ def GetVariableNameItem(self):
+ return self.VariableNameItem
+
+ def SetHelpStringItem(self, HelpStringItem):
+ self.HelpStringItem = HelpStringItem
+ def GetHelpStringItem(self):
+ return self.HelpStringItem
+
+class InfGuidItem():
+ def __init__(self):
+ self.Name = ''
+ self.FeatureFlagExp = ''
+ #
+ # A list contain instance of InfGuidItemCommentContent
+ #
+ self.CommentList = []
+ self.SupArchList = []
+
+ def SetName(self, Name):
+ self.Name = Name
+ def GetName(self):
+ return self.Name
+
+ def SetFeatureFlagExp(self, FeatureFlagExp):
+ self.FeatureFlagExp = FeatureFlagExp
+ def GetFeatureFlagExp(self):
+ return self.FeatureFlagExp
+
+ def SetCommentList(self, CommentList):
+ self.CommentList = CommentList
+ def GetCommentList(self):
+ return self.CommentList
+
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+
+## ParseComment
+#
+# ParseComment
+#
+def ParseGuidComment(CommentsList, InfGuidItemObj):
+ #
+ # Get/Set Usage and HelpString
+ #
+ if CommentsList is not None and len(CommentsList) != 0 :
+ CommentInsList = []
+ PreUsage = None
+ PreGuidType = None
+ PreHelpText = ''
+ BlockFlag = -1
+ Count = 0
+ for CommentItem in CommentsList:
+ Count = Count + 1
+ CommentItemUsage, \
+ CommentItemGuidType, \
+ CommentItemVarString, \
+ CommentItemHelpText = \
+ ParseComment(CommentItem,
+ DT.ALL_USAGE_TOKENS,
+ DT.GUID_TYPE_TOKENS,
+ [],
+ True)
+
+ if CommentItemHelpText is None:
+ CommentItemHelpText = ''
+ if Count == len(CommentsList) and CommentItemUsage == CommentItemGuidType == DT.ITEM_UNDEFINED:
+ CommentItemHelpText = DT.END_OF_LINE
+
+ if Count == len(CommentsList):
+ if BlockFlag == 1 or BlockFlag == 2:
+ if CommentItemUsage == CommentItemGuidType == DT.ITEM_UNDEFINED:
+ BlockFlag = 4
+ else:
+ BlockFlag = 3
+ if BlockFlag == -1:
+ BlockFlag = 4
+ if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
+ if CommentItemUsage == CommentItemGuidType == DT.ITEM_UNDEFINED:
+ if BlockFlag == -1:
+ BlockFlag = 1
+ elif BlockFlag == 1:
+ BlockFlag = 2
+ else:
+ if BlockFlag == 1 or BlockFlag == 2:
+ BlockFlag = 3
+ elif BlockFlag == -1:
+ BlockFlag = 4
+
+ #
+ # Combine two comment line if they are generic comment
+ #
+ if CommentItemUsage == CommentItemGuidType == PreUsage == PreGuidType == DT.ITEM_UNDEFINED:
+ CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
+ PreHelpText = CommentItemHelpText
+
+ if BlockFlag == 4:
+ CommentItemIns = InfGuidItemCommentContent()
+ CommentItemIns.SetUsageItem(CommentItemUsage)
+ CommentItemIns.SetGuidTypeItem(CommentItemGuidType)
+ CommentItemIns.SetVariableNameItem(CommentItemVarString)
+ if CommentItemHelpText == '' or CommentItemHelpText.endswith(DT.END_OF_LINE):
+ CommentItemHelpText = CommentItemHelpText.strip(DT.END_OF_LINE)
+ CommentItemIns.SetHelpStringItem(CommentItemHelpText)
+ CommentInsList.append(CommentItemIns)
+
+ BlockFlag = -1
+ PreUsage = None
+ PreGuidType = None
+ PreHelpText = ''
+
+ elif BlockFlag == 3:
+ #
+ # Add previous help string
+ #
+ CommentItemIns = InfGuidItemCommentContent()
+ CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
+ CommentItemIns.SetGuidTypeItem(DT.ITEM_UNDEFINED)
+ if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
+ PreHelpText = PreHelpText.strip(DT.END_OF_LINE)
+ CommentItemIns.SetHelpStringItem(PreHelpText)
+ CommentInsList.append(CommentItemIns)
+ #
+ # Add Current help string
+ #
+ CommentItemIns = InfGuidItemCommentContent()
+ CommentItemIns.SetUsageItem(CommentItemUsage)
+ CommentItemIns.SetGuidTypeItem(CommentItemGuidType)
+ CommentItemIns.SetVariableNameItem(CommentItemVarString)
+ if CommentItemHelpText == '' or CommentItemHelpText.endswith(DT.END_OF_LINE):
+ CommentItemHelpText = CommentItemHelpText.strip(DT.END_OF_LINE)
+ CommentItemIns.SetHelpStringItem(CommentItemHelpText)
+ CommentInsList.append(CommentItemIns)
+
+ BlockFlag = -1
+ PreUsage = None
+ PreGuidType = None
+ PreHelpText = ''
+
+ else:
+ PreUsage = CommentItemUsage
+ PreGuidType = CommentItemGuidType
+ PreHelpText = CommentItemHelpText
+
+ InfGuidItemObj.SetCommentList(CommentInsList)
+ else:
+ #
+ # Still need to set the USAGE/GUIDTYPE to undefined.
+ #
+ CommentItemIns = InfGuidItemCommentContent()
+ CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
+ CommentItemIns.SetGuidTypeItem(DT.ITEM_UNDEFINED)
+ InfGuidItemObj.SetCommentList([CommentItemIns])
+
+ return InfGuidItemObj
+
+## InfGuidObject
+#
+# InfGuidObject
+#
+class InfGuidObject():
+ def __init__(self):
+ self.Guids = Sdict()
+ #
+ # Macro defined in this section should be only used in this section.
+ #
+ self.Macros = {}
+
+ def SetGuid(self, GuidList, Arch = None):
+ __SupportArchList = []
+ for ArchItem in Arch:
+ #
+ # Validate Arch
+ #
+ if (ArchItem == '' or ArchItem is None):
+ ArchItem = 'COMMON'
+
+ __SupportArchList.append(ArchItem)
+
+ for Item in GuidList:
+ #
+ # Get Comment content of this protocol
+ #
+ CommentsList = None
+ if len(Item) == 3:
+ CommentsList = Item[1]
+ CurrentLineOfItem = Item[2]
+ Item = Item[0]
+ InfGuidItemObj = InfGuidItem()
+ if len(Item) >= 1 and len(Item) <= 2:
+ #
+ # Only GuildName contained
+ #
+ if not IsValidCVariableName(Item[0]):
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]),
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ if (Item[0] != ''):
+ InfGuidItemObj.SetName(Item[0])
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_CNAME_MISSING,
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ if len(Item) == 2:
+ #
+ # Contained CName and Feature Flag Express
+ # <statements> ::= <CName> ["|" <FeatureFlagExpress>]
+ # For GUID entry.
+ #
+ if Item[1].strip() == '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ #
+ # Validate Feature Flag Express
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(Item[1].strip())
+ if not FeatureFlagRtv[0]:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ InfGuidItemObj.SetFeatureFlagExp(Item[1])
+ if len(Item) != 1 and len(Item) != 2:
+ #
+ # Invalid format of GUID statement
+ #
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR,
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+
+ InfGuidItemObj = ParseGuidComment(CommentsList, InfGuidItemObj)
+ InfGuidItemObj.SetSupArchList(__SupportArchList)
+
+ #
+ # Determine GUID name duplicate. Follow below rule:
+ #
+ # A GUID must not be duplicated within a [Guids] section.
+ # A GUID may appear in multiple architectural [Guids]
+ # sections. A GUID listed in an architectural [Guids]
+ # section must not be listed in the common architectural
+ # [Guids] section.
+ #
+ # NOTE: This check will not report error now.
+ #
+ for Item in self.Guids:
+ if Item.GetName() == InfGuidItemObj.GetName():
+ ItemSupArchList = Item.GetSupArchList()
+ for ItemArch in ItemSupArchList:
+ for GuidItemObjArch in __SupportArchList:
+ if ItemArch == GuidItemObjArch:
+ #
+ # ST.ERR_INF_PARSER_ITEM_DUPLICATE
+ #
+ pass
+
+ if ItemArch.upper() == 'COMMON' or GuidItemObjArch.upper() == 'COMMON':
+ #
+ # ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
+ #
+ pass
+
+ if (InfGuidItemObj) in self.Guids:
+ GuidList = self.Guids[InfGuidItemObj]
+ GuidList.append(InfGuidItemObj)
+ self.Guids[InfGuidItemObj] = GuidList
+ else:
+ GuidList = []
+ GuidList.append(InfGuidItemObj)
+ self.Guids[InfGuidItemObj] = GuidList
+
+ return True
+
+ def GetGuid(self):
+ return self.Guids
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfHeaderObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfHeaderObject.py
index 087edca93b..2e70f08b95 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfHeaderObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfHeaderObject.py
@@ -1,113 +1,113 @@
-## @file
-# This file is used to define class objects of INF file header.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfHeaderObject
-'''
-
-## INF file header object
-#
-# A sample file header
-#
-# ## @file xxx.inf FileName
-# # Abstract
-# #
-# # Description
-# #
-# # Copyright
-# #
-# # License
-# #
-#
-class InfHeaderObject():
- def __init__(self):
- self.FileName = ''
- self.Abstract = ''
- self.Description = ''
- self.Copyright = ''
- self.License = ''
-
- ## SetFileName
- #
- # @param FileName: File Name
- #
- def SetFileName(self, FileName):
- if not (FileName == '' or FileName is None):
- self.FileName = FileName
- return True
- else:
- return False
-
- ## GetFileName
- #
- def GetFileName(self):
- return self.FileName
-
- ## SetAbstract
- #
- # @param Abstract: Abstract
- #
- def SetAbstract(self, Abstract):
- if not (Abstract == '' or Abstract is None):
- self.Abstract = Abstract
- return True
- else:
- return False
-
- ## GetAbstract
- #
- def GetAbstract(self):
- return self.Abstract
-
- ## SetDescription
- #
- # @param Description: Description content
- #
- def SetDescription(self, Description):
- if not (Description == '' or Description is None):
- self.Description = Description
- return True
- else:
- return False
-
- ## GetAbstract
- #
- def GetDescription(self):
- return self.Description
-
- ## SetCopyright
- #
- # @param Copyright: Copyright content
- #
- def SetCopyright(self, Copyright):
- if not (Copyright == '' or Copyright is None):
- self.Copyright = Copyright
- return True
- else:
- return False
-
- ## GetCopyright
- #
- def GetCopyright(self):
- return self.Copyright
-
- ## SetCopyright
- #
- # @param License: License content
- #
- def SetLicense(self, License):
- if not (License == '' or License is None):
- self.License = License
- return True
- else:
- return False
-
- ## GetLicense
- #
- def GetLicense(self):
- return self.License
+## @file
+# This file is used to define class objects of INF file header.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfHeaderObject
+'''
+
+## INF file header object
+#
+# A sample file header
+#
+# ## @file xxx.inf FileName
+# # Abstract
+# #
+# # Description
+# #
+# # Copyright
+# #
+# # License
+# #
+#
+class InfHeaderObject():
+ def __init__(self):
+ self.FileName = ''
+ self.Abstract = ''
+ self.Description = ''
+ self.Copyright = ''
+ self.License = ''
+
+ ## SetFileName
+ #
+ # @param FileName: File Name
+ #
+ def SetFileName(self, FileName):
+ if not (FileName == '' or FileName is None):
+ self.FileName = FileName
+ return True
+ else:
+ return False
+
+ ## GetFileName
+ #
+ def GetFileName(self):
+ return self.FileName
+
+ ## SetAbstract
+ #
+ # @param Abstract: Abstract
+ #
+ def SetAbstract(self, Abstract):
+ if not (Abstract == '' or Abstract is None):
+ self.Abstract = Abstract
+ return True
+ else:
+ return False
+
+ ## GetAbstract
+ #
+ def GetAbstract(self):
+ return self.Abstract
+
+ ## SetDescription
+ #
+ # @param Description: Description content
+ #
+ def SetDescription(self, Description):
+ if not (Description == '' or Description is None):
+ self.Description = Description
+ return True
+ else:
+ return False
+
+ ## GetAbstract
+ #
+ def GetDescription(self):
+ return self.Description
+
+ ## SetCopyright
+ #
+ # @param Copyright: Copyright content
+ #
+ def SetCopyright(self, Copyright):
+ if not (Copyright == '' or Copyright is None):
+ self.Copyright = Copyright
+ return True
+ else:
+ return False
+
+ ## GetCopyright
+ #
+ def GetCopyright(self):
+ return self.Copyright
+
+ ## SetCopyright
+ #
+ # @param License: License content
+ #
+ def SetLicense(self, License):
+ if not (License == '' or License is None):
+ self.License = License
+ return True
+ else:
+ return False
+
+ ## GetLicense
+ #
+ def GetLicense(self):
+ return self.License
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py
index 2e56028318..b3433b9e8d 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py
@@ -1,247 +1,247 @@
-## @file
-# This file is used to define class objects of INF file [LibraryClasses] section.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfLibraryClassesObject
-'''
-
-from Logger import StringTable as ST
-from Logger import ToolError
-import Logger.Log as Logger
-from Library import GlobalData
-
-from Library.Misc import Sdict
-from Object.Parser.InfCommonObject import CurrentLine
-from Library.ExpressionValidate import IsValidFeatureFlagExp
-from Library.ParserValidate import IsValidLibName
-
-## GetArchModuleType
-#
-# Get Arch List and ModuleType List
-#
-def GetArchModuleType(KeyList):
- __SupArchList = []
- __SupModuleList = []
-
- for (ArchItem, ModuleItem) in KeyList:
- #
- # Validate Arch
- #
- if (ArchItem == '' or ArchItem is None):
- ArchItem = 'COMMON'
-
- if (ModuleItem == '' or ModuleItem is None):
- ModuleItem = 'COMMON'
-
- if ArchItem not in __SupArchList:
- __SupArchList.append(ArchItem)
-
- List = ModuleItem.split('|')
- for Entry in List:
- if Entry not in __SupModuleList:
- __SupModuleList.append(Entry)
-
- return (__SupArchList, __SupModuleList)
-
-
-class InfLibraryClassItem():
- def __init__(self, LibName='', FeatureFlagExp='', HelpString=None):
- self.LibName = LibName
- self.FeatureFlagExp = FeatureFlagExp
- self.HelpString = HelpString
- self.CurrentLine = CurrentLine()
- self.SupArchList = []
- self.SupModuleList = []
- self.FileGuid = ''
- self.Version = ''
-
- def SetLibName(self, LibName):
- self.LibName = LibName
- def GetLibName(self):
- return self.LibName
-
- def SetHelpString(self, HelpString):
- self.HelpString = HelpString
- def GetHelpString(self):
- return self.HelpString
-
- def SetFeatureFlagExp(self, FeatureFlagExp):
- self.FeatureFlagExp = FeatureFlagExp
- def GetFeatureFlagExp(self):
- return self.FeatureFlagExp
-
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
- def GetSupArchList(self):
- return self.SupArchList
-
- def SetSupModuleList(self, SupModuleList):
- self.SupModuleList = SupModuleList
- def GetSupModuleList(self):
- return self.SupModuleList
-
- #
- # As Build related information
- #
- def SetFileGuid(self, FileGuid):
- self.FileGuid = FileGuid
- def GetFileGuid(self):
- return self.FileGuid
-
- def SetVersion(self, Version):
- self.Version = Version
- def GetVersion(self):
- return self.Version
-
-## INF LibraryClass Section
-#
-#
-#
-class InfLibraryClassObject():
- def __init__(self):
- self.LibraryClasses = Sdict()
- #
- # Macro defined in this section should be only used in this section.
- #
- self.Macros = {}
-
- ##SetLibraryClasses
- #
- #
- # @param HelpString: It can be a common comment or contain a recommend
- # instance.
- #
- def SetLibraryClasses(self, LibContent, KeyList=None):
- #
- # Validate Arch
- #
- (__SupArchList, __SupModuleList) = GetArchModuleType(KeyList)
-
- for LibItem in LibContent:
- LibItemObj = InfLibraryClassItem()
- if not GlobalData.gIS_BINARY_INF:
- HelpStringObj = LibItem[1]
- LibItemObj.CurrentLine.SetFileName(LibItem[2][2])
- LibItemObj.CurrentLine.SetLineNo(LibItem[2][1])
- LibItemObj.CurrentLine.SetLineString(LibItem[2][0])
- LibItem = LibItem[0]
- if HelpStringObj is not None:
- LibItemObj.SetHelpString(HelpStringObj)
- if len(LibItem) >= 1:
- if LibItem[0].strip() != '':
- if IsValidLibName(LibItem[0].strip()):
- if LibItem[0].strip() != 'NULL':
- LibItemObj.SetLibName(LibItem[0])
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_DEFINE_LIB_NAME_INVALID,
- File=GlobalData.gINF_MODULE_NAME,
- Line=LibItemObj.CurrentLine.GetLineNo(),
- ExtraData=LibItemObj.CurrentLine.GetLineString())
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (LibItem[0]),
- File=GlobalData.gINF_MODULE_NAME,
- Line=LibItemObj.CurrentLine.GetLineNo(),
- ExtraData=LibItemObj.CurrentLine.GetLineString())
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_LIBRARY_SECTION_LIBNAME_MISSING,
- File=GlobalData.gINF_MODULE_NAME,
- Line=LibItemObj.CurrentLine.GetLineNo(),
- ExtraData=LibItemObj.CurrentLine.GetLineString())
- if len(LibItem) == 2:
- if LibItem[1].strip() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- File=GlobalData.gINF_MODULE_NAME,
- Line=LibItemObj.CurrentLine.GetLineNo(),
- ExtraData=LibItemObj.CurrentLine.GetLineString())
- #
- # Validate FFE
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(LibItem[1].strip())
- if not FeatureFlagRtv[0]:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
- File=GlobalData.gINF_MODULE_NAME,
- Line=LibItemObj.CurrentLine.GetLineNo(),
- ExtraData=LibItemObj.CurrentLine.GetLineString())
- LibItemObj.SetFeatureFlagExp(LibItem[1].strip())
-
- #
- # Invalid strings
- #
- if len(LibItem) < 1 or len(LibItem) > 2:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_LIBRARY_SECTION_CONTENT_ERROR,
- File=GlobalData.gINF_MODULE_NAME,
- Line=LibItemObj.CurrentLine.GetLineNo(),
- ExtraData=LibItemObj.CurrentLine.GetLineString())
-
- LibItemObj.SetSupArchList(__SupArchList)
- LibItemObj.SetSupModuleList(__SupModuleList)
-
- #
- # Determine Library class duplicate. Follow below rule:
- #
- # A library class keyword must not be duplicated within a
- # [LibraryClasses] section. Library class keywords may appear in
- # multiple architectural and module type [LibraryClasses] sections.
- # A library class keyword listed in an architectural or module type
- # [LibraryClasses] section must not be listed in the common
- # architectural or module type [LibraryClasses] section.
- #
- # NOTE: This check will not report error now. But keep code for future enhancement.
- #
-# for Item in self.LibraryClasses:
-# if Item.GetLibName() == LibItemObj.GetLibName():
-# ItemSupArchList = Item.GetSupArchList()
-# ItemSupModuleList = Item.GetSupModuleList()
-# for ItemArch in ItemSupArchList:
-# for ItemModule in ItemSupModuleList:
-# for LibItemObjArch in __SupArchList:
-# for LibItemObjModule in __SupModuleList:
-# if ItemArch == LibItemObjArch and LibItemObjModule == ItemModule:
-# #
-# # ERR_INF_PARSER_ITEM_DUPLICATE
-# #
-# pass
-# if (ItemArch.upper() == 'COMMON' or LibItemObjArch.upper() == 'COMMON') \
-# and LibItemObjModule == ItemModule:
-# #
-# # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
-# #
-# pass
- else:
- #
- # Assume the file GUID is well formatted.
- #
- LibItemObj.SetFileGuid(LibItem[0])
- LibItemObj.SetVersion(LibItem[1])
- LibItemObj.SetSupArchList(__SupArchList)
-
- if (LibItemObj) in self.LibraryClasses:
- LibraryList = self.LibraryClasses[LibItemObj]
- LibraryList.append(LibItemObj)
- self.LibraryClasses[LibItemObj] = LibraryList
- else:
- LibraryList = []
- LibraryList.append(LibItemObj)
- self.LibraryClasses[LibItemObj] = LibraryList
-
- return True
-
- def GetLibraryClasses(self):
- return self.LibraryClasses
+## @file
+# This file is used to define class objects of INF file [LibraryClasses] section.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfLibraryClassesObject
+'''
+
+from Logger import StringTable as ST
+from Logger import ToolError
+import Logger.Log as Logger
+from Library import GlobalData
+
+from Library.Misc import Sdict
+from Object.Parser.InfCommonObject import CurrentLine
+from Library.ExpressionValidate import IsValidFeatureFlagExp
+from Library.ParserValidate import IsValidLibName
+
+## GetArchModuleType
+#
+# Get Arch List and ModuleType List
+#
+def GetArchModuleType(KeyList):
+ __SupArchList = []
+ __SupModuleList = []
+
+ for (ArchItem, ModuleItem) in KeyList:
+ #
+ # Validate Arch
+ #
+ if (ArchItem == '' or ArchItem is None):
+ ArchItem = 'COMMON'
+
+ if (ModuleItem == '' or ModuleItem is None):
+ ModuleItem = 'COMMON'
+
+ if ArchItem not in __SupArchList:
+ __SupArchList.append(ArchItem)
+
+ List = ModuleItem.split('|')
+ for Entry in List:
+ if Entry not in __SupModuleList:
+ __SupModuleList.append(Entry)
+
+ return (__SupArchList, __SupModuleList)
+
+
+class InfLibraryClassItem():
+ def __init__(self, LibName='', FeatureFlagExp='', HelpString=None):
+ self.LibName = LibName
+ self.FeatureFlagExp = FeatureFlagExp
+ self.HelpString = HelpString
+ self.CurrentLine = CurrentLine()
+ self.SupArchList = []
+ self.SupModuleList = []
+ self.FileGuid = ''
+ self.Version = ''
+
+ def SetLibName(self, LibName):
+ self.LibName = LibName
+ def GetLibName(self):
+ return self.LibName
+
+ def SetHelpString(self, HelpString):
+ self.HelpString = HelpString
+ def GetHelpString(self):
+ return self.HelpString
+
+ def SetFeatureFlagExp(self, FeatureFlagExp):
+ self.FeatureFlagExp = FeatureFlagExp
+ def GetFeatureFlagExp(self):
+ return self.FeatureFlagExp
+
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+
+ def SetSupModuleList(self, SupModuleList):
+ self.SupModuleList = SupModuleList
+ def GetSupModuleList(self):
+ return self.SupModuleList
+
+ #
+ # As Build related information
+ #
+ def SetFileGuid(self, FileGuid):
+ self.FileGuid = FileGuid
+ def GetFileGuid(self):
+ return self.FileGuid
+
+ def SetVersion(self, Version):
+ self.Version = Version
+ def GetVersion(self):
+ return self.Version
+
+## INF LibraryClass Section
+#
+#
+#
+class InfLibraryClassObject():
+ def __init__(self):
+ self.LibraryClasses = Sdict()
+ #
+ # Macro defined in this section should be only used in this section.
+ #
+ self.Macros = {}
+
+ ##SetLibraryClasses
+ #
+ #
+ # @param HelpString: It can be a common comment or contain a recommend
+ # instance.
+ #
+ def SetLibraryClasses(self, LibContent, KeyList=None):
+ #
+ # Validate Arch
+ #
+ (__SupArchList, __SupModuleList) = GetArchModuleType(KeyList)
+
+ for LibItem in LibContent:
+ LibItemObj = InfLibraryClassItem()
+ if not GlobalData.gIS_BINARY_INF:
+ HelpStringObj = LibItem[1]
+ LibItemObj.CurrentLine.SetFileName(LibItem[2][2])
+ LibItemObj.CurrentLine.SetLineNo(LibItem[2][1])
+ LibItemObj.CurrentLine.SetLineString(LibItem[2][0])
+ LibItem = LibItem[0]
+ if HelpStringObj is not None:
+ LibItemObj.SetHelpString(HelpStringObj)
+ if len(LibItem) >= 1:
+ if LibItem[0].strip() != '':
+ if IsValidLibName(LibItem[0].strip()):
+ if LibItem[0].strip() != 'NULL':
+ LibItemObj.SetLibName(LibItem[0])
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_DEFINE_LIB_NAME_INVALID,
+ File=GlobalData.gINF_MODULE_NAME,
+ Line=LibItemObj.CurrentLine.GetLineNo(),
+ ExtraData=LibItemObj.CurrentLine.GetLineString())
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (LibItem[0]),
+ File=GlobalData.gINF_MODULE_NAME,
+ Line=LibItemObj.CurrentLine.GetLineNo(),
+ ExtraData=LibItemObj.CurrentLine.GetLineString())
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_LIBRARY_SECTION_LIBNAME_MISSING,
+ File=GlobalData.gINF_MODULE_NAME,
+ Line=LibItemObj.CurrentLine.GetLineNo(),
+ ExtraData=LibItemObj.CurrentLine.GetLineString())
+ if len(LibItem) == 2:
+ if LibItem[1].strip() == '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
+ File=GlobalData.gINF_MODULE_NAME,
+ Line=LibItemObj.CurrentLine.GetLineNo(),
+ ExtraData=LibItemObj.CurrentLine.GetLineString())
+ #
+ # Validate FFE
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(LibItem[1].strip())
+ if not FeatureFlagRtv[0]:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
+ File=GlobalData.gINF_MODULE_NAME,
+ Line=LibItemObj.CurrentLine.GetLineNo(),
+ ExtraData=LibItemObj.CurrentLine.GetLineString())
+ LibItemObj.SetFeatureFlagExp(LibItem[1].strip())
+
+ #
+ # Invalid strings
+ #
+ if len(LibItem) < 1 or len(LibItem) > 2:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_LIBRARY_SECTION_CONTENT_ERROR,
+ File=GlobalData.gINF_MODULE_NAME,
+ Line=LibItemObj.CurrentLine.GetLineNo(),
+ ExtraData=LibItemObj.CurrentLine.GetLineString())
+
+ LibItemObj.SetSupArchList(__SupArchList)
+ LibItemObj.SetSupModuleList(__SupModuleList)
+
+ #
+ # Determine Library class duplicate. Follow below rule:
+ #
+ # A library class keyword must not be duplicated within a
+ # [LibraryClasses] section. Library class keywords may appear in
+ # multiple architectural and module type [LibraryClasses] sections.
+ # A library class keyword listed in an architectural or module type
+ # [LibraryClasses] section must not be listed in the common
+ # architectural or module type [LibraryClasses] section.
+ #
+ # NOTE: This check will not report error now. But keep code for future enhancement.
+ #
+# for Item in self.LibraryClasses:
+# if Item.GetLibName() == LibItemObj.GetLibName():
+# ItemSupArchList = Item.GetSupArchList()
+# ItemSupModuleList = Item.GetSupModuleList()
+# for ItemArch in ItemSupArchList:
+# for ItemModule in ItemSupModuleList:
+# for LibItemObjArch in __SupArchList:
+# for LibItemObjModule in __SupModuleList:
+# if ItemArch == LibItemObjArch and LibItemObjModule == ItemModule:
+# #
+# # ERR_INF_PARSER_ITEM_DUPLICATE
+# #
+# pass
+# if (ItemArch.upper() == 'COMMON' or LibItemObjArch.upper() == 'COMMON') \
+# and LibItemObjModule == ItemModule:
+# #
+# # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
+# #
+# pass
+ else:
+ #
+ # Assume the file GUID is well formatted.
+ #
+ LibItemObj.SetFileGuid(LibItem[0])
+ LibItemObj.SetVersion(LibItem[1])
+ LibItemObj.SetSupArchList(__SupArchList)
+
+ if (LibItemObj) in self.LibraryClasses:
+ LibraryList = self.LibraryClasses[LibItemObj]
+ LibraryList.append(LibItemObj)
+ self.LibraryClasses[LibItemObj] = LibraryList
+ else:
+ LibraryList = []
+ LibraryList.append(LibItemObj)
+ self.LibraryClasses[LibItemObj] = LibraryList
+
+ return True
+
+ def GetLibraryClasses(self):
+ return self.LibraryClasses
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py b/BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py
index 469d6fbb15..1354ab456b 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py
@@ -1,142 +1,142 @@
-## @file
-# This file is used to define class objects of INF file miscellaneous.
-# Include BootMode/HOB/Event and others. It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfMisc
-'''
-
-import Logger.Log as Logger
-from Logger import ToolError
-
-from Library import DataType as DT
-from Object.Parser.InfCommonObject import InfSectionCommonDef
-from Library.Misc import Sdict
-
-##
-# BootModeObject
-#
-class InfBootModeObject():
- def __init__(self):
- self.SupportedBootModes = ''
- self.HelpString = ''
- self.Usage = ''
-
- def SetSupportedBootModes(self, SupportedBootModes):
- self.SupportedBootModes = SupportedBootModes
- def GetSupportedBootModes(self):
- return self.SupportedBootModes
-
- def SetHelpString(self, HelpString):
- self.HelpString = HelpString
- def GetHelpString(self):
- return self.HelpString
-
- def SetUsage(self, Usage):
- self.Usage = Usage
- def GetUsage(self):
- return self.Usage
-##
-# EventObject
-#
-class InfEventObject():
- def __init__(self):
- self.EventType = ''
- self.HelpString = ''
- self.Usage = ''
-
- def SetEventType(self, EventType):
- self.EventType = EventType
-
- def GetEventType(self):
- return self.EventType
-
- def SetHelpString(self, HelpString):
- self.HelpString = HelpString
- def GetHelpString(self):
- return self.HelpString
-
- def SetUsage(self, Usage):
- self.Usage = Usage
- def GetUsage(self):
- return self.Usage
-##
-# HobObject
-#
-class InfHobObject():
- def __init__(self):
- self.HobType = ''
- self.Usage = ''
- self.SupArchList = []
- self.HelpString = ''
-
- def SetHobType(self, HobType):
- self.HobType = HobType
-
- def GetHobType(self):
- return self.HobType
-
- def SetUsage(self, Usage):
- self.Usage = Usage
- def GetUsage(self):
- return self.Usage
-
- def SetSupArchList(self, ArchList):
- self.SupArchList = ArchList
- def GetSupArchList(self):
- return self.SupArchList
-
- def SetHelpString(self, HelpString):
- self.HelpString = HelpString
- def GetHelpString(self):
- return self.HelpString
-
-##
-# InfSpecialCommentObject
-#
-class InfSpecialCommentObject(InfSectionCommonDef):
- def __init__(self):
- self.SpecialComments = Sdict()
- InfSectionCommonDef.__init__(self)
-
- def SetSpecialComments(self, SepcialSectionList = None, Type = ''):
- if Type == DT.TYPE_HOB_SECTION or \
- Type == DT.TYPE_EVENT_SECTION or \
- Type == DT.TYPE_BOOTMODE_SECTION:
- for Item in SepcialSectionList:
- if Type in self.SpecialComments:
- ObjList = self.SpecialComments[Type]
- ObjList.append(Item)
- self.SpecialComments[Type] = ObjList
- else:
- ObjList = []
- ObjList.append(Item)
- self.SpecialComments[Type] = ObjList
-
- return True
-
- def GetSpecialComments(self):
- return self.SpecialComments
-
-
-
-## ErrorInInf
-#
-# An encapsulate of Error for INF parser.
-#
-def ErrorInInf(Message=None, ErrorCode=None, LineInfo=None, RaiseError=True):
- if ErrorCode is None:
- ErrorCode = ToolError.FORMAT_INVALID
- if LineInfo is None:
- LineInfo = ['', -1, '']
- Logger.Error("InfParser",
- ErrorCode,
- Message=Message,
- File=LineInfo[0],
- Line=LineInfo[1],
- ExtraData=LineInfo[2],
- RaiseError=RaiseError)
+## @file
+# This file is used to define class objects of INF file miscellaneous.
+# Include BootMode/HOB/Event and others. It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfMisc
+'''
+
+import Logger.Log as Logger
+from Logger import ToolError
+
+from Library import DataType as DT
+from Object.Parser.InfCommonObject import InfSectionCommonDef
+from Library.Misc import Sdict
+
+##
+# BootModeObject
+#
+class InfBootModeObject():
+ def __init__(self):
+ self.SupportedBootModes = ''
+ self.HelpString = ''
+ self.Usage = ''
+
+ def SetSupportedBootModes(self, SupportedBootModes):
+ self.SupportedBootModes = SupportedBootModes
+ def GetSupportedBootModes(self):
+ return self.SupportedBootModes
+
+ def SetHelpString(self, HelpString):
+ self.HelpString = HelpString
+ def GetHelpString(self):
+ return self.HelpString
+
+ def SetUsage(self, Usage):
+ self.Usage = Usage
+ def GetUsage(self):
+ return self.Usage
+##
+# EventObject
+#
+class InfEventObject():
+ def __init__(self):
+ self.EventType = ''
+ self.HelpString = ''
+ self.Usage = ''
+
+ def SetEventType(self, EventType):
+ self.EventType = EventType
+
+ def GetEventType(self):
+ return self.EventType
+
+ def SetHelpString(self, HelpString):
+ self.HelpString = HelpString
+ def GetHelpString(self):
+ return self.HelpString
+
+ def SetUsage(self, Usage):
+ self.Usage = Usage
+ def GetUsage(self):
+ return self.Usage
+##
+# HobObject
+#
+class InfHobObject():
+ def __init__(self):
+ self.HobType = ''
+ self.Usage = ''
+ self.SupArchList = []
+ self.HelpString = ''
+
+ def SetHobType(self, HobType):
+ self.HobType = HobType
+
+ def GetHobType(self):
+ return self.HobType
+
+ def SetUsage(self, Usage):
+ self.Usage = Usage
+ def GetUsage(self):
+ return self.Usage
+
+ def SetSupArchList(self, ArchList):
+ self.SupArchList = ArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+
+ def SetHelpString(self, HelpString):
+ self.HelpString = HelpString
+ def GetHelpString(self):
+ return self.HelpString
+
+##
+# InfSpecialCommentObject
+#
+class InfSpecialCommentObject(InfSectionCommonDef):
+ def __init__(self):
+ self.SpecialComments = Sdict()
+ InfSectionCommonDef.__init__(self)
+
+ def SetSpecialComments(self, SepcialSectionList = None, Type = ''):
+ if Type == DT.TYPE_HOB_SECTION or \
+ Type == DT.TYPE_EVENT_SECTION or \
+ Type == DT.TYPE_BOOTMODE_SECTION:
+ for Item in SepcialSectionList:
+ if Type in self.SpecialComments:
+ ObjList = self.SpecialComments[Type]
+ ObjList.append(Item)
+ self.SpecialComments[Type] = ObjList
+ else:
+ ObjList = []
+ ObjList.append(Item)
+ self.SpecialComments[Type] = ObjList
+
+ return True
+
+ def GetSpecialComments(self):
+ return self.SpecialComments
+
+
+
+## ErrorInInf
+#
+# An encapsulate of Error for INF parser.
+#
+def ErrorInInf(Message=None, ErrorCode=None, LineInfo=None, RaiseError=True):
+ if ErrorCode is None:
+ ErrorCode = ToolError.FORMAT_INVALID
+ if LineInfo is None:
+ LineInfo = ['', -1, '']
+ Logger.Error("InfParser",
+ ErrorCode,
+ Message=Message,
+ File=LineInfo[0],
+ Line=LineInfo[1],
+ ExtraData=LineInfo[2],
+ RaiseError=RaiseError)
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py
index 0e8fc7d98b..1ad04758bd 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py
@@ -1,181 +1,181 @@
-## @file
-# This file is used to define class objects of INF file [Packages] section.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfPackageObject
-'''
-
-from Logger import StringTable as ST
-from Logger import ToolError
-import Logger.Log as Logger
-from Library import GlobalData
-
-from Library.Misc import Sdict
-from Library.ParserValidate import IsValidPath
-from Library.ExpressionValidate import IsValidFeatureFlagExp
-
-class InfPackageItem():
- def __init__(self,
- PackageName = '',
- FeatureFlagExp = '',
- HelpString = ''):
- self.PackageName = PackageName
- self.FeatureFlagExp = FeatureFlagExp
- self.HelpString = HelpString
- self.SupArchList = []
-
- def SetPackageName(self, PackageName):
- self.PackageName = PackageName
- def GetPackageName(self):
- return self.PackageName
-
- def SetFeatureFlagExp(self, FeatureFlagExp):
- self.FeatureFlagExp = FeatureFlagExp
- def GetFeatureFlagExp(self):
- return self.FeatureFlagExp
-
- def SetHelpString(self, HelpString):
- self.HelpString = HelpString
- def GetHelpString(self):
- return self.HelpString
-
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
- def GetSupArchList(self):
- return self.SupArchList
-
-
-## INF package section
-#
-#
-#
-class InfPackageObject():
- def __init__(self):
- self.Packages = Sdict()
- #
- # Macro defined in this section should be only used in this section.
- #
- self.Macros = {}
-
- def SetPackages(self, PackageData, Arch = None):
- IsValidFileFlag = False
- SupArchList = []
- for ArchItem in Arch:
- #
- # Validate Arch
- #
- if (ArchItem == '' or ArchItem is None):
- ArchItem = 'COMMON'
- SupArchList.append(ArchItem)
-
- for PackageItem in PackageData:
- PackageItemObj = InfPackageItem()
- HelpStringObj = PackageItem[1]
- CurrentLineOfPackItem = PackageItem[2]
- PackageItem = PackageItem[0]
- if HelpStringObj is not None:
- HelpString = HelpStringObj.HeaderComments + HelpStringObj.TailComments
- PackageItemObj.SetHelpString(HelpString)
- if len(PackageItem) >= 1:
- #
- # Validate file exist/format.
- #
- if IsValidPath(PackageItem[0], ''):
- IsValidFileFlag = True
- elif IsValidPath(PackageItem[0], GlobalData.gINF_MODULE_DIR):
- IsValidFileFlag = True
- elif IsValidPath(PackageItem[0], GlobalData.gWORKSPACE):
- IsValidFileFlag = True
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(PackageItem[0]),
- File=CurrentLineOfPackItem[2],
- Line=CurrentLineOfPackItem[1],
- ExtraData=CurrentLineOfPackItem[0])
- return False
- if IsValidFileFlag:
- PackageItemObj.SetPackageName(PackageItem[0])
- if len(PackageItem) == 2:
- #
- # Validate Feature Flag Express
- #
- if PackageItem[1].strip() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- File=CurrentLineOfPackItem[2],
- Line=CurrentLineOfPackItem[1],
- ExtraData=CurrentLineOfPackItem[0])
- #
- # Validate FFE
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(PackageItem[1].strip())
- if not FeatureFlagRtv[0]:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
- File=CurrentLineOfPackItem[2],
- Line=CurrentLineOfPackItem[1],
- ExtraData=CurrentLineOfPackItem[0])
-
- PackageItemObj.SetFeatureFlagExp(PackageItem[1].strip())
-
- if len(PackageItem) > 2:
- #
- # Invalid format of Package statement
- #
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_PACKAGE_SECTION_CONTENT_ERROR,
- File=CurrentLineOfPackItem[2],
- Line=CurrentLineOfPackItem[1],
- ExtraData=CurrentLineOfPackItem[0])
- PackageItemObj.SetSupArchList(SupArchList)
-
- #
- # Determine package file name duplicate. Follow below rule:
- #
- # A package filename must not be duplicated within a [Packages]
- # section. Package filenames may appear in multiple architectural
- # [Packages] sections. A package filename listed in an
- # architectural [Packages] section must not be listed in the common
- # architectural [Packages] section.
- #
- # NOTE: This check will not report error now.
- #
- for Item in self.Packages:
- if Item.GetPackageName() == PackageItemObj.GetPackageName():
- ItemSupArchList = Item.GetSupArchList()
- for ItemArch in ItemSupArchList:
- for PackageItemObjArch in SupArchList:
- if ItemArch == PackageItemObjArch:
- #
- # ST.ERR_INF_PARSER_ITEM_DUPLICATE
- #
- pass
- if ItemArch.upper() == 'COMMON' or PackageItemObjArch.upper() == 'COMMON':
- #
- # ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
- #
- pass
-
- if (PackageItemObj) in self.Packages:
- PackageList = self.Packages[PackageItemObj]
- PackageList.append(PackageItemObj)
- self.Packages[PackageItemObj] = PackageList
- else:
- PackageList = []
- PackageList.append(PackageItemObj)
- self.Packages[PackageItemObj] = PackageList
-
- return True
-
- def GetPackages(self, Arch = None):
- if Arch is None:
- return self.Packages
+## @file
+# This file is used to define class objects of INF file [Packages] section.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfPackageObject
+'''
+
+from Logger import StringTable as ST
+from Logger import ToolError
+import Logger.Log as Logger
+from Library import GlobalData
+
+from Library.Misc import Sdict
+from Library.ParserValidate import IsValidPath
+from Library.ExpressionValidate import IsValidFeatureFlagExp
+
+class InfPackageItem():
+ def __init__(self,
+ PackageName = '',
+ FeatureFlagExp = '',
+ HelpString = ''):
+ self.PackageName = PackageName
+ self.FeatureFlagExp = FeatureFlagExp
+ self.HelpString = HelpString
+ self.SupArchList = []
+
+ def SetPackageName(self, PackageName):
+ self.PackageName = PackageName
+ def GetPackageName(self):
+ return self.PackageName
+
+ def SetFeatureFlagExp(self, FeatureFlagExp):
+ self.FeatureFlagExp = FeatureFlagExp
+ def GetFeatureFlagExp(self):
+ return self.FeatureFlagExp
+
+ def SetHelpString(self, HelpString):
+ self.HelpString = HelpString
+ def GetHelpString(self):
+ return self.HelpString
+
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+
+
+## INF package section
+#
+#
+#
+class InfPackageObject():
+ def __init__(self):
+ self.Packages = Sdict()
+ #
+ # Macro defined in this section should be only used in this section.
+ #
+ self.Macros = {}
+
+ def SetPackages(self, PackageData, Arch = None):
+ IsValidFileFlag = False
+ SupArchList = []
+ for ArchItem in Arch:
+ #
+ # Validate Arch
+ #
+ if (ArchItem == '' or ArchItem is None):
+ ArchItem = 'COMMON'
+ SupArchList.append(ArchItem)
+
+ for PackageItem in PackageData:
+ PackageItemObj = InfPackageItem()
+ HelpStringObj = PackageItem[1]
+ CurrentLineOfPackItem = PackageItem[2]
+ PackageItem = PackageItem[0]
+ if HelpStringObj is not None:
+ HelpString = HelpStringObj.HeaderComments + HelpStringObj.TailComments
+ PackageItemObj.SetHelpString(HelpString)
+ if len(PackageItem) >= 1:
+ #
+ # Validate file exist/format.
+ #
+ if IsValidPath(PackageItem[0], ''):
+ IsValidFileFlag = True
+ elif IsValidPath(PackageItem[0], GlobalData.gINF_MODULE_DIR):
+ IsValidFileFlag = True
+ elif IsValidPath(PackageItem[0], GlobalData.gWORKSPACE):
+ IsValidFileFlag = True
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(PackageItem[0]),
+ File=CurrentLineOfPackItem[2],
+ Line=CurrentLineOfPackItem[1],
+ ExtraData=CurrentLineOfPackItem[0])
+ return False
+ if IsValidFileFlag:
+ PackageItemObj.SetPackageName(PackageItem[0])
+ if len(PackageItem) == 2:
+ #
+ # Validate Feature Flag Express
+ #
+ if PackageItem[1].strip() == '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
+ File=CurrentLineOfPackItem[2],
+ Line=CurrentLineOfPackItem[1],
+ ExtraData=CurrentLineOfPackItem[0])
+ #
+ # Validate FFE
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(PackageItem[1].strip())
+ if not FeatureFlagRtv[0]:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
+ File=CurrentLineOfPackItem[2],
+ Line=CurrentLineOfPackItem[1],
+ ExtraData=CurrentLineOfPackItem[0])
+
+ PackageItemObj.SetFeatureFlagExp(PackageItem[1].strip())
+
+ if len(PackageItem) > 2:
+ #
+ # Invalid format of Package statement
+ #
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_PACKAGE_SECTION_CONTENT_ERROR,
+ File=CurrentLineOfPackItem[2],
+ Line=CurrentLineOfPackItem[1],
+ ExtraData=CurrentLineOfPackItem[0])
+ PackageItemObj.SetSupArchList(SupArchList)
+
+ #
+ # Determine package file name duplicate. Follow below rule:
+ #
+ # A package filename must not be duplicated within a [Packages]
+ # section. Package filenames may appear in multiple architectural
+ # [Packages] sections. A package filename listed in an
+ # architectural [Packages] section must not be listed in the common
+ # architectural [Packages] section.
+ #
+ # NOTE: This check will not report error now.
+ #
+ for Item in self.Packages:
+ if Item.GetPackageName() == PackageItemObj.GetPackageName():
+ ItemSupArchList = Item.GetSupArchList()
+ for ItemArch in ItemSupArchList:
+ for PackageItemObjArch in SupArchList:
+ if ItemArch == PackageItemObjArch:
+ #
+ # ST.ERR_INF_PARSER_ITEM_DUPLICATE
+ #
+ pass
+ if ItemArch.upper() == 'COMMON' or PackageItemObjArch.upper() == 'COMMON':
+ #
+ # ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
+ #
+ pass
+
+ if (PackageItemObj) in self.Packages:
+ PackageList = self.Packages[PackageItemObj]
+ PackageList.append(PackageItemObj)
+ self.Packages[PackageItemObj] = PackageList
+ else:
+ PackageList = []
+ PackageList.append(PackageItemObj)
+ self.Packages[PackageItemObj] = PackageList
+
+ return True
+
+ def GetPackages(self, Arch = None):
+ if Arch is None:
+ return self.Packages
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py
index fd8065fab5..ff6eb06174 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py
@@ -1,669 +1,669 @@
-## @file
-# This file is used to define class objects of INF file [Pcds] section.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfPcdObject
-'''
-import os
-import re
-
-from Logger import StringTable as ST
-from Logger import ToolError
-import Logger.Log as Logger
-from Library import GlobalData
-from Library import DataType as DT
-
-from Library.Misc import Sdict
-from Library.Misc import GetHelpStringByRemoveHashKey
-from Library.ParserValidate import IsValidPcdType
-from Library.ParserValidate import IsValidCVariableName
-from Library.ParserValidate import IsValidPcdValue
-from Library.ParserValidate import IsValidArch
-from Library.CommentParsing import ParseComment
-from Library.StringUtils import GetSplitValueList
-from Library.StringUtils import IsHexDigitUINT32
-from Library.ExpressionValidate import IsValidFeatureFlagExp
-from Parser.InfAsBuiltProcess import GetPackageListInfo
-from Parser.DecParser import Dec
-
-from Object.Parser.InfPackagesObject import InfPackageItem
-
-def ValidateArch(ArchItem, PcdTypeItem1, LineNo, SupArchDict, SupArchList):
- #
- # Validate Arch
- #
- if (ArchItem == '' or ArchItem is None):
- ArchItem = 'COMMON'
-
- if PcdTypeItem1.upper != DT.TAB_INF_FEATURE_PCD.upper():
- ArchList = GetSplitValueList(ArchItem, ' ')
- for ArchItemNew in ArchList:
- if not IsValidArch(ArchItemNew):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ArchItemNew),
- File=GlobalData.gINF_MODULE_NAME,
- Line=LineNo,
- ExtraData=ArchItemNew)
- SupArchDict[PcdTypeItem1] = ArchList
- else:
- SupArchList.append(ArchItem)
-
- return SupArchList, SupArchDict
-
-def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj):
- CommentInsList = []
- PreUsage = None
- PreHelpText = ''
- BlockFlag = -1
- FFEHelpText = ''
- CommentItemHelpText = ''
- Count = 0
- for CommentItem in CommentList:
- Count = Count + 1
- CommentItemUsage, CommentType, CommentString, CommentItemHelpText = ParseComment(CommentItem,
- DT.ALL_USAGE_TOKENS,
- {},
- [],
- False)
- if CommentType and CommentString:
- pass
-
- if PcdTypeItem == 'FeaturePcd':
- CommentItemUsage = DT.USAGE_ITEM_CONSUMES
- if CommentItemHelpText is None:
- CommentItemHelpText = ''
-
- if Count == 1:
- FFEHelpText = CommentItemHelpText
- else:
- FFEHelpText = FFEHelpText + DT.END_OF_LINE + CommentItemHelpText
-
- if Count == len(CommentList):
- CommentItemHelpText = FFEHelpText
- BlockFlag = 4
- else:
- continue
-
- if CommentItemHelpText is None:
- CommentItemHelpText = ''
- if Count == len(CommentList) and CommentItemUsage == DT.ITEM_UNDEFINED:
- CommentItemHelpText = DT.END_OF_LINE
-
- if Count == len(CommentList) and (BlockFlag == 1 or BlockFlag == 2):
- if CommentItemUsage == DT.ITEM_UNDEFINED:
- BlockFlag = 4
- else:
- BlockFlag = 3
- elif BlockFlag == -1 and Count == len(CommentList):
- BlockFlag = 4
-
- if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
- if CommentItemUsage == DT.ITEM_UNDEFINED:
- if BlockFlag == -1:
- BlockFlag = 1
- elif BlockFlag == 1:
- BlockFlag = 2
- else:
- if BlockFlag == 1 or BlockFlag == 2:
- BlockFlag = 3
- elif BlockFlag == -1:
- BlockFlag = 4
- #
- # Combine two comment line if they are generic comment
- #
- if CommentItemUsage == PreUsage == DT.ITEM_UNDEFINED:
- CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
-
- PreHelpText = CommentItemHelpText
-
- if BlockFlag == 4:
- CommentItemIns = InfPcdItemCommentContent()
- CommentItemIns.SetUsageItem(CommentItemUsage)
- CommentItemIns.SetHelpStringItem(CommentItemHelpText)
- CommentInsList.append(CommentItemIns)
-
- BlockFlag = -1
- PreUsage = None
- PreHelpText = ''
-
- elif BlockFlag == 3:
- #
- # Add previous help string
- #
- CommentItemIns = InfPcdItemCommentContent()
- CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
- if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
- PreHelpText += DT.END_OF_LINE
- CommentItemIns.SetHelpStringItem(PreHelpText)
- CommentInsList.append(CommentItemIns)
- #
- # Add Current help string
- #
- CommentItemIns = InfPcdItemCommentContent()
- CommentItemIns.SetUsageItem(CommentItemUsage)
- CommentItemIns.SetHelpStringItem(CommentItemHelpText)
- CommentInsList.append(CommentItemIns)
-
- BlockFlag = -1
- PreUsage = None
- PreHelpText = ''
-
- else:
- PreUsage = CommentItemUsage
- PreHelpText = CommentItemHelpText
-
- PcdItemObj.SetHelpStringList(CommentInsList)
-
- return PcdItemObj
-
-class InfPcdItemCommentContent():
- def __init__(self):
- #
- # ## SOMETIMES_CONSUMES ## HelpString
- #
- self.UsageItem = ''
- #
- # Help String
- #
- self.HelpStringItem = ''
-
- def SetUsageItem(self, UsageItem):
- self.UsageItem = UsageItem
- def GetUsageItem(self):
- return self.UsageItem
-
- def SetHelpStringItem(self, HelpStringItem):
- self.HelpStringItem = HelpStringItem
- def GetHelpStringItem(self):
- return self.HelpStringItem
-
-## InfPcdItem
-#
-# This class defined Pcd item used in Module files
-#
-# @param CName: Input value for CName, default is ''
-# @param Token: Input value for Token, default is ''
-# @param TokenSpaceGuidCName: Input value for TokenSpaceGuidCName, default
-# is ''
-# @param DatumType: Input value for DatumType, default is ''
-# @param MaxDatumSize: Input value for MaxDatumSize, default is ''
-# @param DefaultValue: Input value for DefaultValue, default is ''
-# @param ItemType: Input value for ItemType, default is ''
-# @param ValidUsage: Input value for ValidUsage, default is []
-# @param SkuInfoList: Input value for SkuInfoList, default is {}
-# @param SupModuleList: Input value for SupModuleList, default is []
-#
-class InfPcdItem():
- def __init__(self):
- self.CName = ''
- self.Token = ''
- self.TokenSpaceGuidCName = ''
- self.TokenSpaceGuidValue = ''
- self.DatumType = ''
- self.MaxDatumSize = ''
- self.DefaultValue = ''
- self.Offset = ''
- self.ValidUsage = ''
- self.ItemType = ''
- self.SupModuleList = []
- self.HelpStringList = []
- self.FeatureFlagExp = ''
- self.SupArchList = []
- self.PcdErrorsList = []
-
- def SetCName(self, CName):
- self.CName = CName
- def GetCName(self):
- return self.CName
-
- def SetToken(self, Token):
- self.Token = Token
- def GetToken(self):
- return self.Token
-
- def SetTokenSpaceGuidCName(self, TokenSpaceGuidCName):
- self.TokenSpaceGuidCName = TokenSpaceGuidCName
- def GetTokenSpaceGuidCName(self):
- return self.TokenSpaceGuidCName
-
- def SetTokenSpaceGuidValue(self, TokenSpaceGuidValue):
- self.TokenSpaceGuidValue = TokenSpaceGuidValue
- def GetTokenSpaceGuidValue(self):
- return self.TokenSpaceGuidValue
-
- def SetDatumType(self, DatumType):
- self.DatumType = DatumType
- def GetDatumType(self):
- return self.DatumType
-
- def SetMaxDatumSize(self, MaxDatumSize):
- self.MaxDatumSize = MaxDatumSize
- def GetMaxDatumSize(self):
- return self.MaxDatumSize
-
- def SetDefaultValue(self, DefaultValue):
- self.DefaultValue = DefaultValue
- def GetDefaultValue(self):
- return self.DefaultValue
-
- def SetPcdErrorsList(self, PcdErrorsList):
- self.PcdErrorsList = PcdErrorsList
- def GetPcdErrorsList(self):
- return self.PcdErrorsList
-
- def SetItemType(self, ItemType):
- self.ItemType = ItemType
- def GetItemType(self):
- return self.ItemType
-
- def SetSupModuleList(self, SupModuleList):
- self.SupModuleList = SupModuleList
- def GetSupModuleList(self):
- return self.SupModuleList
-
- def SetHelpStringList(self, HelpStringList):
- self.HelpStringList = HelpStringList
- def GetHelpStringList(self):
- return self.HelpStringList
-
- def SetFeatureFlagExp(self, FeatureFlagExp):
- self.FeatureFlagExp = FeatureFlagExp
- def GetFeatureFlagExp(self):
- return self.FeatureFlagExp
-
- def SetSupportArchList(self, ArchList):
- self.SupArchList = ArchList
- def GetSupportArchList(self):
- return self.SupArchList
-
- def SetOffset(self, Offset):
- self.Offset = Offset
- def GetOffset(self):
- return self.Offset
-
- def SetValidUsage(self, ValidUsage):
- self.ValidUsage = ValidUsage
-
- def GetValidUsage(self):
- return self.ValidUsage
-
-##
-#
-#
-#
-class InfPcdObject():
- def __init__(self, FileName):
- self.Pcds = Sdict()
- self.FileName = FileName
-
- def SetPcds(self, PcdContent, KeysList=None, PackageInfo=None):
-
- if GlobalData.gIS_BINARY_INF:
- self.SetAsBuildPcds(PcdContent, KeysList, PackageInfo)
- return True
-
- #
- # Validate Arch
- #
- SupArchList = []
- SupArchDict = {}
- PcdTypeItem = ''
- for (PcdTypeItem1, ArchItem, LineNo) in KeysList:
- SupArchList, SupArchDict = ValidateArch(ArchItem, PcdTypeItem1, LineNo, SupArchDict, SupArchList)
-
- #
- # Validate PcdType
- #
- if (PcdTypeItem1 == '' or PcdTypeItem1 is None):
- return False
- else:
- if not IsValidPcdType(PcdTypeItem1):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_PCD_SECTION_TYPE_ERROR % (DT.PCD_USAGE_TYPE_LIST_OF_MODULE),
- File=GlobalData.gINF_MODULE_NAME,
- Line=LineNo,
- ExtraData=PcdTypeItem1)
- return False
-
- PcdTypeItem = PcdTypeItem1
-
- for PcdItem in PcdContent:
- PcdItemObj = InfPcdItem()
- CommentList = PcdItem[1]
- CurrentLineOfPcdItem = PcdItem[2]
- PcdItem = PcdItem[0]
-
- if CommentList is not None and len(CommentList) != 0:
- PcdItemObj = ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj)
- else:
- CommentItemIns = InfPcdItemCommentContent()
- CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
- PcdItemObj.SetHelpStringList([CommentItemIns])
-
- if len(PcdItem) >= 1 and len(PcdItem) <= 3:
- PcdItemObj = SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj)
-
- if len(PcdItem) >= 2 and len(PcdItem) <= 3:
- #
- # Contain PcdName and Value, validate value.
- #
- if IsValidPcdValue(PcdItem[1]) or PcdItem[1].strip() == "":
- PcdItemObj.SetDefaultValue(PcdItem[1])
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_PCD_VALUE_INVALID,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
- ExtraData=PcdItem[1])
-
- if len(PcdItem) == 3:
- #
- # Contain PcdName, value, and FeatureFlag express
- #
- #
- # Validate Feature Flag Express
- #
- if PcdItem[2].strip() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
- ExtraData=CurrentLineOfPcdItem[0])
- #
- # Validate FFE
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(PcdItem[2].strip())
- if not FeatureFlagRtv[0]:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
- ExtraData=CurrentLineOfPcdItem[0])
- PcdItemObj.SetFeatureFlagExp(PcdItem[2])
-
- if len(PcdItem) < 1 or len(PcdItem) > 3:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_PCD_SECTION_CONTENT_ERROR,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
- ExtraData=CurrentLineOfPcdItem[0])
- return False
-
- if PcdTypeItem.upper != DT.TAB_INF_FEATURE_PCD.upper():
- PcdItemObj.SetSupportArchList(SupArchDict[PcdTypeItem])
- else:
- PcdItemObj.SetSupportArchList(SupArchList)
-
- if (PcdTypeItem, PcdItemObj) in self.Pcds:
- PcdsList = self.Pcds[PcdTypeItem, PcdItemObj]
- PcdsList.append(PcdItemObj)
- self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
- else:
- PcdsList = []
- PcdsList.append(PcdItemObj)
- self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
-
- return True
-
- def SetAsBuildPcds(self, PcdContent, KeysList=None, PackageInfo=None):
- for PcdItem in PcdContent:
- PcdItemObj = InfPcdItem()
- CommentList = PcdItem[1]
- CurrentLineOfPcdItem = PcdItem[2]
- PcdItem = PcdItem[0]
- CommentString = ''
-
- for CommentLine in CommentList:
- CommentString = GetHelpStringByRemoveHashKey(CommentLine)
- CommentItemIns = InfPcdItemCommentContent()
- CommentItemIns.SetHelpStringItem(CommentString)
- CommentItemIns.SetUsageItem(CommentString)
- PcdItemObj.SetHelpStringList(PcdItemObj.GetHelpStringList() + [CommentItemIns])
- if PcdItemObj.GetValidUsage():
- PcdItemObj.SetValidUsage(PcdItemObj.GetValidUsage() + DT.TAB_VALUE_SPLIT + CommentString)
- else:
- PcdItemObj.SetValidUsage(CommentString)
-
- PcdItemObj.SetItemType(KeysList[0][0])
- #
- # Set PcdTokenSpaceCName and CName
- #
- PcdItemObj = SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj)
- #
- # Set Value/DatumType/OffSet/Token
- #
- PcdItemObj = SetValueDatumTypeMaxSizeToken(PcdItem,
- CurrentLineOfPcdItem,
- PcdItemObj,
- KeysList[0][1],
- PackageInfo)
-
- PcdTypeItem = KeysList[0][0]
- if (PcdTypeItem, PcdItemObj) in self.Pcds:
- PcdsList = self.Pcds[PcdTypeItem, PcdItemObj]
- PcdsList.append(PcdItemObj)
- self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
- else:
- PcdsList = []
- PcdsList.append(PcdItemObj)
- self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
-
- def GetPcds(self):
- return self.Pcds
-
-def ParserPcdInfoInDec(String):
- ValueList = GetSplitValueList(String, DT.TAB_VALUE_SPLIT, 3)
-
- #
- # DatumType, Token
- #
- return ValueList[2], ValueList[3]
-
-def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineOfPcdItem, PcdItemObj, Arch, PackageInfo=None):
- #
- # Package information not been generated currently, we need to parser INF file to get information.
- #
- if not PackageInfo:
- PackageInfo = []
- InfFileName = CurrentLineOfPcdItem[2]
- PackageInfoList = GetPackageListInfo(InfFileName, GlobalData.gWORKSPACE, -1)
- for PackageInfoListItem in PackageInfoList:
- PackageInfoIns = InfPackageItem()
- PackageInfoIns.SetPackageName(PackageInfoListItem)
- PackageInfo.append(PackageInfoIns)
-
- PcdInfoInDecHasFound = False
- for PackageItem in PackageInfo:
- if PcdInfoInDecHasFound:
- break
- PackageName = PackageItem.PackageName
- #
- # Open DEC file to get information
- #
- FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gWORKSPACE, PackageName)))
-
- DecParser = None
- if FullFileName not in GlobalData.gPackageDict:
- DecParser = Dec(FullFileName)
- GlobalData.gPackageDict[FullFileName] = DecParser
- else:
- DecParser = GlobalData.gPackageDict[FullFileName]
-
- #
- # Find PCD information.
- #
- DecPcdsDict = DecParser.GetPcdSectionObject().ValueDict
- for Key in DecPcdsDict.keys():
- if (Key[0] == 'PCDSDYNAMICEX' and PcdItemObj.GetItemType() == 'PcdEx') and \
- (Key[1] == 'COMMON' or Key[1] == Arch):
- for PcdInDec in DecPcdsDict[Key]:
- if PcdInDec.TokenCName == PcdItemObj.CName and \
- PcdInDec.TokenSpaceGuidCName == PcdItemObj.TokenSpaceGuidCName:
- PcdItemObj.SetToken(PcdInDec.TokenValue)
- PcdItemObj.SetDatumType(PcdInDec.DatumType)
- PcdItemObj.SetSupportArchList([Arch])
- PcdItemObj.SetDefaultValue(PcdInDec.DefaultValue)
-
- if (Key[0] == 'PCDSPATCHABLEINMODULE' and PcdItemObj.GetItemType() == 'PatchPcd') and \
- (Key[1] == 'COMMON' or Key[1] == Arch):
- for PcdInDec in DecPcdsDict[Key]:
- if PcdInDec.TokenCName == PcdItemObj.CName and \
- PcdInDec.TokenSpaceGuidCName == PcdItemObj.TokenSpaceGuidCName:
- PcdItemObj.SetToken(PcdInDec.TokenValue)
- PcdItemObj.SetDatumType(PcdInDec.DatumType)
- PcdItemObj.SetSupportArchList([Arch])
-
- if PcdItemObj.GetDatumType() == 'VOID*':
- if len(PcdItem) > 1:
- PcdItemObj.SetMaxDatumSize('%s' % (len(GetSplitValueList(PcdItem[1], DT.TAB_COMMA_SPLIT))))
-
- DecGuidsDict = DecParser.GetGuidSectionObject().ValueDict
- for Key in DecGuidsDict.keys():
- if Key == 'COMMON' or Key == Arch:
- for GuidInDec in DecGuidsDict[Key]:
- if GuidInDec.GuidCName == PcdItemObj.TokenSpaceGuidCName:
- PcdItemObj.SetTokenSpaceGuidValue(GuidInDec.GuidString)
-
- if PcdItemObj.GetItemType().upper() == DT.TAB_INF_PATCH_PCD.upper():
- #
- # Validate Value.
- #
- # convert the value from a decimal 0 to a formatted hex value.
- if PcdItem[1] == "0":
- DatumType = PcdItemObj.GetDatumType()
- if DatumType == "UINT8":
- PcdItem[1] = "0x00"
- if DatumType == "UINT16":
- PcdItem[1] = "0x0000"
- if DatumType == "UINT32":
- PcdItem[1] = "0x00000000"
- if DatumType == "UINT64":
- PcdItem[1] = "0x0000000000000000"
-
- if ValidatePcdValueOnDatumType(PcdItem[1], PcdItemObj.GetDatumType()):
- PcdItemObj.SetDefaultValue(PcdItem[1])
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_ASBUILD_PCD_VALUE_INVALID % ("\"" + PcdItem[1] + "\"", "\"" +
- PcdItemObj.GetDatumType() + "\""),
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
- ExtraData=CurrentLineOfPcdItem[0])
- #
- # validate offset
- #
- if PcdItemObj.GetItemType().upper() == DT.TAB_INF_PATCH_PCD.upper():
- if not IsHexDigitUINT32(PcdItem[2]):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_ASBUILD_PCD_OFFSET_FORMAT_INVALID % ("\"" + PcdItem[2] + "\""),
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
- ExtraData=CurrentLineOfPcdItem[0])
- PcdItemObj.SetOffset(PcdItem[2])
-
- if PcdItemObj.GetToken() == '' or PcdItemObj.GetDatumType() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_ASBUILD_PCD_DECLARITION_MISS % ("\"" + PcdItem[0] + "\""),
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
- ExtraData=CurrentLineOfPcdItem[0])
-
- return PcdItemObj
-
-def ValidatePcdValueOnDatumType(Value, Type):
-
- Value = Value.strip()
- #
- # Boolean type only allow 0x00 or 0x01 as value per INF spec
- #
- if Type == 'BOOLEAN':
- if not (Value == '0x00' or Value == '0x01'):
- return False
- elif Type == 'VOID*':
- if not Value.startswith("{"):
- return False
- if not Value.endswith("}"):
- return False
- #
- # Strip "{" at head and "}" at tail.
- #
- Value = Value[1:-1]
- ValueList = GetSplitValueList(Value, DT.TAB_COMMA_SPLIT)
-
- ReIsValidHexByte = re.compile("^0x[0-9a-f]{1,2}$", re.IGNORECASE)
- for ValueItem in ValueList:
- if not ReIsValidHexByte.match(ValueItem):
- return False
-
- elif Type == 'UINT8' or Type == 'UINT16' or Type == 'UINT32' or Type == 'UINT64':
-
- ReIsValidUint8z = re.compile('^0[x|X][a-fA-F0-9]{2}$')
- ReIsValidUint16z = re.compile('^0[x|X][a-fA-F0-9]{4}$')
- ReIsValidUint32z = re.compile('^0[x|X][a-fA-F0-9]{8}$')
- ReIsValidUint64z = re.compile('^0[x|X][a-fA-F0-9]{16}$')
-
- if not ReIsValidUint8z.match(Value) and Type == 'UINT8':
- return False
- elif not ReIsValidUint16z.match(Value) and Type == 'UINT16':
- return False
- elif not ReIsValidUint32z.match(Value) and Type == 'UINT32':
- return False
- elif not ReIsValidUint64z.match(Value) and Type == 'UINT64':
- return False
- else:
- #
- # Since we assume the DEC file always correct, should never go to here.
- #
- pass
-
- return True
-
-def SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj):
- #
- # Only PCD Name specified
- # <PcdName> ::= <TokenSpaceGuidCName> "." <TokenCName>
- #
- PcdId = GetSplitValueList(PcdItem[0], DT.TAB_SPLIT)
- if len(PcdId) != 2:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_PCD_NAME_FORMAT_ERROR,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
- ExtraData=CurrentLineOfPcdItem[0])
- else:
- #
- # Validate PcdTokenSpaceGuidCName
- #
- if not IsValidCVariableName(PcdId[0]):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_PCD_CVAR_GUID,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
- ExtraData=PcdId[0])
- if not IsValidCVariableName(PcdId[1]):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_PCD_CVAR_PCDCNAME,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
- ExtraData=PcdId[1])
- PcdItemObj.SetTokenSpaceGuidCName(PcdId[0])
- PcdItemObj.SetCName(PcdId[1])
-
- return PcdItemObj
+## @file
+# This file is used to define class objects of INF file [Pcds] section.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfPcdObject
+'''
+import os
+import re
+
+from Logger import StringTable as ST
+from Logger import ToolError
+import Logger.Log as Logger
+from Library import GlobalData
+from Library import DataType as DT
+
+from Library.Misc import Sdict
+from Library.Misc import GetHelpStringByRemoveHashKey
+from Library.ParserValidate import IsValidPcdType
+from Library.ParserValidate import IsValidCVariableName
+from Library.ParserValidate import IsValidPcdValue
+from Library.ParserValidate import IsValidArch
+from Library.CommentParsing import ParseComment
+from Library.StringUtils import GetSplitValueList
+from Library.StringUtils import IsHexDigitUINT32
+from Library.ExpressionValidate import IsValidFeatureFlagExp
+from Parser.InfAsBuiltProcess import GetPackageListInfo
+from Parser.DecParser import Dec
+
+from Object.Parser.InfPackagesObject import InfPackageItem
+
+def ValidateArch(ArchItem, PcdTypeItem1, LineNo, SupArchDict, SupArchList):
+ #
+ # Validate Arch
+ #
+ if (ArchItem == '' or ArchItem is None):
+ ArchItem = 'COMMON'
+
+ if PcdTypeItem1.upper != DT.TAB_INF_FEATURE_PCD.upper():
+ ArchList = GetSplitValueList(ArchItem, ' ')
+ for ArchItemNew in ArchList:
+ if not IsValidArch(ArchItemNew):
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ArchItemNew),
+ File=GlobalData.gINF_MODULE_NAME,
+ Line=LineNo,
+ ExtraData=ArchItemNew)
+ SupArchDict[PcdTypeItem1] = ArchList
+ else:
+ SupArchList.append(ArchItem)
+
+ return SupArchList, SupArchDict
+
+def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj):
+ CommentInsList = []
+ PreUsage = None
+ PreHelpText = ''
+ BlockFlag = -1
+ FFEHelpText = ''
+ CommentItemHelpText = ''
+ Count = 0
+ for CommentItem in CommentList:
+ Count = Count + 1
+ CommentItemUsage, CommentType, CommentString, CommentItemHelpText = ParseComment(CommentItem,
+ DT.ALL_USAGE_TOKENS,
+ {},
+ [],
+ False)
+ if CommentType and CommentString:
+ pass
+
+ if PcdTypeItem == 'FeaturePcd':
+ CommentItemUsage = DT.USAGE_ITEM_CONSUMES
+ if CommentItemHelpText is None:
+ CommentItemHelpText = ''
+
+ if Count == 1:
+ FFEHelpText = CommentItemHelpText
+ else:
+ FFEHelpText = FFEHelpText + DT.END_OF_LINE + CommentItemHelpText
+
+ if Count == len(CommentList):
+ CommentItemHelpText = FFEHelpText
+ BlockFlag = 4
+ else:
+ continue
+
+ if CommentItemHelpText is None:
+ CommentItemHelpText = ''
+ if Count == len(CommentList) and CommentItemUsage == DT.ITEM_UNDEFINED:
+ CommentItemHelpText = DT.END_OF_LINE
+
+ if Count == len(CommentList) and (BlockFlag == 1 or BlockFlag == 2):
+ if CommentItemUsage == DT.ITEM_UNDEFINED:
+ BlockFlag = 4
+ else:
+ BlockFlag = 3
+ elif BlockFlag == -1 and Count == len(CommentList):
+ BlockFlag = 4
+
+ if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
+ if CommentItemUsage == DT.ITEM_UNDEFINED:
+ if BlockFlag == -1:
+ BlockFlag = 1
+ elif BlockFlag == 1:
+ BlockFlag = 2
+ else:
+ if BlockFlag == 1 or BlockFlag == 2:
+ BlockFlag = 3
+ elif BlockFlag == -1:
+ BlockFlag = 4
+ #
+ # Combine two comment line if they are generic comment
+ #
+ if CommentItemUsage == PreUsage == DT.ITEM_UNDEFINED:
+ CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
+
+ PreHelpText = CommentItemHelpText
+
+ if BlockFlag == 4:
+ CommentItemIns = InfPcdItemCommentContent()
+ CommentItemIns.SetUsageItem(CommentItemUsage)
+ CommentItemIns.SetHelpStringItem(CommentItemHelpText)
+ CommentInsList.append(CommentItemIns)
+
+ BlockFlag = -1
+ PreUsage = None
+ PreHelpText = ''
+
+ elif BlockFlag == 3:
+ #
+ # Add previous help string
+ #
+ CommentItemIns = InfPcdItemCommentContent()
+ CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
+ if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
+ PreHelpText += DT.END_OF_LINE
+ CommentItemIns.SetHelpStringItem(PreHelpText)
+ CommentInsList.append(CommentItemIns)
+ #
+ # Add Current help string
+ #
+ CommentItemIns = InfPcdItemCommentContent()
+ CommentItemIns.SetUsageItem(CommentItemUsage)
+ CommentItemIns.SetHelpStringItem(CommentItemHelpText)
+ CommentInsList.append(CommentItemIns)
+
+ BlockFlag = -1
+ PreUsage = None
+ PreHelpText = ''
+
+ else:
+ PreUsage = CommentItemUsage
+ PreHelpText = CommentItemHelpText
+
+ PcdItemObj.SetHelpStringList(CommentInsList)
+
+ return PcdItemObj
+
+class InfPcdItemCommentContent():
+ def __init__(self):
+ #
+ # ## SOMETIMES_CONSUMES ## HelpString
+ #
+ self.UsageItem = ''
+ #
+ # Help String
+ #
+ self.HelpStringItem = ''
+
+ def SetUsageItem(self, UsageItem):
+ self.UsageItem = UsageItem
+ def GetUsageItem(self):
+ return self.UsageItem
+
+ def SetHelpStringItem(self, HelpStringItem):
+ self.HelpStringItem = HelpStringItem
+ def GetHelpStringItem(self):
+ return self.HelpStringItem
+
+## InfPcdItem
+#
+# This class defined Pcd item used in Module files
+#
+# @param CName: Input value for CName, default is ''
+# @param Token: Input value for Token, default is ''
+# @param TokenSpaceGuidCName: Input value for TokenSpaceGuidCName, default
+# is ''
+# @param DatumType: Input value for DatumType, default is ''
+# @param MaxDatumSize: Input value for MaxDatumSize, default is ''
+# @param DefaultValue: Input value for DefaultValue, default is ''
+# @param ItemType: Input value for ItemType, default is ''
+# @param ValidUsage: Input value for ValidUsage, default is []
+# @param SkuInfoList: Input value for SkuInfoList, default is {}
+# @param SupModuleList: Input value for SupModuleList, default is []
+#
+class InfPcdItem():
+ def __init__(self):
+ self.CName = ''
+ self.Token = ''
+ self.TokenSpaceGuidCName = ''
+ self.TokenSpaceGuidValue = ''
+ self.DatumType = ''
+ self.MaxDatumSize = ''
+ self.DefaultValue = ''
+ self.Offset = ''
+ self.ValidUsage = ''
+ self.ItemType = ''
+ self.SupModuleList = []
+ self.HelpStringList = []
+ self.FeatureFlagExp = ''
+ self.SupArchList = []
+ self.PcdErrorsList = []
+
+ def SetCName(self, CName):
+ self.CName = CName
+ def GetCName(self):
+ return self.CName
+
+ def SetToken(self, Token):
+ self.Token = Token
+ def GetToken(self):
+ return self.Token
+
+ def SetTokenSpaceGuidCName(self, TokenSpaceGuidCName):
+ self.TokenSpaceGuidCName = TokenSpaceGuidCName
+ def GetTokenSpaceGuidCName(self):
+ return self.TokenSpaceGuidCName
+
+ def SetTokenSpaceGuidValue(self, TokenSpaceGuidValue):
+ self.TokenSpaceGuidValue = TokenSpaceGuidValue
+ def GetTokenSpaceGuidValue(self):
+ return self.TokenSpaceGuidValue
+
+ def SetDatumType(self, DatumType):
+ self.DatumType = DatumType
+ def GetDatumType(self):
+ return self.DatumType
+
+ def SetMaxDatumSize(self, MaxDatumSize):
+ self.MaxDatumSize = MaxDatumSize
+ def GetMaxDatumSize(self):
+ return self.MaxDatumSize
+
+ def SetDefaultValue(self, DefaultValue):
+ self.DefaultValue = DefaultValue
+ def GetDefaultValue(self):
+ return self.DefaultValue
+
+ def SetPcdErrorsList(self, PcdErrorsList):
+ self.PcdErrorsList = PcdErrorsList
+ def GetPcdErrorsList(self):
+ return self.PcdErrorsList
+
+ def SetItemType(self, ItemType):
+ self.ItemType = ItemType
+ def GetItemType(self):
+ return self.ItemType
+
+ def SetSupModuleList(self, SupModuleList):
+ self.SupModuleList = SupModuleList
+ def GetSupModuleList(self):
+ return self.SupModuleList
+
+ def SetHelpStringList(self, HelpStringList):
+ self.HelpStringList = HelpStringList
+ def GetHelpStringList(self):
+ return self.HelpStringList
+
+ def SetFeatureFlagExp(self, FeatureFlagExp):
+ self.FeatureFlagExp = FeatureFlagExp
+ def GetFeatureFlagExp(self):
+ return self.FeatureFlagExp
+
+ def SetSupportArchList(self, ArchList):
+ self.SupArchList = ArchList
+ def GetSupportArchList(self):
+ return self.SupArchList
+
+ def SetOffset(self, Offset):
+ self.Offset = Offset
+ def GetOffset(self):
+ return self.Offset
+
+ def SetValidUsage(self, ValidUsage):
+ self.ValidUsage = ValidUsage
+
+ def GetValidUsage(self):
+ return self.ValidUsage
+
+##
+#
+#
+#
+class InfPcdObject():
+ def __init__(self, FileName):
+ self.Pcds = Sdict()
+ self.FileName = FileName
+
+ def SetPcds(self, PcdContent, KeysList=None, PackageInfo=None):
+
+ if GlobalData.gIS_BINARY_INF:
+ self.SetAsBuildPcds(PcdContent, KeysList, PackageInfo)
+ return True
+
+ #
+ # Validate Arch
+ #
+ SupArchList = []
+ SupArchDict = {}
+ PcdTypeItem = ''
+ for (PcdTypeItem1, ArchItem, LineNo) in KeysList:
+ SupArchList, SupArchDict = ValidateArch(ArchItem, PcdTypeItem1, LineNo, SupArchDict, SupArchList)
+
+ #
+ # Validate PcdType
+ #
+ if (PcdTypeItem1 == '' or PcdTypeItem1 is None):
+ return False
+ else:
+ if not IsValidPcdType(PcdTypeItem1):
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_PCD_SECTION_TYPE_ERROR % (DT.PCD_USAGE_TYPE_LIST_OF_MODULE),
+ File=GlobalData.gINF_MODULE_NAME,
+ Line=LineNo,
+ ExtraData=PcdTypeItem1)
+ return False
+
+ PcdTypeItem = PcdTypeItem1
+
+ for PcdItem in PcdContent:
+ PcdItemObj = InfPcdItem()
+ CommentList = PcdItem[1]
+ CurrentLineOfPcdItem = PcdItem[2]
+ PcdItem = PcdItem[0]
+
+ if CommentList is not None and len(CommentList) != 0:
+ PcdItemObj = ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj)
+ else:
+ CommentItemIns = InfPcdItemCommentContent()
+ CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
+ PcdItemObj.SetHelpStringList([CommentItemIns])
+
+ if len(PcdItem) >= 1 and len(PcdItem) <= 3:
+ PcdItemObj = SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj)
+
+ if len(PcdItem) >= 2 and len(PcdItem) <= 3:
+ #
+ # Contain PcdName and Value, validate value.
+ #
+ if IsValidPcdValue(PcdItem[1]) or PcdItem[1].strip() == "":
+ PcdItemObj.SetDefaultValue(PcdItem[1])
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_PCD_VALUE_INVALID,
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
+ ExtraData=PcdItem[1])
+
+ if len(PcdItem) == 3:
+ #
+ # Contain PcdName, value, and FeatureFlag express
+ #
+ #
+ # Validate Feature Flag Express
+ #
+ if PcdItem[2].strip() == '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
+ ExtraData=CurrentLineOfPcdItem[0])
+ #
+ # Validate FFE
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(PcdItem[2].strip())
+ if not FeatureFlagRtv[0]:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
+ ExtraData=CurrentLineOfPcdItem[0])
+ PcdItemObj.SetFeatureFlagExp(PcdItem[2])
+
+ if len(PcdItem) < 1 or len(PcdItem) > 3:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_PCD_SECTION_CONTENT_ERROR,
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
+ ExtraData=CurrentLineOfPcdItem[0])
+ return False
+
+ if PcdTypeItem.upper != DT.TAB_INF_FEATURE_PCD.upper():
+ PcdItemObj.SetSupportArchList(SupArchDict[PcdTypeItem])
+ else:
+ PcdItemObj.SetSupportArchList(SupArchList)
+
+ if (PcdTypeItem, PcdItemObj) in self.Pcds:
+ PcdsList = self.Pcds[PcdTypeItem, PcdItemObj]
+ PcdsList.append(PcdItemObj)
+ self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
+ else:
+ PcdsList = []
+ PcdsList.append(PcdItemObj)
+ self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
+
+ return True
+
+ def SetAsBuildPcds(self, PcdContent, KeysList=None, PackageInfo=None):
+ for PcdItem in PcdContent:
+ PcdItemObj = InfPcdItem()
+ CommentList = PcdItem[1]
+ CurrentLineOfPcdItem = PcdItem[2]
+ PcdItem = PcdItem[0]
+ CommentString = ''
+
+ for CommentLine in CommentList:
+ CommentString = GetHelpStringByRemoveHashKey(CommentLine)
+ CommentItemIns = InfPcdItemCommentContent()
+ CommentItemIns.SetHelpStringItem(CommentString)
+ CommentItemIns.SetUsageItem(CommentString)
+ PcdItemObj.SetHelpStringList(PcdItemObj.GetHelpStringList() + [CommentItemIns])
+ if PcdItemObj.GetValidUsage():
+ PcdItemObj.SetValidUsage(PcdItemObj.GetValidUsage() + DT.TAB_VALUE_SPLIT + CommentString)
+ else:
+ PcdItemObj.SetValidUsage(CommentString)
+
+ PcdItemObj.SetItemType(KeysList[0][0])
+ #
+ # Set PcdTokenSpaceCName and CName
+ #
+ PcdItemObj = SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj)
+ #
+ # Set Value/DatumType/OffSet/Token
+ #
+ PcdItemObj = SetValueDatumTypeMaxSizeToken(PcdItem,
+ CurrentLineOfPcdItem,
+ PcdItemObj,
+ KeysList[0][1],
+ PackageInfo)
+
+ PcdTypeItem = KeysList[0][0]
+ if (PcdTypeItem, PcdItemObj) in self.Pcds:
+ PcdsList = self.Pcds[PcdTypeItem, PcdItemObj]
+ PcdsList.append(PcdItemObj)
+ self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
+ else:
+ PcdsList = []
+ PcdsList.append(PcdItemObj)
+ self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
+
+ def GetPcds(self):
+ return self.Pcds
+
+def ParserPcdInfoInDec(String):
+ ValueList = GetSplitValueList(String, DT.TAB_VALUE_SPLIT, 3)
+
+ #
+ # DatumType, Token
+ #
+ return ValueList[2], ValueList[3]
+
+def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineOfPcdItem, PcdItemObj, Arch, PackageInfo=None):
+ #
+ # Package information not been generated currently, we need to parser INF file to get information.
+ #
+ if not PackageInfo:
+ PackageInfo = []
+ InfFileName = CurrentLineOfPcdItem[2]
+ PackageInfoList = GetPackageListInfo(InfFileName, GlobalData.gWORKSPACE, -1)
+ for PackageInfoListItem in PackageInfoList:
+ PackageInfoIns = InfPackageItem()
+ PackageInfoIns.SetPackageName(PackageInfoListItem)
+ PackageInfo.append(PackageInfoIns)
+
+ PcdInfoInDecHasFound = False
+ for PackageItem in PackageInfo:
+ if PcdInfoInDecHasFound:
+ break
+ PackageName = PackageItem.PackageName
+ #
+ # Open DEC file to get information
+ #
+ FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gWORKSPACE, PackageName)))
+
+ DecParser = None
+ if FullFileName not in GlobalData.gPackageDict:
+ DecParser = Dec(FullFileName)
+ GlobalData.gPackageDict[FullFileName] = DecParser
+ else:
+ DecParser = GlobalData.gPackageDict[FullFileName]
+
+ #
+ # Find PCD information.
+ #
+ DecPcdsDict = DecParser.GetPcdSectionObject().ValueDict
+ for Key in DecPcdsDict.keys():
+ if (Key[0] == 'PCDSDYNAMICEX' and PcdItemObj.GetItemType() == 'PcdEx') and \
+ (Key[1] == 'COMMON' or Key[1] == Arch):
+ for PcdInDec in DecPcdsDict[Key]:
+ if PcdInDec.TokenCName == PcdItemObj.CName and \
+ PcdInDec.TokenSpaceGuidCName == PcdItemObj.TokenSpaceGuidCName:
+ PcdItemObj.SetToken(PcdInDec.TokenValue)
+ PcdItemObj.SetDatumType(PcdInDec.DatumType)
+ PcdItemObj.SetSupportArchList([Arch])
+ PcdItemObj.SetDefaultValue(PcdInDec.DefaultValue)
+
+ if (Key[0] == 'PCDSPATCHABLEINMODULE' and PcdItemObj.GetItemType() == 'PatchPcd') and \
+ (Key[1] == 'COMMON' or Key[1] == Arch):
+ for PcdInDec in DecPcdsDict[Key]:
+ if PcdInDec.TokenCName == PcdItemObj.CName and \
+ PcdInDec.TokenSpaceGuidCName == PcdItemObj.TokenSpaceGuidCName:
+ PcdItemObj.SetToken(PcdInDec.TokenValue)
+ PcdItemObj.SetDatumType(PcdInDec.DatumType)
+ PcdItemObj.SetSupportArchList([Arch])
+
+ if PcdItemObj.GetDatumType() == 'VOID*':
+ if len(PcdItem) > 1:
+ PcdItemObj.SetMaxDatumSize('%s' % (len(GetSplitValueList(PcdItem[1], DT.TAB_COMMA_SPLIT))))
+
+ DecGuidsDict = DecParser.GetGuidSectionObject().ValueDict
+ for Key in DecGuidsDict.keys():
+ if Key == 'COMMON' or Key == Arch:
+ for GuidInDec in DecGuidsDict[Key]:
+ if GuidInDec.GuidCName == PcdItemObj.TokenSpaceGuidCName:
+ PcdItemObj.SetTokenSpaceGuidValue(GuidInDec.GuidString)
+
+ if PcdItemObj.GetItemType().upper() == DT.TAB_INF_PATCH_PCD.upper():
+ #
+ # Validate Value.
+ #
+ # convert the value from a decimal 0 to a formatted hex value.
+ if PcdItem[1] == "0":
+ DatumType = PcdItemObj.GetDatumType()
+ if DatumType == "UINT8":
+ PcdItem[1] = "0x00"
+ if DatumType == "UINT16":
+ PcdItem[1] = "0x0000"
+ if DatumType == "UINT32":
+ PcdItem[1] = "0x00000000"
+ if DatumType == "UINT64":
+ PcdItem[1] = "0x0000000000000000"
+
+ if ValidatePcdValueOnDatumType(PcdItem[1], PcdItemObj.GetDatumType()):
+ PcdItemObj.SetDefaultValue(PcdItem[1])
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_ASBUILD_PCD_VALUE_INVALID % ("\"" + PcdItem[1] + "\"", "\"" +
+ PcdItemObj.GetDatumType() + "\""),
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
+ ExtraData=CurrentLineOfPcdItem[0])
+ #
+ # validate offset
+ #
+ if PcdItemObj.GetItemType().upper() == DT.TAB_INF_PATCH_PCD.upper():
+ if not IsHexDigitUINT32(PcdItem[2]):
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_ASBUILD_PCD_OFFSET_FORMAT_INVALID % ("\"" + PcdItem[2] + "\""),
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
+ ExtraData=CurrentLineOfPcdItem[0])
+ PcdItemObj.SetOffset(PcdItem[2])
+
+ if PcdItemObj.GetToken() == '' or PcdItemObj.GetDatumType() == '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_ASBUILD_PCD_DECLARITION_MISS % ("\"" + PcdItem[0] + "\""),
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
+ ExtraData=CurrentLineOfPcdItem[0])
+
+ return PcdItemObj
+
+def ValidatePcdValueOnDatumType(Value, Type):
+
+ Value = Value.strip()
+ #
+ # Boolean type only allow 0x00 or 0x01 as value per INF spec
+ #
+ if Type == 'BOOLEAN':
+ if not (Value == '0x00' or Value == '0x01'):
+ return False
+ elif Type == 'VOID*':
+ if not Value.startswith("{"):
+ return False
+ if not Value.endswith("}"):
+ return False
+ #
+ # Strip "{" at head and "}" at tail.
+ #
+ Value = Value[1:-1]
+ ValueList = GetSplitValueList(Value, DT.TAB_COMMA_SPLIT)
+
+ ReIsValidHexByte = re.compile("^0x[0-9a-f]{1,2}$", re.IGNORECASE)
+ for ValueItem in ValueList:
+ if not ReIsValidHexByte.match(ValueItem):
+ return False
+
+ elif Type == 'UINT8' or Type == 'UINT16' or Type == 'UINT32' or Type == 'UINT64':
+
+ ReIsValidUint8z = re.compile('^0[x|X][a-fA-F0-9]{2}$')
+ ReIsValidUint16z = re.compile('^0[x|X][a-fA-F0-9]{4}$')
+ ReIsValidUint32z = re.compile('^0[x|X][a-fA-F0-9]{8}$')
+ ReIsValidUint64z = re.compile('^0[x|X][a-fA-F0-9]{16}$')
+
+ if not ReIsValidUint8z.match(Value) and Type == 'UINT8':
+ return False
+ elif not ReIsValidUint16z.match(Value) and Type == 'UINT16':
+ return False
+ elif not ReIsValidUint32z.match(Value) and Type == 'UINT32':
+ return False
+ elif not ReIsValidUint64z.match(Value) and Type == 'UINT64':
+ return False
+ else:
+ #
+ # Since we assume the DEC file always correct, should never go to here.
+ #
+ pass
+
+ return True
+
+def SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj):
+ #
+ # Only PCD Name specified
+ # <PcdName> ::= <TokenSpaceGuidCName> "." <TokenCName>
+ #
+ PcdId = GetSplitValueList(PcdItem[0], DT.TAB_SPLIT)
+ if len(PcdId) != 2:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_PCD_NAME_FORMAT_ERROR,
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
+ ExtraData=CurrentLineOfPcdItem[0])
+ else:
+ #
+ # Validate PcdTokenSpaceGuidCName
+ #
+ if not IsValidCVariableName(PcdId[0]):
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_PCD_CVAR_GUID,
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
+ ExtraData=PcdId[0])
+ if not IsValidCVariableName(PcdId[1]):
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_PCD_CVAR_PCDCNAME,
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
+ ExtraData=PcdId[1])
+ PcdItemObj.SetTokenSpaceGuidCName(PcdId[0])
+ PcdItemObj.SetCName(PcdId[1])
+
+ return PcdItemObj
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py
index 1968c36573..9c852f508b 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py
@@ -1,337 +1,337 @@
-## @file
-# This file is used to define class objects of INF file [Ppis] section.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfPpiObject
-'''
-
-from Library.ParserValidate import IsValidCVariableName
-from Library.CommentParsing import ParseComment
-from Library.ExpressionValidate import IsValidFeatureFlagExp
-
-from Library.Misc import Sdict
-from Library import DataType as DT
-import Logger.Log as Logger
-from Logger import ToolError
-from Logger import StringTable as ST
-
-def ParsePpiComment(CommentsList, InfPpiItemObj):
- PreNotify = None
- PreUsage = None
- PreHelpText = ''
- BlockFlag = -1
- CommentInsList = []
- Count = 0
- for CommentItem in CommentsList:
- Count = Count + 1
- CommentItemUsage, \
- CommentItemNotify, \
- CommentItemString, \
- CommentItemHelpText = \
- ParseComment(CommentItem,
- DT.ALL_USAGE_TOKENS,
- DT.PPI_NOTIFY_TOKENS,
- ['PPI'],
- False)
-
- #
- # To avoid PyLint error
- #
- if CommentItemString:
- pass
-
- if CommentItemHelpText is None:
- CommentItemHelpText = ''
- if Count == len(CommentsList) and CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
- CommentItemHelpText = DT.END_OF_LINE
- #
- # For the Last comment Item, set BlockFlag.
- #
- if Count == len(CommentsList):
- if BlockFlag == 1 or BlockFlag == 2:
- if CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
- BlockFlag = 4
- else:
- BlockFlag = 3
- elif BlockFlag == -1:
- BlockFlag = 4
-
- #
- # Comment USAGE and NOTIFY information are "UNDEFINED"
- #
- if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
- if CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
- if BlockFlag == -1:
- BlockFlag = 1
- elif BlockFlag == 1:
- BlockFlag = 2
- else:
- if BlockFlag == 1 or BlockFlag == 2:
- BlockFlag = 3
- #
- # An item have Usage or Notify information and the first time get this information
- #
- elif BlockFlag == -1:
- BlockFlag = 4
-
- #
- # Combine two comment line if they are generic comment
- #
- if CommentItemUsage == CommentItemNotify == PreUsage == PreNotify == DT.ITEM_UNDEFINED:
- CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
- #
- # Store this information for next line may still need combine operation.
- #
- PreHelpText = CommentItemHelpText
-
- if BlockFlag == 4:
- CommentItemIns = InfPpiItemCommentContent()
- CommentItemIns.SetUsage(CommentItemUsage)
- CommentItemIns.SetNotify(CommentItemNotify)
- CommentItemIns.SetHelpStringItem(CommentItemHelpText)
- CommentInsList.append(CommentItemIns)
-
- BlockFlag = -1
- PreUsage = None
- PreNotify = None
- PreHelpText = ''
-
- elif BlockFlag == 3:
- #
- # Add previous help string
- #
- CommentItemIns = InfPpiItemCommentContent()
- CommentItemIns.SetUsage(DT.ITEM_UNDEFINED)
- CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
- if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
- PreHelpText += DT.END_OF_LINE
- CommentItemIns.SetHelpStringItem(PreHelpText)
- CommentInsList.append(CommentItemIns)
- #
- # Add Current help string
- #
- CommentItemIns = InfPpiItemCommentContent()
- CommentItemIns.SetUsage(CommentItemUsage)
- CommentItemIns.SetNotify(CommentItemNotify)
- CommentItemIns.SetHelpStringItem(CommentItemHelpText)
- CommentInsList.append(CommentItemIns)
-
- BlockFlag = -1
- PreUsage = None
- PreNotify = None
- PreHelpText = ''
- else:
- PreUsage = CommentItemUsage
- PreNotify = CommentItemNotify
- PreHelpText = CommentItemHelpText
-
- InfPpiItemObj.SetCommentList(CommentInsList)
-
- return InfPpiItemObj
-
-class InfPpiItemCommentContent():
- def __init__(self):
- #
- # ## SOMETIMES_CONSUMES ## HelpString
- #
- self.UsageItem = ''
- #
- # Help String
- #
- self.HelpStringItem = ''
- self.Notify = ''
- self.CommentList = []
-
- def SetUsage(self, UsageItem):
- self.UsageItem = UsageItem
- def GetUsage(self):
- return self.UsageItem
-
- def SetNotify(self, Notify):
- if Notify != DT.ITEM_UNDEFINED:
- self.Notify = 'true'
- def GetNotify(self):
- return self.Notify
-
- def SetHelpStringItem(self, HelpStringItem):
- self.HelpStringItem = HelpStringItem
- def GetHelpStringItem(self):
- return self.HelpStringItem
-
-class InfPpiItem():
- def __init__(self):
- self.Name = ''
- self.FeatureFlagExp = ''
- self.SupArchList = []
- self.CommentList = []
-
- def SetName(self, Name):
- self.Name = Name
- def GetName(self):
- return self.Name
-
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
- def GetSupArchList(self):
- return self.SupArchList
-
- def SetCommentList(self, CommentList):
- self.CommentList = CommentList
- def GetCommentList(self):
- return self.CommentList
-
- def SetFeatureFlagExp(self, FeatureFlagExp):
- self.FeatureFlagExp = FeatureFlagExp
- def GetFeatureFlagExp(self):
- return self.FeatureFlagExp
-##
-#
-#
-#
-class InfPpiObject():
- def __init__(self):
- self.Ppis = Sdict()
- #
- # Macro defined in this section should be only used in this section.
- #
- self.Macros = {}
-
- def SetPpi(self, PpiList, Arch = None):
- __SupArchList = []
- for ArchItem in Arch:
- #
- # Validate Arch
- #
- if (ArchItem == '' or ArchItem is None):
- ArchItem = 'COMMON'
- __SupArchList.append(ArchItem)
-
- for Item in PpiList:
- #
- # Get Comment content of this protocol
- #
- CommentsList = None
- if len(Item) == 3:
- CommentsList = Item[1]
- CurrentLineOfItem = Item[2]
- Item = Item[0]
- InfPpiItemObj = InfPpiItem()
- if len(Item) >= 1 and len(Item) <= 2:
- #
- # Only CName contained
- #
- if not IsValidCVariableName(Item[0]):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]),
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- if (Item[0] != ''):
- InfPpiItemObj.SetName(Item[0])
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_CNAME_MISSING,
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- #
- # Have FeatureFlag information
- #
- if len(Item) == 2:
- #
- # Contained CName and Feature Flag Express
- # <statements> ::= <CName> ["|" <FeatureFlagExpress>]
- # Item[1] should not be empty
- #
- if Item[1].strip() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- #
- # Validate Feature Flag Express for PPI entry
- # Item[1] contain FFE information
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(Item[1].strip())
- if not FeatureFlagRtv[0]:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- InfPpiItemObj.SetFeatureFlagExp(Item[1])
- if len(Item) != 1 and len(Item) != 2:
- #
- # Invalid format of Ppi statement
- #
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR,
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
-
- #
- # Get/Set Usage and HelpString for PPI entry
- #
- if CommentsList is not None and len(CommentsList) != 0:
- InfPpiItemObj = ParsePpiComment(CommentsList, InfPpiItemObj)
- else:
- CommentItemIns = InfPpiItemCommentContent()
- CommentItemIns.SetUsage(DT.ITEM_UNDEFINED)
- CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
- InfPpiItemObj.SetCommentList([CommentItemIns])
-
- InfPpiItemObj.SetSupArchList(__SupArchList)
-
- #
- # Determine PPI name duplicate. Follow below rule:
- #
- # A PPI must not be duplicated within a [Ppis] section.
- # A PPI may appear in multiple architectural [Ppis]
- # sections. A PPI listed in an architectural [Ppis]
- # section must not be listed in the common architectural
- # [Ppis] section.
- #
- # NOTE: This check will not report error now.
- #
- for Item in self.Ppis:
- if Item.GetName() == InfPpiItemObj.GetName():
- ItemSupArchList = Item.GetSupArchList()
- for ItemArch in ItemSupArchList:
- for PpiItemObjArch in __SupArchList:
- if ItemArch == PpiItemObjArch:
- #
- # ST.ERR_INF_PARSER_ITEM_DUPLICATE
- #
- pass
- if ItemArch.upper() == 'COMMON' or PpiItemObjArch.upper() == 'COMMON':
- #
- # ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
- #
- pass
-
- if (InfPpiItemObj) in self.Ppis:
- PpiList = self.Ppis[InfPpiItemObj]
- PpiList.append(InfPpiItemObj)
- self.Ppis[InfPpiItemObj] = PpiList
- else:
- PpiList = []
- PpiList.append(InfPpiItemObj)
- self.Ppis[InfPpiItemObj] = PpiList
-
- return True
-
-
- def GetPpi(self):
- return self.Ppis
+## @file
+# This file is used to define class objects of INF file [Ppis] section.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfPpiObject
+'''
+
+from Library.ParserValidate import IsValidCVariableName
+from Library.CommentParsing import ParseComment
+from Library.ExpressionValidate import IsValidFeatureFlagExp
+
+from Library.Misc import Sdict
+from Library import DataType as DT
+import Logger.Log as Logger
+from Logger import ToolError
+from Logger import StringTable as ST
+
+def ParsePpiComment(CommentsList, InfPpiItemObj):
+ PreNotify = None
+ PreUsage = None
+ PreHelpText = ''
+ BlockFlag = -1
+ CommentInsList = []
+ Count = 0
+ for CommentItem in CommentsList:
+ Count = Count + 1
+ CommentItemUsage, \
+ CommentItemNotify, \
+ CommentItemString, \
+ CommentItemHelpText = \
+ ParseComment(CommentItem,
+ DT.ALL_USAGE_TOKENS,
+ DT.PPI_NOTIFY_TOKENS,
+ ['PPI'],
+ False)
+
+ #
+ # To avoid PyLint error
+ #
+ if CommentItemString:
+ pass
+
+ if CommentItemHelpText is None:
+ CommentItemHelpText = ''
+ if Count == len(CommentsList) and CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
+ CommentItemHelpText = DT.END_OF_LINE
+ #
+ # For the Last comment Item, set BlockFlag.
+ #
+ if Count == len(CommentsList):
+ if BlockFlag == 1 or BlockFlag == 2:
+ if CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
+ BlockFlag = 4
+ else:
+ BlockFlag = 3
+ elif BlockFlag == -1:
+ BlockFlag = 4
+
+ #
+ # Comment USAGE and NOTIFY information are "UNDEFINED"
+ #
+ if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
+ if CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
+ if BlockFlag == -1:
+ BlockFlag = 1
+ elif BlockFlag == 1:
+ BlockFlag = 2
+ else:
+ if BlockFlag == 1 or BlockFlag == 2:
+ BlockFlag = 3
+ #
+ # An item have Usage or Notify information and the first time get this information
+ #
+ elif BlockFlag == -1:
+ BlockFlag = 4
+
+ #
+ # Combine two comment line if they are generic comment
+ #
+ if CommentItemUsage == CommentItemNotify == PreUsage == PreNotify == DT.ITEM_UNDEFINED:
+ CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
+ #
+ # Store this information for next line may still need combine operation.
+ #
+ PreHelpText = CommentItemHelpText
+
+ if BlockFlag == 4:
+ CommentItemIns = InfPpiItemCommentContent()
+ CommentItemIns.SetUsage(CommentItemUsage)
+ CommentItemIns.SetNotify(CommentItemNotify)
+ CommentItemIns.SetHelpStringItem(CommentItemHelpText)
+ CommentInsList.append(CommentItemIns)
+
+ BlockFlag = -1
+ PreUsage = None
+ PreNotify = None
+ PreHelpText = ''
+
+ elif BlockFlag == 3:
+ #
+ # Add previous help string
+ #
+ CommentItemIns = InfPpiItemCommentContent()
+ CommentItemIns.SetUsage(DT.ITEM_UNDEFINED)
+ CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
+ if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
+ PreHelpText += DT.END_OF_LINE
+ CommentItemIns.SetHelpStringItem(PreHelpText)
+ CommentInsList.append(CommentItemIns)
+ #
+ # Add Current help string
+ #
+ CommentItemIns = InfPpiItemCommentContent()
+ CommentItemIns.SetUsage(CommentItemUsage)
+ CommentItemIns.SetNotify(CommentItemNotify)
+ CommentItemIns.SetHelpStringItem(CommentItemHelpText)
+ CommentInsList.append(CommentItemIns)
+
+ BlockFlag = -1
+ PreUsage = None
+ PreNotify = None
+ PreHelpText = ''
+ else:
+ PreUsage = CommentItemUsage
+ PreNotify = CommentItemNotify
+ PreHelpText = CommentItemHelpText
+
+ InfPpiItemObj.SetCommentList(CommentInsList)
+
+ return InfPpiItemObj
+
+class InfPpiItemCommentContent():
+ def __init__(self):
+ #
+ # ## SOMETIMES_CONSUMES ## HelpString
+ #
+ self.UsageItem = ''
+ #
+ # Help String
+ #
+ self.HelpStringItem = ''
+ self.Notify = ''
+ self.CommentList = []
+
+ def SetUsage(self, UsageItem):
+ self.UsageItem = UsageItem
+ def GetUsage(self):
+ return self.UsageItem
+
+ def SetNotify(self, Notify):
+ if Notify != DT.ITEM_UNDEFINED:
+ self.Notify = 'true'
+ def GetNotify(self):
+ return self.Notify
+
+ def SetHelpStringItem(self, HelpStringItem):
+ self.HelpStringItem = HelpStringItem
+ def GetHelpStringItem(self):
+ return self.HelpStringItem
+
+class InfPpiItem():
+ def __init__(self):
+ self.Name = ''
+ self.FeatureFlagExp = ''
+ self.SupArchList = []
+ self.CommentList = []
+
+ def SetName(self, Name):
+ self.Name = Name
+ def GetName(self):
+ return self.Name
+
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+
+ def SetCommentList(self, CommentList):
+ self.CommentList = CommentList
+ def GetCommentList(self):
+ return self.CommentList
+
+ def SetFeatureFlagExp(self, FeatureFlagExp):
+ self.FeatureFlagExp = FeatureFlagExp
+ def GetFeatureFlagExp(self):
+ return self.FeatureFlagExp
+##
+#
+#
+#
+class InfPpiObject():
+ def __init__(self):
+ self.Ppis = Sdict()
+ #
+ # Macro defined in this section should be only used in this section.
+ #
+ self.Macros = {}
+
+ def SetPpi(self, PpiList, Arch = None):
+ __SupArchList = []
+ for ArchItem in Arch:
+ #
+ # Validate Arch
+ #
+ if (ArchItem == '' or ArchItem is None):
+ ArchItem = 'COMMON'
+ __SupArchList.append(ArchItem)
+
+ for Item in PpiList:
+ #
+ # Get Comment content of this protocol
+ #
+ CommentsList = None
+ if len(Item) == 3:
+ CommentsList = Item[1]
+ CurrentLineOfItem = Item[2]
+ Item = Item[0]
+ InfPpiItemObj = InfPpiItem()
+ if len(Item) >= 1 and len(Item) <= 2:
+ #
+ # Only CName contained
+ #
+ if not IsValidCVariableName(Item[0]):
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]),
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ if (Item[0] != ''):
+ InfPpiItemObj.SetName(Item[0])
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_CNAME_MISSING,
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ #
+ # Have FeatureFlag information
+ #
+ if len(Item) == 2:
+ #
+ # Contained CName and Feature Flag Express
+ # <statements> ::= <CName> ["|" <FeatureFlagExpress>]
+ # Item[1] should not be empty
+ #
+ if Item[1].strip() == '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ #
+ # Validate Feature Flag Express for PPI entry
+ # Item[1] contain FFE information
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(Item[1].strip())
+ if not FeatureFlagRtv[0]:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ InfPpiItemObj.SetFeatureFlagExp(Item[1])
+ if len(Item) != 1 and len(Item) != 2:
+ #
+ # Invalid format of Ppi statement
+ #
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR,
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+
+ #
+ # Get/Set Usage and HelpString for PPI entry
+ #
+ if CommentsList is not None and len(CommentsList) != 0:
+ InfPpiItemObj = ParsePpiComment(CommentsList, InfPpiItemObj)
+ else:
+ CommentItemIns = InfPpiItemCommentContent()
+ CommentItemIns.SetUsage(DT.ITEM_UNDEFINED)
+ CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
+ InfPpiItemObj.SetCommentList([CommentItemIns])
+
+ InfPpiItemObj.SetSupArchList(__SupArchList)
+
+ #
+ # Determine PPI name duplicate. Follow below rule:
+ #
+ # A PPI must not be duplicated within a [Ppis] section.
+ # A PPI may appear in multiple architectural [Ppis]
+ # sections. A PPI listed in an architectural [Ppis]
+ # section must not be listed in the common architectural
+ # [Ppis] section.
+ #
+ # NOTE: This check will not report error now.
+ #
+ for Item in self.Ppis:
+ if Item.GetName() == InfPpiItemObj.GetName():
+ ItemSupArchList = Item.GetSupArchList()
+ for ItemArch in ItemSupArchList:
+ for PpiItemObjArch in __SupArchList:
+ if ItemArch == PpiItemObjArch:
+ #
+ # ST.ERR_INF_PARSER_ITEM_DUPLICATE
+ #
+ pass
+ if ItemArch.upper() == 'COMMON' or PpiItemObjArch.upper() == 'COMMON':
+ #
+ # ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
+ #
+ pass
+
+ if (InfPpiItemObj) in self.Ppis:
+ PpiList = self.Ppis[InfPpiItemObj]
+ PpiList.append(InfPpiItemObj)
+ self.Ppis[InfPpiItemObj] = PpiList
+ else:
+ PpiList = []
+ PpiList.append(InfPpiItemObj)
+ self.Ppis[InfPpiItemObj] = PpiList
+
+ return True
+
+
+ def GetPpi(self):
+ return self.Ppis
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py
index 80bfca6077..00de9272a8 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py
@@ -1,305 +1,305 @@
-## @file
-# This file is used to define class objects of INF file [Protocols] section.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfProtocolObject
-'''
-
-from Library.ParserValidate import IsValidCVariableName
-from Library.CommentParsing import ParseComment
-from Library.ExpressionValidate import IsValidFeatureFlagExp
-
-from Library.Misc import Sdict
-
-from Object.Parser.InfMisc import ErrorInInf
-
-from Library import DataType as DT
-from Logger import StringTable as ST
-
-def ParseProtocolComment(CommentsList, InfProtocolItemObj):
- CommentInsList = []
- PreUsage = None
- PreNotify = None
- PreHelpText = ''
- BlockFlag = -1
- Count = 0
- for CommentItem in CommentsList:
- Count = Count + 1
- CommentItemUsage, \
- CommentItemNotify, \
- CommentItemString, \
- CommentItemHelpText = \
- ParseComment(CommentItem,
- DT.PROTOCOL_USAGE_TOKENS,
- DT.PROTOCOL_NOTIFY_TOKENS,
- ['PROTOCOL'],
- False)
-
- if CommentItemString:
- pass
-
- if CommentItemHelpText is None:
- CommentItemHelpText = ''
- if Count == len(CommentsList) and CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
- CommentItemHelpText = DT.END_OF_LINE
-
- if Count == len(CommentsList):
- if BlockFlag == 1 or BlockFlag == 2:
- if CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
- BlockFlag = 4
- else:
- BlockFlag = 3
- elif BlockFlag == -1:
- BlockFlag = 4
-
- if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
- if CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
- if BlockFlag == -1:
- BlockFlag = 1
- elif BlockFlag == 1:
- BlockFlag = 2
- else:
- if BlockFlag == 1 or BlockFlag == 2:
- BlockFlag = 3
- elif BlockFlag == -1:
- BlockFlag = 4
-
- #
- # Combine two comment line if they are generic comment
- #
- if CommentItemUsage == CommentItemNotify == PreUsage == PreNotify == DT.ITEM_UNDEFINED:
- CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
-
- PreHelpText = CommentItemHelpText
-
- if BlockFlag == 4:
- CommentItemIns = InfProtocolItemCommentContent()
- CommentItemIns.SetUsageItem(CommentItemUsage)
- CommentItemIns.SetNotify(CommentItemNotify)
- CommentItemIns.SetHelpStringItem(CommentItemHelpText)
- CommentInsList.append(CommentItemIns)
-
- BlockFlag = -1
- PreUsage = None
- PreNotify = None
- PreHelpText = ''
-
- elif BlockFlag == 3:
- #
- # Add previous help string
- #
- CommentItemIns = InfProtocolItemCommentContent()
- CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
- CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
- if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
- PreHelpText += DT.END_OF_LINE
- CommentItemIns.SetHelpStringItem(PreHelpText)
- CommentInsList.append(CommentItemIns)
- #
- # Add Current help string
- #
- CommentItemIns = InfProtocolItemCommentContent()
- CommentItemIns.SetUsageItem(CommentItemUsage)
- CommentItemIns.SetNotify(CommentItemNotify)
- CommentItemIns.SetHelpStringItem(CommentItemHelpText)
- CommentInsList.append(CommentItemIns)
-
- BlockFlag = -1
- PreUsage = None
- PreNotify = None
- PreHelpText = ''
-
- else:
- PreUsage = CommentItemUsage
- PreNotify = CommentItemNotify
- PreHelpText = CommentItemHelpText
-
- InfProtocolItemObj.SetCommentList(CommentInsList)
-
- return InfProtocolItemObj
-
-class InfProtocolItemCommentContent():
- def __init__(self):
- #
- # ## SOMETIMES_CONSUMES ## HelpString
- #
- self.UsageItem = ''
- #
- # Help String
- #
- self.HelpStringItem = ''
- self.Notify = ''
- self.CommentList = []
-
- def SetUsageItem(self, UsageItem):
- self.UsageItem = UsageItem
- def GetUsageItem(self):
- return self.UsageItem
-
- def SetNotify(self, Notify):
- if Notify != DT.ITEM_UNDEFINED:
- self.Notify = 'true'
- def GetNotify(self):
- return self.Notify
-
- def SetHelpStringItem(self, HelpStringItem):
- self.HelpStringItem = HelpStringItem
- def GetHelpStringItem(self):
- return self.HelpStringItem
-
-class InfProtocolItem():
- def __init__(self):
- self.Name = ''
- self.FeatureFlagExp = ''
- self.SupArchList = []
- self.CommentList = []
-
- def SetName(self, Name):
- self.Name = Name
- def GetName(self):
- return self.Name
-
- def SetFeatureFlagExp(self, FeatureFlagExp):
- self.FeatureFlagExp = FeatureFlagExp
- def GetFeatureFlagExp(self):
- return self.FeatureFlagExp
-
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
- def GetSupArchList(self):
- return self.SupArchList
-
- def SetCommentList(self, CommentList):
- self.CommentList = CommentList
- def GetCommentList(self):
- return self.CommentList
-
-##
-#
-#
-#
-class InfProtocolObject():
- def __init__(self):
- self.Protocols = Sdict()
- #
- # Macro defined in this section should be only used in this section.
- #
- self.Macros = {}
-
- def SetProtocol(self, ProtocolContent, Arch = None,):
- __SupArchList = []
- for ArchItem in Arch:
- #
- # Validate Arch
- #
- if (ArchItem == '' or ArchItem is None):
- ArchItem = 'COMMON'
- __SupArchList.append(ArchItem)
-
- for Item in ProtocolContent:
- #
- # Get Comment content of this protocol
- #
- CommentsList = None
- if len(Item) == 3:
- CommentsList = Item[1]
- CurrentLineOfItem = Item[2]
- LineInfo = (CurrentLineOfItem[2], CurrentLineOfItem[1], CurrentLineOfItem[0])
- Item = Item[0]
- InfProtocolItemObj = InfProtocolItem()
- if len(Item) >= 1 and len(Item) <= 2:
- #
- # Only CName contained
- #
- if not IsValidCVariableName(Item[0]):
- ErrorInInf(ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]),
- LineInfo=LineInfo)
- if (Item[0] != ''):
- InfProtocolItemObj.SetName(Item[0])
- else:
- ErrorInInf(ST.ERR_INF_PARSER_CNAME_MISSING,
- LineInfo=LineInfo)
- if len(Item) == 2:
- #
- # Contained CName and Feature Flag Express
- # <statements> ::= <CName> ["|"
- # <FeatureFlagExpress>]
- # For Protocol Object
- #
- if Item[1].strip() == '':
- ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- LineInfo=LineInfo)
- #
- # Validate Feature Flag Express for Item[1]
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(Item[1].strip())
- if not FeatureFlagRtv[0]:
- ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
- LineInfo=LineInfo)
- InfProtocolItemObj.SetFeatureFlagExp(Item[1])
-
- if len(Item) < 1 or len(Item) > 2:
- #
- # Invalid format of Protocols statement
- #
- ErrorInInf(ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR,
- LineInfo=LineInfo)
-
- #
- # Get/Set Usage and HelpString for Protocol entry
- #
- if CommentsList is not None and len(CommentsList) != 0:
- InfProtocolItemObj = ParseProtocolComment(CommentsList, InfProtocolItemObj)
- else:
- CommentItemIns = InfProtocolItemCommentContent()
- CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
- CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
- InfProtocolItemObj.SetCommentList([CommentItemIns])
-
- InfProtocolItemObj.SetSupArchList(__SupArchList)
-
- #
- # Determine protocol name duplicate. Follow below rule:
- #
- # A protocol must not be duplicated within a [Protocols] section.
- # A protocol may appear in multiple architectural [Protocols]
- # sections. A protocol listed in an architectural [Protocols]
- # section must not be listed in the common architectural
- # [Protocols] section.
- #
- # NOTE: This check will not report error now.
- #
- for Item in self.Protocols:
- if Item.GetName() == InfProtocolItemObj.GetName():
- ItemSupArchList = Item.GetSupArchList()
- for ItemArch in ItemSupArchList:
- for ProtocolItemObjArch in __SupArchList:
- if ItemArch == ProtocolItemObjArch:
- #
- # ST.ERR_INF_PARSER_ITEM_DUPLICATE
- #
- pass
- if ItemArch.upper() == 'COMMON' or ProtocolItemObjArch.upper() == 'COMMON':
- #
- # ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
- #
- pass
-
- if (InfProtocolItemObj) in self.Protocols:
- ProcotolList = self.Protocols[InfProtocolItemObj]
- ProcotolList.append(InfProtocolItemObj)
- self.Protocols[InfProtocolItemObj] = ProcotolList
- else:
- ProcotolList = []
- ProcotolList.append(InfProtocolItemObj)
- self.Protocols[InfProtocolItemObj] = ProcotolList
-
- return True
-
- def GetProtocol(self):
- return self.Protocols
+## @file
+# This file is used to define class objects of INF file [Protocols] section.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfProtocolObject
+'''
+
+from Library.ParserValidate import IsValidCVariableName
+from Library.CommentParsing import ParseComment
+from Library.ExpressionValidate import IsValidFeatureFlagExp
+
+from Library.Misc import Sdict
+
+from Object.Parser.InfMisc import ErrorInInf
+
+from Library import DataType as DT
+from Logger import StringTable as ST
+
+def ParseProtocolComment(CommentsList, InfProtocolItemObj):
+ CommentInsList = []
+ PreUsage = None
+ PreNotify = None
+ PreHelpText = ''
+ BlockFlag = -1
+ Count = 0
+ for CommentItem in CommentsList:
+ Count = Count + 1
+ CommentItemUsage, \
+ CommentItemNotify, \
+ CommentItemString, \
+ CommentItemHelpText = \
+ ParseComment(CommentItem,
+ DT.PROTOCOL_USAGE_TOKENS,
+ DT.PROTOCOL_NOTIFY_TOKENS,
+ ['PROTOCOL'],
+ False)
+
+ if CommentItemString:
+ pass
+
+ if CommentItemHelpText is None:
+ CommentItemHelpText = ''
+ if Count == len(CommentsList) and CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
+ CommentItemHelpText = DT.END_OF_LINE
+
+ if Count == len(CommentsList):
+ if BlockFlag == 1 or BlockFlag == 2:
+ if CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
+ BlockFlag = 4
+ else:
+ BlockFlag = 3
+ elif BlockFlag == -1:
+ BlockFlag = 4
+
+ if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
+ if CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
+ if BlockFlag == -1:
+ BlockFlag = 1
+ elif BlockFlag == 1:
+ BlockFlag = 2
+ else:
+ if BlockFlag == 1 or BlockFlag == 2:
+ BlockFlag = 3
+ elif BlockFlag == -1:
+ BlockFlag = 4
+
+ #
+ # Combine two comment line if they are generic comment
+ #
+ if CommentItemUsage == CommentItemNotify == PreUsage == PreNotify == DT.ITEM_UNDEFINED:
+ CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
+
+ PreHelpText = CommentItemHelpText
+
+ if BlockFlag == 4:
+ CommentItemIns = InfProtocolItemCommentContent()
+ CommentItemIns.SetUsageItem(CommentItemUsage)
+ CommentItemIns.SetNotify(CommentItemNotify)
+ CommentItemIns.SetHelpStringItem(CommentItemHelpText)
+ CommentInsList.append(CommentItemIns)
+
+ BlockFlag = -1
+ PreUsage = None
+ PreNotify = None
+ PreHelpText = ''
+
+ elif BlockFlag == 3:
+ #
+ # Add previous help string
+ #
+ CommentItemIns = InfProtocolItemCommentContent()
+ CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
+ CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
+ if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
+ PreHelpText += DT.END_OF_LINE
+ CommentItemIns.SetHelpStringItem(PreHelpText)
+ CommentInsList.append(CommentItemIns)
+ #
+ # Add Current help string
+ #
+ CommentItemIns = InfProtocolItemCommentContent()
+ CommentItemIns.SetUsageItem(CommentItemUsage)
+ CommentItemIns.SetNotify(CommentItemNotify)
+ CommentItemIns.SetHelpStringItem(CommentItemHelpText)
+ CommentInsList.append(CommentItemIns)
+
+ BlockFlag = -1
+ PreUsage = None
+ PreNotify = None
+ PreHelpText = ''
+
+ else:
+ PreUsage = CommentItemUsage
+ PreNotify = CommentItemNotify
+ PreHelpText = CommentItemHelpText
+
+ InfProtocolItemObj.SetCommentList(CommentInsList)
+
+ return InfProtocolItemObj
+
+class InfProtocolItemCommentContent():
+ def __init__(self):
+ #
+ # ## SOMETIMES_CONSUMES ## HelpString
+ #
+ self.UsageItem = ''
+ #
+ # Help String
+ #
+ self.HelpStringItem = ''
+ self.Notify = ''
+ self.CommentList = []
+
+ def SetUsageItem(self, UsageItem):
+ self.UsageItem = UsageItem
+ def GetUsageItem(self):
+ return self.UsageItem
+
+ def SetNotify(self, Notify):
+ if Notify != DT.ITEM_UNDEFINED:
+ self.Notify = 'true'
+ def GetNotify(self):
+ return self.Notify
+
+ def SetHelpStringItem(self, HelpStringItem):
+ self.HelpStringItem = HelpStringItem
+ def GetHelpStringItem(self):
+ return self.HelpStringItem
+
+class InfProtocolItem():
+ def __init__(self):
+ self.Name = ''
+ self.FeatureFlagExp = ''
+ self.SupArchList = []
+ self.CommentList = []
+
+ def SetName(self, Name):
+ self.Name = Name
+ def GetName(self):
+ return self.Name
+
+ def SetFeatureFlagExp(self, FeatureFlagExp):
+ self.FeatureFlagExp = FeatureFlagExp
+ def GetFeatureFlagExp(self):
+ return self.FeatureFlagExp
+
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+
+ def SetCommentList(self, CommentList):
+ self.CommentList = CommentList
+ def GetCommentList(self):
+ return self.CommentList
+
+##
+#
+#
+#
+class InfProtocolObject():
+ def __init__(self):
+ self.Protocols = Sdict()
+ #
+ # Macro defined in this section should be only used in this section.
+ #
+ self.Macros = {}
+
+ def SetProtocol(self, ProtocolContent, Arch = None,):
+ __SupArchList = []
+ for ArchItem in Arch:
+ #
+ # Validate Arch
+ #
+ if (ArchItem == '' or ArchItem is None):
+ ArchItem = 'COMMON'
+ __SupArchList.append(ArchItem)
+
+ for Item in ProtocolContent:
+ #
+ # Get Comment content of this protocol
+ #
+ CommentsList = None
+ if len(Item) == 3:
+ CommentsList = Item[1]
+ CurrentLineOfItem = Item[2]
+ LineInfo = (CurrentLineOfItem[2], CurrentLineOfItem[1], CurrentLineOfItem[0])
+ Item = Item[0]
+ InfProtocolItemObj = InfProtocolItem()
+ if len(Item) >= 1 and len(Item) <= 2:
+ #
+ # Only CName contained
+ #
+ if not IsValidCVariableName(Item[0]):
+ ErrorInInf(ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]),
+ LineInfo=LineInfo)
+ if (Item[0] != ''):
+ InfProtocolItemObj.SetName(Item[0])
+ else:
+ ErrorInInf(ST.ERR_INF_PARSER_CNAME_MISSING,
+ LineInfo=LineInfo)
+ if len(Item) == 2:
+ #
+ # Contained CName and Feature Flag Express
+ # <statements> ::= <CName> ["|"
+ # <FeatureFlagExpress>]
+ # For Protocol Object
+ #
+ if Item[1].strip() == '':
+ ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
+ LineInfo=LineInfo)
+ #
+ # Validate Feature Flag Express for Item[1]
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(Item[1].strip())
+ if not FeatureFlagRtv[0]:
+ ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
+ LineInfo=LineInfo)
+ InfProtocolItemObj.SetFeatureFlagExp(Item[1])
+
+ if len(Item) < 1 or len(Item) > 2:
+ #
+ # Invalid format of Protocols statement
+ #
+ ErrorInInf(ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR,
+ LineInfo=LineInfo)
+
+ #
+ # Get/Set Usage and HelpString for Protocol entry
+ #
+ if CommentsList is not None and len(CommentsList) != 0:
+ InfProtocolItemObj = ParseProtocolComment(CommentsList, InfProtocolItemObj)
+ else:
+ CommentItemIns = InfProtocolItemCommentContent()
+ CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
+ CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
+ InfProtocolItemObj.SetCommentList([CommentItemIns])
+
+ InfProtocolItemObj.SetSupArchList(__SupArchList)
+
+ #
+ # Determine protocol name duplicate. Follow below rule:
+ #
+ # A protocol must not be duplicated within a [Protocols] section.
+ # A protocol may appear in multiple architectural [Protocols]
+ # sections. A protocol listed in an architectural [Protocols]
+ # section must not be listed in the common architectural
+ # [Protocols] section.
+ #
+ # NOTE: This check will not report error now.
+ #
+ for Item in self.Protocols:
+ if Item.GetName() == InfProtocolItemObj.GetName():
+ ItemSupArchList = Item.GetSupArchList()
+ for ItemArch in ItemSupArchList:
+ for ProtocolItemObjArch in __SupArchList:
+ if ItemArch == ProtocolItemObjArch:
+ #
+ # ST.ERR_INF_PARSER_ITEM_DUPLICATE
+ #
+ pass
+ if ItemArch.upper() == 'COMMON' or ProtocolItemObjArch.upper() == 'COMMON':
+ #
+ # ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
+ #
+ pass
+
+ if (InfProtocolItemObj) in self.Protocols:
+ ProcotolList = self.Protocols[InfProtocolItemObj]
+ ProcotolList.append(InfProtocolItemObj)
+ self.Protocols[InfProtocolItemObj] = ProcotolList
+ else:
+ ProcotolList = []
+ ProcotolList.append(InfProtocolItemObj)
+ self.Protocols[InfProtocolItemObj] = ProcotolList
+
+ return True
+
+ def GetProtocol(self):
+ return self.Protocols
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py
index 75ea209c48..de95c2f14e 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py
@@ -1,233 +1,233 @@
-## @file
-# This file is used to define class objects of INF file [Sources] section.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfSourcesObject
-'''
-
-import os
-
-from Logger import StringTable as ST
-from Logger import ToolError
-import Logger.Log as Logger
-from Library import GlobalData
-
-from Library.Misc import Sdict
-from Library.ExpressionValidate import IsValidFeatureFlagExp
-from Object.Parser.InfCommonObject import InfSectionCommonDef
-from Library.Misc import ValidFile
-from Library.ParserValidate import IsValidFamily
-from Library.ParserValidate import IsValidPath
-
-## __GenSourceInstance
-#
-#
-def GenSourceInstance(Item, CurrentLineOfItem, ItemObj):
-
- IsValidFileFlag = False
-
- if len(Item) < 6 and len(Item) >= 1:
- #
- # File | Family | TagName | ToolCode | FeatureFlagExpr
- #
- if len(Item) == 5:
- #
- # Validate Feature Flag Express
- #
- if Item[4].strip() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- #
- # Validate FFE
- #
- FeatureFlagRtv = IsValidFeatureFlagExp(Item[4].strip())
- if not FeatureFlagRtv[0]:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- ItemObj.SetFeatureFlagExp(Item[4])
- if len(Item) >= 4:
- if Item[3].strip() == '':
- ItemObj.SetToolCode(Item[3])
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_TOOLCODE_NOT_PERMITTED%(Item[2]),
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- if len(Item) >= 3:
- if Item[2].strip() == '':
- ItemObj.SetTagName(Item[2])
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED%(Item[2]),
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- if len(Item) >= 2:
- if IsValidFamily(Item[1].strip()):
- #
- # To align with UDP specification. "*" is not permitted in UDP specification
- #
- if Item[1].strip() == "*":
- Item[1] = ""
- ItemObj.SetFamily(Item[1])
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_SOURCE_SECTION_FAMILY_INVALID%(Item[1]),
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- if len(Item) >= 1:
- #
- # Validate file name exist.
- #
- FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR, Item[0])))
- if not (ValidFile(FullFileName) or ValidFile(Item[0])):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_FILELIST_EXIST%(Item[0]),
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
-
- #
- # Validate file exist/format.
- #
-
- if IsValidPath(Item[0], GlobalData.gINF_MODULE_DIR):
- IsValidFileFlag = True
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Item[0]),
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
- return False
- if IsValidFileFlag:
- ItemObj.SetSourceFileName(Item[0])
- else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_SOURCES_SECTION_CONTENT_ERROR,
- File=CurrentLineOfItem[2],
- Line=CurrentLineOfItem[1],
- ExtraData=CurrentLineOfItem[0])
-
- return ItemObj
-
-## InfSourcesItemObject()
-#
-#
-class InfSourcesItemObject():
- def __init__(self, \
- SourceFileName = '', \
- Family = '', \
- TagName = '', \
- ToolCode = '', \
- FeatureFlagExp = ''):
- self.SourceFileName = SourceFileName
- self.Family = Family
- self.TagName = TagName
- self.ToolCode = ToolCode
- self.FeatureFlagExp = FeatureFlagExp
- self.HeaderString = ''
- self.TailString = ''
- self.SupArchList = []
-
- def SetSourceFileName(self, SourceFilename):
- self.SourceFileName = SourceFilename
- def GetSourceFileName(self):
- return self.SourceFileName
-
- def SetFamily(self, Family):
- self.Family = Family
- def GetFamily(self):
- return self.Family
-
- def SetTagName(self, TagName):
- self.TagName = TagName
- def GetTagName(self):
- return self.TagName
-
- def SetToolCode(self, ToolCode):
- self.ToolCode = ToolCode
- def GetToolCode(self):
- return self.ToolCode
-
- def SetFeatureFlagExp(self, FeatureFlagExp):
- self.FeatureFlagExp = FeatureFlagExp
- def GetFeatureFlagExp(self):
- return self.FeatureFlagExp
-
- def SetHeaderString(self, HeaderString):
- self.HeaderString = HeaderString
- def GetHeaderString(self):
- return self.HeaderString
-
- def SetTailString(self, TailString):
- self.TailString = TailString
- def GetTailString(self):
- return self.TailString
-
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
- def GetSupArchList(self):
- return self.SupArchList
-##
-#
-#
-#
-class InfSourcesObject(InfSectionCommonDef):
- def __init__(self):
- self.Sources = Sdict()
- InfSectionCommonDef.__init__(self)
-
- def SetSources(self, SourceList, Arch = None):
- __SupArchList = []
- for ArchItem in Arch:
- #
- # Validate Arch
- #
- if (ArchItem == '' or ArchItem is None):
- ArchItem = 'COMMON'
- __SupArchList.append(ArchItem)
-
- for Item in SourceList:
- ItemObj = InfSourcesItemObject()
- CurrentLineOfItem = Item[2]
- Item = Item[0]
-
- ItemObj = GenSourceInstance(Item, CurrentLineOfItem, ItemObj)
-
- ItemObj.SetSupArchList(__SupArchList)
-
- if (ItemObj) in self.Sources:
- SourceContent = self.Sources[ItemObj]
- SourceContent.append(ItemObj)
- self.Sources[ItemObj] = SourceContent
- else:
- SourceContent = []
- SourceContent.append(ItemObj)
- self.Sources[ItemObj] = SourceContent
-
- return True
-
- def GetSources(self):
- return self.Sources
+## @file
+# This file is used to define class objects of INF file [Sources] section.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfSourcesObject
+'''
+
+import os
+
+from Logger import StringTable as ST
+from Logger import ToolError
+import Logger.Log as Logger
+from Library import GlobalData
+
+from Library.Misc import Sdict
+from Library.ExpressionValidate import IsValidFeatureFlagExp
+from Object.Parser.InfCommonObject import InfSectionCommonDef
+from Library.Misc import ValidFile
+from Library.ParserValidate import IsValidFamily
+from Library.ParserValidate import IsValidPath
+
+## __GenSourceInstance
+#
+#
+def GenSourceInstance(Item, CurrentLineOfItem, ItemObj):
+
+ IsValidFileFlag = False
+
+ if len(Item) < 6 and len(Item) >= 1:
+ #
+ # File | Family | TagName | ToolCode | FeatureFlagExpr
+ #
+ if len(Item) == 5:
+ #
+ # Validate Feature Flag Express
+ #
+ if Item[4].strip() == '':
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ #
+ # Validate FFE
+ #
+ FeatureFlagRtv = IsValidFeatureFlagExp(Item[4].strip())
+ if not FeatureFlagRtv[0]:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ ItemObj.SetFeatureFlagExp(Item[4])
+ if len(Item) >= 4:
+ if Item[3].strip() == '':
+ ItemObj.SetToolCode(Item[3])
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_TOOLCODE_NOT_PERMITTED%(Item[2]),
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ if len(Item) >= 3:
+ if Item[2].strip() == '':
+ ItemObj.SetTagName(Item[2])
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED%(Item[2]),
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ if len(Item) >= 2:
+ if IsValidFamily(Item[1].strip()):
+ #
+ # To align with UDP specification. "*" is not permitted in UDP specification
+ #
+ if Item[1].strip() == "*":
+ Item[1] = ""
+ ItemObj.SetFamily(Item[1])
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_SOURCE_SECTION_FAMILY_INVALID%(Item[1]),
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ if len(Item) >= 1:
+ #
+ # Validate file name exist.
+ #
+ FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR, Item[0])))
+ if not (ValidFile(FullFileName) or ValidFile(Item[0])):
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_FILELIST_EXIST%(Item[0]),
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+
+ #
+ # Validate file exist/format.
+ #
+
+ if IsValidPath(Item[0], GlobalData.gINF_MODULE_DIR):
+ IsValidFileFlag = True
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Item[0]),
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+ return False
+ if IsValidFileFlag:
+ ItemObj.SetSourceFileName(Item[0])
+ else:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_SOURCES_SECTION_CONTENT_ERROR,
+ File=CurrentLineOfItem[2],
+ Line=CurrentLineOfItem[1],
+ ExtraData=CurrentLineOfItem[0])
+
+ return ItemObj
+
+## InfSourcesItemObject()
+#
+#
+class InfSourcesItemObject():
+ def __init__(self, \
+ SourceFileName = '', \
+ Family = '', \
+ TagName = '', \
+ ToolCode = '', \
+ FeatureFlagExp = ''):
+ self.SourceFileName = SourceFileName
+ self.Family = Family
+ self.TagName = TagName
+ self.ToolCode = ToolCode
+ self.FeatureFlagExp = FeatureFlagExp
+ self.HeaderString = ''
+ self.TailString = ''
+ self.SupArchList = []
+
+ def SetSourceFileName(self, SourceFilename):
+ self.SourceFileName = SourceFilename
+ def GetSourceFileName(self):
+ return self.SourceFileName
+
+ def SetFamily(self, Family):
+ self.Family = Family
+ def GetFamily(self):
+ return self.Family
+
+ def SetTagName(self, TagName):
+ self.TagName = TagName
+ def GetTagName(self):
+ return self.TagName
+
+ def SetToolCode(self, ToolCode):
+ self.ToolCode = ToolCode
+ def GetToolCode(self):
+ return self.ToolCode
+
+ def SetFeatureFlagExp(self, FeatureFlagExp):
+ self.FeatureFlagExp = FeatureFlagExp
+ def GetFeatureFlagExp(self):
+ return self.FeatureFlagExp
+
+ def SetHeaderString(self, HeaderString):
+ self.HeaderString = HeaderString
+ def GetHeaderString(self):
+ return self.HeaderString
+
+ def SetTailString(self, TailString):
+ self.TailString = TailString
+ def GetTailString(self):
+ return self.TailString
+
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+##
+#
+#
+#
+class InfSourcesObject(InfSectionCommonDef):
+ def __init__(self):
+ self.Sources = Sdict()
+ InfSectionCommonDef.__init__(self)
+
+ def SetSources(self, SourceList, Arch = None):
+ __SupArchList = []
+ for ArchItem in Arch:
+ #
+ # Validate Arch
+ #
+ if (ArchItem == '' or ArchItem is None):
+ ArchItem = 'COMMON'
+ __SupArchList.append(ArchItem)
+
+ for Item in SourceList:
+ ItemObj = InfSourcesItemObject()
+ CurrentLineOfItem = Item[2]
+ Item = Item[0]
+
+ ItemObj = GenSourceInstance(Item, CurrentLineOfItem, ItemObj)
+
+ ItemObj.SetSupArchList(__SupArchList)
+
+ if (ItemObj) in self.Sources:
+ SourceContent = self.Sources[ItemObj]
+ SourceContent.append(ItemObj)
+ self.Sources[ItemObj] = SourceContent
+ else:
+ SourceContent = []
+ SourceContent.append(ItemObj)
+ self.Sources[ItemObj] = SourceContent
+
+ return True
+
+ def GetSources(self):
+ return self.Sources
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py
index ce017dbebb..c7593bfa82 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py
@@ -1,127 +1,127 @@
-## @file
-# This file is used to define class objects of INF file [UserExtension] section.
-# It will consumed by InfParser.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-
-'''
-InfUserExtensionsObject
-'''
-
-from Logger import StringTable as ST
-from Logger import ToolError
-import Logger.Log as Logger
-from Library import GlobalData
-
-from Library.Misc import Sdict
-
-class InfUserExtensionItem():
- def __init__(self,
- Content = '',
- UserId = '',
- IdString = ''):
- self.Content = Content
- self.UserId = UserId
- self.IdString = IdString
- self.SupArchList = []
-
- def SetContent(self, Content):
- self.Content = Content
- def GetContent(self):
- return self.Content
-
- def SetUserId(self, UserId):
- self.UserId = UserId
- def GetUserId(self):
- return self.UserId
-
- def SetIdString(self, IdString):
- self.IdString = IdString
- def GetIdString(self):
- return self.IdString
-
- def SetSupArchList(self, SupArchList):
- self.SupArchList = SupArchList
- def GetSupArchList(self):
- return self.SupArchList
-
-##
-#
-#
-#
-class InfUserExtensionObject():
- def __init__(self):
- self.UserExtension = Sdict()
-
- def SetUserExtension(self, UserExtensionCont, IdContent=None, LineNo=None):
- if not UserExtensionCont or UserExtensionCont == '':
- return True
- #
- # IdContent is a list contain UserId and IdString
- # For this call the general section header parser, if no definition of
- # IdString/UserId, it will return 'COMMON'
- #
- for IdContentItem in IdContent:
- InfUserExtensionItemObj = InfUserExtensionItem()
- if IdContentItem[0] == 'COMMON':
- UserId = ''
- else:
- UserId = IdContentItem[0]
-
- if IdContentItem[1] == 'COMMON':
- IdString = ''
- else:
- IdString = IdContentItem[1]
-
- #
- # Fill UserExtensionObj members.
- #
- InfUserExtensionItemObj.SetUserId(UserId)
- InfUserExtensionItemObj.SetIdString(IdString)
- InfUserExtensionItemObj.SetContent(UserExtensionCont)
- InfUserExtensionItemObj.SetSupArchList(IdContentItem[2])
-
-# for CheckItem in self.UserExtension:
-# if IdContentItem[0] == CheckItem[0] and IdContentItem[1] == CheckItem[1]:
-# if IdContentItem[2].upper() == 'COMMON' or CheckItem[2].upper() == 'COMMON':
-# #
-# # For COMMON ARCH type, do special check.
-# #
-# Logger.Error('InfParser',
-# ToolError.FORMAT_INVALID,
-# ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\
-# (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),
-# File=GlobalData.gINF_MODULE_NAME,
-# Line=LineNo,
-# ExtraData=None)
-
- if IdContentItem in self.UserExtension:
- #
- # Each UserExtensions section header must have a unique set
- # of UserId, IdString and Arch values.
- # This means that the same UserId can be used in more than one
- # section header, provided the IdString or Arch values are
- # different. The same IdString values can be used in more than
- # one section header if the UserId or Arch values are
- # different. The same UserId and the same IdString can be used
- # in a section header if the Arch values are different in each
- # of the section headers.
- #
- Logger.Error('InfParser',
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\
- (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),
- File=GlobalData.gINF_MODULE_NAME,
- Line=LineNo,
- ExtraData=None)
- else:
- UserExtensionList = []
- UserExtensionList.append(InfUserExtensionItemObj)
- self.UserExtension[IdContentItem] = UserExtensionList
-
- return True
-
- def GetUserExtension(self):
- return self.UserExtension
+## @file
+# This file is used to define class objects of INF file [UserExtension] section.
+# It will consumed by InfParser.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+
+'''
+InfUserExtensionsObject
+'''
+
+from Logger import StringTable as ST
+from Logger import ToolError
+import Logger.Log as Logger
+from Library import GlobalData
+
+from Library.Misc import Sdict
+
+class InfUserExtensionItem():
+ def __init__(self,
+ Content = '',
+ UserId = '',
+ IdString = ''):
+ self.Content = Content
+ self.UserId = UserId
+ self.IdString = IdString
+ self.SupArchList = []
+
+ def SetContent(self, Content):
+ self.Content = Content
+ def GetContent(self):
+ return self.Content
+
+ def SetUserId(self, UserId):
+ self.UserId = UserId
+ def GetUserId(self):
+ return self.UserId
+
+ def SetIdString(self, IdString):
+ self.IdString = IdString
+ def GetIdString(self):
+ return self.IdString
+
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+
+##
+#
+#
+#
+class InfUserExtensionObject():
+ def __init__(self):
+ self.UserExtension = Sdict()
+
+ def SetUserExtension(self, UserExtensionCont, IdContent=None, LineNo=None):
+ if not UserExtensionCont or UserExtensionCont == '':
+ return True
+ #
+ # IdContent is a list contain UserId and IdString
+ # For this call the general section header parser, if no definition of
+ # IdString/UserId, it will return 'COMMON'
+ #
+ for IdContentItem in IdContent:
+ InfUserExtensionItemObj = InfUserExtensionItem()
+ if IdContentItem[0] == 'COMMON':
+ UserId = ''
+ else:
+ UserId = IdContentItem[0]
+
+ if IdContentItem[1] == 'COMMON':
+ IdString = ''
+ else:
+ IdString = IdContentItem[1]
+
+ #
+ # Fill UserExtensionObj members.
+ #
+ InfUserExtensionItemObj.SetUserId(UserId)
+ InfUserExtensionItemObj.SetIdString(IdString)
+ InfUserExtensionItemObj.SetContent(UserExtensionCont)
+ InfUserExtensionItemObj.SetSupArchList(IdContentItem[2])
+
+# for CheckItem in self.UserExtension:
+# if IdContentItem[0] == CheckItem[0] and IdContentItem[1] == CheckItem[1]:
+# if IdContentItem[2].upper() == 'COMMON' or CheckItem[2].upper() == 'COMMON':
+# #
+# # For COMMON ARCH type, do special check.
+# #
+# Logger.Error('InfParser',
+# ToolError.FORMAT_INVALID,
+# ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\
+# (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),
+# File=GlobalData.gINF_MODULE_NAME,
+# Line=LineNo,
+# ExtraData=None)
+
+ if IdContentItem in self.UserExtension:
+ #
+ # Each UserExtensions section header must have a unique set
+ # of UserId, IdString and Arch values.
+ # This means that the same UserId can be used in more than one
+ # section header, provided the IdString or Arch values are
+ # different. The same IdString values can be used in more than
+ # one section header if the UserId or Arch values are
+ # different. The same UserId and the same IdString can be used
+ # in a section header if the Arch values are different in each
+ # of the section headers.
+ #
+ Logger.Error('InfParser',
+ ToolError.FORMAT_INVALID,
+ ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\
+ (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),
+ File=GlobalData.gINF_MODULE_NAME,
+ Line=LineNo,
+ ExtraData=None)
+ else:
+ UserExtensionList = []
+ UserExtensionList.append(InfUserExtensionItemObj)
+ self.UserExtension[IdContentItem] = UserExtensionList
+
+ return True
+
+ def GetUserExtension(self):
+ return self.UserExtension
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/__init__.py b/BaseTools/Source/Python/UPT/Object/Parser/__init__.py
index 268ce7ca1e..5174f3091c 100644
--- a/BaseTools/Source/Python/UPT/Object/Parser/__init__.py
+++ b/BaseTools/Source/Python/UPT/Object/Parser/__init__.py
@@ -1,14 +1,14 @@
-## @file
-# Python 'Object' package initialization file.
-#
-# This file is required to make Python interpreter treat the directory
-# as containing package.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-
-'''
-PARSER
-'''
+## @file
+# Python 'Object' package initialization file.
+#
+# This file is required to make Python interpreter treat the directory
+# as containing package.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+'''
+PARSER
+'''
diff --git a/BaseTools/Source/Python/UPT/Object/__init__.py b/BaseTools/Source/Python/UPT/Object/__init__.py
index 53db4406dc..2e53a314e0 100644
--- a/BaseTools/Source/Python/UPT/Object/__init__.py
+++ b/BaseTools/Source/Python/UPT/Object/__init__.py
@@ -1,14 +1,14 @@
-## @file
-# Python 'Object' package initialization file.
-#
-# This file is required to make Python interpreter treat the directory
-# as containing package.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-
-'''
-Object
-'''
+## @file
+# Python 'Object' package initialization file.
+#
+# This file is required to make Python interpreter treat the directory
+# as containing package.
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+'''
+Object
+'''