]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Ecc/Check.py
Sync EDKII BaseTools to BaseTools project r1903.
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / Check.py
index c8bc54de3e5bb6cad242345f73e0ddf608df1570..a8ec638fce1768c8423e028a6f73ea250415397f 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to define checkpoints used by ECC tool\r
 #\r
-# Copyright (c) 2008, Intel Corporation\r
+# Copyright (c) 2008 - 2010, Intel Corporation\r
 # All rights reserved. This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -298,7 +298,11 @@ class Check(object):
             for Key in RecordDict:\r
                 if len(RecordDict[Key]) > 1:\r
                     for Item in RecordDict[Key]:\r
-                        EccGlobalData.gDb.TblReport.Insert(ERROR_INCLUDE_FILE_CHECK_NAME, OtherMsg = "The file name for '%s' is duplicate" % (Item[1]), BelongsToTable = 'File', BelongsToItem = Item[0])\r
+                        Path = Item[1].replace(EccGlobalData.gWorkspace, '')\r
+                        if Path.startswith('\\') or Path.startswith('/'):\r
+                            Path = Path[1:]\r
+                        if not EccGlobalData.gException.IsException(ERROR_INCLUDE_FILE_CHECK_NAME, Path):\r
+                            EccGlobalData.gDb.TblReport.Insert(ERROR_INCLUDE_FILE_CHECK_NAME, OtherMsg = "The file name for [%s] is duplicate" % Path, BelongsToTable = 'File', BelongsToItem = Item[0])\r
 \r
     # Check whether all include file contents is guarded by a #ifndef statement.\r
     def IncludeFileCheckIfndef(self):\r
@@ -527,7 +531,7 @@ class Check(object):
         if EccGlobalData.gConfig.MetaDataFileCheckPcdDuplicate == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for duplicate PCDs defined in both DSC and FDF files ...")\r
             SqlCommand = """\r
-                         select A.ID, A.Value2, B.ID, B.Value2 from Dsc as A, Fdf as B\r
+                         select A.ID, A.Value2, A.BelongsToFile, B.ID, B.Value2, B.BelongsToFile from Dsc as A, Fdf as B\r
                          where A.Model >= %s and A.Model < %s\r
                          and B.Model >= %s and B.Model < %s\r
                          and A.Value2 = B.Value2\r
@@ -537,10 +541,17 @@ class Check(object):
                          """% (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)\r
             RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)\r
             for Record in RecordSet:\r
+                SqlCommand1 = """select Name from File where ID = %s""" %Record[2]\r
+                SqlCommand2 = """select Name from File where ID = %s""" %Record[5]\r
+                DscFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand1)[0][0])[0]\r
+                FdfFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand2)[0][0])[0]\r
+                print DscFileName, 111, FdfFileName\r
+                if DscFileName != FdfFileName:\r
+                    continue\r
                 if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1]):\r
                     EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg = "The PCD [%s] is defined in both FDF file and DSC file" % (Record[1]), BelongsToTable = 'Dsc', BelongsToItem = Record[0])\r
                 if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[3]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg = "The PCD [%s] is defined in both FDF file and DSC file" % (Record[3]), BelongsToTable = 'Fdf', BelongsToItem = Record[2])\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg = "The PCD [%s] is defined in both FDF file and DSC file" % (Record[4]), BelongsToTable = 'Fdf', BelongsToItem = Record[3])\r
 \r
             EdkLogger.quiet("Checking for duplicate PCDs defined in DEC files ...")\r
             SqlCommand = """\r
@@ -664,7 +675,7 @@ class Check(object):
                 for Tbl in TableSet:\r
                     TblName = 'Identifier' + str(Tbl[0])\r
                     SqlCommand = """\r
