|
From: <hc...@us...> - 2010-08-16 11:30:50
|
Revision: 2015
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2015&view=rev
Author: hchen30
Date: 2010-08-16 11:30:42 +0000 (Mon, 16 Aug 2010)
Log Message:
-----------
1. Add a new checkpoint for ECC to check whether a file has Non-ASCII char.
Modified Paths:
--------------
trunk/BaseTools/Source/Python/CommonDataClass/DataClass.py
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/c.py
trunk/BaseTools/Source/Python/Ecc/config.ini
Modified: trunk/BaseTools/Source/Python/CommonDataClass/DataClass.py
===================================================================
--- trunk/BaseTools/Source/Python/CommonDataClass/DataClass.py 2010-08-11 07:29:32 UTC (rev 2014)
+++ trunk/BaseTools/Source/Python/CommonDataClass/DataClass.py 2010-08-16 11:30:42 UTC (rev 2015)
@@ -29,6 +29,7 @@
MODEL_FILE_FDF = 1014
MODEL_FILE_INC = 1015
MODEL_FILE_CIF = 1016
+MODEL_FILE_OTHERS = 1099
MODEL_IDENTIFIER_FILE_HEADER = 2001
MODEL_IDENTIFIER_FUNCTION_HEADER = 2002
@@ -104,6 +105,8 @@
('MODEL_FILE_DSC', MODEL_FILE_DSC),
('MODEL_FILE_FDF', MODEL_FILE_FDF),
('MODEL_FILE_INC', MODEL_FILE_INC),
+ ('MODEL_FILE_CIF', MODEL_FILE_CIF),
+ ('MODEL_FILE_OTHERS', MODEL_FILE_OTHERS),
('MODEL_IDENTIFIER_FILE_HEADER', MODEL_IDENTIFIER_FILE_HEADER),
('MODEL_IDENTIFIER_FUNCTION_HEADER', MODEL_IDENTIFIER_FUNCTION_HEADER),
('MODEL_IDENTIFIER_COMMENT', MODEL_IDENTIFIER_COMMENT),
@@ -167,10 +170,10 @@
## FunctionClass
#
# This class defines a structure of a function
-#
+#
# @param ID: ID of a Function
# @param Header: Header of a Function
-# @param Modifier: Modifier of a Function
+# @param Modifier: Modifier of a Function
# @param Name: Name of a Function
# @param ReturnStatement: ReturnStatement of a Funciont
# @param StartLine: StartLine of a Function
@@ -185,7 +188,7 @@
#
# @var ID: ID of a Function
# @var Header: Header of a Function
-# @var Modifier: Modifier of a Function
+# @var Modifier: Modifier of a Function
# @var Name: Name of a Function
# @var ReturnStatement: ReturnStatement of a Funciont
# @var StartLine: StartLine of a Function
@@ -206,7 +209,7 @@
FunNameStartLine = -1, FunNameStartColumn = -1):
self.ID = ID
self.Header = Header
- self.Modifier = Modifier
+ self.Modifier = Modifier
self.Name = Name
self.ReturnStatement = ReturnStatement
self.StartLine = StartLine
@@ -218,14 +221,14 @@
self.BelongsToFile = BelongsToFile
self.FunNameStartLine = FunNameStartLine
self.FunNameStartColumn = FunNameStartColumn
-
+
self.IdentifierList = IdentifierList
self.PcdList = PcdList
## IdentifierClass
#
# This class defines a structure of a variable
-#
+#
# @param ID: ID of a Identifier
# @param Modifier: Modifier of a Identifier
# @param Type: Type of a Identifier
@@ -271,7 +274,7 @@
## PcdClass
#
# This class defines a structure of a Pcd
-#
+#
# @param ID: ID of a Pcd
# @param CName: CName of a Pcd
# @param TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd
@@ -316,7 +319,7 @@
## FileClass
#
# This class defines a structure of a file
-#
+#
# @param ID: ID of a File
# @param Name: Name of a File
# @param ExtName: ExtName of a File
@@ -342,14 +345,14 @@
class FileClass(object):
def __init__(self, ID = -1, Name = '', ExtName = '', Path = '', FullPath = '', Model = MODEL_UNKNOWN, TimeStamp = '', \
FunctionList = [], IdentifierList = [], PcdList = []):
- self.ID = ID
+ self.ID = ID
self.Name = Name
- self.ExtName = ExtName
+ self.ExtName = ExtName
self.Path = Path
self.FullPath = FullPath
self.Model = Model
self.TimeStamp = TimeStamp
-
+
self.FunctionList = FunctionList
self.IdentifierList = IdentifierList
self.PcdList = PcdList
Modified: trunk/BaseTools/Source/Python/Ecc/Check.py
===================================================================
--- trunk/BaseTools/Source/Python/Ecc/Check.py 2010-08-11 07:29:32 UTC (rev 2014)
+++ trunk/BaseTools/Source/Python/Ecc/Check.py 2010-08-16 11:30:42 UTC (rev 2015)
@@ -30,6 +30,7 @@
# Check all required checkpoints
def Check(self):
+ self.GeneralCheck()
self.MetaDataFileCheck()
self.DoxygenCheck()
self.IncludeFileCheck()
@@ -38,6 +39,30 @@
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 ...")
+ BinaryExtList = ['EXE', 'EFI', 'FV', 'ROM', 'DLL', 'COM', 'BMP', 'GIF', 'PYD', 'CMP', 'BIN', 'JPG', 'UNI', 'RAW', 'COM2', 'LIB', 'DEPEX']
+ SqlCommand = """select ID, FullPath, ExtName from File"""
+ RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
+ for Record in RecordSet:
+ if Record[2].upper() not in 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()
Modified: trunk/BaseTools/Source/Python/Ecc/Configuration.py
===================================================================
--- trunk/BaseTools/Source/Python/Ecc/Configuration.py 2010-08-11 07:29:32 UTC (rev 2014)
+++ trunk/BaseTools/Source/Python/Ecc/Configuration.py 2010-08-16 11:30:42 UTC (rev 2015)
@@ -28,7 +28,7 @@
class Configuration(object):
def __init__(self, Filename):
self.Filename = Filename
-
+
self.Version = 0.1
## Identify to if check all items
@@ -49,14 +49,14 @@
# 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 @@
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 @@
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 @@
# 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 @@
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 @@
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
@@ -236,13 +238,13 @@
self.SkipDirList = []
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
@@ -259,7 +261,7 @@
if List[0] == 'SkipDirList':
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():
Modified: trunk/BaseTools/Source/Python/Ecc/EccToolError.py
===================================================================
--- trunk/BaseTools/Source/Python/Ecc/EccToolError.py 2010-08-11 07:29:32 UTC (rev 2014)
+++ trunk/BaseTools/Source/Python/Ecc/EccToolError.py 2010-08-16 11:30:42 UTC (rev 2015)
@@ -19,6 +19,7 @@
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 @@
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 : "",
Modified: trunk/BaseTools/Source/Python/Ecc/c.py
===================================================================
--- trunk/BaseTools/Source/Python/Ecc/c.py 2010-08-11 07:29:32 UTC (rev 2014)
+++ trunk/BaseTools/Source/Python/Ecc/c.py 2010-08-16 11:30:42 UTC (rev 2015)
@@ -514,7 +514,9 @@
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 @@
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:
Modified: trunk/BaseTools/Source/Python/Ecc/config.ini
===================================================================
--- trunk/BaseTools/Source/Python/Ecc/config.ini 2010-08-11 07:29:32 UTC (rev 2014)
+++ trunk/BaseTools/Source/Python/Ecc/config.ini 2010-08-16 11:30:42 UTC (rev 2015)
@@ -21,7 +21,7 @@
# 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 @@
GeneralCheckCarriageReturn = 1
# Check whether the file exists
GeneralCheckFileExistence = 1
+# Check whether file has non ACSII char
+GeneralCheckNonAcsii = 1
#
# Space Checking
@@ -81,7 +83,7 @@
# 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 @@
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 @@
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|