diff options
Diffstat (limited to 'BaseTools/Source/Python/UPT/Object/Parser')
6 files changed, 374 insertions, 256 deletions
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py index 3685fedd5c..f968beee60 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py @@ -2,7 +2,7 @@ # This file is used to define class objects of INF file [Binaries] section.
# It will consumed by InfParser.
#
-# 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
@@ -99,6 +99,7 @@ class InfBianryCommonItem(InfBianryItem, CurrentLine): self.CommonType = ''
self.TagName = ''
self.Family = ''
+ self.GuidValue = ''
InfBianryItem.__init__(self)
CurrentLine.__init__(self)
@@ -116,6 +117,11 @@ class InfBianryCommonItem(InfBianryItem, CurrentLine): self.Family = Family
def GetFamily(self):
return self.Family
+
+ def SetGuidValue(self, GuidValue):
+ self.GuidValue = GuidValue
+ def GetGuidValue(self):
+ return self.GuidValue
##
#
@@ -150,7 +156,7 @@ class InfBinariesObject(InfSectionCommonDef): if len(VerContent) < 2:
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (VerContent[0]),
+ ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (VerContent[0], 2),
File=VerCurrentLine.GetFileName(),
Line=VerCurrentLine.GetLineNo(),
ExtraData=VerCurrentLine.GetLineString())
@@ -291,18 +297,29 @@ class InfBinariesObject(InfSectionCommonDef): CurrentLineOfItem = Item[2]
GlobalData.gINF_CURRENT_LINE = CurrentLineOfItem
InfBianryCommonItemObj = None
- if len(ItemContent) < 2:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (ItemContent[0]),
- File=CurrentLineOfItem.GetFileName(),
- Line=CurrentLineOfItem.GetLineNo(),
- ExtraData=CurrentLineOfItem.GetLineString())
- return False
- if len(ItemContent) > 6:
+ 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], 6),
+ ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (ItemContent[0], 7),
File=CurrentLineOfItem.GetFileName(),
Line=CurrentLineOfItem.GetLineNo(),
ExtraData=CurrentLineOfItem.GetLineString())
@@ -318,7 +335,7 @@ class InfBinariesObject(InfSectionCommonDef): 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,
@@ -342,44 +359,64 @@ class InfBinariesObject(InfSectionCommonDef): 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,
- ItemContent[1])))
- if not (ValidFile(FullFileName) or ValidFile(ItemContent[1])):
+ FileName)))
+ if not (ValidFile(FullFileName) or ValidFile(FileName)):
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (ItemContent[1]),
+ 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(ItemContent[1], GlobalData.gINF_MODULE_DIR):
+ 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 % (ItemContent[1]),
+ 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(ItemContent[1])
+ InfBianryCommonItemObj.SetFileName(FileName)
if len(ItemContent) >= 3:
#
# Add Target information
#
- InfBianryCommonItemObj.SetTarget(ItemContent[2])
+ if BinaryFileType != 'FREEFORM':
+ InfBianryCommonItemObj.SetTarget(ItemContent[2])
+
if len(ItemContent) >= 4:
#
# Add Family information
#
- InfBianryCommonItemObj.SetFamily(ItemContent[3])
+ if BinaryFileType != 'FREEFORM':
+ InfBianryCommonItemObj.SetFamily(ItemContent[3])
+ else:
+ InfBianryCommonItemObj.SetTarget(ItemContent[3])
+
if len(ItemContent) >= 5:
#
# TagName entries are build system specific. If there
@@ -388,28 +425,62 @@ class InfBinariesObject(InfSectionCommonDef): # system specific content cannot be distributed using
# the UDP
#
- 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())
- if len(ItemContent) == 6:
+ 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 ItemContent[5].strip() == '':
+ 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())
+ 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())
+ FeatureFlagRtv = IsValidFeatureFlagExp(ItemContent[6].strip())
if not FeatureFlagRtv[0]:
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
@@ -417,7 +488,7 @@ class InfBinariesObject(InfSectionCommonDef): File=CurrentLineOfItem.GetFileName(),
Line=CurrentLineOfItem.GetLineNo(),
ExtraData=CurrentLineOfItem.GetLineString())
- InfBianryCommonItemObj.SetFeatureFlagExp(ItemContent[5])
+ InfBianryCommonItemObj.SetFeatureFlagExp(ItemContent[6])
InfBianryCommonItemObj.SetSupArchList(__SupArchList)
@@ -489,7 +560,7 @@ class InfBinariesObject(InfSectionCommonDef): if len(UiContent) < 2:
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (UiContent[0]),
+ ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (UiContent[0], 2),
File=UiCurrentLine.GetFileName(),
Line=UiCurrentLine.GetLineNo(),
ExtraData=UiCurrentLine.GetLineString())
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py index 5549525a6c..391669fe64 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py @@ -2,7 +2,7 @@ # This file is used to define class objects of INF file [BuildOptions] section.
# It will consumed by InfParser.
#
-# 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
@@ -84,8 +84,8 @@ class InfBuildOptionsObject(InfSectionCommonDef): if len(BuildOptCont) >= 1:
InfBuildOptionItemObj = InfBuildOptionItem()
InfBuildOptionItemObj.SetAsBuildList(BuildOptCont)
+ InfBuildOptionItemObj.SetSupArchList(ArchList)
self.BuildOptions.append(InfBuildOptionItemObj)
-
return True
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py index c7883e6980..be9a0e196e 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py @@ -2,7 +2,7 @@ # This file is used to define class objects of [Defines] section for INF file.
# It will consumed by InfParser
#
-# 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
@@ -27,6 +27,7 @@ from Library.String 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
@@ -185,6 +186,7 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.BaseName = None
self.FileGuid = None
self.ModuleType = None
+ self.ModuleUniFileName = None
self.InfVersion = None
self.EdkReleaseVersion = None
self.UefiSpecificationVersion = None
@@ -216,8 +218,7 @@ class InfDefSection(InfDefSectionOptionRomInfo): if self.BaseName != None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_BASE_NAME),
LineInfo=self.CurrentLine)
- return False
-
+ return False
if not (BaseName == '' or BaseName == None):
if IsValidWord(BaseName) and not BaseName.startswith("_"):
self.BaseName = InfDefMember()
@@ -301,6 +302,23 @@ class InfDefSection(InfDefSectionOptionRomInfo): def GetModuleType(self):
return self.ModuleType
+ ## SetModuleUniFileName
+ #
+ # @param ModuleUniFileName: ModuleUniFileName
+ #
+ def SetModuleUniFileName(self, ModuleUniFileName, Comments):
+ if Comments:
+ pass
+ if self.ModuleUniFileName != 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
@@ -520,10 +538,8 @@ class InfDefSection(InfDefSectionOptionRomInfo): # 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%\
@@ -542,13 +558,11 @@ class InfDefSection(InfDefSectionOptionRomInfo): if not FeatureFlagRtv[0]:
ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%\
(FeatureFlagRtv[1]),
- LineInfo=self.CurrentLine)
-
+ 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)
@@ -563,10 +577,8 @@ class InfDefSection(InfDefSectionOptionRomInfo): # 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]),
@@ -588,7 +600,6 @@ class InfDefSection(InfDefSectionOptionRomInfo): if len(ValueList) > 2:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(UnloadImages),
LineInfo=self.CurrentLine)
-
InfDefineUnloadImageItemObj.Comments = Comments
self.UnloadImages.append(InfDefineUnloadImageItemObj)
@@ -603,10 +614,8 @@ class InfDefSection(InfDefSectionOptionRomInfo): # 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]),
@@ -638,7 +647,6 @@ class InfDefSection(InfDefSectionOptionRomInfo): if len(ValueList) > 3:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Constructor),
LineInfo=self.CurrentLine)
-
InfDefineConstructorItemObj.Comments = Comments
self.Constructor.append(InfDefineConstructorItemObj)
@@ -653,10 +661,8 @@ class InfDefSection(InfDefSectionOptionRomInfo): # 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]),
@@ -715,8 +721,6 @@ class InfDefSection(InfDefSectionOptionRomInfo): def GetShadow(self):
return self.Shadow
-
-
#
# <Family> ::= {"MSFT"} {"GCC"}
# <CustomMake> ::= [<Family> "|"] <Filename>
@@ -788,8 +792,7 @@ class InfDefSection(InfDefSectionOptionRomInfo): else:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Name),
LineInfo=self.CurrentLine)
- return False
-
+ return False
return True
def GetSpecification(self):
@@ -860,6 +863,7 @@ gFUNCTION_MAPPING_FOR_DEFINE_SECTION = { #
# 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,
@@ -891,7 +895,6 @@ class InfDefMember(): self.Name = Name
self.Value = Value
self.CurrentLine = CurrentLine()
-
def GetName(self):
return self.Name
def SetName(self, Name):
@@ -914,8 +917,7 @@ class InfDefObject(InfSectionCommonDef): #
HasFoundInfVersionFalg = False
LineInfo = ['', -1, '']
- ArchListString = ' '.join(Arch)
-
+ ArchListString = ' '.join(Arch)
#
# Parse Define items.
#
@@ -923,6 +925,15 @@ class InfDefObject(InfSectionCommonDef): 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())
@@ -932,7 +943,6 @@ class InfDefObject(InfSectionCommonDef): RaiseError=True)
if Name == DT.TAB_INF_DEFINES_INF_VERSION:
HasFoundInfVersionFalg = True
-
if not (Name == '' or Name == None):
#
# Process "SPEC" Keyword definition.
@@ -953,8 +963,7 @@ class InfDefObject(InfSectionCommonDef): #
if Name not in gFUNCTION_MAPPING_FOR_DEFINE_SECTION.keys():
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_SECTION_KEYWORD_INVALID%(Name),
- LineInfo=LineInfo)
-
+ LineInfo=LineInfo)
else:
ProcessFunc = gFUNCTION_MAPPING_FOR_DEFINE_SECTION[Name]
if (ProcessFunc != None):
@@ -980,7 +989,6 @@ class InfDefObject(InfSectionCommonDef): if (ProcessFunc != None):
ProcessFunc(DefineList, Value, InfLineCommentObj)
self.Defines[ArchListString] = DefineList
-
#
# After set, check whether INF_VERSION defined.
#
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py index 4f1a3f4e81..23125552e0 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py @@ -2,7 +2,7 @@ # This file is used to define class objects of INF file [Guids] section.
# It will consumed by InfParser.
#
-# 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
@@ -156,7 +156,6 @@ def ParseGuidComment(CommentsList, InfGuidItemObj): #
if CommentItemUsage == CommentItemGuidType == PreUsage == PreGuidType == DT.ITEM_UNDEFINED:
CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
-
PreHelpText = CommentItemHelpText
if BlockFlag == 4:
@@ -164,6 +163,8 @@ def ParseGuidComment(CommentsList, InfGuidItemObj): 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)
@@ -180,7 +181,7 @@ def ParseGuidComment(CommentsList, InfGuidItemObj): CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
CommentItemIns.SetGuidTypeItem(DT.ITEM_UNDEFINED)
if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
- PreHelpText += DT.END_OF_LINE
+ PreHelpText = PreHelpText.strip(DT.END_OF_LINE)
CommentItemIns.SetHelpStringItem(PreHelpText)
CommentInsList.append(CommentItemIns)
#
@@ -190,6 +191,8 @@ def ParseGuidComment(CommentsList, InfGuidItemObj): 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)
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py index a37692ee23..b18c4c381b 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py @@ -2,7 +2,7 @@ # This file is used to define class objects of INF file [LibraryClasses] section.
# It will consumed by InfParser.
#
-# 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
@@ -236,6 +236,7 @@ class InfLibraryClassObject(): #
LibItemObj.SetFileGuid(LibItem[0])
LibItemObj.SetVersion(LibItem[1])
+ LibItemObj.SetSupArchList(__SupArchList)
if self.LibraryClasses.has_key((LibItemObj)):
LibraryList = self.LibraryClasses[LibItemObj]
diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py b/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py index fc5227451a..7b07036f91 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py @@ -2,7 +2,7 @@ # This file is used to define class objects of INF file [Pcds] section.
# It will consumed by InfParser.
#
-# 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
@@ -21,12 +21,12 @@ import re from Logger import StringTable as ST
from Logger import ToolError
import Logger.Log as Logger
-from Library import GlobalData
+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 IsValidPcdType
from Library.ParserValidate import IsValidCVariableName
from Library.ParserValidate import IsValidPcdValue
from Library.ParserValidate import IsValidArch
@@ -45,21 +45,21 @@ def ValidateArch(ArchItem, PcdTypeItem1, LineNo, SupArchDict, SupArchList): #
if (ArchItem == '' or ArchItem == 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",
+ Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
- ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ArchItemNew),
+ ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ArchItemNew),
File=GlobalData.gINF_MODULE_NAME,
- Line=LineNo,
+ Line=LineNo,
ExtraData=ArchItemNew)
- SupArchDict[PcdTypeItem1] = ArchList
+ SupArchDict[PcdTypeItem1] = ArchList
else:
SupArchList.append(ArchItem)
-
+
return SupArchList, SupArchDict
def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj):
@@ -68,47 +68,47 @@ def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj): PreHelpText = ''
BlockFlag = -1
FFEHelpText = ''
- CommentItemHelpText = ''
- Count = 0
+ CommentItemHelpText = ''
+ Count = 0
for CommentItem in CommentList:
Count = Count + 1
- CommentItemUsage, CommentType, CommentString, CommentItemHelpText = ParseComment(CommentItem,
- DT.ALL_USAGE_TOKENS,
- {},
+ CommentItemUsage, CommentType, CommentString, CommentItemHelpText = ParseComment(CommentItem,
+ DT.ALL_USAGE_TOKENS,
+ {},
[],
False)
if CommentType and CommentString:
- pass
-
+ pass
+
if PcdTypeItem == 'FeaturePcd':
CommentItemUsage = DT.USAGE_ITEM_CONSUMES
if CommentItemHelpText == 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 == 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
-
+ BlockFlag = 4
+
if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
if CommentItemUsage == DT.ITEM_UNDEFINED:
if BlockFlag == -1:
@@ -125,19 +125,19 @@ def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj): #
if CommentItemUsage == PreUsage == DT.ITEM_UNDEFINED:
CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
-
+
PreHelpText = CommentItemHelpText
-
- if BlockFlag == 4:
+
+ 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
@@ -145,7 +145,7 @@ def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj): CommentItemIns = InfPcdItemCommentContent()
CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
- PreHelpText += DT.END_OF_LINE
+ PreHelpText += DT.END_OF_LINE
CommentItemIns.SetHelpStringItem(PreHelpText)
CommentInsList.append(CommentItemIns)
#
@@ -155,18 +155,18 @@ def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj): CommentItemIns.SetUsageItem(CommentItemUsage)
CommentItemIns.SetHelpStringItem(CommentItemHelpText)
CommentInsList.append(CommentItemIns)
-
+
BlockFlag = -1
PreUsage = None
- PreHelpText = ''
-
+ PreHelpText = ''
+
else:
PreUsage = CommentItemUsage
PreHelpText = CommentItemHelpText
-
+
PcdItemObj.SetHelpStringList(CommentInsList)
-
- return PcdItemObj
+
+ return PcdItemObj
class InfPcdItemCommentContent():
def __init__(self):
@@ -178,17 +178,17 @@ class InfPcdItemCommentContent(): # 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
@@ -211,88 +211,94 @@ class InfPcdItem(): self.Token = ''
self.TokenSpaceGuidCName = ''
self.TokenSpaceGuidValue = ''
- self.DatumType = ''
- self.MaxDatumSize = ''
- self.DefaultValue = ''
- self.Offset = ''
- self.ValidUsage = ''
- self.ItemType = ''
- self.SupModuleList = []
+ self.DatumType = ''
+ self.MaxDatumSize = ''
+ self.DefaultValue = ''
+ self.Offset = ''
+ self.ValidUsage = ''
+ self.ItemType = ''
+ self.SupModuleList = []
self.HelpStringList = []
self.FeatureFlagExp = ''
- self.SupArchList = []
+ self.SupArchList = []
self.PcdErrorsList = []
-
+
def SetCName(self, CName):
- self.CName = CName
+ self.CName = CName
def GetCName(self):
return self.CName
-
+
def SetToken(self, Token):
- self.Token = Token
+ self.Token = Token
def GetToken(self):
return self.Token
-
+
def SetTokenSpaceGuidCName(self, TokenSpaceGuidCName):
- self.TokenSpaceGuidCName = TokenSpaceGuidCName
+ self.TokenSpaceGuidCName = TokenSpaceGuidCName
def GetTokenSpaceGuidCName(self):
return self.TokenSpaceGuidCName
-
+
def SetTokenSpaceGuidValue(self, TokenSpaceGuidValue):
- self.TokenSpaceGuidValue = TokenSpaceGuidValue
+ self.TokenSpaceGuidValue = TokenSpaceGuidValue
def GetTokenSpaceGuidValue(self):
return self.TokenSpaceGuidValue
-
+
def SetDatumType(self, DatumType):
- self.DatumType = DatumType
+ self.DatumType = DatumType
def GetDatumType(self):
return self.DatumType
-
+
def SetMaxDatumSize(self, MaxDatumSize):
- self.MaxDatumSize = MaxDatumSize
+ self.MaxDatumSize = MaxDatumSize
def GetMaxDatumSize(self):
return self.MaxDatumSize
def SetDefaultValue(self, DefaultValue):
- self.DefaultValue = DefaultValue
+ self.DefaultValue = DefaultValue
def GetDefaultValue(self):
return self.DefaultValue
-
+
def SetPcdErrorsList(self, PcdErrorsList):
- self.PcdErrorsList = PcdErrorsList
+ self.PcdErrorsList = PcdErrorsList
def GetPcdErrorsList(self):
return self.PcdErrorsList
def SetItemType(self, ItemType):
- self.ItemType = ItemType
+ self.ItemType = ItemType
def GetItemType(self):
return self.ItemType
def SetSupModuleList(self, SupModuleList):
- self.SupModuleList = 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
+
##
#
#
@@ -301,13 +307,13 @@ class InfPcdObject(): def __init__(self, FileName):
self.Pcds = Sdict()
self.FileName = FileName
-
- def SetPcds(self, PcdContent, KeysList = None, PackageInfo = None):
-
+
+ def SetPcds(self, PcdContent, KeysList=None, PackageInfo=None):
+
if GlobalData.gIS_BINARY_INF:
self.SetAsBuildPcds(PcdContent, KeysList, PackageInfo)
return True
-
+
#
# Validate Arch
#
@@ -316,7 +322,7 @@ class InfPcdObject(): PcdTypeItem = ''
for (PcdTypeItem1, ArchItem, LineNo) in KeysList:
SupArchList, SupArchDict = ValidateArch(ArchItem, PcdTypeItem1, LineNo, SupArchDict, SupArchList)
-
+
#
# Validate PcdType
#
@@ -324,32 +330,32 @@ class InfPcdObject(): 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,
+ 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 != 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.
@@ -357,13 +363,13 @@ class InfPcdObject(): if IsValidPcdValue(PcdItem[1]) or PcdItem[1].strip() == "":
PcdItemObj.SetDefaultValue(PcdItem[1])
else:
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_PCD_VALUE_INVALID,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
ExtraData=PcdItem[1])
-
+
if len(PcdItem) == 3:
#
# Contain PcdName, value, and FeatureFlag express
@@ -372,40 +378,40 @@ class InfPcdObject(): # Validate Feature Flag Express
#
if PcdItem[2].strip() == '':
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
+ 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],
+ 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,
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_PCD_SECTION_CONTENT_ERROR,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
ExtraData=CurrentLineOfPcdItem[0])
- return False
-
+ return False
+
if PcdTypeItem.upper != DT.TAB_INF_FEATURE_PCD.upper():
PcdItemObj.SetSupportArchList(SupArchDict[PcdTypeItem])
else:
PcdItemObj.SetSupportArchList(SupArchList)
-
- if self.Pcds.has_key((PcdTypeItem, PcdItemObj)):
+
+ if self.Pcds.has_key((PcdTypeItem, PcdItemObj)):
PcdsList = self.Pcds[PcdTypeItem, PcdItemObj]
PcdsList.append(PcdItemObj)
self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
@@ -413,56 +419,64 @@ class InfPcdObject(): PcdsList = []
PcdsList.append(PcdItemObj)
self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
-
+
return True
-
- def SetAsBuildPcds(self, PcdContent, KeysList = None, PackageInfo = None):
+
+ 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 CommmentLine in CommentList:
- CommentString += GetHelpStringByRemoveHashKey(CommmentLine)
-
- PcdItemObj.SetHelpStringList(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)
+ PcdItemObj = SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj)
#
- # Set Value/DatumType/MaxDatumSize/Token
+ # Set Value/DatumType/OffSet/Token
#
- PcdItemObj = SetValueDatumTypeMaxSizeToken(PcdItem,
- CurrentLineOfPcdItem,
+ PcdItemObj = SetValueDatumTypeMaxSizeToken(PcdItem,
+ CurrentLineOfPcdItem,
PcdItemObj,
KeysList[0][1],
PackageInfo)
-
+
PcdTypeItem = KeysList[0][0]
- if self.Pcds.has_key((PcdTypeItem, PcdItemObj)):
+ if self.Pcds.has_key((PcdTypeItem, PcdItemObj)):
PcdsList = self.Pcds[PcdTypeItem, PcdItemObj]
PcdsList.append(PcdItemObj)
self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
else:
PcdsList = []
PcdsList.append(PcdItemObj)
- self.Pcds[PcdTypeItem, PcdItemObj] = PcdsList
-
+ 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):
+def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineOfPcdItem, PcdItemObj, Arch, PackageInfo=None):
#
# Package information not been generated currently, we need to parser INF file to get information.
#
@@ -484,8 +498,14 @@ def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineOfPcdItem, PcdItemObj, Arc # Open DEC file to get information
#
FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gWORKSPACE, PackageName)))
-
- DecParser = Dec(FullFileName)
+
+ DecParser = None
+ if FullFileName not in GlobalData.gPackageDict:
+ DecParser = Dec(FullFileName)
+ GlobalData.gPackageDict[FullFileName] = DecParser
+ else:
+ DecParser = GlobalData.gPackageDict[FullFileName]
+
#
# Find PCD information.
#
@@ -499,7 +519,8 @@ def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineOfPcdItem, PcdItemObj, Arc 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]:
@@ -507,11 +528,12 @@ def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineOfPcdItem, PcdItemObj, Arc PcdInDec.TokenSpaceGuidCName == PcdItemObj.TokenSpaceGuidCName:
PcdItemObj.SetToken(PcdInDec.TokenValue)
PcdItemObj.SetDatumType(PcdInDec.DatumType)
- PcdItemObj.SetSupportArchList([Arch])
-
+ PcdItemObj.SetSupportArchList([Arch])
+
if PcdItemObj.GetDatumType() == 'VOID*':
- PcdItemObj.SetMaxDatumSize('%s'%(len(GetSplitValueList(PcdItem[1], DT.TAB_COMMA_SPLIT))))
-
+ 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:
@@ -519,51 +541,64 @@ def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineOfPcdItem, PcdItemObj, Arc if GuidInDec.GuidCName == PcdItemObj.TokenSpaceGuidCName:
PcdItemObj.SetTokenSpaceGuidValue(GuidInDec.GuidString)
- #
- # Validate Value.
- #
- 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])
-
+ #
+ # 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],
+ 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
+ return False
elif Type == 'VOID*':
if not Value.startswith("{"):
return False
@@ -572,23 +607,23 @@ def ValidatePcdValueOnDatumType(Value, Type): #
# Strip "{" at head and "}" at tail.
#
- Value = Value[1:-1]
+ 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
+ return False
elif not ReIsValidUint16z.match(Value) and Type == 'UINT16':
return False
elif not ReIsValidUint32z.match(Value) and Type == 'UINT32':
@@ -600,41 +635,41 @@ def ValidatePcdValueOnDatumType(Value, Type): # Since we assume the DEC file always correct, should never go to here.
#
pass
-
- return True
-
+
+ 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,
+ if len(PcdId) != 2:
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_PCD_NAME_FORMAT_ERROR,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
ExtraData=CurrentLineOfPcdItem[0])
else:
#
# Validate PcdTokenSpaceGuidCName
#
if not IsValidCVariableName(PcdId[0]):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_PCD_CVAR_GUID,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
ExtraData=PcdId[0])
if not IsValidCVariableName(PcdId[1]):
- Logger.Error("InfParser",
- ToolError.FORMAT_INVALID,
+ Logger.Error("InfParser",
+ ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_PCD_CVAR_PCDCNAME,
- File=CurrentLineOfPcdItem[2],
- Line=CurrentLineOfPcdItem[1],
+ File=CurrentLineOfPcdItem[2],
+ Line=CurrentLineOfPcdItem[1],
ExtraData=PcdId[1])
PcdItemObj.SetTokenSpaceGuidCName(PcdId[0])
PcdItemObj.SetCName(PcdId[1])
-
- return PcdItemObj
\ No newline at end of file +
+ return PcdItemObj
|