From b3d07ff8d21ecab5a8060815e9abe73c904e3ed9 Mon Sep 17 00:00:00 2001 From: Hess Chen Date: Mon, 25 Aug 2014 01:16:34 +0000 Subject: This patch is going to: 1. Add a checkpoint to check if an UNI file is a valid UTF-16 file 2. Add a checkpoint to check if a GUID/PPI/PROTOCOL/PCD is in a valid format. 3. Some other minor changes. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen Reviewed-by: Yingke Liu git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15886 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Python/Ecc/MetaFileWorkspace/MetaDataTable.py | 2 +- .../Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 24 ++++++++++++++++++++-- .../Python/Ecc/MetaFileWorkspace/MetaFileTable.py | 8 +++++--- 3 files changed, 28 insertions(+), 6 deletions(-) (limited to 'BaseTools/Source/Python/Ecc/MetaFileWorkspace') diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py index 0d53f05d8b..a27e98c975 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py @@ -98,7 +98,7 @@ class Table(object): SqlCommand = """drop table IF EXISTS %s""" % self.Table try: self.Cur.execute(SqlCommand) - except sqlite3.Error, e: + except Exception, e: print "An error occurred when Drop a table:", e.args[0] ## Get count diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 949d067945..1c3e968785 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -433,6 +433,7 @@ class InfParser(MetaFileParser): def Start(self): NmakeLine = '' Content = '' + Usage = '' try: Content = open(str(self.MetaFile), 'r').readlines() except: @@ -451,8 +452,26 @@ class InfParser(MetaFileParser): IsFindBlockComment = False for Index in range(0, len(Content)): + if self._SectionType in [MODEL_EFI_GUID, + MODEL_EFI_PROTOCOL, + MODEL_EFI_PPI, + MODEL_PCD_FIXED_AT_BUILD, + MODEL_PCD_PATCHABLE_IN_MODULE, + MODEL_PCD_FEATURE_FLAG, + MODEL_PCD_DYNAMIC_EX, + MODEL_PCD_DYNAMIC]: + Line = Content[Index].strip() + if Line.startswith(TAB_COMMENT_SPLIT): + continue + elif Line.find(TAB_COMMENT_SPLIT) > 0: + Usage = Line[Line.find(TAB_COMMENT_SPLIT):] + Line = Line[:Line.find(TAB_COMMENT_SPLIT)] + else: + Usage = '' + else: # skip empty, commented, block commented lines - Line = CleanString(Content[Index], AllowCppStyleComment=True) + Line = CleanString(Content[Index], AllowCppStyleComment=True) + Usage = '' NextLine = '' if Index + 1 < len(Content): NextLine = CleanString(Content[Index + 1]) @@ -539,7 +558,8 @@ class InfParser(MetaFileParser): -1, self._LineIndex+1, -1, - 0 + 0, + Usage ) if IsFindBlockComment: EdkLogger.error("Parser", FORMAT_INVALID, "Open block comments (starting with /*) are expected to end with */", diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py index 89bc7f262f..54a3016948 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py @@ -51,6 +51,7 @@ class ModuleTable(MetaFileTable): Value1 TEXT NOT NULL, Value2 TEXT, Value3 TEXT, + Usage TEXT, Scope1 TEXT, Scope2 TEXT, BelongsToItem REAL NOT NULL, @@ -84,14 +85,15 @@ class ModuleTable(MetaFileTable): # @param Enabled: If this item enabled # def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON', - BelongsToItem=-1, BelongsToFile = -1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0): - (Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2)) + BelongsToItem=-1, BelongsToFile = -1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0, Usage=''): + (Value1, Value2, Value3, Usage, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Usage, Scope1, Scope2)) return Table.Insert( self, Model, Value1, Value2, Value3, + Usage, Scope1, Scope2, BelongsToItem, @@ -113,7 +115,7 @@ class ModuleTable(MetaFileTable): # def Query(self, Model, Arch=None, Platform=None): ConditionString = "Model=%s AND Enabled>=0" % Model - ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine" + ValueString = "Value1,Value2,Value3,Usage,Scope1,Scope2,ID,StartLine" if Arch != None and Arch != 'COMMON': ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch -- cgit v1.2.3