BaseTool: Error handling for PCD datumtype.
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / DecBuildData.py
index ee00ec0..4d6edad 100644 (file)
@@ -394,11 +394,7 @@ class DecBuildData(PackageBuildClassObject):
                     struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo)\r
 \r
             struct_pcd.PackageDecs = dep_pkgs\r
-            if not struct_pcd.StructuredPcdIncludeFile:\r
-                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 ))\r
-\r
             str_pcd_set.append(struct_pcd)\r
-\r
         return str_pcd_set\r
 \r
     ## Retrieve PCD declarations for given type\r
@@ -446,6 +442,7 @@ class DecBuildData(PackageBuildClassObject):
                                         list(validlists),\r
                                         list(expressions)\r
                                         )\r
+            PcdObj.DefinitionPosition = (self.MetaFile.File,LineNo)\r
             if "." in TokenSpaceGuid:\r
                 StrPcdSet.append((PcdObj,LineNo))\r
             else:\r
@@ -454,6 +451,14 @@ class DecBuildData(PackageBuildClassObject):
         StructurePcds = self.ProcessStructurePcd(StrPcdSet)\r
         for pcd in StructurePcds:\r
             Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd\r
+        StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')\r
+        for pcd in Pcds.values():\r
+            if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
+                if StructPattern.match(pcd.DatumType) == None:\r
+                    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])\r
+        for struct_pcd in Pcds.values():\r
+            if isinstance(struct_pcd,StructurePcd) and not struct_pcd.StructuredPcdIncludeFile:\r
+                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] ))\r
 \r
         return Pcds\r
     @property\r