-                                 select Name, ID from %s where value like '%%%s%%' and Model = %s\r
+                                 select Name, ID from %s where value like '%s' and Model = %s\r
                                  """ % (TblName, PcdName, MODEL_IDENTIFIER_FUNCTION_CALLING)\r
                     RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
                     TblNumber = TblName.replace('Identifier', '')\r
@@ -726,29 +737,35 @@ class Check(object):
 \r
     # Naming Convention Check\r
     def NamingConventionCheck(self):\r
-\r
-        for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-            for F in Filenames:\r
-                if os.path.splitext(F)[1] in ('.h', '.c'):\r
-                    FullName = os.path.join(Dirpath, F)\r
-                    Id = c.GetTableID(FullName)\r
-                    if Id < 0:\r
-                        continue\r
-                    FileTable = 'Identifier' + str(Id)\r
-                    self.NamingConventionCheckDefineStatement(FileTable)\r
-                    self.NamingConventionCheckTypedefStatement(FileTable)\r
-                    self.NamingConventionCheckIfndefStatement(FileTable)\r
-                    self.NamingConventionCheckVariableName(FileTable)           \r
-                    self.NamingConventionCheckSingleCharacterVariable(FileTable)\r
+        if EccGlobalData.gConfig.NamingConventionCheckDefineStatement == '1' \\r
+        or EccGlobalData.gConfig.NamingConventionCheckTypedefStatement == '1' \\r
+        or EccGlobalData.gConfig.NamingConventionCheckIfndefStatement == '1' \\r
+        or EccGlobalData.gConfig.NamingConventionCheckVariableName == '1' \\r
+        or EccGlobalData.gConfig.NamingConventionCheckSingleCharacterVariable == '1' \\r
+        or EccGlobalData.gConfig.NamingConventionCheckAll == '1'\\r
+        or EccGlobalData.gConfig.CheckAll == '1':\r
+            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+                for F in Filenames:\r
+                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
+                        FullName = os.path.join(Dirpath, F)\r
+                        Id = c.GetTableID(FullName)\r
+                        if Id < 0:\r
+                            continue\r
+                        FileTable = 'Identifier' + str(Id)\r
+                        self.NamingConventionCheckDefineStatement(FileTable)\r
+                        self.NamingConventionCheckTypedefStatement(FileTable)\r
+                        self.NamingConventionCheckIfndefStatement(FileTable)\r
+                        self.NamingConventionCheckVariableName(FileTable)\r
+                        self.NamingConventionCheckSingleCharacterVariable(FileTable)\r
 \r
         self.NamingConventionCheckPathName()\r
         self.NamingConventionCheckFunctionName()\r
-        \r
+\r
     # Check whether only capital letters are used for #define declarations\r
     def NamingConventionCheckDefineStatement(self, FileTable):\r
         if EccGlobalData.gConfig.NamingConventionCheckDefineStatement == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking naming covention of #define statement ...")\r
-            \r
+\r
             SqlCommand = """select ID, Value from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_MACRO_DEFINE)\r
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r
@@ -763,7 +780,7 @@ class Check(object):
     def NamingConventionCheckTypedefStatement(self, FileTable):\r
         if EccGlobalData.gConfig.NamingConventionCheckTypedefStatement == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking naming covention of #typedef statement ...")\r
-            \r
+\r
             SqlCommand = """select ID, Name from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_TYPEDEF)\r
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r
@@ -783,7 +800,7 @@ class Check(object):
     def NamingConventionCheckIfndefStatement(self, FileTable):\r
         if EccGlobalData.gConfig.NamingConventionCheckTypedefStatement == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking naming covention of #ifndef statement ...")\r
-            \r
+\r
             SqlCommand = """select ID, Value from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_MACRO_IFNDEF)\r
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r
@@ -818,7 +835,7 @@ class Check(object):
         if EccGlobalData.gConfig.NamingConventionCheckVariableName == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking naming covention of variable name ...")\r
             Pattern = re.compile(r'^[A-Zgm]+\S*[a-z]\S*$')\r
-            \r
+\r
             SqlCommand = """select ID, Name from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_VARIABLE)\r
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r
@@ -846,7 +863,7 @@ class Check(object):
     def NamingConventionCheckSingleCharacterVariable(self, FileTable):\r
         if EccGlobalData.gConfig.NamingConventionCheckSingleCharacterVariable == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking naming covention of single character variable name ...")\r
-            \r
+\r
             SqlCommand = """select ID, Name from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_VARIABLE)\r
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r