summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/Ecc
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2010-09-06 01:58:00 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2010-09-06 01:58:00 +0000
commite56468c072e0d53834787f4ad0e292b33cc6be08 (patch)
tree9b101cd782db879a969041b7bd389ad2b8453b10 /BaseTools/Source/Python/Ecc
parent034ffda8b2ec8575a9a6f42b1dc9ff6db1621a97 (diff)
downloadedk2-platforms-e56468c072e0d53834787f4ad0e292b33cc6be08.tar.xz
Sync EDKII BaseTools to BaseTools project r2042.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10850 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/Ecc')
-rw-r--r--BaseTools/Source/Python/Ecc/Check.py292
-rw-r--r--BaseTools/Source/Python/Ecc/Configuration.py63
-rw-r--r--BaseTools/Source/Python/Ecc/Database.py109
-rw-r--r--BaseTools/Source/Python/Ecc/Ecc.py4
-rw-r--r--BaseTools/Source/Python/Ecc/EccGlobalData.py2
-rw-r--r--BaseTools/Source/Python/Ecc/EccToolError.py2
-rw-r--r--BaseTools/Source/Python/Ecc/MetaDataParser.py21
-rw-r--r--BaseTools/Source/Python/Ecc/c.py48
-rw-r--r--BaseTools/Source/Python/Ecc/config.ini15
9 files changed, 339 insertions, 217 deletions
diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py
index dbfedb514b..1e9ce34f8b 100644
--- a/BaseTools/Source/Python/Ecc/Check.py
+++ b/BaseTools/Source/Python/Ecc/Check.py
@@ -30,6 +30,7 @@ class Check(object):
# Check all required checkpoints
def Check(self):
+ self.GeneralCheck()
self.MetaDataFileCheck()
self.DoxygenCheck()
self.IncludeFileCheck()
@@ -38,6 +39,29 @@ class Check(object):
self.FunctionLayoutCheck()
self.NamingConventionCheck()
+ # General Checking
+ def GeneralCheck(self):
+ self.GeneralCheckNonAcsii()
+
+ # Check whether file has non ACSII char
+ def GeneralCheckNonAcsii(self):
+ if EccGlobalData.gConfig.GeneralCheckNonAcsii == '1' or EccGlobalData.gConfig.GeneralCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
+ EdkLogger.quiet("Checking Non-ACSII char in file ...")
+ SqlCommand = """select ID, FullPath, ExtName from File"""
+ RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
+ for Record in RecordSet:
+ if Record[2].upper() not in EccGlobalData.gConfig.BinaryExtList:
+ op = open(Record[1]).readlines()
+ IndexOfLine = 0
+ for Line in op:
+ IndexOfLine += 1
+ IndexOfChar = 0
+ for Char in Line:
+ IndexOfChar += 1
+ if ord(Char) > 126:
+ OtherMsg = "File %s has Non-ASCII char at line %s column %s" %(Record[1], IndexOfLine, IndexOfChar)
+ EccGlobalData.gDb.TblReport.Insert(ERROR_GENERAL_CHECK_NON_ACSII, OtherMsg = OtherMsg, BelongsToTable = 'File', BelongsToItem = Record[0])
+
# C Function Layout Checking
def FunctionLayoutCheck(self):
self.FunctionLayoutCheckReturnType()
@@ -67,22 +91,26 @@ class Check(object):
if EccGlobalData.gConfig.CFunctionLayoutCheckReturnType == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking function layout return type ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.c', '.h'):
- FullName = os.path.join(Dirpath, F)
- c.CheckFuncLayoutReturnType(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.c', '.h'):
+# FullName = os.path.join(Dirpath, F)
+# c.CheckFuncLayoutReturnType(FullName)
+ for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:
+ c.CheckFuncLayoutReturnType(FullName)
# Check whether any optional functional modifiers exist and next to the return type
def FunctionLayoutCheckModifier(self):
if EccGlobalData.gConfig.CFunctionLayoutCheckOptionalFunctionalModifier == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking function layout modifier ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.c', '.h'):
- FullName = os.path.join(Dirpath, F)
- c.CheckFuncLayoutModifier(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.c', '.h'):
+# FullName = os.path.join(Dirpath, F)
+# c.CheckFuncLayoutModifier(FullName)
+ for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:
+ c.CheckFuncLayoutModifier(FullName)
# Check whether the next line contains the function name, left justified, followed by the beginning of the parameter list
# Check whether the closing parenthesis is on its own line and also indented two spaces
@@ -90,33 +118,41 @@ class Check(object):
if EccGlobalData.gConfig.CFunctionLayoutCheckFunctionName == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking function layout function name ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.c', '.h'):
- FullName = os.path.join(Dirpath, F)
- c.CheckFuncLayoutName(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.c', '.h'):
+# FullName = os.path.join(Dirpath, F)
+# c.CheckFuncLayoutName(FullName)
+ for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:
+ c.CheckFuncLayoutName(FullName)
+
# Check whether the function prototypes in include files have the same form as function definitions
def FunctionLayoutCheckPrototype(self):
if EccGlobalData.gConfig.CFunctionLayoutCheckFunctionPrototype == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking function layout function prototype ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.c'):
- FullName = os.path.join(Dirpath, F)
- EdkLogger.quiet("[PROTOTYPE]" + FullName)
- c.CheckFuncLayoutPrototype(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.c'):
+# FullName = os.path.join(Dirpath, F)
+# EdkLogger.quiet("[PROTOTYPE]" + FullName)
+# c.CheckFuncLayoutPrototype(FullName)
+ for FullName in EccGlobalData.gCFileList:
+ EdkLogger.quiet("[PROTOTYPE]" + FullName)
+ c.CheckFuncLayoutPrototype(FullName)
# Check whether the body of a function is contained by open and close braces that must be in the first column
def FunctionLayoutCheckBody(self):
if EccGlobalData.gConfig.CFunctionLayoutCheckFunctionBody == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking function layout function body ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.c'):
- FullName = os.path.join(Dirpath, F)
- c.CheckFuncLayoutBody(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.c'):
+# FullName = os.path.join(Dirpath, F)
+# c.CheckFuncLayoutBody(FullName)
+ for FullName in EccGlobalData.gCFileList:
+ c.CheckFuncLayoutBody(FullName)
# Check whether the data declarations is the first code in a module.
# self.CFunctionLayoutCheckDataDeclaration = 1
@@ -125,11 +161,14 @@ class Check(object):
if EccGlobalData.gConfig.CFunctionLayoutCheckNoInitOfVariable == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking function layout local variables ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.c'):
- FullName = os.path.join(Dirpath, F)
- c.CheckFuncLayoutLocalVariable(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.c'):
+# FullName = os.path.join(Dirpath, F)
+# c.CheckFuncLayoutLocalVariable(FullName)
+
+ for FullName in EccGlobalData.gCFileList:
+ c.CheckFuncLayoutLocalVariable(FullName)
# Check whether no use of STATIC for functions
# self.CFunctionLayoutCheckNoStatic = 1
@@ -150,22 +189,26 @@ class Check(object):
if EccGlobalData.gConfig.DeclarationDataTypeCheckNoUseCType == '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking Declaration No use C type ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.h', '.c'):
- FullName = os.path.join(Dirpath, F)
- c.CheckDeclNoUseCType(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.h', '.c'):
+# FullName = os.path.join(Dirpath, F)
+# c.CheckDeclNoUseCType(FullName)
+ for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:
+ c.CheckDeclNoUseCType(FullName)
# Check whether the modifiers IN, OUT, OPTIONAL, and UNALIGNED are used only to qualify arguments to a function and should not appear in a data type declaration
def DeclCheckInOutModifier(self):
if EccGlobalData.gConfig.DeclarationDataTypeCheckInOutModifier == '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking Declaration argument modifier ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.h', '.c'):
- FullName = os.path.join(Dirpath, F)
- c.CheckDeclArgModifier(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.h', '.c'):
+# FullName = os.path.join(Dirpath, F)
+# c.CheckDeclArgModifier(FullName)
+ for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:
+ c.CheckDeclArgModifier(FullName)
# Check whether the EFIAPI modifier should be used at the entry of drivers, events, and member functions of protocols
def DeclCheckEFIAPIModifier(self):
@@ -177,24 +220,30 @@ class Check(object):
if EccGlobalData.gConfig.DeclarationDataTypeCheckEnumeratedType == '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking Declaration enum typedef ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.h', '.c'):
- FullName = os.path.join(Dirpath, F)
- EdkLogger.quiet("[ENUM]" + FullName)
- c.CheckDeclEnumTypedef(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.h', '.c'):
+# FullName = os.path.join(Dirpath, F)
+# EdkLogger.quiet("[ENUM]" + FullName)
+# c.CheckDeclEnumTypedef(FullName)
+ for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:
+ EdkLogger.quiet("[ENUM]" + FullName)
+ c.CheckDeclEnumTypedef(FullName)
# Check whether Structure Type has a 'typedef' and the name is capital
def DeclCheckStructureDeclaration(self):
if EccGlobalData.gConfig.DeclarationDataTypeCheckStructureDeclaration == '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking Declaration struct typedef ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.h', '.c'):
- FullName = os.path.join(Dirpath, F)
- EdkLogger.quiet("[STRUCT]" + FullName)
- c.CheckDeclStructTypedef(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.h', '.c'):
+# FullName = os.path.join(Dirpath, F)
+# EdkLogger.quiet("[STRUCT]" + FullName)
+# c.CheckDeclStructTypedef(FullName)
+ for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:
+ EdkLogger.quiet("[STRUCT]" + FullName)
+ c.CheckDeclStructTypedef(FullName)
# Check whether having same Structure
def DeclCheckSameStructure(self):
@@ -223,12 +272,15 @@ class Check(object):
if EccGlobalData.gConfig.DeclarationDataTypeCheckUnionType == '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking Declaration union typedef ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.h', '.c'):
- FullName = os.path.join(Dirpath, F)
- EdkLogger.quiet("[UNION]" + FullName)
- c.CheckDeclUnionTypedef(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.h', '.c'):
+# FullName = os.path.join(Dirpath, F)
+# EdkLogger.quiet("[UNION]" + FullName)
+# c.CheckDeclUnionTypedef(FullName)
+ for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:
+ EdkLogger.quiet("[UNION]" + FullName)
+ c.CheckDeclUnionTypedef(FullName)
# Predicate Expression Checking
def PredicateExpressionCheck(self):
@@ -241,35 +293,46 @@ class Check(object):
if EccGlobalData.gConfig.PredicateExpressionCheckBooleanValue == '1' or EccGlobalData.gConfig.PredicateExpressionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking predicate expression Boolean value ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.c'):
- FullName = os.path.join(Dirpath, F)
- EdkLogger.quiet("[BOOLEAN]" + FullName)
- c.CheckBooleanValueComparison(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.c'):
+# FullName = os.path.join(Dirpath, F)
+# EdkLogger.quiet("[BOOLEAN]" + FullName)
+# c.CheckBooleanValueComparison(FullName)
+ for FullName in EccGlobalData.gCFileList:
+ EdkLogger.quiet("[BOOLEAN]" + FullName)
+ c.CheckBooleanValueComparison(FullName)
# Check whether Non-Boolean comparisons use a compare operator (==, !=, >, < >=, <=).
def PredicateExpressionCheckNonBooleanOperator(self):
if EccGlobalData.gConfig.PredicateExpressionCheckNonBooleanOperator == '1' or EccGlobalData.gConfig.PredicateExpressionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking predicate expression Non-Boolean variable...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.c'):
- FullName = os.path.join(Dirpath, F)
- EdkLogger.quiet("[NON-BOOLEAN]" + FullName)
- c.CheckNonBooleanValueComparison(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.c'):
+# FullName = os.path.join(Dirpath, F)
+# EdkLogger.quiet("[NON-BOOLEAN]" + FullName)
+# c.CheckNonBooleanValueComparison(FullName)
+ for FullName in EccGlobalData.gCFileList:
+ EdkLogger.quiet("[NON-BOOLEAN]" + FullName)
+ c.CheckNonBooleanValueComparison(FullName)
+
# Check whether a comparison of any pointer to zero must be done via the NULL type
def PredicateExpressionCheckComparisonNullType(self):
if EccGlobalData.gConfig.PredicateExpressionCheckComparisonNullType == '1' or EccGlobalData.gConfig.PredicateExpressionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking predicate expression NULL pointer ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.c'):
- FullName = os.path.join(Dirpath, F)
- EdkLogger.quiet("[POINTER]" + FullName)
- c.CheckPointerNullComparison(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.c'):
+# FullName = os.path.join(Dirpath, F)
+# EdkLogger.quiet("[POINTER]" + FullName)
+# c.CheckPointerNullComparison(FullName)
+ for FullName in EccGlobalData.gCFileList:
+ EdkLogger.quiet("[POINTER]" + FullName)
+ c.CheckPointerNullComparison(FullName)
+
# Include file checking
def IncludeFileCheck(self):
self.IncludeFileCheckIfndef()
@@ -309,22 +372,26 @@ class Check(object):
if EccGlobalData.gConfig.IncludeFileCheckIfndefStatement == '1' or EccGlobalData.gConfig.IncludeFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking header file ifndef ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.h'):
- FullName = os.path.join(Dirpath, F)
- MsgList = c.CheckHeaderFileIfndef(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.h'):
+# FullName = os.path.join(Dirpath, F)
+# MsgList = c.CheckHeaderFileIfndef(FullName)
+ for FullName in EccGlobalData.gHFileList:
+ MsgList = c.CheckHeaderFileIfndef(FullName)
# Check whether include files NOT contain code or define data variables
def IncludeFileCheckData(self):
if EccGlobalData.gConfig.IncludeFileCheckData == '1' or EccGlobalData.gConfig.IncludeFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking header file data ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.h'):
- FullName = os.path.join(Dirpath, F)
- MsgList = c.CheckHeaderFileData(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.h'):
+# FullName = os.path.join(Dirpath, F)
+# MsgList = c.CheckHeaderFileData(FullName)
+ for FullName in EccGlobalData.gHFileList:
+ MsgList = c.CheckHeaderFileData(FullName)
# Doxygen document checking
def DoxygenCheck(self):
@@ -347,24 +414,28 @@ class Check(object):
MsgList = c.CheckFileHeaderDoxygenComments(FullName)
elif Ext in ('.inf', '.dec', '.dsc', '.fdf'):
FullName = os.path.join(Dirpath, F)
- if not open(FullName).read().startswith('## @file'):
+ op = open(FullName).readlines()
+ if not op[0].startswith('## @file') and op[6].startswith('## @file') and op[7].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):
if EccGlobalData.gConfig.DoxygenCheckFunctionHeader == '1' or EccGlobalData.gConfig.DoxygenCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking Doxygen function header ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.h', '.c'):
- FullName = os.path.join(Dirpath, F)
- MsgList = c.CheckFuncHeaderDoxygenComments(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.h', '.c'):
+# FullName = os.path.join(Dirpath, F)
+# MsgList = c.CheckFuncHeaderDoxygenComments(FullName)
+ for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:
+ MsgList = c.CheckFuncHeaderDoxygenComments(FullName)
+
# Check whether the first line of text in a comment block is a brief description of the element being documented.
# The brief description must end with a period.
@@ -377,22 +448,26 @@ class Check(object):
if EccGlobalData.gConfig.DoxygenCheckCommentFormat == '1' or EccGlobalData.gConfig.DoxygenCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking Doxygen comment ///< ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.h', '.c'):
- FullName = os.path.join(Dirpath, F)
- MsgList = c.CheckDoxygenTripleForwardSlash(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.h', '.c'):
+# FullName = os.path.join(Dirpath, F)
+# MsgList = c.CheckDoxygenTripleForwardSlash(FullName)
+ for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:
+ MsgList = c.CheckDoxygenTripleForwardSlash(FullName)
# Check whether only Doxygen commands allowed to mark the code are @bug and @todo.
def DoxygenCheckCommand(self):
if EccGlobalData.gConfig.DoxygenCheckCommand == '1' or EccGlobalData.gConfig.DoxygenCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking Doxygen command ...")
- for Dirpath, Dirnames, Filenames in self.WalkTree():
- for F in Filenames:
- if os.path.splitext(F)[1] in ('.h', '.c'):
- FullName = os.path.join(Dirpath, F)
- MsgList = c.CheckDoxygenCommand(FullName)
+# for Dirpath, Dirnames, Filenames in self.WalkTree():
+# for F in Filenames:
+# if os.path.splitext(F)[1] in ('.h', '.c'):
+# FullName = os.path.join(Dirpath, F)
+# MsgList = c.CheckDoxygenCommand(FullName)
+ for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:
+ MsgList = c.CheckDoxygenCommand(FullName)
# Meta-Data File Processing Checking
def MetaDataFileCheck(self):
@@ -556,7 +631,6 @@ class Check(object):
SqlCommand2 = """select Name from File where ID = %s""" %Record[5]
DscFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand1)[0][0])[0]
FdfFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand2)[0][0])[0]
- print DscFileName, 111, FdfFileName
if DscFileName != FdfFileName:
continue
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1]):
@@ -680,8 +754,8 @@ class Check(object):
SqlCommand = """
select ID from File where FullPath in
(select B.Path || '\\' || A.Value1 from INF as A, File as B where A.Model = %s and A.BelongsToFile = %s
- and B.ID = %s)
- """ %(MODEL_EFI_SOURCE_FILE, BelongsToFile, BelongsToFile)
+ and B.ID = %s and (B.Model = %s or B.Model = %s))
+ """ %(MODEL_EFI_SOURCE_FILE, BelongsToFile, BelongsToFile, MODEL_FILE_C, MODEL_FILE_H)
TableSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
for Tbl in TableSet:
TblName = 'Identifier' + str(Tbl[0])
@@ -714,7 +788,7 @@ class Check(object):
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':
@@ -733,7 +807,7 @@ class Check(object):
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):
diff --git a/BaseTools/Source/Python/Ecc/Configuration.py b/BaseTools/Source/Python/Ecc/Configuration.py
index 310cb5716b..1478ee6351 100644
--- a/BaseTools/Source/Python/Ecc/Configuration.py
+++ b/BaseTools/Source/Python/Ecc/Configuration.py
@@ -28,7 +28,7 @@ from Common.String import *
class Configuration(object):
def __init__(self, Filename):
self.Filename = Filename
-
+
self.Version = 0.1
## Identify to if check all items
@@ -49,14 +49,14 @@ class Configuration(object):
# SpaceCheckAll
#
self.AutoCorrect = 0
-
+
# List customized Modifer here, split with ','
# Defaultly use the definition in class DataType
self.ModifierList = MODIFIER_LIST
-
+
## General Checking
self.GeneralCheckAll = 0
-
+
# Check whether NO Tab is used, replaced with spaces
self.GeneralCheckNoTab = 1
# The width of Tab
@@ -77,31 +77,33 @@ class Configuration(object):
self.GeneralCheckCarriageReturn = 1
# Check whether the file exists
self.GeneralCheckFileExistence = 1
-
+ # Check whether file has non ACSII char
+ self.GeneralCheckNonAcsii = 1
+
## Space Checking
self.SpaceCheckAll = 1
-
+
## Predicate Expression Checking
self.PredicateExpressionCheckAll = 0
-
+
# Check whether Boolean values, variable type BOOLEAN not use explicit comparisons to TRUE or FALSE
self.PredicateExpressionCheckBooleanValue = 1
- # Check whether Non-Boolean comparisons use a compare operator (==, !=, >, < >=, <=).
+ # Check whether Non-Boolean comparisons use a compare operator (==, !=, >, < >=, <=).
self.PredicateExpressionCheckNonBooleanOperator = 1
# Check whether a comparison of any pointer to zero must be done via the NULL type
self.PredicateExpressionCheckComparisonNullType = 1
-
+
## Headers Checking
self.HeaderCheckAll = 0
-
+
# Check whether File header exists
self.HeaderCheckFile = 1
# Check whether Function header exists
self.HeaderCheckFunction = 1
-
+
## C Function Layout Checking
self.CFunctionLayoutCheckAll = 0
-
+
# Check whether return type exists and in the first line
self.CFunctionLayoutCheckReturnType = 1
# Check whether any optional functional modifiers exist and next to the return type
@@ -119,10 +121,10 @@ class Configuration(object):
self.CFunctionLayoutCheckNoInitOfVariable = 1
# Check whether no use of STATIC for functions
self.CFunctionLayoutCheckNoStatic = 1
-
+
## Include Files Checking
self.IncludeFileCheckAll = 0
-
+
#Check whether having include files with same name
self.IncludeFileCheckSameName = 1
# Check whether all include file contents is guarded by a #ifndef statement.
@@ -132,10 +134,10 @@ class Configuration(object):
# Check whether include files contain only public or only private data
# Check whether include files NOT contain code or define data variables
self.IncludeFileCheckData = 1
-
+
## Declarations and Data Types Checking
self.DeclarationDataTypeCheckAll = 0
-
+
# Check whether no use of int, unsigned, char, void, static, long in any .c, .h or .asl files.
self.DeclarationDataTypeCheckNoUseCType = 1
# Check whether the modifiers IN, OUT, OPTIONAL, and UNALIGNED are used only to qualify arguments to a function and should not appear in a data type declaration
@@ -150,10 +152,10 @@ class Configuration(object):
self.DeclarationDataTypeCheckSameStructure = 1
# Check whether Union Type has a 'typedef' and the name is capital
self.DeclarationDataTypeCheckUnionType = 1
-
+
## Naming Conventions Checking
self.NamingConventionCheckAll = 0
-
+
# Check whether only capital letters are used for #define declarations
self.NamingConventionCheckDefineStatement = 1
# Check whether only capital letters are used for typedef declarations
@@ -172,33 +174,33 @@ class Configuration(object):
self.NamingConventionCheckFunctionName = 1
# Check whether NO use short variable name with single character
self.NamingConventionCheckSingleCharacterVariable = 1
-
+
## Doxygen Checking
self.DoxygenCheckAll = 0
-
+
# Check whether the file headers are followed Doxygen special documentation blocks in section 2.3.5
self.DoxygenCheckFileHeader = 1
# Check whether the function headers are followed Doxygen special documentation blocks in section 2.3.5
self.DoxygenCheckFunctionHeader = 1
- # Check whether the first line of text in a comment block is a brief description of the element being documented.
+ # Check whether the first line of text in a comment block is a brief description of the element being documented.
# The brief description must end with a period.
self.DoxygenCheckCommentDescription = 1
# Check whether comment lines with '///< ... text ...' format, if it is used, it should be after the code section.
self.DoxygenCheckCommentFormat = 1
# Check whether only Doxygen commands allowed to mark the code are @bug and @todo.
self.DoxygenCheckCommand = 1
-
+
## Meta-Data File Processing Checking
self.MetaDataFileCheckAll = 0
-
+
# Check whether each file defined in meta-data exists
self.MetaDataFileCheckPathName = 1
# Generate a list for all files defined in meta-data files
self.MetaDataFileCheckGenerateFileList = 1
# The path of log file
self.MetaDataFileCheckPathOfGenerateFileList = 'File.log'
- # Check whether all Library Instances defined for a given module (or dependent library instance) match the module's type.
- # Each Library Instance must specify the Supported Module Types in its INF file,
+ # Check whether all Library Instances defined for a given module (or dependent library instance) match the module's type.
+ # Each Library Instance must specify the Supported Module Types in its INF file,
# and any module specifying the library instance must be one of the supported types.
self.MetaDataFileCheckLibraryInstance = 1
# Check whether a Library Instance has been defined for all dependent library classes
@@ -235,14 +237,17 @@ class Configuration(object):
# The directory listed here will not be parsed, split with ','
self.SkipDirList = []
+ # A list for binary file ext name
+ self.BinaryExtList = []
+
self.ParseConfig()
-
+
def ParseConfig(self):
Filepath = os.path.normpath(self.Filename)
if not os.path.isfile(Filepath):
ErrorMsg = "Can't find configuration file '%s'" % Filepath
EdkLogger.error("Ecc", EdkLogger.ECC_ERROR, ErrorMsg, File = Filepath)
-
+
LineNo = 0
for Line in open(Filepath, 'r'):
LineNo = LineNo + 1
@@ -258,8 +263,10 @@ class Configuration(object):
continue
if List[0] == 'SkipDirList':
List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
+ if List[0] == 'BinaryExtList':
+ List[1] = GetSplitValueList(List[1], TAB_COMMA_SPLIT)
self.__dict__[List[0]] = List[1]
-
+
def ShowMe(self):
print self.Filename
for Key in self.__dict__.keys():
diff --git a/BaseTools/Source/Python/Ecc/Database.py b/BaseTools/Source/Python/Ecc/Database.py
index 9520be4345..4b79cb708f 100644
--- a/BaseTools/Source/Python/Ecc/Database.py
+++ b/BaseTools/Source/Python/Ecc/Database.py
@@ -41,7 +41,7 @@ DATABASE_PATH = "Ecc.db"
# This class defined the ECC databse
# During the phase of initialization, the database will create all tables and
# insert all records of table DataModel
-#
+#
# @param object: Inherited from object class
# @param DbPath: A string for the path of the ECC database
#
@@ -64,7 +64,7 @@ class Database(object):
self.TblDec = None
self.TblDsc = None
self.TblFdf = None
-
+
## Initialize ECC database
#
# 1. Delete all old existing tables
@@ -85,7 +85,7 @@ class Database(object):
# to avoid non-ascii charater conversion error
self.Conn.text_factory = str
self.Cur = self.Conn.cursor()
-
+
self.TblDataModel = TableDataModel(self.Cur)
self.TblFile = TableFile(self.Cur)
self.TblFunction = TableFunction(self.Cur)
@@ -96,7 +96,7 @@ class Database(object):
self.TblDec = TableDec(self.Cur)
self.TblDsc = TableDsc(self.Cur)
self.TblFdf = TableFdf(self.Cur)
-
+
#
# Create new tables
#
@@ -110,7 +110,7 @@ class Database(object):
self.TblDec.Create()
self.TblDsc.Create()
self.TblFdf.Create()
-
+
#
# Init each table's ID
#
@@ -123,13 +123,13 @@ class Database(object):
self.TblDec.InitID()
self.TblDsc.InitID()
self.TblFdf.InitID()
-
+
#
# Initialize table DataModel
#
if NewDatabase:
self.TblDataModel.InitTable()
-
+
EdkLogger.verbose("Initialize ECC database ... DONE!")
## Query a table
@@ -138,7 +138,7 @@ class Database(object):
#
def QueryTable(self, Table):
Table.Query()
-
+
## Close entire database
#
# Commit all first
@@ -147,15 +147,15 @@ class Database(object):
def Close(self):
#
# Commit to file
- #
+ #
self.Conn.commit()
-
+
#
# Close connection and cursor
#
self.Cur.close()
self.Conn.close()
-
+
## Insert one file information
#
# Insert one file's information to the database
@@ -171,43 +171,44 @@ class Database(object):
# Insert a record for file
#
FileID = self.TblFile.Insert(File.Name, File.ExtName, File.Path, File.FullPath, Model = File.Model, TimeStamp = File.TimeStamp)
- IdTable = TableIdentifier(self.Cur)
- IdTable.Table = "Identifier%s" % FileID
- IdTable.Create()
- #
- # Insert function of file
- #
- for Function in File.FunctionList:
- FunctionID = self.TblFunction.Insert(Function.Header, Function.Modifier, Function.Name, Function.ReturnStatement, \
- Function.StartLine, Function.StartColumn, Function.EndLine, Function.EndColumn, \
- Function.BodyStartLine, Function.BodyStartColumn, FileID, \
- Function.FunNameStartLine, Function.FunNameStartColumn)
+ if File.Model == DataClass.MODEL_FILE_C or File.Model == DataClass.MODEL_FILE_H:
+ IdTable = TableIdentifier(self.Cur)
+ IdTable.Table = "Identifier%s" % FileID
+ IdTable.Create()
+ #
+ # Insert function of file
+ #
+ for Function in File.FunctionList:
+ FunctionID = self.TblFunction.Insert(Function.Header, Function.Modifier, Function.Name, Function.ReturnStatement, \
+ Function.StartLine, Function.StartColumn, Function.EndLine, Function.EndColumn, \
+ Function.BodyStartLine, Function.BodyStartColumn, FileID, \
+ Function.FunNameStartLine, Function.FunNameStartColumn)
+ #
+ # Insert Identifier of function
+ #
+ for Identifier in Function.IdentifierList:
+ IdentifierID = IdTable.Insert(Identifier.Modifier, Identifier.Type, Identifier.Name, Identifier.Value, Identifier.Model, \
+ FileID, FunctionID, Identifier.StartLine, Identifier.StartColumn, Identifier.EndLine, Identifier.EndColumn)
+ #
+ # Insert Pcd of function
+ #
+ for Pcd in Function.PcdList:
+ PcdID = self.TblPcd.Insert(Pcd.CName, Pcd.TokenSpaceGuidCName, Pcd.Token, Pcd.DatumType, Pcd.Model, \
+ FileID, FunctionID, Pcd.StartLine, Pcd.StartColumn, Pcd.EndLine, Pcd.EndColumn)
#
- # Insert Identifier of function
+ # Insert Identifier of file
#
- for Identifier in Function.IdentifierList:
+ for Identifier in File.IdentifierList:
IdentifierID = IdTable.Insert(Identifier.Modifier, Identifier.Type, Identifier.Name, Identifier.Value, Identifier.Model, \
- FileID, FunctionID, Identifier.StartLine, Identifier.StartColumn, Identifier.EndLine, Identifier.EndColumn)
+ FileID, -1, Identifier.StartLine, Identifier.StartColumn, Identifier.EndLine, Identifier.EndColumn)
#
- # Insert Pcd of function
+ # Insert Pcd of file
#
- for Pcd in Function.PcdList:
+ for Pcd in File.PcdList:
PcdID = self.TblPcd.Insert(Pcd.CName, Pcd.TokenSpaceGuidCName, Pcd.Token, Pcd.DatumType, Pcd.Model, \
- FileID, FunctionID, Pcd.StartLine, Pcd.StartColumn, Pcd.EndLine, Pcd.EndColumn)
- #
- # Insert Identifier of file
- #
- for Identifier in File.IdentifierList:
- IdentifierID = IdTable.Insert(Identifier.Modifier, Identifier.Type, Identifier.Name, Identifier.Value, Identifier.Model, \
- FileID, -1, Identifier.StartLine, Identifier.StartColumn, Identifier.EndLine, Identifier.EndColumn)
- #
- # Insert Pcd of file
- #
- for Pcd in File.PcdList:
- PcdID = self.TblPcd.Insert(Pcd.CName, Pcd.TokenSpaceGuidCName, Pcd.Token, Pcd.DatumType, Pcd.Model, \
- FileID, -1, Pcd.StartLine, Pcd.StartColumn, Pcd.EndLine, Pcd.EndColumn)
-
+ FileID, -1, Pcd.StartLine, Pcd.StartColumn, Pcd.EndLine, Pcd.EndColumn)
+
EdkLogger.verbose("Insert information from file %s ... DONE!" % File.FullPath)
## UpdateIdentifierBelongsToFunction
@@ -217,7 +218,7 @@ class Database(object):
#
def UpdateIdentifierBelongsToFunction_disabled(self):
EdkLogger.verbose("Update 'BelongsToFunction' for Identifiers started ...")
-
+
SqlCommand = """select ID, BelongsToFile, StartLine, EndLine, Model from Identifier"""
EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand)
self.Cur.execute(SqlCommand)
@@ -233,7 +234,7 @@ class Database(object):
# Check whether an identifier belongs to a function
#
EdkLogger.debug(4, "For common identifiers ... ")
- SqlCommand = """select ID from Function
+ SqlCommand = """select ID from Function
where StartLine < %s and EndLine > %s
and BelongsToFile = %s""" % (StartLine, EndLine, BelongsToFile)
EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand)
@@ -243,13 +244,13 @@ class Database(object):
SqlCommand = """Update Identifier set BelongsToFunction = %s where ID = %s""" % (ID[0], IdentifierID)
EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand)
self.Cur.execute(SqlCommand)
-
+
#
# Check whether the identifier is a function header
#
- EdkLogger.debug(4, "For function headers ... ")
+ EdkLogger.debug(4, "For function headers ... ")
if Model == DataClass.MODEL_IDENTIFIER_COMMENT:
- SqlCommand = """select ID from Function
+ SqlCommand = """select ID from Function
where StartLine = %s + 1
and BelongsToFile = %s""" % (EndLine, BelongsToFile)
EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand)
@@ -259,7 +260,7 @@ class Database(object):
SqlCommand = """Update Identifier set BelongsToFunction = %s, Model = %s where ID = %s""" % (ID[0], DataClass.MODEL_IDENTIFIER_FUNCTION_HEADER, IdentifierID)
EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand)
self.Cur.execute(SqlCommand)
-
+
EdkLogger.verbose("Update 'BelongsToFunction' for Identifiers ... DONE")
@@ -270,7 +271,7 @@ class Database(object):
#
def UpdateIdentifierBelongsToFunction(self):
EdkLogger.verbose("Update 'BelongsToFunction' for Identifiers started ...")
-
+
SqlCommand = """select ID, BelongsToFile, StartLine, EndLine from Function"""
Records = self.TblFunction.Exec(SqlCommand)
Data1 = []
@@ -308,7 +309,7 @@ class Database(object):
# self.Cur.executemany(SqlCommand, Data2)
#
# EdkLogger.verbose("Update 'BelongsToFunction' for Identifiers ... DONE")
-
+
##
#
@@ -320,11 +321,11 @@ if __name__ == '__main__':
#EdkLogger.SetLevel(EdkLogger.VERBOSE)
EdkLogger.SetLevel(EdkLogger.DEBUG_0)
EdkLogger.verbose("Start at " + time.strftime('%H:%M:%S', time.localtime()))
-
+
Db = Database(DATABASE_PATH)
Db.InitDatabase()
Db.QueryTable(Db.TblDataModel)
-
+
identifier1 = DataClass.IdentifierClass(-1, '', '', "i''1", 'aaa', DataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 32, 43, 54, 43)
identifier2 = DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', DataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 15, 43, 20, 43)
identifier3 = DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', DataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 55, 43, 58, 43)
@@ -333,12 +334,12 @@ if __name__ == '__main__':
file = DataClass.FileClass(-1, 'F1', 'c', 'C:\\', 'C:\\F1.exe', DataClass.MODEL_FILE_C, '2007-12-28', [fun1], [identifier1, identifier2, identifier3, identifier4], [])
Db.InsertOneFile(file)
Db.UpdateIdentifierBelongsToFunction()
-
+
Db.QueryTable(Db.TblFile)
Db.QueryTable(Db.TblFunction)
Db.QueryTable(Db.TblPcd)
Db.QueryTable(Db.TblIdentifier)
-
+
Db.Close()
EdkLogger.verbose("End at " + time.strftime('%H:%M:%S', time.localtime()))
-
+
diff --git a/BaseTools/Source/Python/Ecc/Ecc.py b/BaseTools/Source/Python/Ecc/Ecc.py
index 62b265bbaa..e9a1c2a890 100644
--- a/BaseTools/Source/Python/Ecc/Ecc.py
+++ b/BaseTools/Source/Python/Ecc/Ecc.py
@@ -106,6 +106,8 @@ class Ecc(object):
self.BuildMetaDataFileDatabase()
EccGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EccGlobalData.gDb)
+ EccGlobalData.gCFileList = GetFileList(MODEL_FILE_C, EccGlobalData.gDb)
+ EccGlobalData.gHFileList = GetFileList(MODEL_FILE_H, EccGlobalData.gDb)
## BuildMetaDataFileDatabase
#
@@ -227,7 +229,7 @@ class Ecc(object):
if Options.Workspace:
os.environ["WORKSPACE"] = Options.Workspace
-
+
# Check workspace envirnoment
if "WORKSPACE" not in os.environ:
EdkLogger.error("ECC", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found",
diff --git a/BaseTools/Source/Python/Ecc/EccGlobalData.py b/BaseTools/Source/Python/Ecc/EccGlobalData.py
index 29e4aca0d0..5226e4a7d1 100644
--- a/BaseTools/Source/Python/Ecc/EccGlobalData.py
+++ b/BaseTools/Source/Python/Ecc/EccGlobalData.py
@@ -21,4 +21,6 @@ gTarget = ''
gConfig = None
gDb = None
gIdentifierTableList = []
+gCFileList = []
+gHFileList = []
gException = None \ No newline at end of file
diff --git a/BaseTools/Source/Python/Ecc/EccToolError.py b/BaseTools/Source/Python/Ecc/EccToolError.py
index 985737f192..48810e466c 100644
--- a/BaseTools/Source/Python/Ecc/EccToolError.py
+++ b/BaseTools/Source/Python/Ecc/EccToolError.py
@@ -19,6 +19,7 @@ ERROR_GENERAL_CHECK_NO_ASM = 1004
ERROR_GENERAL_CHECK_NO_PROGMA = 1005
ERROR_GENERAL_CHECK_CARRIAGE_RETURN = 1006
ERROR_GENERAL_CHECK_FILE_EXISTENCE = 1007
+ERROR_GENERAL_CHECK_NON_ACSII = 1008
ERROR_SPACE_CHECK_ALL = 2000
@@ -105,6 +106,7 @@ gEccErrorMessage = {
ERROR_GENERAL_CHECK_NO_PROGMA : """There should be no use of "#progma" in source file except "#pragma pack(#)\"""",
ERROR_GENERAL_CHECK_CARRIAGE_RETURN : "There should be a carriage return at the end of the file",
ERROR_GENERAL_CHECK_FILE_EXISTENCE : "File not found",
+ ERROR_GENERAL_CHECK_NON_ACSII : "File has invalid Non-ACSII char",
ERROR_SPACE_CHECK_ALL : "",
diff --git a/BaseTools/Source/Python/Ecc/MetaDataParser.py b/BaseTools/Source/Python/Ecc/MetaDataParser.py
index 36ad6e492f..4dda2e5360 100644
--- a/BaseTools/Source/Python/Ecc/MetaDataParser.py
+++ b/BaseTools/Source/Python/Ecc/MetaDataParser.py
@@ -26,7 +26,7 @@ def GetIncludeListOfFile(WorkSpace, Filepath, Db):
Filepath = os.path.normpath(Filepath)
SqlCommand = """
select Value1, FullPath from Inf, File where Inf.Model = %s and Inf.BelongsToFile in(
- select distinct B.BelongsToFile from File as A left join Inf as B
+ select distinct B.BelongsToFile from File as A left join Inf as B
where A.ID = B.BelongsToFile and B.Model = %s and (A.Path || '%s' || B.Value1) = '%s')
and Inf.BelongsToFile = File.ID""" \
% (MODEL_META_DATA_PACKAGE, MODEL_EFI_SOURCE_FILE, '\\', Filepath)
@@ -36,7 +36,7 @@ def GetIncludeListOfFile(WorkSpace, Filepath, Db):
InfFullPath = os.path.normpath(os.path.join(WorkSpace, Record[1]))
(DecPath, DecName) = os.path.split(DecFullPath)
(InfPath, InfName) = os.path.split(InfFullPath)
- SqlCommand = """select Value1 from Dec where BelongsToFile =
+ SqlCommand = """select Value1 from Dec where BelongsToFile =
(select ID from File where FullPath = '%s') and Model = %s""" \
% (DecFullPath, MODEL_EFI_INCLUDE)
NewRecordSet = Db.TblDec.Exec(SqlCommand)
@@ -46,9 +46,22 @@ def GetIncludeListOfFile(WorkSpace, Filepath, Db):
IncludePath = os.path.normpath(os.path.join(DecPath, NewRecord[0]))
if IncludePath not in IncludeList:
IncludeList.append(IncludePath)
-
+
return IncludeList
+## Get the file list
+#
+# Search table file and find all specific type files
+#
+def GetFileList(FileModel, Db):
+ FileList = []
+ SqlCommand = """select FullPath from File where Model = %s""" % str(FileModel)
+ RecordSet = Db.TblFile.Exec(SqlCommand)
+ for Record in RecordSet:
+ FileList.append(Record[0])
+
+ return FileList
+
## Get the table list
#
# Search table file and find all small tables
@@ -60,6 +73,6 @@ def GetTableList(FileModelList, Table, Db):
for Record in RecordSet:
TableName = Table + str(Record[0])
TableList.append(TableName)
-
+
return TableList
diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py
index 941392be0f..5a8c1d13e7 100644
--- a/BaseTools/Source/Python/Ecc/c.py
+++ b/BaseTools/Source/Python/Ecc/c.py
@@ -514,7 +514,9 @@ def CollectSourceCodeDataIntoDB(RootDir):
dirnames.append(Dirname)
for f in filenames:
+ collector = None
FullName = os.path.normpath(os.path.join(dirpath, f))
+ model = DataClass.MODEL_FILE_OTHERS
if os.path.splitext(f)[1] in ('.h', '.c'):
EdkLogger.info("Parsing " + FullName)
model = f.endswith('c') and DataClass.MODEL_FILE_C or DataClass.MODEL_FILE_H
@@ -526,12 +528,13 @@ def CollectSourceCodeDataIntoDB(RootDir):
collector.CleanFileProfileBuffer()
collector.ParseFileWithClearedPPDirective()
# collector.PrintFragments()
- BaseName = os.path.basename(f)
- DirName = os.path.dirname(FullName)
- Ext = os.path.splitext(f)[1].lstrip('.')
- ModifiedTime = os.path.getmtime(FullName)
- FileObj = DataClass.FileClass(-1, BaseName, Ext, DirName, FullName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), [])
- FileObjList.append(FileObj)
+ BaseName = os.path.basename(f)
+ DirName = os.path.dirname(FullName)
+ Ext = os.path.splitext(f)[1].lstrip('.')
+ ModifiedTime = os.path.getmtime(FullName)
+ FileObj = DataClass.FileClass(-1, BaseName, Ext, DirName, FullName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), [])
+ FileObjList.append(FileObj)
+ if collector:
collector.CleanFileProfileBuffer()
if len(ParseErrorFileList) > 0:
@@ -539,7 +542,8 @@ def CollectSourceCodeDataIntoDB(RootDir):
Db = GetDB()
for file in FileObjList:
- Db.InsertOneFile(file)
+ if file.ExtName.upper() not in ['INF', 'DEC', 'DSC', 'FDF']:
+ Db.InsertOneFile(file)
Db.UpdateIdentifierBelongsToFunction()
@@ -552,7 +556,6 @@ def GetTableID(FullFileName, ErrorMsgList = None):
from File
where FullPath like '%s'
""" % FullFileName
-
ResultSet = Db.TblFile.Exec(SqlStatement)
FileID = -1
@@ -567,6 +570,8 @@ def GetTableID(FullFileName, ErrorMsgList = None):
return FileID
def GetIncludeFileList(FullFileName):
+ if os.path.splitext(FullFileName)[1].upper() not in ('.H'):
+ return []
IFList = IncludeFileListDict.get(FullFileName)
if IFList != None:
return IFList
@@ -2301,21 +2306,32 @@ def CheckFileHeaderDoxygenComments(FullFileName):
FileTable = 'Identifier' + str(FileID)
SqlStatement = """ select Value, ID
from %s
- where Model = %d and StartLine = 1 and StartColumn = 0
+ where Model = %d and (StartLine = 1 or StartLine = 7 or StartLine = 8) and StartColumn = 0
""" % (FileTable, DataClass.MODEL_IDENTIFIER_COMMENT)
ResultSet = Db.TblFile.Exec(SqlStatement)
if len(ResultSet) == 0:
PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'No Comment appear at the very beginning of file.', 'File', FileID)
return ErrorMsgList
+ IsFoundError1 = True
+ IsFoundError2 = True
+ IsFoundError3 = True
for Result in ResultSet:
- CommentStr = Result[0]
- if not CommentStr.startswith('/** @file'):
- PrintErrorMsg(ERROR_DOXYGEN_CHECK_FILE_HEADER, 'File header comment should begin with ""/** @file""', FileTable, Result[1])
- if not CommentStr.endswith('**/'):
- PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header comment should end with **/', FileTable, Result[1])
- if CommentStr.find('.') == -1:
- PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMENT_DESCRIPTION, 'Comment description should end with period \'.\'', FileTable, Result[1])
+ CommentStr = Result[0].strip()
+ ID = Result[1]
+ if CommentStr.startswith('/** @file'):
+ IsFoundError1 = False
+ if CommentStr.endswith('**/'):
+ IsFoundError2 = False
+ if CommentStr.find('.') != -1:
+ IsFoundError3 = False
+
+ if IsFoundError1:
+ PrintErrorMsg(ERROR_DOXYGEN_CHECK_FILE_HEADER, 'File header comment should begin with ""/** @file""', FileTable, ID)
+ if IsFoundError2:
+ PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header comment should end with ""**/""', FileTable, ID)
+ if IsFoundError3:
+ PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMENT_DESCRIPTION, 'Comment description should end with period "".""', FileTable, ID)
def CheckFuncHeaderDoxygenComments(FullFileName):
ErrorMsgList = []
diff --git a/BaseTools/Source/Python/Ecc/config.ini b/BaseTools/Source/Python/Ecc/config.ini
index 973bc68b38..357c52ced0 100644
--- a/BaseTools/Source/Python/Ecc/config.ini
+++ b/BaseTools/Source/Python/Ecc/config.ini
@@ -21,7 +21,7 @@ Version = 0.1
# Identify to if check all items
# 1 - Check all items and ignore all other detailed items
# 0 - Not check all items, the tool will go through all other detailed items to decide to check or not
-#
+#
CheckAll = 0
#
@@ -68,6 +68,8 @@ GeneralCheckNoProgma = 1
GeneralCheckCarriageReturn = 1
# Check whether the file exists
GeneralCheckFileExistence = 1
+# Check whether file has non ACSII char
+GeneralCheckNonAcsii = 1
#
# Space Checking
@@ -81,7 +83,7 @@ PredicateExpressionCheckAll = 0
# Check whether Boolean values, variable type BOOLEAN not use explicit comparisons to TRUE or FALSE
PredicateExpressionCheckBooleanValue = 1
-# Check whether Non-Boolean comparisons use a compare operator (==, !=, >, < >=, <=).
+# Check whether Non-Boolean comparisons use a compare operator (==, !=, >, < >=, <=).
PredicateExpressionCheckNonBooleanOperator = 1
# Check whether a comparison of any pointer to zero must be done via the NULL type
PredicateExpressionCheckComparisonNullType = 1
@@ -189,7 +191,7 @@ DoxygenCheckAll = 0
DoxygenCheckFileHeader = 1
# Check whether the function headers are followed Doxygen special documentation blocks in section 2.3.5
DoxygenCheckFunctionHeader = 1
-# Check whether the first line of text in a comment block is a brief description of the element being documented.
+# Check whether the first line of text in a comment block is a brief description of the element being documented.
# The brief description must end with a period.
DoxygenCheckCommentDescription = 1
# Check whether comment lines with '///< ... text ...' format, if it is used, it should be after the code section.
@@ -208,8 +210,8 @@ MetaDataFileCheckPathName = 1
MetaDataFileCheckGenerateFileList = 1
# The path of log file
MetaDataFileCheckPathOfGenerateFileList = File.log
-# Check whether all Library Instances defined for a given module (or dependent library instance) match the module's type.
-# Each Library Instance must specify the Supported Module Types in its INF file,
+# Check whether all Library Instances defined for a given module (or dependent library instance) match the module's type.
+# Each Library Instance must specify the Supported Module Types in its INF file,
# and any module specifying the library instance must be one of the supported types.
MetaDataFileCheckLibraryInstance = 1
# Check whether a Library Instance has been defined for all dependent library classes
@@ -242,3 +244,6 @@ MetaDataFileCheckModuleFileGuidDuplication = 1
# GotoStatementCheckAll = 0
# SpellingCheckAll = 0
#
+
+# A list for binary file ext name
+BinaryExtList = EXE, EFI, FV, ROM, DLL, COM, BMP, GIF, PYD, CMP, BIN, JPG, UNI, RAW, COM2, LIB, DEPEX, SYS, DB