diff options
author | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-10-15 21:20:00 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-10-16 14:48:49 +0800 |
commit | ff4d0f851d43a0ad70a87e8b74b7303fc215361f (patch) | |
tree | fbca9572041959053cbf8bcc15a41a9977272c32 | |
parent | 0fab42ba27c207c0fe268a435704b949d79e7725 (diff) | |
download | edk2-ff4d0f851d43a0ad70a87e8b74b7303fc215361f.tar.gz edk2-ff4d0f851d43a0ad70a87e8b74b7303fc215361f.tar.bz2 edk2-ff4d0f851d43a0ad70a87e8b74b7303fc215361f.zip |
BaseTools: Support to use struct name as datum type before max size
Original it hard code to use "VOID*", this patch extend it to both
support VOID* and valid struct name.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
-rw-r--r-- | BaseTools/Source/Python/Common/Misc.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/Workspace/MetaFileParser.py | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 6abbb9a944..b32b7cdc5f 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -50,6 +50,8 @@ valuePatternGcc = re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$') pcdPatternGcc = re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)')
secReGeneral = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
+StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')
+
## Dictionary used to store file time stamp for quick re-access
gFileTimeStampCache = {} # {file path : file time stamp}
@@ -1459,7 +1461,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''): Size = ''
if len(FieldList) > 1 and FieldList[1]:
DataType = FieldList[1]
- if FieldList[1] != TAB_VOID:
+ if FieldList[1] != TAB_VOID and StructPattern.match(FieldList[1]) is None:
IsValid = False
if len(FieldList) > 2:
Size = FieldList[2]
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index f1707c06fe..804a4aa5cb 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -29,7 +29,7 @@ import Common.GlobalData as GlobalData from CommonDataClass.DataClass import *
from Common.DataType import *
from Common.StringUtils import *
-from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue
+from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue, StructPattern
from Common.Expression import *
from CommonDataClass.Exceptions import *
from Common.LongFilePathSupport import OpenLongFilePath as open
@@ -1614,8 +1614,8 @@ class DscParser(MetaFileParser): ValList, Valid, Index = AnalyzeDscPcd(self._ValueList[2], self._ItemType)
if not Valid:
if self._ItemType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT, MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE):
- if ValList[1] != TAB_VOID and ValList[2]:
- EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect. Only VOID* type PCD need the maxsize info.", File=self._FileWithError,
+ if ValList[1] != TAB_VOID and StructPattern.match(ValList[1]) is None and ValList[2]:
+ EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect. The datum type info should be VOID* or a valid struct name.", File=self._FileWithError,
Line=self._LineIndex + 1, ExtraData="%s.%s|%s" % (self._ValueList[0], self._ValueList[1], self._ValueList[2]))
EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect.", File=self._FileWithError, Line=self._LineIndex + 1,
ExtraData="%s.%s|%s" % (self._ValueList[0], self._ValueList[1], self._ValueList[2]))
|