]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/Build: Add error report for incorrect syntax in DEC file.
authorBob Feng <bob.c.feng@intel.com>
Tue, 23 Jun 2015 08:45:06 +0000 (08:45 +0000)
committerbobfeng <bobfeng@Edk2>
Tue, 23 Jun 2015 08:45:06 +0000 (08:45 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Bob Feng" <bob.c.feng@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17685 6f19259b-4bc3-4df7-8a09-765794883524

BaseTools/Source/Python/Workspace/MetaFileTable.py

index 89a12cd228018398c1edc1d5cf8d11499cca0e51..449e56efcc16408b89faafe41cbb8c906ca760da 100644 (file)
@@ -17,6 +17,7 @@
 import uuid\r
 \r
 import Common.EdkLogger as EdkLogger\r
+from Common.BuildToolError import FORMAT_INVALID\r
 \r
 from MetaDataTable import Table, TableFile\r
 from MetaDataTable import ConvertToSqlString\r
@@ -226,24 +227,39 @@ class PackageTable(MetaFileTable):
         return self.Exec(SqlCommand)\r
 \r
     def GetValidExpression(self, TokenSpaceGuid, PcdCName):\r
-        SqlCommand = "select Value1 from %s WHERE Value2='%s' and Value3='%s'" % (self.Table, TokenSpaceGuid, PcdCName)\r
+        SqlCommand = "select Value1,StartLine from %s WHERE Value2='%s' and Value3='%s'" % (self.Table, TokenSpaceGuid, PcdCName)\r
         self.Cur.execute(SqlCommand)\r
         validateranges = []\r
         validlists = []\r
         expressions = []\r
-        for row in self.Cur:\r
-            comment = row[0]\r
-            comment = comment.strip("#")\r
-            comment = comment.strip()\r
-            if comment.startswith("@ValidRange"):\r
-                comment = comment.replace("@ValidRange", "", 1)\r
-                validateranges.append(comment.split("|")[1].strip())\r
-            if comment.startswith("@ValidList"):\r
-                comment = comment.replace("@ValidList", "", 1)\r
-                validlists.append(comment.split("|")[1].strip())\r
-            if comment.startswith("@Expression"):\r
-                comment = comment.replace("@Expression", "", 1)\r
-                expressions.append(comment.split("|")[1].strip())\r
+        try:\r
+            for row in self.Cur:\r
+                comment = row[0]\r
+                \r
+                LineNum = row[1]\r
+                comment = comment.strip("#")\r
+                comment = comment.strip()\r
+                oricomment = comment\r
+                if comment.startswith("@ValidRange"):\r
+                    comment = comment.replace("@ValidRange", "", 1)\r
+                    validateranges.append(comment.split("|")[1].strip())\r
+                if comment.startswith("@ValidList"):\r
+                    comment = comment.replace("@ValidList", "", 1)\r
+                    validlists.append(comment.split("|")[1].strip())\r
+                if comment.startswith("@Expression"):\r
+                    comment = comment.replace("@Expression", "", 1)\r
+                    expressions.append(comment.split("|")[1].strip())\r
+        except Exception, Exc:\r
+            ValidType = ""\r
+            if oricomment.startswith("@ValidRange"):\r
+                ValidType = "@ValidRange"\r
+            if oricomment.startswith("@ValidList"):\r
+                ValidType = "@ValidList"\r
+            if oricomment.startswith("@Expression"):\r
+                ValidType = "@Expression"\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "The syntax for %s of PCD %s.%s is incorrect" % (ValidType,TokenSpaceGuid, PcdCName),\r
+                            ExtraData=oricomment,File=self.MetaFile, Line=LineNum)\r
+            return set(), set(), set()\r
         return set(validateranges), set(validlists), set(expressions)\r
 ## Python class representation of table storing platform data\r
 class PlatformTable(MetaFileTable):\r