Reviewed-by: Liming Gao <[email protected]>
>-----Original Message----- >From: edk2-devel [mailto:[email protected]] On Behalf Of >Yonghong Zhu >Sent: Monday, October 15, 2018 9:23 PM >To: [email protected] >Subject: [edk2] [Patch] 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 <[email protected]> >--- > BaseTools/Source/Python/Common/Misc.py | 4 +++- > 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 2cf9574..3c71dfc 100644 >--- a/BaseTools/Source/Python/Common/Misc.py >+++ b/BaseTools/Source/Python/Common/Misc.py >@@ -47,10 +47,12 @@ startPatternGeneral = re.compile("^Start[' ']+Length[' >']+Name[' ']+Class") > addressPatternGeneral = re.compile("^Address[' ']+Publics by Value[' >']+Rva\+Base") > 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} > > ## Dictionary used to store dependencies of files > gDependencyDatabase = {} # arch : {file path : [dependent files list]} >@@ -1461,11 +1463,11 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''): > if PcdType in (MODEL_PCD_FIXED_AT_BUILD, >MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_DEFAULT, >MODEL_PCD_DYNAMIC_EX_DEFAULT): > Value = FieldList[0] > 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] > if IsValid: > if DataType == "": >diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py >b/BaseTools/Source/Python/Workspace/MetaFileParser.py >index 79e3180..f33b91c 100644 >--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py >+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py >@@ -27,11 +27,11 @@ import Common.EdkLogger as EdkLogger > 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 > from collections import defaultdict > from .MetaFileTable import MetaFileStorage >@@ -1610,12 +1610,12 @@ class DscParser(MetaFileParser): > return > > 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])) > PcdValue = ValList[Index] > if PcdValue and "." not in self._ValueList[0]: >-- >2.6.1.windows.1 > >_______________________________________________ >edk2-devel mailing list >[email protected] >https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

