This patch is going to:

1.	Add a recovery mode for UPT failure
2.	Add UNI file support
3.	Add binary file header support
4.	Add support for PCD error message
5.	Add support for replace
6.	Format generated INF/DEC files
7.	Update dependency check
8.	Other minor fixes


Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Gao, Liming <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15896 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Hess Chen
2014-08-26 05:58:02 +00:00
committed by hchen30
parent f0aa06e385
commit 421ccda307
56 changed files with 5945 additions and 1710 deletions

View File

@ -1,7 +1,7 @@
## @file DecPomAlignment.py
# This file contained the adapter for convert INF parser object to POM Object
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@ -23,9 +23,11 @@ import os.path
from os import sep
import platform
import re
import Logger.Log as Logger
from Logger import StringTable as ST
from Logger.ToolError import UPT_MUL_DEC_ERROR
from Logger.ToolError import FORMAT_INVALID
from Library.Parsing import NormPath
from Library.DataType import ARCH_LIST
@ -36,10 +38,9 @@ from Library.DataType import TAB_DEC_DEFINES_PACKAGE_NAME
from Library.DataType import TAB_DEC_DEFINES_PACKAGE_GUID
from Library.DataType import TAB_DEC_DEFINES_PACKAGE_VERSION
from Library.DataType import TAB_DEC_DEFINES_DEC_SPECIFICATION
from Library.DataType import TAB_DEC_DEFINES_PKG_UNI_FILE
from Library.DataType import TAB_ARCH_COMMON
from Library.CommentParsing import ParseHeaderCommentSection
from Library.DataType import TAB_INCLUDES
from Library.CommentParsing import ParseGenericComment
from Library.DataType import TAB_LIBRARY_CLASSES
from Library.DataType import TAB_PCDS
from Library.DataType import TAB_PCDS_FIXED_AT_BUILD_NULL
@ -49,12 +50,33 @@ from Library.DataType import TAB_PCDS_DYNAMIC_EX_NULL
from Library.DataType import TAB_PCDS_DYNAMIC_NULL
from Library.DataType import TAB_PTR_TYPE_PCD
from Library.DataType import ITEM_UNDEFINED
from Library.DataType import TAB_DEC_BINARY_ABSTRACT
from Library.DataType import TAB_DEC_BINARY_DESCRIPTION
from Library.DataType import TAB_LANGUAGE_EN_US
from Library.DataType import TAB_BINARY_HEADER_IDENTIFIER
from Library.DataType import TAB_BINARY_HEADER_USERID
from Library.DataType import TAB_LANGUAGE_EN_X
from Library.DataType import TAB_LANGUAGE_EN
from Library.DataType import TAB_STR_TOKENCNAME
from Library.DataType import TAB_STR_TOKENPROMPT
from Library.DataType import TAB_STR_TOKENHELP
from Library.DataType import TAB_STR_TOKENERR
from Library.DataType import TAB_HEX_START
from Library.DataType import TAB_SPLIT
from Library.CommentParsing import ParseHeaderCommentSection
from Library.CommentParsing import ParseGenericComment
from Library.CommentParsing import ParseDecPcdGenericComment
from Library.CommentParsing import ParseDecPcdTailComment
from Library.Misc import GetFiles
from Library.Misc import Sdict
from Library.Misc import GetRelativePath
from Library.Misc import PathClass
from Library.Misc import ValidateUNIFilePath
from Library.UniClassObject import UniFileClassObject
from Library.UniClassObject import ConvertSpecialUnicodes
from Library.UniClassObject import GetLanguageCode1766
from Library.ParserValidate import IsValidPath
from Parser.DecParser import Dec
from Object.POM.PackageObject import PackageObject
from Object.POM.CommonObject import UserExtensionObject
from Object.POM.CommonObject import IncludeObject
@ -64,6 +86,8 @@ from Object.POM.CommonObject import PpiObject
from Object.POM.CommonObject import LibraryClassObject
from Object.POM.CommonObject import PcdObject
from Object.POM.CommonObject import TextObject
from Object.POM.CommonObject import MiscFileObject
from Object.POM.CommonObject import FileObject
## DecPomAlignment
@ -78,6 +102,8 @@ class DecPomAlignment(PackageObject):
self.SupArchList = ARCH_LIST
self.CheckMulDec = CheckMulDec
self.DecParser = None
self.UniFileClassObject = None
self.PcdDefaultValueDict = {}
#
# Load Dec file
@ -104,8 +130,8 @@ class DecPomAlignment(PackageObject):
self.SetFullPath(Filename)
self.SetRelaPath(Path)
self.SetFileName(Name)
self.SetPackagePath(Path[Path.upper().find(self.WorkspaceDir.upper()) + len(self.WorkspaceDir) + 1:])
self.SetCombinePath(Filename[Filename.upper().find(self.WorkspaceDir.upper()) + len(self.WorkspaceDir) + 1:])
self.SetPackagePath(GetRelativePath(Path, self.WorkspaceDir))
self.SetCombinePath(GetRelativePath(Filename, self.WorkspaceDir))
self.DecParser = Dec(Filename)
@ -164,8 +190,8 @@ class DecPomAlignment(PackageObject):
# Generate user extensions
#
self.GenUserExtensions()
## Generate user extention
## Generate user extension
#
#
def GenUserExtensions(self):
@ -182,6 +208,11 @@ class DecPomAlignment(PackageObject):
Identifier = Item.IdString
if Identifier.startswith('"') and Identifier.endswith('"'):
Identifier = Identifier[1:-1]
#
# Generate miscellaneous files of DEC file
#
if UserId == 'TianoCore' and Identifier == 'ExtraFiles':
self.GenMiscFiles(Item.UserString)
UserExtension.SetIdentifier(Identifier)
UserExtension.SetStatement(Item.UserString)
UserExtension.SetSupArchList(
@ -190,7 +221,31 @@ class DecPomAlignment(PackageObject):
self.SetUserExtensionList(
self.GetUserExtensionList() + [UserExtension]
)
## Generate miscellaneous files on DEC file
#
#
def GenMiscFiles(self, Content):
MiscFileObj = MiscFileObject()
for Line in Content.splitlines():
FileName = ''
if '#' in Line:
FileName = Line[:Line.find('#')]
else:
FileName = Line
if FileName:
if IsValidPath(FileName, self.GetRelaPath()):
FileObj = FileObject()
FileObj.SetURI(FileName)
MiscFileObj.SetFileList(MiscFileObj.GetFileList()+[FileObj])
else:
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Line),
File=self.GetFileName(),
ExtraData=Line)
self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj])
## Generate Package Header
#
# Gen Package Header of Dec as <Key> = <Value>
@ -210,7 +265,8 @@ class DecPomAlignment(PackageObject):
# put items into Dict except for PackageName, Guid, Version, DEC_SPECIFICATION
#
SkipItemList = [TAB_DEC_DEFINES_PACKAGE_NAME, \
TAB_DEC_DEFINES_PACKAGE_GUID, TAB_DEC_DEFINES_PACKAGE_VERSION, TAB_DEC_DEFINES_DEC_SPECIFICATION]
TAB_DEC_DEFINES_PACKAGE_GUID, TAB_DEC_DEFINES_PACKAGE_VERSION, \
TAB_DEC_DEFINES_DEC_SPECIFICATION, TAB_DEC_DEFINES_PKG_UNI_FILE]
if Item.Key in SkipItemList:
continue
DefinesDict['%s = %s' % (Item.Key, Item.Value)] = TAB_ARCH_COMMON
@ -221,6 +277,12 @@ class DecPomAlignment(PackageObject):
# DefObj.GetPackageVersion())
self.SetName(os.path.splitext(self.GetFileName())[0])
self.SetGuid(DefObj.GetPackageGuid())
if DefObj.GetPackageUniFile():
ValidateUNIFilePath(DefObj.GetPackageUniFile())
self.UniFileClassObject = \
UniFileClassObject([PathClass(os.path.join(DefObj.GetPackagePath(), DefObj.GetPackageUniFile()))])
else:
self.UniFileClassObject = None
if DefinesDict:
UserExtension = UserExtensionObject()
@ -232,16 +294,80 @@ class DecPomAlignment(PackageObject):
)
#
# Get All header comment section information
# Get File header information
#
if self.UniFileClassObject:
Lang = TAB_LANGUAGE_EN_X
else:
Lang = TAB_LANGUAGE_EN_US
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(self.DecParser.GetHeadComment(),
ContainerFile)
self.SetAbstract(Abstract)
self.SetDescription(Description)
self.SetCopyright(Copyright)
self.SetLicense(License)
if Abstract:
self.SetAbstract((Lang, Abstract))
if Description:
self.SetDescription((Lang, Description))
if Copyright:
self.SetCopyright(('', Copyright))
if License:
self.SetLicense(('', License))
#
# Get Binary header information
#
if self.DecParser.BinaryHeadComment:
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(self.DecParser.BinaryHeadComment,
ContainerFile, True)
if not Abstract or not Description or not Copyright or not License:
Logger.Error('MkPkg',
FORMAT_INVALID,
ST.ERR_INVALID_BINARYHEADER_FORMAT,
ContainerFile)
else:
self.SetBinaryHeaderAbstract((Lang, Abstract))
self.SetBinaryHeaderDescription((Lang, Description))
self.SetBinaryHeaderCopyright(('', Copyright))
self.SetBinaryHeaderLicense(('', License))
BinaryAbstractList = []
BinaryDescriptionList = []
#Get Binary header from UNI file
# Initialize the UniStrDict dictionary, top keys are language codes
UniStrDict = {}
if self.UniFileClassObject:
UniStrDict = self.UniFileClassObject.OrderedStringList
for Lang in UniStrDict:
for StringDefClassObject in UniStrDict[Lang]:
Lang = GetLanguageCode1766(Lang)
if StringDefClassObject.StringName == TAB_DEC_BINARY_ABSTRACT:
if (Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue)) \
not in self.GetBinaryHeaderAbstract():
BinaryAbstractList.append((Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
if StringDefClassObject.StringName == TAB_DEC_BINARY_DESCRIPTION:
if (Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue)) \
not in self.GetBinaryHeaderDescription():
BinaryDescriptionList.append((Lang,
ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
#Combine Binary header from DEC file and UNI file
BinaryAbstractList = self.GetBinaryHeaderAbstract() + BinaryAbstractList
BinaryDescriptionList = self.GetBinaryHeaderDescription() + BinaryDescriptionList
BinaryCopyrightList = self.GetBinaryHeaderCopyright()
BinaryLicenseList = self.GetBinaryHeaderLicense()
#Generate the UserExtensionObject for TianoCore."BinaryHeader"
if BinaryAbstractList or BinaryDescriptionList or BinaryCopyrightList or BinaryLicenseList:
BinaryUserExtension = UserExtensionObject()
BinaryUserExtension.SetBinaryAbstract(BinaryAbstractList)
BinaryUserExtension.SetBinaryDescription(BinaryDescriptionList)
BinaryUserExtension.SetBinaryCopyright(BinaryCopyrightList)
BinaryUserExtension.SetBinaryLicense(BinaryLicenseList)
BinaryUserExtension.SetIdentifier(TAB_BINARY_HEADER_IDENTIFIER)
BinaryUserExtension.SetUserID(TAB_BINARY_HEADER_USERID)
self.SetUserExtensionList(self.GetUserExtensionList() + [BinaryUserExtension])
## GenIncludes
#
# Gen Includes of Dec
@ -257,7 +383,7 @@ class DecPomAlignment(PackageObject):
IncObj = self.DecParser.GetIncludeSectionObject()
for Item in IncObj.GetAllIncludes():
IncludePath = os.path.normpath(Item.File)
if platform.system() != 'Windows':
if platform.system() != 'Windows' and platform.system() != 'Microsoft':
IncludePath = IncludePath.replace('\\', '/')
if IncludePath in IncludesDict:
if Item.GetArchList() == [TAB_ARCH_COMMON] or IncludesDict[IncludePath] == [TAB_ARCH_COMMON]:
@ -401,6 +527,8 @@ class DecPomAlignment(PackageObject):
ListObject.SetGuid(Value)
ListObject.SetSupArchList(Item.GetArchList())
if HelpTxt:
if self.UniFileClassObject:
HelpTxt.SetLang(TAB_LANGUAGE_EN_X)
ListObject.SetHelpTextList([HelpTxt])
DeclarationsList.append(ListObject)
@ -437,6 +565,8 @@ class DecPomAlignment(PackageObject):
HelpTxt = ParseGenericComment(Item.GetHeadComment() + \
Item.GetTailComment(), None, '@libraryclass')
if HelpTxt:
if self.UniFileClassObject:
HelpTxt.SetLang(TAB_LANGUAGE_EN_X)
LibraryClass.SetHelpTextList([HelpTxt])
LibraryClassDeclarations.append(LibraryClass)
@ -452,7 +582,6 @@ class DecPomAlignment(PackageObject):
#
def GenPcds(self, ContainerFile):
Logger.Debug(2, "Generate %s ..." % TAB_PCDS)
PcdObj = self.DecParser.GetPcdSectionObject()
#
# Get all Pcds
@ -464,6 +593,37 @@ class DecPomAlignment(PackageObject):
(TAB_PCDS_FEATURE_FLAG_NULL, 'FeaturePcd'),
(TAB_PCDS_DYNAMIC_EX_NULL, 'PcdEx'),
(TAB_PCDS_DYNAMIC_NULL, 'Pcd')]
PromptStrList = []
HelpStrList = []
PcdErrStrList = []
# Initialize UniStrDict dictionary, top keys are language codes
UniStrDict = {}
StrList = []
Language = ''
if self.UniFileClassObject:
Language = TAB_LANGUAGE_EN_X
else:
Language = TAB_LANGUAGE_EN_US
if self.UniFileClassObject:
UniStrDict = self.UniFileClassObject.OrderedStringList
for Lang in UniStrDict:
for StringDefClassObject in UniStrDict[Lang]:
StrList = StringDefClassObject.StringName.split('_')
# StringName format is STR_<TOKENSPACECNAME>_<PCDCNAME>_PROMPT
if len(StrList) == 4 and StrList[0] == TAB_STR_TOKENCNAME and StrList[3] == TAB_STR_TOKENPROMPT:
PromptStrList.append((GetLanguageCode1766(Lang), StringDefClassObject.StringName, \
StringDefClassObject.StringValue))
# StringName format is STR_<TOKENSPACECNAME>_<PCDCNAME>_HELP
if len(StrList) == 4 and StrList[0] == TAB_STR_TOKENCNAME and StrList[3] == TAB_STR_TOKENHELP:
HelpStrList.append((GetLanguageCode1766(Lang), StringDefClassObject.StringName, \
StringDefClassObject.StringValue))
# StringName format is STR_<TOKENSPACECNAME>_ERR_##
if len(StrList) == 4 and StrList[0] == TAB_STR_TOKENCNAME and StrList[2] == TAB_STR_TOKENERR:
PcdErrStrList.append((GetLanguageCode1766(Lang), StringDefClassObject.StringName, \
StringDefClassObject.StringValue))
#
# For each PCD type
#
@ -478,15 +638,234 @@ class DecPomAlignment(PackageObject):
ContainerFile,
(Item.TokenSpaceGuidCName, Item.TokenCName,
Item.DefaultValue, Item.DatumType, Item.TokenValue,
Type, Item.GetHeadComment(), Item.GetTailComment(),
'')
)
Type, Item.GetHeadComment(), Item.GetTailComment(),''),
Language,
self.DecParser.GetDefineSectionMacro()
)
PcdDeclaration.SetSupArchList(Item.GetArchListOfType(PcdType))
PcdDeclarations.append(PcdDeclaration)
self.SetPcdList(self.GetPcdList() + PcdDeclarations)
#
# Get PCD error message from PCD error comment section in DEC file
#
for PcdErr in PcdDeclaration.GetPcdErrorsList():
if (PcdDeclaration.GetTokenSpaceGuidCName(), PcdErr.GetErrorNumber()) \
in self.DecParser.PcdErrorCommentDict:
Key = (PcdDeclaration.GetTokenSpaceGuidCName(), PcdErr.GetErrorNumber())
PcdErr.SetErrorMessageList(PcdErr.GetErrorMessageList() + \
[(Language, self.DecParser.PcdErrorCommentDict[Key])])
for Index in range(0, len(PromptStrList)):
StrNameList = PromptStrList[Index][1].split('_')
if StrNameList[1].lower() == Item.TokenSpaceGuidCName.lower() and \
StrNameList[2].lower() == Item.TokenCName.lower():
TxtObj = TextObject()
TxtObj.SetLang(PromptStrList[Index][0])
TxtObj.SetString(PromptStrList[Index][2])
for Prompt in PcdDeclaration.GetPromptList():
if Prompt.GetLang() == TxtObj.GetLang() and \
Prompt.GetString() == TxtObj.GetString():
break
else:
PcdDeclaration.SetPromptList(PcdDeclaration.GetPromptList() + [TxtObj])
for Index in range(0, len(HelpStrList)):
StrNameList = HelpStrList[Index][1].split('_')
if StrNameList[1].lower() == Item.TokenSpaceGuidCName.lower() and \
StrNameList[2].lower() == Item.TokenCName.lower():
TxtObj = TextObject()
TxtObj.SetLang(HelpStrList[Index][0])
TxtObj.SetString(HelpStrList[Index][2])
for HelpStrObj in PcdDeclaration.GetHelpTextList():
if HelpStrObj.GetLang() == TxtObj.GetLang() and \
HelpStrObj.GetString() == TxtObj.GetString():
break
else:
PcdDeclaration.SetHelpTextList(PcdDeclaration.GetHelpTextList() + [TxtObj])
#
# Get PCD error message from UNI file
#
for Index in range(0, len(PcdErrStrList)):
StrNameList = PcdErrStrList[Index][1].split('_')
if StrNameList[1].lower() == Item.TokenSpaceGuidCName.lower() and \
StrNameList[2].lower() == TAB_STR_TOKENERR.lower():
for PcdErr in PcdDeclaration.GetPcdErrorsList():
if PcdErr.GetErrorNumber().lower() == (TAB_HEX_START + StrNameList[3]).lower() and \
(PcdErrStrList[Index][0], PcdErrStrList[Index][2]) not in PcdErr.GetErrorMessageList():
PcdErr.SetErrorMessageList(PcdErr.GetErrorMessageList() + \
[(PcdErrStrList[Index][0], PcdErrStrList[Index][2])])
#
# Check to prevent missing error message if a Pcd has the error code.
#
for PcdErr in PcdDeclaration.GetPcdErrorsList():
if PcdErr.GetErrorNumber().strip():
if not PcdErr.GetErrorMessageList():
Logger.Error('UPT',
FORMAT_INVALID,
ST.ERR_DECPARSE_PCD_UNMATCHED_ERRORCODE % PcdErr.GetErrorNumber(),
ContainerFile,
PcdErr.GetLineNum(),
PcdErr.GetFileLine())
PcdDeclarations.append(PcdDeclaration)
self.SetPcdList(self.GetPcdList() + PcdDeclarations)
self.CheckPcdValue()
##
# Get error message via language
# @param ErrorMessageList: Error message tuple list the language and its message
# @param Lang: the language of setting
# @return: the error message described in the related UNI file
def GetEnErrorMessage(self, ErrorMessageList):
if self.FullPath:
pass
Lang = TAB_LANGUAGE_EN_US
for (Language, Message) in ErrorMessageList:
if Language == Lang:
return Message
for (Language, Message) in ErrorMessageList:
if Language.find(TAB_LANGUAGE_EN) >= 0:
return Message
else:
try:
return ErrorMessageList[0][1]
except IndexError:
return ''
return ''
##
# Replace the strings for Python eval function.
# @param ReplaceValue: The string that needs to be replaced.
# @return: The string was replaced, then eval function is always making out it.
def ReplaceForEval(self, ReplaceValue, IsRange=False, IsExpr=False):
if self.FullPath:
pass
#
# deal with "NOT EQ", "NOT LT", "NOT GT", "NOT LE", "NOT GE", "NOT NOT"
#
NOTNOT_Pattern = '[\t\s]*NOT[\t\s]+NOT[\t\s]*'
NOTGE_Pattern = '[\t\s]*NOT[\t\s]+GE[\t\s]*'
NOTLE_Pattern = '[\t\s]*NOT[\t\s]+LE[\t\s]*'
NOTGT_Pattern = '[\t\s]*NOT[\t\s]+GT[\t\s]*'
NOTLT_Pattern = '[\t\s]*NOT[\t\s]+LT[\t\s]*'
NOTEQ_Pattern = '[\t\s]*NOT[\t\s]+EQ[\t\s]*'
ReplaceValue = re.compile(NOTNOT_Pattern).sub('', ReplaceValue)
ReplaceValue = re.compile(NOTLT_Pattern).sub('x >= ', ReplaceValue)
ReplaceValue = re.compile(NOTGT_Pattern).sub('x <= ', ReplaceValue)
ReplaceValue = re.compile(NOTLE_Pattern).sub('x > ', ReplaceValue)
ReplaceValue = re.compile(NOTGE_Pattern).sub('x < ', ReplaceValue)
ReplaceValue = re.compile(NOTEQ_Pattern).sub('x != ', ReplaceValue)
if IsRange:
ReplaceValue = ReplaceValue.replace('EQ', 'x ==')
ReplaceValue = ReplaceValue.replace('LT', 'x <')
ReplaceValue = ReplaceValue.replace('LE', 'x <=')
ReplaceValue = ReplaceValue.replace('GT', 'x >')
ReplaceValue = ReplaceValue.replace('GE', 'x >=')
ReplaceValue = ReplaceValue.replace('XOR', 'x ^')
elif IsExpr:
ReplaceValue = ReplaceValue.replace('EQ', '==')
ReplaceValue = ReplaceValue.replace('NE', '!=')
ReplaceValue = ReplaceValue.replace('LT', '<')
ReplaceValue = ReplaceValue.replace('LE', '<=')
ReplaceValue = ReplaceValue.replace('GT', '>')
ReplaceValue = ReplaceValue.replace('GE', '>=')
ReplaceValue = ReplaceValue.replace('XOR', '^')
ReplaceValue = ReplaceValue.replace('AND', 'and')
ReplaceValue = ReplaceValue.replace('&&', ' and ')
ReplaceValue = ReplaceValue.replace('xor', '^')
ReplaceValue = ReplaceValue.replace('OR', 'or')
ReplaceValue = ReplaceValue.replace('||', ' or ')
ReplaceValue = ReplaceValue.replace('NOT', 'not')
if ReplaceValue.find('!') >= 0 and ReplaceValue[ReplaceValue.index('!') + 1] != '=':
ReplaceValue = ReplaceValue.replace('!', ' not ')
if '.' in ReplaceValue:
Pattern = '[a-zA-Z0-9]{1,}\.[a-zA-Z0-9]{1,}'
MatchedList = re.findall(Pattern, ReplaceValue)
for MatchedItem in MatchedList:
if MatchedItem not in self.PcdDefaultValueDict:
Logger.Error("Dec File Parser", FORMAT_INVALID, Message=ST.ERR_DECPARSE_PCD_NODEFINED % MatchedItem,
File=self.FullPath)
ReplaceValue = ReplaceValue.replace(MatchedItem, self.PcdDefaultValueDict[MatchedItem])
return ReplaceValue
##
# Check pcd's default value according to the pcd's description
#
def CheckPcdValue(self):
for Pcd in self.GetPcdList():
self.PcdDefaultValueDict[TAB_SPLIT.join((Pcd.GetTokenSpaceGuidCName(), Pcd.GetCName())).strip()] = \
Pcd.GetDefaultValue()
for Pcd in self.GetPcdList():
ValidationExpressions = []
PcdGuidName = TAB_SPLIT.join((Pcd.GetTokenSpaceGuidCName(), Pcd.GetCName()))
Valids = Pcd.GetPcdErrorsList()
for Valid in Valids:
Expression = Valid.GetExpression()
if Expression:
#
# Delete the 'L' prefix of a quoted string, this operation is for eval()
#
QUOTED_PATTERN = '[\t\s]*L?"[^"]*"'
QuotedMatchedObj = re.search(QUOTED_PATTERN, Expression)
if QuotedMatchedObj:
MatchedStr = QuotedMatchedObj.group().strip()
if MatchedStr.startswith('L'):
Expression = Expression.replace(MatchedStr, MatchedStr[1:].strip())
Expression = self.ReplaceForEval(Expression, IsExpr=True)
Expression = Expression.replace(PcdGuidName, 'x')
Message = self.GetEnErrorMessage(Valid.GetErrorMessageList())
ValidationExpressions.append((Expression, Message))
ValidList = Valid.GetValidValue()
if ValidList:
ValidValue = 'x in %s' % [eval(v) for v in ValidList.split(' ') if v]
Message = self.GetEnErrorMessage(Valid.GetErrorMessageList())
ValidationExpressions.append((ValidValue, Message))
ValidValueRange = Valid.GetValidValueRange()
if ValidValueRange:
ValidValueRange = self.ReplaceForEval(ValidValueRange, IsRange=True)
if ValidValueRange.find('-') >= 0:
ValidValueRange = ValidValueRange.replace('-', '<= x <=')
elif not ValidValueRange.startswith('x ') and not ValidValueRange.startswith('not ') \
and not ValidValueRange.startswith('not(') and not ValidValueRange.startswith('('):
ValidValueRange = 'x %s' % ValidValueRange
Message = self.GetEnErrorMessage(Valid.GetErrorMessageList())
ValidationExpressions.append((ValidValueRange, Message))
DefaultValue = self.PcdDefaultValueDict[PcdGuidName.strip()]
#
# Delete the 'L' prefix of a quoted string, this operation is for eval()
#
QUOTED_PATTERN = '[\t\s]*L?"[^"]*"'
QuotedMatchedObj = re.search(QUOTED_PATTERN, DefaultValue)
if QuotedMatchedObj:
MatchedStr = QuotedMatchedObj.group().strip()
if MatchedStr.startswith('L'):
DefaultValue = DefaultValue.replace(MatchedStr, MatchedStr[1:].strip())
try:
DefaultValue = eval(DefaultValue.replace('TRUE', 'True').replace('true', 'True')
.replace('FALSE', 'False').replace('false', 'False'))
except BaseException:
pass
for (Expression, Msg) in ValidationExpressions:
try:
if not eval(Expression, {'x':DefaultValue}):
Logger.Error("Dec File Parser", FORMAT_INVALID, ExtraData='%s, value = %s' %\
(PcdGuidName, DefaultValue), Message=Msg, File=self.FullPath)
except TypeError:
Logger.Error("Dec File Parser", FORMAT_INVALID, ExtraData=PcdGuidName, \
Message=Msg, File=self.FullPath)
## GenModuleFileList
#
def GenModuleFileList(self, ContainerFile):
@ -562,9 +941,11 @@ class DecPomAlignment(PackageObject):
# @param PcdInfo: Pcd information, of format (TokenGuidCName,
# TokenName, Value, DatumType, Token, Type,
# GenericComment, TailComment, Arch)
# @param Language: The language of HelpText, Prompt
#
def GenPcdDeclaration(ContainerFile, PcdInfo):
def GenPcdDeclaration(ContainerFile, PcdInfo, Language, MacroReplaceDict):
HelpStr = ''
PromptStr = ''
TailHelpStr = ''
TokenGuidCName, TokenName, Value, DatumType, Token, Type, \
GenericComment, TailComment, Arch = PcdInfo
@ -585,10 +966,13 @@ def GenPcdDeclaration(ContainerFile, PcdInfo):
Pcd.SetSupArchList(SupArchList)
if GenericComment:
HelpStr, PcdErr = ParseDecPcdGenericComment(GenericComment,
ContainerFile)
if PcdErr:
Pcd.SetPcdErrorsList([PcdErr])
HelpStr, PcdErrList, PromptStr = ParseDecPcdGenericComment(GenericComment,
ContainerFile,
TokenGuidCName,
TokenName,
MacroReplaceDict)
if PcdErrList:
Pcd.SetPcdErrorsList(PcdErrList)
if TailComment:
SupModuleList, TailHelpStr = ParseDecPcdTailComment(TailComment,
@ -600,8 +984,14 @@ def GenPcdDeclaration(ContainerFile, PcdInfo):
HelpStr += '\n'
HelpStr += TailHelpStr
if HelpStr:
HelpTxtObj = TextObject()
HelpTxtObj = TextObject()
HelpTxtObj.SetLang(Language)
HelpTxtObj.SetString(HelpStr)
Pcd.SetHelpTextList([HelpTxtObj])
if PromptStr:
TxtObj = TextObject()
TxtObj.SetLang(Language)
TxtObj.SetString(PromptStr)
Pcd.SetPromptList([TxtObj])
return Pcd

View File

@ -1,7 +1,7 @@
## @file InfPomAlignment.py
# This file contained the adapter for convert INF parser object to POM Object
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@ -18,10 +18,8 @@ InfPomAlignment
# Import modules
#
import os.path
from Logger import StringTable as ST
import Logger.Log as Logger
from Library.String import FORMAT_INVALID
from Library.String import PARSER_ERROR
from Library.String import NormPath
@ -29,10 +27,15 @@ from Library.String import GetSplitValueList
from Library.Misc import ConvertVersionToDecimal
from Library.Misc import GetHelpStringByRemoveHashKey
from Library.Misc import ConvertArchList
from Library.Misc import GetRelativePath
from Library.Misc import PathClass
from Library.Parsing import GetPkgInfoFromDec
from Library.UniClassObject import UniFileClassObject
from Library.UniClassObject import ConvertSpecialUnicodes
from Library.UniClassObject import GetLanguageCode1766
from Library import DataType as DT
from Library import GlobalData
from Library.ParserValidate import IsValidPath
from Object.POM import CommonObject
from Object.POM.ModuleObject import ModuleObject
from Object.POM.ModuleObject import ExternObject
@ -47,7 +50,7 @@ from Object.POM.ModuleObject import AsBuiltObject
from PomAdapter.InfPomAlignmentMisc import GenModuleHeaderUserExt
from PomAdapter.InfPomAlignmentMisc import GenBinaryData
from Parser import InfParser
from PomAdapter.DecPomAlignment import DecPomAlignment
## InfPomAlignment
@ -62,7 +65,6 @@ class InfPomAlignment(ModuleObject):
#
def __init__(self, FileName, WorkSpace=None, PackagePath='', Skip=False):
ModuleObject.__init__(self)
self.Parser = None
self.FileName = FileName
self.WorkSpace = WorkSpace
@ -72,7 +74,7 @@ class InfPomAlignment(ModuleObject):
self.ModulePath = ''
self.WorkspaceDir = " "
self.CustomMakefile = []
self.UniFileClassObject = None
self.SetPackagePath(PackagePath)
#
# Call GenInfPomObjects function to fill POM object.
@ -80,8 +82,10 @@ class InfPomAlignment(ModuleObject):
if Skip:
OrigConfig = Logger.SUPRESS_ERROR
Logger.SUPRESS_ERROR = True
self._GenInfPomObjects(Skip)
Logger.SUPRESS_ERROR = OrigConfig
try:
self._GenInfPomObjects(Skip)
finally:
Logger.SUPRESS_ERROR = OrigConfig
else:
self._GenInfPomObjects(Skip)
@ -111,7 +115,6 @@ class InfPomAlignment(ModuleObject):
self._GenGuidProtocolPpis(DT.TAB_PROTOCOLS)
self._GenGuidProtocolPpis(DT.TAB_PPIS)
self._GenDepexes()
self._GenMiscFiles(self.FullPath, Skip)
## Convert [Defines] section content to InfDefObject
#
@ -134,7 +137,6 @@ class InfPomAlignment(ModuleObject):
ArchList = GetSplitValueList(ArchString, ' ')
ArchList = ConvertArchList(ArchList)
HasCalledFlag = False
#
# Get data from Sdict()
#
@ -147,26 +149,21 @@ class InfPomAlignment(ModuleObject):
# ModuleSurfaceArea.Header.Name element
#
self.SetName(os.path.splitext(os.path.basename(self.FileName))[0])
self.WorkspaceDir = " "
#
# CombinePath and ModulePath
#
PathCount = self.FullPath.upper().find(self.WorkSpace.upper()) + len(self.WorkSpace) + 1
CombinePath = self.FullPath[PathCount:]
CombinePath = GetRelativePath(self.FullPath, self.WorkSpace)
self.SetCombinePath(CombinePath)
ModulePath = os.path.split(CombinePath)[0]
ModuleRelativePath = ModulePath
if self.GetPackagePath() != '':
ModuleRelativePath = ModulePath[ModulePath.find(self.GetPackagePath()) + len(self.GetPackagePath()) + 1:]
ModuleRelativePath = GetRelativePath(ModulePath, self.GetPackagePath())
self.SetModulePath(ModuleRelativePath)
#
# For Define Seciton Items.
#
DefineObj = ValueList
#
# Convert UEFI/PI version to decimal number
#
@ -179,7 +176,6 @@ class InfPomAlignment(ModuleObject):
__PiVersion = ConvertVersionToDecimal(__PiVersion)
self.SetPiSpecificationVersion(str(__PiVersion))
SpecList = DefineObj.GetSpecification()
NewSpecList = []
for SpecItem in SpecList:
@ -214,6 +210,10 @@ class InfPomAlignment(ModuleObject):
ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("BASE_NAME"), File=self.FullPath)
else:
self.SetBaseName(DefineObj.GetBaseName().GetValue())
if DefineObj.GetModuleUniFileName():
self.UniFileClassObject = UniFileClassObject([PathClass(DefineObj.GetModuleUniFileName())])
else:
self.UniFileClassObject = None
if DefineObj.GetInfVersion() == None:
Logger.Error("InfParser", FORMAT_INVALID,
ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("INF_VERSION"), File=self.FullPath)
@ -247,7 +247,6 @@ class InfPomAlignment(ModuleObject):
#
Logger.Error("Parser", PARSER_ERROR, ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF, ExtraData=self.FullPath,
RaiseError=Logger.IS_RAISE_ERROR)
#
# if there is Shadow, Should judge the MODULE_TYPE in
# SEC, PEI_CORE and PEIM
@ -259,12 +258,10 @@ class InfPomAlignment(ModuleObject):
if DefineObj.GetPcdIsDriver() != None:
self.SetPcdIsDriver(DefineObj.GetPcdIsDriver().GetValue())
#
# LIBRARY_CLASS
#
self._GenModuleHeaderLibClass(DefineObj, ArchList)
#
# CUSTOM_MAKEFILE
#
@ -276,7 +273,6 @@ class InfPomAlignment(ModuleObject):
if not HasCalledFlag:
self._GenModuleHeaderExterns(DefineObj)
HasCalledFlag = True
#
# each module has only one module header
#
@ -289,28 +285,45 @@ class InfPomAlignment(ModuleObject):
# put all define statement into user-extension sections
#
DefinesDictNew = GenModuleHeaderUserExt(DefineObj, ArchString)
if DefinesDictNew:
UserExtension = CommonObject.UserExtensionObject()
UserExtension.SetDefinesDict(DefinesDictNew)
UserExtension.SetIdentifier('DefineModifiers')
UserExtension.SetUserID('EDK2')
self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension])
#
# Get all meta-file header information
# the record is list of items formated:
# [LineValue, Arch, StartLine, ID, Third]
#
InfHeaderObj = self.Parser.InfHeader
#
# Put header information into POM object
#
self.SetAbstract(InfHeaderObj.GetAbstract())
self.SetDescription(InfHeaderObj.GetDescription())
self.SetCopyright(InfHeaderObj.GetCopyright())
self.SetLicense(InfHeaderObj.GetLicense())
if self.UniFileClassObject:
Lang = DT.TAB_LANGUAGE_EN_X
else:
Lang = DT.TAB_LANGUAGE_EN_US
if InfHeaderObj.GetAbstract():
self.SetAbstract((Lang, InfHeaderObj.GetAbstract()))
if InfHeaderObj.GetDescription():
self.SetDescription((Lang, InfHeaderObj.GetDescription()))
if InfHeaderObj.GetCopyright():
self.SetCopyright(('', InfHeaderObj.GetCopyright()))
if InfHeaderObj.GetLicense():
self.SetLicense(('', InfHeaderObj.GetLicense()))
#
# Put Binary header information into POM object
#
InfBinaryHeaderObj = self.Parser.InfBinaryHeader
if InfBinaryHeaderObj.GetAbstract():
self.SetBinaryHeaderAbstract((Lang, InfBinaryHeaderObj.GetAbstract()))
if InfBinaryHeaderObj.GetDescription():
self.SetBinaryHeaderDescription((Lang, InfBinaryHeaderObj.GetDescription()))
if InfBinaryHeaderObj.GetCopyright():
self.SetBinaryHeaderCopyright(('', InfBinaryHeaderObj.GetCopyright()))
if InfBinaryHeaderObj.GetLicense():
self.SetBinaryHeaderLicense(('', InfBinaryHeaderObj.GetLicense()))
## GenModuleHeaderLibClass
#
@ -390,6 +403,8 @@ class InfPomAlignment(ModuleObject):
Hob.SetSupArchList(Item.GetSupArchList())
if Item.GetHelpString():
HelpTextObj = CommonObject.TextObject()
if self.UniFileClassObject:
HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpTextObj.SetString(Item.GetHelpString())
Hob.SetHelpTextList([HelpTextObj])
HobList.append(Hob)
@ -402,6 +417,8 @@ class InfPomAlignment(ModuleObject):
Event.SetUsage(Item.GetUsage())
if Item.GetHelpString():
HelpTextObj = CommonObject.TextObject()
if self.UniFileClassObject:
HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpTextObj.SetString(Item.GetHelpString())
Event.SetHelpTextList([HelpTextObj])
EventList.append(Event)
@ -414,6 +431,8 @@ class InfPomAlignment(ModuleObject):
BootMode.SetUsage(Item.GetUsage())
if Item.GetHelpString():
HelpTextObj = CommonObject.TextObject()
if self.UniFileClassObject:
HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpTextObj.SetString(Item.GetHelpString())
BootMode.SetHelpTextList([HelpTextObj])
BootModeList.append(BootMode)
@ -433,18 +452,14 @@ class InfPomAlignment(ModuleObject):
BuildOptionsList = self.Parser.InfBuildOptionSection.GetBuildOptions()
if not GlobalData.gIS_BINARY_INF:
BuildOptionDict = {}
for BuildOptionObj in BuildOptionsList:
ArchList = BuildOptionObj.GetSupArchList()
ArchList = ConvertArchList(ArchList)
BuildOptionsContent = BuildOptionObj.GetContent()
ArchString = ' '.join(ArchList)
if not BuildOptionsContent:
continue
BuildOptionDict[ArchString] = BuildOptionsContent
if not BuildOptionDict:
return
UserExtension = CommonObject.UserExtensionObject()
@ -473,7 +488,6 @@ class InfPomAlignment(ModuleObject):
#
LibClassObj = self.Parser.InfLibraryClassSection.LibraryClasses
Keys = LibClassObj.keys()
for Key in Keys:
LibraryClassData = LibClassObj[Key]
for Item in LibraryClassData:
@ -485,14 +499,14 @@ class InfPomAlignment(ModuleObject):
LibraryClass.SetSupArchList(ConvertArchList(Item.GetSupArchList()))
LibraryClass.SetSupModuleList(Item.GetSupModuleList())
HelpStringObj = Item.GetHelpString()
if HelpStringObj != None:
CommentString = GetHelpStringByRemoveHashKey(HelpStringObj.HeaderComments +
HelpStringObj.TailComments)
HelpTextHeaderObj = CommonObject.TextObject()
if self.UniFileClassObject:
HelpTextHeaderObj.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpTextHeaderObj.SetString(CommentString)
LibraryClass.SetHelpTextList([HelpTextHeaderObj])
self.SetLibraryClassList(self.GetLibraryClassList() + [LibraryClass])
## GenPackages
@ -508,7 +522,6 @@ class InfPomAlignment(ModuleObject):
# Get all Packages
#
PackageObj = self.Parser.InfPackageSection.Packages
#
# Go through each arch
#
@ -546,13 +559,11 @@ class InfPomAlignment(ModuleObject):
def _GenPcds(self):
if not GlobalData.gIS_BINARY_INF:
Logger.Debug(2, "Generate %s ..." % DT.TAB_PCDS)
#
# Get all Pcds
#
PcdObj = self.Parser.InfPcdSection.Pcds
KeysList = PcdObj.keys()
#
# Go through each arch
#
@ -571,6 +582,8 @@ class InfPomAlignment(ModuleObject):
Pcd.SetFeatureFlag(PcdItemObj.GetFeatureFlagExp())
Pcd.SetSupArchList(ConvertArchList(PcdItemObj.GetSupportArchList()))
HelpTextObj = CommonObject.TextObject()
if self.UniFileClassObject:
HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpTextObj.SetString(CommentItem.GetHelpStringItem())
Pcd.SetHelpTextList([HelpTextObj])
PcdList = self.GetPcdList()
@ -636,11 +649,47 @@ class InfPomAlignment(ModuleObject):
Identifier = UserExtensionDataObj.GetIdString()
if Identifier.startswith('"') and Identifier.endswith('"'):
Identifier = Identifier[1:-1]
#
# Generate miscellaneous files on INF file
#
if UserId == 'TianoCore' and Identifier == 'ExtraFiles':
self._GenMiscFiles(UserExtensionDataObj.GetContent())
UserExtension.SetIdentifier(Identifier)
UserExtension.SetStatement(UserExtensionDataObj.GetContent())
UserExtension.SetSupArchList(ConvertArchList(UserExtensionDataObj.GetSupArchList()))
self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension])
#
# Gen UserExtensions of TianoCore."BinaryHeader"
#
#Get Binary header from INF file
BinaryAbstractList = self.BinaryHeaderAbstractList
BinaryDescriptionList = self.BinaryHeaderDescriptionList
BinaryCopyrightList = self.BinaryHeaderCopyrightList
BinaryLicenseList = self.BinaryHeaderLicenseList
#Get Binary header from UNI file
# Initialize UniStrDict, the top keys are language codes
UniStrDict = {}
if self.UniFileClassObject:
UniStrDict = self.UniFileClassObject.OrderedStringList
for Lang in UniStrDict:
for StringDefClassObject in UniStrDict[Lang]:
Lang = GetLanguageCode1766(Lang)
if StringDefClassObject.StringName == DT.TAB_INF_BINARY_ABSTRACT:
BinaryAbstractList.append((Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
if StringDefClassObject.StringName == DT.TAB_INF_BINARY_DESCRIPTION:
BinaryDescriptionList.append((Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
if BinaryAbstractList or BinaryDescriptionList or BinaryCopyrightList or BinaryLicenseList:
BinaryUserExtension = CommonObject.UserExtensionObject()
BinaryUserExtension.SetBinaryAbstract(BinaryAbstractList)
BinaryUserExtension.SetBinaryDescription(BinaryDescriptionList)
BinaryUserExtension.SetBinaryCopyright(BinaryCopyrightList)
BinaryUserExtension.SetBinaryLicense(BinaryLicenseList)
BinaryUserExtension.SetIdentifier(DT.TAB_BINARY_HEADER_IDENTIFIER)
BinaryUserExtension.SetUserID(DT.TAB_BINARY_HEADER_USERID)
self.SetUserExtensionList(self.GetUserExtensionList() + [BinaryUserExtension])
def _GenDepexesList(self, SmmDepexList, DxeDepexList, PeiDepexList):
if SmmDepexList:
self.SetSmmDepex(SmmDepexList)
@ -675,10 +724,14 @@ class InfPomAlignment(ModuleObject):
ModuleType = Depex.GetModuleType()
ModuleTypeList = []
if IsLibraryClass:
if not self.GetIsLibraryModList():
if self.GetModuleType() == 'BASE' and not ModuleType:
Logger.Error("\nMkPkg", PARSER_ERROR,
ST.ERR_INF_PARSER_DEPEX_SECTION_INVALID_FOR_BASE_LIBRARY_CLASS,
self.GetFullPath(), RaiseError=True)
if self.GetModuleType() != 'BASE' and not self.GetIsLibraryModList():
Logger.Error("\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_INVALID_FOR_LIBRARY_CLASS,
self.GetFullPath(), RaiseError=True)
if ModuleType and ModuleType not in self.GetIsLibraryModList():
if self.GetModuleType() != 'BASE' and ModuleType and ModuleType not in self.GetIsLibraryModList():
Logger.Error("\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED,
self.GetFullPath(), RaiseError=True)
if ModuleType:
@ -713,6 +766,8 @@ class InfPomAlignment(ModuleObject):
DepexIns.SetFeatureFlag(Depex.GetFeatureFlagExp())
if Depex.HelpString:
HelpIns = CommonObject.TextObject()
if self.UniFileClassObject:
HelpIns.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpIns.SetString(GetHelpStringByRemoveHashKey(Depex.HelpString))
DepexIns.SetHelpText(HelpIns)
@ -771,6 +826,7 @@ class InfPomAlignment(ModuleObject):
AsBuildLibIns = AsBuildLibraryClassObject()
AsBuildLibIns.SetLibGuid(LibItem.GetFileGuid())
AsBuildLibIns.SetLibVersion(LibItem.GetVersion())
AsBuildLibIns.SetSupArchList(LibItem.GetSupArchList())
AsBuildLibraryClassList.append(AsBuildLibIns)
AsBuildIns.SetLibraryInstancesList(AsBuildLibraryClassList)
@ -778,7 +834,7 @@ class InfPomAlignment(ModuleObject):
# BuildOption AsBuild Info
#
for BuildOptionItem in self.Parser.InfBuildOptionSection.GetBuildOptions():
AsBuildBuildOptionList += BuildOptionItem.GetAsBuildList()
AsBuildBuildOptionList.append(BuildOptionItem)
AsBuildIns.SetBuildFlagsList(AsBuildBuildOptionList)
#
@ -786,13 +842,34 @@ class InfPomAlignment(ModuleObject):
#
AsBuildIns = self._GenAsBuiltPcds(self.Parser.InfPcdSection.GetPcds(), AsBuildIns)
#
# Parse the DEC file that contains the GUID value of the GUID CName which is used by
# SUBTYPE_GUID type binary file in the Binaries section in the INF file
#
DecObjList = []
if not self.PackagePath:
WorkSpace = os.path.normpath(self.WorkSpace)
TempPath = ModulePath = os.path.normpath(self.ModulePath)
while ModulePath:
TempPath = ModulePath
ModulePath = os.path.dirname(ModulePath)
PackageName = TempPath
DecFilePath = os.path.normpath(os.path.join(WorkSpace, PackageName))
if DecFilePath:
for File in os.listdir(DecFilePath):
if File.upper().endswith('.DEC'):
DecFileFullPath = os.path.normpath(os.path.join(DecFilePath, File))
DecObjList.append(DecPomAlignment(DecFileFullPath, self.WorkSpace))
BinariesDict, AsBuildIns, BinaryFileObjectList = GenBinaryData(BinaryData, BinaryObj,
BinariesDict,
AsBuildIns,
BinaryFileObjectList,
self.GetSupArchList(),
self.BinaryModule)
self.BinaryModule,
DecObjList)
BinariesDict2 = {}
for Key in BinariesDict:
ValueList = BinariesDict[Key]
@ -855,9 +932,13 @@ class InfPomAlignment(ModuleObject):
Pcd.SetItemType(PcdItem[0])
Pcd.SetFeatureFlag(PcdItemObj.GetFeatureFlagExp())
Pcd.SetSupArchList(ConvertArchList(PcdItemObj.GetSupportArchList()))
HelpTextObj = CommonObject.TextObject()
HelpTextObj.SetString(PcdItemObj.GetHelpStringList())
Pcd.SetHelpTextList([HelpTextObj])
Pcd.SetValidUsage(PcdItemObj.GetValidUsage())
for CommentItem in PcdItemObj.GetHelpStringList():
HelpTextObj = CommonObject.TextObject()
if self.UniFileClassObject:
HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpTextObj.SetString(CommentItem.GetHelpStringItem())
Pcd.SetHelpTextList(Pcd.GetHelpTextList() + [HelpTextObj])
AsBuildPatchPcdList.append(Pcd)
else:
PcdItemObj = PcdItem[1]
@ -870,9 +951,13 @@ class InfPomAlignment(ModuleObject):
Pcd.SetItemType(PcdItem[0])
Pcd.SetFeatureFlag(PcdItemObj.GetFeatureFlagExp())
Pcd.SetSupArchList(ConvertArchList(PcdItemObj.GetSupportArchList()))
HelpTextObj = CommonObject.TextObject()
HelpTextObj.SetString(PcdItemObj.GetHelpStringList())
Pcd.SetHelpTextList([HelpTextObj])
Pcd.SetValidUsage(PcdItemObj.GetValidUsage())
for CommentItem in PcdItemObj.GetHelpStringList():
HelpTextObj = CommonObject.TextObject()
if self.UniFileClassObject:
HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpTextObj.SetString(CommentItem.GetHelpStringItem())
Pcd.SetHelpTextList(Pcd.GetHelpTextList() + [HelpTextObj])
AsBuildPcdExList.append(Pcd)
AsBuildIns.SetPatchPcdList(AsBuildPatchPcdList)
AsBuildIns.SetPcdExList(AsBuildPcdExList)
@ -914,11 +999,13 @@ class InfPomAlignment(ModuleObject):
ListObject.SetSupArchList(ConvertArchList(Item.GetSupArchList()))
ListObject.SetFeatureFlag(Item.GetFeatureFlagExp())
HelpString = GuidComentItem.GetHelpStringItem()
HelpTxtTailObj = CommonObject.TextObject()
HelpTxtTailObj.SetString(HelpString)
ListObject.SetHelpTextList([HelpTxtTailObj])
if HelpString.strip():
HelpTxtTailObj = CommonObject.TextObject()
if self.UniFileClassObject:
HelpTxtTailObj.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpTxtTailObj.SetString(HelpString)
ListObject.SetHelpTextList([HelpTxtTailObj])
GuidProtocolPpiList.append(ListObject)
elif Type == DT.TAB_PROTOCOLS:
ProtocolData = ProtocolObj.keys()
@ -931,10 +1018,13 @@ class InfPomAlignment(ModuleObject):
ListObject.SetFeatureFlag(Item.GetFeatureFlagExp())
ListObject.SetNotify(CommentItem.GetNotify())
ListObject.SetUsage(CommentItem.GetUsageItem())
HelpTxtObj = CommonObject.TextObject()
HelpString = CommentItem.GetHelpStringItem()
HelpTxtObj.SetString(HelpString)
ListObject.SetHelpTextList([HelpTxtObj])
if HelpString.strip():
HelpTxtObj = CommonObject.TextObject()
if self.UniFileClassObject:
HelpTxtObj.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpTxtObj.SetString(HelpString)
ListObject.SetHelpTextList([HelpTxtObj])
GuidProtocolPpiList.append(ListObject)
elif Type == DT.TAB_PPIS:
PpiData = PpisObj.keys()
@ -947,10 +1037,13 @@ class InfPomAlignment(ModuleObject):
ListObject.SetFeatureFlag(Item.GetFeatureFlagExp())
ListObject.SetNotify(CommentItem.GetNotify())
ListObject.SetUsage(CommentItem.GetUsage())
HelpTextObj = CommonObject.TextObject()
HelpString = CommentItem.GetHelpStringItem()
HelpTextObj.SetString(HelpString)
ListObject.SetHelpTextList([HelpTextObj])
if HelpString.strip():
HelpTextObj = CommonObject.TextObject()
if self.UniFileClassObject:
HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpTextObj.SetString(HelpString)
ListObject.SetHelpTextList([HelpTextObj])
GuidProtocolPpiList.append(ListObject)
if Type == DT.TAB_GUIDS:
@ -966,6 +1059,24 @@ class InfPomAlignment(ModuleObject):
#
# @param ContainerFile: The Inf file full path
#
def _GenMiscFiles(self, ContainerFile, Skip):
pass
def _GenMiscFiles(self, Content):
MiscFileObj = CommonObject.MiscFileObject()
for Line in Content.splitlines():
FileName = ''
if '#' in Line:
FileName = Line[:Line.find('#')]
else:
FileName = Line
if FileName:
if IsValidPath(FileName, GlobalData.gINF_MODULE_DIR):
FileObj = CommonObject.FileObject()
FileObj.SetURI(FileName)
MiscFileObj.SetFileList(MiscFileObj.GetFileList()+[FileObj])
else:
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Line),
File=GlobalData.gINF_MODULE_NAME,
ExtraData=Line)
self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj])

