* [Patch] BaseTools: Support to use struct name as datum type before max size
@ 2018-10-15 13:22 Yonghong Zhu
2018-10-16 0:36 ` Gao, Liming
0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2018-10-15 13:22 UTC (permalink / raw)
To: edk2-devel
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch] BaseTools: Support to use struct name as datum type before max size
2018-10-15 13:22 [Patch] BaseTools: Support to use struct name as datum type before max size Yonghong Zhu
@ 2018-10-16 0:36 ` Gao, Liming
0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-10-16 0:36 UTC (permalink / raw)
To: Zhu, Yonghong, edk2-devel@lists.01.org
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>Yonghong Zhu
>Sent: Monday, October 15, 2018 9:23 PM
>To: edk2-devel@lists.01.org
>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 <yonghong.zhu@intel.com>
>---
> 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
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-16 0:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-15 13:22 [Patch] BaseTools: Support to use struct name as datum type before max size Yonghong Zhu
2018-10-16 0:36 ` Gao, Liming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox