public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTool: Error handling for PCD datumtype.
@ 2018-03-19  4:05 BobCF
  2018-03-19  4:08 ` Gao, Liming
  0 siblings, 1 reply; 3+ messages in thread
From: BobCF @ 2018-03-19  4:05 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

Report error if the Pcd DatumType is wrong.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/Python/Workspace/BuildClassObject.py |  2 ++
 BaseTools/Source/Python/Workspace/DecBuildData.py     | 13 +++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index 1352fa21c8..a306dc0b23 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -67,10 +67,11 @@ class PcdClassObject(object):
         self.DscDefaultValue = None
         self.DscRawValue = None
         if IsDsc:
             self.DscDefaultValue = Value
         self.PcdValueFromComm = ""
+        self.DefinitionPosition = ("","")
 
     ## Convert the class to a string
     #
     #  Convert each member of the class to string
     #  Organize to a signle line format string
@@ -176,10 +177,11 @@ class StructurePcd(PcdClassObject):
         self.validateranges = PcdObject.validateranges if PcdObject.validateranges else self.validateranges
         self.validlists = PcdObject.validlists if PcdObject.validlists else self.validlists
         self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions
         self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue
         self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm
+        self.DefinitionPosition = PcdObject.DefinitionPosition if PcdObject.DefinitionPosition else self.DefinitionPosition
         if type(PcdObject) is StructurePcd:
             self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile
             self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs
             self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues
             self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py
index ee00ec0719..4d6edadc8f 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -392,15 +392,11 @@ class DecBuildData(PackageBuildClassObject):
                     struct_pcd.SetDecDefaultValue(item.DefaultValue)
                 else:
                     struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo)
 
             struct_pcd.PackageDecs = dep_pkgs
-            if not struct_pcd.StructuredPcdIncludeFile:
-                EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName,self.MetaFile.File,LineNo ))
-
             str_pcd_set.append(struct_pcd)
-
         return str_pcd_set
 
     ## Retrieve PCD declarations for given type
     def _GetPcd(self, Type):
         Pcds = sdict()
@@ -444,18 +440,27 @@ class DecBuildData(PackageBuildClassObject):
                                         None,
                                         list(validateranges),
                                         list(validlists),
                                         list(expressions)
                                         )
+            PcdObj.DefinitionPosition = (self.MetaFile.File,LineNo)
             if "." in TokenSpaceGuid:
                 StrPcdSet.append((PcdObj,LineNo))
             else:
                 Pcds[PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type]] = PcdObj
 
         StructurePcds = self.ProcessStructurePcd(StrPcdSet)
         for pcd in StructurePcds:
             Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd
+        StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')
+        for pcd in Pcds.values():
+            if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:
+                if StructPattern.match(pcd.DatumType) == None:
+                    EdkLogger.error('build', FORMAT_INVALID, "DatumType only support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct name.", pcd.DefinitionPosition[0],pcd.DefinitionPosition[1])
+        for struct_pcd in Pcds.values():
+            if isinstance(struct_pcd,StructurePcd) and not struct_pcd.StructuredPcdIncludeFile:
+                EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName,struct_pcd.DefinitionPosition[0],struct_pcd.DefinitionPosition[1] ))
 
         return Pcds
     @property
     def CommonIncludes(self):
         if self._CommonIncludes is None:
-- 
2.14.3.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [Patch] BaseTool: Error handling for PCD datumtype.
@ 2018-03-05  1:39 BobCF
  0 siblings, 0 replies; 3+ messages in thread
From: BobCF @ 2018-03-05  1:39 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

Report error if the Pcd DatumType is wrong.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/Python/Workspace/BuildClassObject.py |  2 ++
 BaseTools/Source/Python/Workspace/DecBuildData.py     | 13 +++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index 711ba492ef..ec7c704fa5 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -66,10 +66,11 @@ class PcdClassObject(object):
         self.expressions = expressions
         self.DscDefaultValue = None
         self.DscRawValue = None
         if IsDsc:
             self.DscDefaultValue = Value
+        self.DefinitionPosition = ("","")
 
     ## Convert the class to a string
     #
     #  Convert each member of the class to string
     #  Organize to a signle line format string
@@ -175,10 +176,11 @@ class StructurePcd(PcdClassObject):
         self.IsFromDsc = PcdObject.IsFromDsc if PcdObject.IsFromDsc else self.IsFromDsc
         self.validateranges = PcdObject.validateranges if PcdObject.validateranges else self.validateranges
         self.validlists = PcdObject.validlists if PcdObject.validlists else self.validlists
         self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions
         self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue
+        self.DefinitionPosition = PcdObject.DefinitionPosition if PcdObject.DefinitionPosition else self.DefinitionPosition
         if type(PcdObject) is StructurePcd:
             self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile
             self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs
             self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues
             self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py
index ee00ec0719..4d6edadc8f 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -392,15 +392,11 @@ class DecBuildData(PackageBuildClassObject):
                     struct_pcd.SetDecDefaultValue(item.DefaultValue)
                 else:
                     struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo)
 
             struct_pcd.PackageDecs = dep_pkgs
-            if not struct_pcd.StructuredPcdIncludeFile:
-                EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName,self.MetaFile.File,LineNo ))
-
             str_pcd_set.append(struct_pcd)
-
         return str_pcd_set
 
     ## Retrieve PCD declarations for given type
     def _GetPcd(self, Type):
         Pcds = sdict()
@@ -444,18 +440,27 @@ class DecBuildData(PackageBuildClassObject):
                                         None,
                                         list(validateranges),
                                         list(validlists),
                                         list(expressions)
                                         )
+            PcdObj.DefinitionPosition = (self.MetaFile.File,LineNo)
             if "." in TokenSpaceGuid:
                 StrPcdSet.append((PcdObj,LineNo))
             else:
                 Pcds[PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type]] = PcdObj
 
         StructurePcds = self.ProcessStructurePcd(StrPcdSet)
         for pcd in StructurePcds:
             Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd
+        StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')
+        for pcd in Pcds.values():
+            if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:
+                if StructPattern.match(pcd.DatumType) == None:
+                    EdkLogger.error('build', FORMAT_INVALID, "DatumType only support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct name.", pcd.DefinitionPosition[0],pcd.DefinitionPosition[1])
+        for struct_pcd in Pcds.values():
+            if isinstance(struct_pcd,StructurePcd) and not struct_pcd.StructuredPcdIncludeFile:
+                EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName,struct_pcd.DefinitionPosition[0],struct_pcd.DefinitionPosition[1] ))
 
         return Pcds
     @property
     def CommonIncludes(self):
         if self._CommonIncludes is None:
-- 
2.14.3.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-19  4:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-19  4:05 [Patch] BaseTool: Error handling for PCD datumtype BobCF
2018-03-19  4:08 ` Gao, Liming
  -- strict thread matches above, loose matches on Subject: below --
2018-03-05  1:39 BobCF

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox