summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/UPT/Object
diff options
context:
space:
mode:
authorHess Chen <hesheng.chen@intel.com>2014-08-26 05:58:02 +0000
committerhchen30 <hchen30@6f19259b-4bc3-4df7-8a09-765794883524>2014-08-26 05:58:02 +0000
commit421ccda3079077dd613308526e02d797f5cc356a (patch)
treeecf0907550f140643cb5ab965fd3b87d837b8ee4 /BaseTools/Source/Python/UPT/Object
parentf0aa06e385c41743ac805bed9469aac336a6ec4c (diff)
downloadedk2-platforms-421ccda3079077dd613308526e02d797f5cc356a.tar.xz
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
Diffstat (limited to 'BaseTools/Source/Python/UPT/Object')
-rw-r--r--BaseTools/Source/Python/UPT/Object/POM/CommonObject.py208
-rw-r--r--BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py15
-rw-r--r--BaseTools/Source/Python/UPT/Object/POM/PackageObject.py14
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py147
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py4
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py62
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py9
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py3
-rw-r--r--BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py405
9 files changed, 586 insertions, 281 deletions
diff --git a/BaseTools/Source/Python/UPT/Object/POM/CommonObject.py b/BaseTools/Source/Python/UPT/Object/POM/CommonObject.py
index 1418a2f4bd..ec8a8d44ce 100644
--- a/BaseTools/Source/Python/UPT/Object/POM/CommonObject.py
+++ b/BaseTools/Source/Python/UPT/Object/POM/CommonObject.py
@@ -1,7 +1,7 @@
## @file
# This file is used to define common items of class 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
@@ -14,7 +14,7 @@
'''
Common Object
'''
-from Library.DataType import LANGUAGE_EN_US
+from Library.DataType import TAB_LANGUAGE_EN_US
## HelpTextObject
#
@@ -44,6 +44,20 @@ class HelpTextListObject(object):
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
@@ -60,6 +74,7 @@ class CommonPropertiesObject(HelpTextObject, HelpTextListObject):
self.Usage = []
self.FeatureFlag = ''
self.SupArchList = []
+ self.GuidValue = ''
HelpTextObject.__init__(self)
HelpTextListObject.__init__(self)
@@ -80,6 +95,12 @@ class CommonPropertiesObject(HelpTextObject, HelpTextListObject):
def GetSupArchList(self):
return self.SupArchList
+
+ def SetGuidValue(self, GuidValue):
+ self.GuidValue = GuidValue
+
+ def GetGuidValue(self):
+ return self.GuidValue
## CommonHeaderObject
#
@@ -89,35 +110,96 @@ class CommonPropertiesObject(HelpTextObject, HelpTextListObject):
#
class CommonHeaderObject(object):
def __init__(self):
- self.Abstract = ''
- self.Description = ''
- self.Copyright = ''
- self.License = ''
+ self.AbstractList = []
+ self.DescriptionList = []
+ self.CopyrightList = []
+ self.LicenseList = []
def SetAbstract(self, Abstract):
- self.Abstract = Abstract
+ if isinstance(Abstract, list):
+ self.AbstractList = Abstract
+ else:
+ self.AbstractList.append(Abstract)
def GetAbstract(self):
- return self.Abstract
+ return self.AbstractList
def SetDescription(self, Description):
- self.Description = Description
+ if isinstance(Description, list):
+ self.DescriptionList = Description
+ else:
+ self.DescriptionList.append(Description)
def GetDescription(self):
- return self.Description
+ return self.DescriptionList
def SetCopyright(self, Copyright):
- self.Copyright = Copyright
+ if isinstance(Copyright, list):
+ self.CopyrightList = Copyright
+ else:
+ self.CopyrightList.append(Copyright)
def GetCopyright(self):
- return self.Copyright
+ return self.CopyrightList
def SetLicense(self, License):
- self.License = License
+ if isinstance(License, list):
+ self.LicenseList = License
+ else:
+ self.LicenseList.append(License)
def GetLicense(self):
- return self.License
+ 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
@@ -177,7 +259,7 @@ class ClonedRecordObject(object):
#
class TextObject(object):
def __init__(self):
- self.Lang = LANGUAGE_EN_US
+ self.Lang = TAB_LANGUAGE_EN_US
self.String = ''
def SetLang(self, Lang):
@@ -224,10 +306,10 @@ class FileNameObject(CommonPropertiesObject):
#
class FileObject(object):
def __init__(self):
- self.Executable = ''
+ self.Executable = ''
self.Uri = ''
self.OsType = ''
-
+
def SetExecutable(self, Executable):
self.Executable = Executable
@@ -478,6 +560,11 @@ class UserExtensionObject(object):
def __init__(self):
self.UserID = ''
self.Identifier = ''
+ self.BinaryAbstractList = []
+ self.BinaryDescriptionList = []
+ self.BinaryCopyrightList = []
+ self.BinaryLicenseList = []
+ self.UniLangDefsList = []
#
# { Statement : Arch , ... }
#
@@ -519,6 +606,60 @@ class UserExtensionObject(object):
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
@@ -600,6 +741,10 @@ class PcdErrorObject(object):
self.Expression = ''
self.ErrorNumber = ''
self.ErrorMessageList = []
+ self.TokenSpaceGuidCName = ''
+ self.CName = ''
+ self.FileLine = ''
+ self.LineNum = 0
def SetValidValue(self, ValidValue):
self.ValidValue = ValidValue
@@ -637,7 +782,31 @@ class PcdErrorObject(object):
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
@@ -692,7 +861,7 @@ class IncludeObject(CommonPropertiesObject):
# @param SkuInfoList: Input value for SkuInfoList, default is {}
# @param SupModuleList: Input value for SupModuleList, default is []
#
-class PcdObject(CommonPropertiesObject, HelpTextListObject):
+class PcdObject(CommonPropertiesObject, HelpTextListObject, PromptListObject):
def __init__(self):
self.PcdCName = ''
self.CName = ''
@@ -709,6 +878,7 @@ class PcdObject(CommonPropertiesObject, HelpTextListObject):
self.SupModuleList = []
CommonPropertiesObject.__init__(self)
HelpTextListObject.__init__(self)
+ PromptListObject.__init__(self)
def SetPcdCName(self, PcdCName):
self.PcdCName = PcdCName
diff --git a/BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py b/BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py
index 620bbb411f..e85b8fa010 100644
--- a/BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py
+++ b/BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py
@@ -1,7 +1,7 @@
## @file
# This file is used to define a class object to describe a module
#
-# 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,6 +21,7 @@ ModuleObject
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
@@ -94,7 +95,7 @@ class SpecObject(object):
#
# This class defined header items used in Module file
#
-class ModuleHeaderObject(IdentificationObject, CommonHeaderObject):
+class ModuleHeaderObject(IdentificationObject, CommonHeaderObject, BinaryHeaderObject):
def __init__(self):
self.IsLibrary = False
self.IsLibraryModList = []
@@ -103,6 +104,7 @@ class ModuleHeaderObject(IdentificationObject, CommonHeaderObject):
self.PcdIsDriver = ''
self.PiSpecificationVersion = ''
self.UefiSpecificationVersion = ''
+ self.UNIFlag = False
#
# SpecObject
#
@@ -126,6 +128,7 @@ class ModuleHeaderObject(IdentificationObject, CommonHeaderObject):
self.SupArchList = []
IdentificationObject.__init__(self)
CommonHeaderObject.__init__(self)
+ BinaryHeaderObject.__init__(self)
def SetIsLibrary(self, IsLibrary):
self.IsLibrary = IsLibrary
@@ -277,6 +280,7 @@ class AsBuildLibraryClassObject(object):
def __init__(self):
self.LibGuid = ''
self.LibVersion = ''
+ self.SupArchList = []
def SetLibGuid(self, LibGuid):
self.LibGuid = LibGuid
@@ -288,6 +292,11 @@ class AsBuildLibraryClassObject(object):
def GetLibVersion(self):
return self.LibVersion
+ def SetSupArchList(self, SupArchList):
+ self.SupArchList = SupArchList
+ def GetSupArchList(self):
+ return self.SupArchList
+
##
# AsBuiltObject
#
@@ -308,7 +317,7 @@ class AsBuiltObject(object):
#
# List of BinaryBuildFlag object
#
- self.BinaryBuildFlagList = ''
+ self.BinaryBuildFlagList = []
def SetPatchPcdList(self, PatchPcdList):
self.PatchPcdList = PatchPcdList
diff --git a/BaseTools/Source/Python/UPT/Object/POM/PackageObject.py b/BaseTools/Source/Python/UPT/Object/POM/PackageObject.py
index 098954d4ed..57bdcf96a3 100644
--- a/BaseTools/Source/Python/UPT/Object/POM/PackageObject.py
+++ b/BaseTools/Source/Python/UPT/Object/POM/PackageObject.py
@@ -1,7 +1,7 @@
## @file
# This file is used to define a class object to describe a package
#
-# 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,6 +21,7 @@ PackageObject
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
@@ -44,10 +45,11 @@ class PackageIncludeFileObject(StandardIncludeFileObject):
##
# PackageObject
#
-class PackageObject(IdentificationObject, CommonHeaderObject):
+class PackageObject(IdentificationObject, CommonHeaderObject, BinaryHeaderObject):
def __init__(self):
IdentificationObject.__init__(self)
CommonHeaderObject.__init__(self)
+ BinaryHeaderObject.__init__(self)
#
# LibraryClassObject
#
@@ -85,8 +87,12 @@ class PackageObject(IdentificationObject, CommonHeaderObject):
#
self.PcdList = []
#
- # UserExtensionObject
+ # {(PcdTokenSpaceGuidCName, PcdErrroNumber): PcdErrorMessageList}
+ #
+ self.PcdErrorCommentDict = {}
#
+ # UserExtensionObject
+ #
self.UserExtensionList = []
#
# MiscFileObject
@@ -104,6 +110,8 @@ class PackageObject(IdentificationObject, CommonHeaderObject):
self.PcdChecks = []
+ self.UNIFlag = False
+
def SetLibraryClassList(self, LibraryClassList):
self.LibraryClassList = LibraryClassList
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