From 901fd8223893d5cdb68ef84f265d23f4180a33bc Mon Sep 17 00:00:00 2001 From: Bob Feng Date: Tue, 23 Jun 2015 08:45:06 +0000 Subject: BaseTools/Build: Add error report for incorrect syntax in DEC file. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: "Bob Feng" Reviewed-by: Laszlo Ersek 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 | 44 +++++++++++++++------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'BaseTools') diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py index 89a12cd228..449e56efcc 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py @@ -17,6 +17,7 @@ import uuid import Common.EdkLogger as EdkLogger +from Common.BuildToolError import FORMAT_INVALID from MetaDataTable import Table, TableFile from MetaDataTable import ConvertToSqlString @@ -226,24 +227,39 @@ class PackageTable(MetaFileTable): return self.Exec(SqlCommand) def GetValidExpression(self, TokenSpaceGuid, PcdCName): - SqlCommand = "select Value1 from %s WHERE Value2='%s' and Value3='%s'" % (self.Table, TokenSpaceGuid, PcdCName) + SqlCommand = "select Value1,StartLine from %s WHERE Value2='%s' and Value3='%s'" % (self.Table, TokenSpaceGuid, PcdCName) self.Cur.execute(SqlCommand) validateranges = [] validlists = [] expressions = [] - for row in self.Cur: - comment = row[0] - comment = comment.strip("#") - comment = comment.strip() - if comment.startswith("@ValidRange"): - comment = comment.replace("@ValidRange", "", 1) - validateranges.append(comment.split("|")[1].strip()) - if comment.startswith("@ValidList"): - comment = comment.replace("@ValidList", "", 1) - validlists.append(comment.split("|")[1].strip()) - if comment.startswith("@Expression"): - comment = comment.replace("@Expression", "", 1) - expressions.append(comment.split("|")[1].strip()) + try: + for row in self.Cur: + comment = row[0] + + LineNum = row[1] + comment = comment.strip("#") + comment = comment.strip() + oricomment = comment + if comment.startswith("@ValidRange"): + comment = comment.replace("@ValidRange", "", 1) + validateranges.append(comment.split("|")[1].strip()) + if comment.startswith("@ValidList"): + comment = comment.replace("@ValidList", "", 1) + validlists.append(comment.split("|")[1].strip()) + if comment.startswith("@Expression"): + comment = comment.replace("@Expression", "", 1) + expressions.append(comment.split("|")[1].strip()) + except Exception, Exc: + ValidType = "" + if oricomment.startswith("@ValidRange"): + ValidType = "@ValidRange" + if oricomment.startswith("@ValidList"): + ValidType = "@ValidList" + if oricomment.startswith("@Expression"): + ValidType = "@Expression" + EdkLogger.error('Parser', FORMAT_INVALID, "The syntax for %s of PCD %s.%s is incorrect" % (ValidType,TokenSpaceGuid, PcdCName), + ExtraData=oricomment,File=self.MetaFile, Line=LineNum) + return set(), set(), set() return set(validateranges), set(validlists), set(expressions) ## Python class representation of table storing platform data class PlatformTable(MetaFileTable): -- cgit v1.2.3