|
From: <qh...@us...> - 2010-05-13 00:53:42
|
Revision: 1971
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=1971&view=rev
Author: qhuang8
Date: 2010-05-13 00:53:35 +0000 (Thu, 13 May 2010)
Log Message:
-----------
Enhance ECC tool to add two new check items:
1. Check the doxygen file header for INF/DEC/DSC/FDF to start with "## @file"
2. Check the FILE_GUID duplication for all INFs scanned with new error code 10016.
Modified Paths:
--------------
trunk/BaseTools/Source/Python/Ecc/Check.py
trunk/BaseTools/Source/Python/Ecc/Configuration.py
trunk/BaseTools/Source/Python/Ecc/EccToolError.py
trunk/BaseTools/Source/Python/Ecc/config.ini
trunk/BaseTools/Source/Python/Table/TableReport.py
Modified: trunk/BaseTools/Source/Python/Ecc/Check.py
===================================================================
--- trunk/BaseTools/Source/Python/Ecc/Check.py 2010-05-12 01:33:12 UTC (rev 1970)
+++ trunk/BaseTools/Source/Python/Ecc/Check.py 2010-05-13 00:53:35 UTC (rev 1971)
@@ -341,9 +341,19 @@
for Dirpath, Dirnames, Filenames in self.WalkTree():
for F in Filenames:
- if os.path.splitext(F)[1] in ('.h', '.c'):
+ Ext = os.path.splitext(F)[1]
+ if Ext in ('.h', '.c'):
FullName = os.path.join(Dirpath, F)
MsgList = c.CheckFileHeaderDoxygenComments(FullName)
+ elif Ext in ('.inf', '.dec', '.dsc', '.fdf'):
+ FullName = os.path.join(Dirpath, F)
+ if not open(FullName).read().startswith('## @file'):
+ SqlStatement = """ select ID from File where FullPath like '%s'""" % FullName
+ ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)
+ for Result in ResultSet:
+ Msg = 'INF/DEC/DSC/FDF file header comment should begin with ""## @file""'
+ EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])
+
# Check whether the function headers are followed Doxygen special documentation blocks in section 2.3.5
def DoxygenCheckFunctionHeader(self):
@@ -399,6 +409,7 @@
self.MetaDataFileCheckGuidDuplicate()
self.MetaDataFileCheckModuleFileNoUse()
self.MetaDataFileCheckPcdType()
+ self.MetaDataFileCheckModuleFileGuidDuplication()
# Check whether each file defined in meta-data exists
def MetaDataFileCheckPathName(self):
@@ -692,6 +703,38 @@
#ERROR_META_DATA_FILE_CHECK_PCD_TYPE
pass
+ # Internal worker function to get the INF workspace relative path from FileID
+ def GetInfFilePathFromID(self, FileID):
+ Table = EccGlobalData.gDb.TblFile
+ SqlCommand = """select A.FullPath from %s as A where A.ID = %s""" % (Table.Table, FileID)
+ RecordSet = Table.Exec(SqlCommand)
+ Path = ""
+ for Record in RecordSet:
+ Path = Record[0].replace(EccGlobalData.gWorkspace, '')
+ if Path.startswith('\\') or Path.startswith('/'):
+ Path = Path[1:]
+ return Path
+
+ # Check whether two module INFs under one workspace has the same FILE_GUID value
+ def MetaDataFileCheckModuleFileGuidDuplication(self):
+ if EccGlobalData.gConfig.MetaDataFileCheckModuleFileGuidDuplication == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
+ EdkLogger.quiet("Checking for pcd type in c code function usage ...")
+ Table = EccGlobalData.gDb.TblInf
+ SqlCommand = """
+ select A.ID, A.Value2, A.BelongsToFile, B.BelongsToFile from %s as A, %s as B
+ where A.Value1 = 'FILE_GUID' and B.Value1 = 'FILE_GUID' and
+ A.Value2 = B.Value2 and A.ID <> B.ID group by A.ID
+ """ % (Table.Table, Table.Table)
+ RecordSet = Table.Exec(SqlCommand)
+ for Record in RecordSet:
+ InfPath1 = self.GetInfFilePathFromID(Record[2])
+ InfPath2 = self.GetInfFilePathFromID(Record[3])
+ if InfPath1 and InfPath2:
+ if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_GUID_DUPLICATION, InfPath1):
+ Msg = "The FILE_GUID of INF file [%s] is duplicated with that of %s" % (InfPath1, InfPath2)
+ EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_GUID_DUPLICATION, OtherMsg = Msg, BelongsToTable = Table.Table, BelongsToItem = Record[0])
+
+
# Check whether these is duplicate Guid/Ppi/Protocol name
def CheckGuidProtocolPpi(self, ErrorID, Model, Table):
Name = ''
Modified: trunk/BaseTools/Source/Python/Ecc/Configuration.py
===================================================================
--- trunk/BaseTools/Source/Python/Ecc/Configuration.py 2010-05-12 01:33:12 UTC (rev 1970)
+++ trunk/BaseTools/Source/Python/Ecc/Configuration.py 2010-05-13 00:53:35 UTC (rev 1971)
@@ -222,7 +222,9 @@
self.MetaDataFileCheckModuleFileNoUse = 1
# Check whether the PCD is correctly used in C function via its type
self.MetaDataFileCheckPcdType = 1
-
+ # Check whether there are FILE_GUID duplication among different INF files
+ self.MetaDataFileCheckModuleFileGuidDuplication = 1
+
#
# The check points in this section are reserved
#
Modified: trunk/BaseTools/Source/Python/Ecc/EccToolError.py
===================================================================
--- trunk/BaseTools/Source/Python/Ecc/EccToolError.py 2010-05-12 01:33:12 UTC (rev 1970)
+++ trunk/BaseTools/Source/Python/Ecc/EccToolError.py 2010-05-13 00:53:35 UTC (rev 1971)
@@ -92,6 +92,7 @@
ERROR_META_DATA_FILE_CHECK_DUPLICATE_PPI = 10013
ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE = 10014
ERROR_META_DATA_FILE_CHECK_PCD_TYPE = 10015
+ERROR_META_DATA_FILE_CHECK_MODULE_FILE_GUID_DUPLICATION = 10016
ERROR_SPELLING_CHECK_ALL = 11000
@@ -177,7 +178,7 @@
ERROR_META_DATA_FILE_CHECK_DUPLICATE_PPI : "Duplicate PPI found",
ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE : "No used module files found",
ERROR_META_DATA_FILE_CHECK_PCD_TYPE : "Wrong C code function used for this kind of PCD",
-
+ ERROR_META_DATA_FILE_CHECK_MODULE_FILE_GUID_DUPLICATION : "Module file has FILE_GUID collision with other module file",
ERROR_SPELLING_CHECK_ALL : "",
}
Modified: trunk/BaseTools/Source/Python/Ecc/config.ini
===================================================================
--- trunk/BaseTools/Source/Python/Ecc/config.ini 2010-05-12 01:33:12 UTC (rev 1970)
+++ trunk/BaseTools/Source/Python/Ecc/config.ini 2010-05-13 00:53:35 UTC (rev 1971)
@@ -2,7 +2,7 @@
# This file is used to set configuration of ECC tool
# For the items listed below, 1 means valid, 0 means invalid
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -233,6 +233,8 @@
MetaDataFileCheckModuleFileNoUse = 1
# Check whether the PCD is correctly used in C function via its type
MetaDataFileCheckPcdType = 1
+# Check whether there are FILE_GUID duplication among different INF files
+MetaDataFileCheckModuleFileGuidDuplication = 1
#
# The check points in this section are reserved
Modified: trunk/BaseTools/Source/Python/Table/TableReport.py
===================================================================
--- trunk/BaseTools/Source/Python/Table/TableReport.py 2010-05-12 01:33:12 UTC (rev 1970)
+++ trunk/BaseTools/Source/Python/Table/TableReport.py 2010-05-13 00:53:35 UTC (rev 1971)
@@ -105,7 +105,7 @@
IsCorrected = Record[5]
SqlCommand = ''
if BelongsToTable == 'File':
- SqlCommand = """select 0, FullPath from %s where ID = %s
+ SqlCommand = """select 1, FullPath from %s where ID = %s
""" % (BelongsToTable, BelongsToItem)
else:
SqlCommand = """select A.StartLine, B.FullPath from %s as A, File as B
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|