]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Ecc/c.py
Sync EDKII BaseTools to BaseTools project r2042.
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / c.py
index 941392be0fe0a9322e96cf37a5e347fccdfd221c..5a8c1d13e7d60c51f390cdb13aaa8bded0d08ff0 100644 (file)
@@ -514,7 +514,9 @@ def CollectSourceCodeDataIntoDB(RootDir):
                     dirnames.append(Dirname)\r
 \r
         for f in filenames:\r
+            collector = None\r
             FullName = os.path.normpath(os.path.join(dirpath, f))\r
+            model = DataClass.MODEL_FILE_OTHERS\r
             if os.path.splitext(f)[1] in ('.h', '.c'):\r
                 EdkLogger.info("Parsing " + FullName)\r
                 model = f.endswith('c') and DataClass.MODEL_FILE_C or DataClass.MODEL_FILE_H\r
@@ -526,12 +528,13 @@ def CollectSourceCodeDataIntoDB(RootDir):
                     collector.CleanFileProfileBuffer()\r
                     collector.ParseFileWithClearedPPDirective()\r
 #                collector.PrintFragments()\r
-                BaseName = os.path.basename(f)\r
-                DirName = os.path.dirname(FullName)\r
-                Ext = os.path.splitext(f)[1].lstrip('.')\r
-                ModifiedTime = os.path.getmtime(FullName)\r
-                FileObj = DataClass.FileClass(-1, BaseName, Ext, DirName, FullName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), [])\r
-                FileObjList.append(FileObj)\r
+            BaseName = os.path.basename(f)\r
+            DirName = os.path.dirname(FullName)\r
+            Ext = os.path.splitext(f)[1].lstrip('.')\r
+            ModifiedTime = os.path.getmtime(FullName)\r
+            FileObj = DataClass.FileClass(-1, BaseName, Ext, DirName, FullName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), [])\r
+            FileObjList.append(FileObj)\r
+            if collector:\r
                 collector.CleanFileProfileBuffer()\r
 \r
     if len(ParseErrorFileList) > 0:\r
@@ -539,7 +542,8 @@ def CollectSourceCodeDataIntoDB(RootDir):
 \r
     Db = GetDB()\r
     for file in FileObjList:\r
-        Db.InsertOneFile(file)\r
+        if file.ExtName.upper() not in ['INF', 'DEC', 'DSC', 'FDF']:\r
+            Db.InsertOneFile(file)\r
 \r
     Db.UpdateIdentifierBelongsToFunction()\r
 \r
@@ -552,7 +556,6 @@ def GetTableID(FullFileName, ErrorMsgList = None):
                        from File\r
                        where FullPath like '%s'\r
                    """ % FullFileName\r
-\r
     ResultSet = Db.TblFile.Exec(SqlStatement)\r
 \r
     FileID = -1\r
@@ -567,6 +570,8 @@ def GetTableID(FullFileName, ErrorMsgList = None):
     return FileID\r
 \r
 def GetIncludeFileList(FullFileName):\r
+    if os.path.splitext(FullFileName)[1].upper() not in ('.H'):\r
+        return []\r
     IFList = IncludeFileListDict.get(FullFileName)\r
     if IFList != None:\r
         return IFList\r
@@ -2301,21 +2306,32 @@ def CheckFileHeaderDoxygenComments(FullFileName):
     FileTable = 'Identifier' + str(FileID)\r
     SqlStatement = """ select Value, ID\r
                        from %s\r
-                       where Model = %d and StartLine = 1 and StartColumn = 0\r
+                       where Model = %d and (StartLine = 1 or StartLine = 7 or StartLine = 8) and StartColumn = 0\r
                    """ % (FileTable, DataClass.MODEL_IDENTIFIER_COMMENT)\r
     ResultSet = Db.TblFile.Exec(SqlStatement)\r
     if len(ResultSet) == 0:\r
         PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'No Comment appear at the very beginning of file.', 'File', FileID)\r
         return ErrorMsgList\r
 \r
+    IsFoundError1 = True\r
+    IsFoundError2 = True\r
+    IsFoundError3 = True\r
     for Result in ResultSet:\r
-        CommentStr = Result[0]\r
-        if not CommentStr.startswith('/** @file'):\r
-            PrintErrorMsg(ERROR_DOXYGEN_CHECK_FILE_HEADER, 'File header comment should begin with ""/** @file""', FileTable, Result[1])\r
-        if not CommentStr.endswith('**/'):\r
-            PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header comment should end with **/', FileTable, Result[1])\r
-        if CommentStr.find('.') == -1:\r
-            PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMENT_DESCRIPTION, 'Comment description should end with period \'.\'', FileTable, Result[1])\r
+        CommentStr = Result[0].strip()\r
+        ID = Result[1]\r
+        if CommentStr.startswith('/** @file'):\r
+            IsFoundError1 = False\r
+        if CommentStr.endswith('**/'):\r
+            IsFoundError2 = False\r
+        if CommentStr.find('.') != -1:\r
+            IsFoundError3 = False\r
+\r
+    if IsFoundError1:\r
+        PrintErrorMsg(ERROR_DOXYGEN_CHECK_FILE_HEADER, 'File header comment should begin with ""/** @file""', FileTable, ID)\r
+    if IsFoundError2:\r
+        PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header comment should end with ""**/""', FileTable, ID)\r
+    if IsFoundError3:\r
+        PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMENT_DESCRIPTION, 'Comment description should end with period "".""', FileTable, ID)\r
 \r
 def CheckFuncHeaderDoxygenComments(FullFileName):\r
     ErrorMsgList = []\r