View File

@ -1,7 +1,7 @@
## @file InfPomAlignmentMisc.py
# This file contained the routines for InfPomAlignment
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@ -24,6 +24,10 @@ from Library import DataType as DT
from Library.Misc import ConvertArchList
from Object.POM.ModuleObject import BinaryFileObject
from Object.POM import CommonObject
from Library.String import FORMAT_INVALID
from Library.Misc import CheckGuidRegFormat
from Logger import StringTable as ST
## GenModuleHeaderUserExt
#
@ -167,7 +171,8 @@ def _GenInfDefineStateMent(HeaderComment, Name, Value, TailComment):
## GenBinaryData
#
#
def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObjectList, SupArchList, BinaryModule):
def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObjectList, \
SupArchList, BinaryModule, DecObjList=None):
if BinaryModule:
pass
OriSupArchList = SupArchList
@ -179,6 +184,7 @@ def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObj
else:
TagName = ''
Family = ''
FFE = ItemObj.GetFeatureFlagExp()
#
@ -200,6 +206,41 @@ def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObj
FileNameObj.SetFileType(ItemObj.GetType())
FileNameObj.SetFilename(ItemObj.GetFileName())
FileNameObj.SetFeatureFlag(FFE)
#
# Get GUID value of the GUID CName in the DEC file
#
if ItemObj.GetType() == DT.SUBTYPE_GUID_BINARY_FILE_TYPE:
if not CheckGuidRegFormat(ItemObj.GetGuidValue()):
if not DecObjList:
if DT.TAB_HORIZON_LINE_SPLIT in ItemObj.GetGuidValue() or \
DT.TAB_COMMA_SPLIT in ItemObj.GetGuidValue():
Logger.Error("\nMkPkg",
FORMAT_INVALID,
ST.ERR_DECPARSE_DEFINE_PKGGUID,
ExtraData=ItemObj.GetGuidValue(),
RaiseError=True)
else:
Logger.Error("\nMkPkg",
FORMAT_INVALID,
ST.ERR_UNI_SUBGUID_VALUE_DEFINE_DEC_NOT_FOUND % \
(ItemObj.GetGuidValue()),
RaiseError=True)
else:
for DecObj in DecObjList:
for GuidObj in DecObj.GetGuidList():
if GuidObj.GetCName() == ItemObj.GetGuidValue():
FileNameObj.SetGuidValue(GuidObj.GetGuid())
break
if not FileNameObj.GetGuidValue():
Logger.Error("\nMkPkg",
FORMAT_INVALID,
ST.ERR_DECPARSE_CGUID_NOT_FOUND % \
(ItemObj.GetGuidValue()),
RaiseError=True)
else:
FileNameObj.SetGuidValue(ItemObj.GetGuidValue().strip())
FileNameObj.SetSupArchList(SupArchList)
FileNameList = [FileNameObj]