Sync BaseTool trunk (version r2460) into EDKII BaseTools. The change mainly includes:
1. Support use expression as DSC file PCD value. 2. Update FDF parser to fix bug to get complete macro value. 3. Fix bug to replace SET statement macro and evaluate SET statement PCD value in FDF file. 4. Fix a bug for MACRO defined in conditional block cannot be processed correctly Signed-off-by: lgao4 Reviewed-by: gikidy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12827 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -15,6 +15,7 @@ import re
|
||||
from CommonDataClass.DataClass import *
|
||||
from Common.DataType import SUP_MODULE_LIST_STRING, TAB_VALUE_SPLIT
|
||||
from EccToolError import *
|
||||
from MetaDataParser import ParseHeaderCommentSection
|
||||
import EccGlobalData
|
||||
import c
|
||||
|
||||
@ -48,7 +49,7 @@ class Check(object):
|
||||
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)
|
||||
RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
if Record[2].upper() not in EccGlobalData.gConfig.BinaryExtList:
|
||||
op = open(Record[1]).readlines()
|
||||
@ -415,13 +416,81 @@ class Check(object):
|
||||
elif Ext in ('.inf', '.dec', '.dsc', '.fdf'):
|
||||
FullName = os.path.join(Dirpath, F)
|
||||
op = open(FullName).readlines()
|
||||
if not op[0].startswith('## @file') and op[6].startswith('## @file') and op[7].startswith('## @file'):
|
||||
FileLinesList = op
|
||||
LineNo = 0
|
||||
CurrentSection = MODEL_UNKNOWN
|
||||
HeaderSectionLines = []
|
||||
HeaderCommentStart = False
|
||||
HeaderCommentEnd = False
|
||||
|
||||
for Line in FileLinesList:
|
||||
LineNo = LineNo + 1
|
||||
Line = Line.strip()
|
||||
if (LineNo < len(FileLinesList) - 1):
|
||||
NextLine = FileLinesList[LineNo].strip()
|
||||
|
||||
#
|
||||
# blank line
|
||||
#
|
||||
if (Line == '' or not Line) and LineNo == len(FileLinesList):
|
||||
LastSectionFalg = True
|
||||
|
||||
#
|
||||
# check whether file header comment section started
|
||||
#
|
||||
if Line.startswith('#') and \
|
||||
(Line.find('@file') > -1) and \
|
||||
not HeaderCommentStart:
|
||||
if CurrentSection != MODEL_UNKNOWN:
|
||||
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"" or ""# @file""at the very top file'
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])
|
||||
|
||||
else:
|
||||
CurrentSection = MODEL_IDENTIFIER_FILE_HEADER
|
||||
#
|
||||
# Append the first line to section lines.
|
||||
#
|
||||
HeaderSectionLines.append((Line, LineNo))
|
||||
HeaderCommentStart = True
|
||||
continue
|
||||
|
||||
#
|
||||
# Collect Header content.
|
||||
#
|
||||
if (Line.startswith('#') and CurrentSection == MODEL_IDENTIFIER_FILE_HEADER) and\
|
||||
HeaderCommentStart and not Line.startswith('##') and not\
|
||||
HeaderCommentEnd and NextLine != '':
|
||||
HeaderSectionLines.append((Line, LineNo))
|
||||
continue
|
||||
#
|
||||
# Header content end
|
||||
#
|
||||
if (Line.startswith('##') or not Line.strip().startswith("#")) and HeaderCommentStart \
|
||||
and not HeaderCommentEnd:
|
||||
if Line.startswith('##'):
|
||||
HeaderCommentEnd = True
|
||||
HeaderSectionLines.append((Line, LineNo))
|
||||
ParseHeaderCommentSection(HeaderSectionLines, FullName)
|
||||
break
|
||||
if HeaderCommentStart == False:
|
||||
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""'
|
||||
Msg = 'INF/DEC/DSC/FDF file header comment should begin with ""## @file"" or ""# @file"" at the very top file'
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])
|
||||
if HeaderCommentEnd == False:
|
||||
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 end with ""##"" at the end of file header comment block'
|
||||
# Check whether File header Comment End with '##'
|
||||
if EccGlobalData.gConfig.HeaderCheckFileCommentEnd == '1' or EccGlobalData.gConfig.HeaderCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
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):
|
||||
@ -504,9 +573,9 @@ class Check(object):
|
||||
def MetaDataFileCheckLibraryInstance(self):
|
||||
if EccGlobalData.gConfig.MetaDataFileCheckLibraryInstance == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking for library instance type issue ...")
|
||||
SqlCommand = """select A.ID, A.Value2, B.Value2 from Inf as A left join Inf as B
|
||||
where A.Value1 = 'LIBRARY_CLASS' and A.Model = %s
|
||||
and B.Value1 = 'MODULE_TYPE' and B.Model = %s and A.BelongsToFile = B.BelongsToFile
|
||||
SqlCommand = """select A.ID, A.Value3, B.Value3 from Inf as A left join Inf as B
|
||||
where A.Value2 = 'LIBRARY_CLASS' and A.Model = %s
|
||||
and B.Value2 = 'MODULE_TYPE' and B.Model = %s and A.BelongsToFile = B.BelongsToFile
|
||||
group by A.BelongsToFile""" % (MODEL_META_DATA_HEADER, MODEL_META_DATA_HEADER)
|
||||
RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
|
||||
LibraryClasses = {}
|
||||
@ -528,8 +597,8 @@ class Check(object):
|
||||
if Record[2] != 'BASE' and Record[2] not in SupModType:
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_2, OtherMsg="The Library Class '%s' does not specify its supported module types" % (List[0]), BelongsToTable='Inf', BelongsToItem=Record[0])
|
||||
|
||||
SqlCommand = """select A.ID, A.Value1, B.Value2 from Inf as A left join Inf as B
|
||||
where A.Model = %s and B.Value1 = '%s' and B.Model = %s
|
||||
SqlCommand = """select A.ID, A.Value1, B.Value3 from Inf as A left join Inf as B
|
||||
where A.Model = %s and B.Value2 = '%s' and B.Model = %s
|
||||
and B.BelongsToFile = A.BelongsToFile""" \
|
||||
% (MODEL_EFI_LIBRARY_CLASS, 'MODULE_TYPE', MODEL_META_DATA_HEADER)
|
||||
RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
|
||||
@ -558,11 +627,13 @@ class Check(object):
|
||||
SqlCommand = """select ID, Value1, Value2 from Dsc where Model = %s""" % MODEL_EFI_LIBRARY_CLASS
|
||||
LibraryClasses = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)
|
||||
for LibraryClass in LibraryClasses:
|
||||
if LibraryClass[1].upper() != 'NULL':
|
||||
if LibraryClass[1].upper() == 'NULL' or LibraryClass[1].startswith('!ifdef') or LibraryClass[1].startswith('!ifndef') or LibraryClass[1].endswith('!endif'):
|
||||
continue
|
||||
else:
|
||||
LibraryIns = os.path.normpath(os.path.join(EccGlobalData.gWorkspace, LibraryClass[2]))
|
||||
SqlCommand = """select Value2 from Inf where BelongsToFile =
|
||||
SqlCommand = """select Value3 from Inf where BelongsToFile =
|
||||
(select ID from File where lower(FullPath) = lower('%s'))
|
||||
and Value1 = '%s'""" % (LibraryIns, 'LIBRARY_CLASS')
|
||||
and Value2 = '%s'""" % (LibraryIns, 'LIBRARY_CLASS')
|
||||
RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
|
||||
IsFound = False
|
||||
for Record in RecordSet:
|
||||
@ -591,8 +662,8 @@ class Check(object):
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_NO_USE, OtherMsg="The Library Class [%s] is not used in any platform" % (Record[1]), BelongsToTable='Inf', BelongsToItem=Record[0])
|
||||
SqlCommand = """
|
||||
select A.ID, A.Value1, A.BelongsToFile, A.StartLine, B.StartLine from Dsc as A left join Dsc as B
|
||||
where A.Model = %s and B.Model = %s and A.Value3 = B.Value3 and A.Arch = B.Arch and A.ID <> B.ID
|
||||
and A.Value1 = B.Value1 and A.StartLine <> B.StartLine and B.BelongsToFile = A.BelongsToFile""" \
|
||||
where A.Model = %s and B.Model = %s and A.Scope1 = B.Scope1 and A.Scope2 = B.Scope2 and A.ID <> B.ID
|
||||
and A.Value1 = B.Value1 and A.Value2 <> B.Value2 and A.BelongsToItem = -1 and B.BelongsToItem = -1 and A.StartLine <> B.StartLine and B.BelongsToFile = A.BelongsToFile""" \
|
||||
% (MODEL_EFI_LIBRARY_CLASS, MODEL_EFI_LIBRARY_CLASS)
|
||||
RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
@ -631,9 +702,10 @@ class Check(object):
|
||||
if EccGlobalData.gConfig.MetaDataFileCheckPcdDuplicate == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking for duplicate PCDs defined in both DSC and FDF files ...")
|
||||
SqlCommand = """
|
||||
select A.ID, A.Value2, A.BelongsToFile, B.ID, B.Value2, B.BelongsToFile from Dsc as A, Fdf as B
|
||||
select A.ID, A.Value1, A.Value2, A.BelongsToFile, B.ID, B.Value1, B.Value2, B.BelongsToFile from Dsc as A, Fdf as B
|
||||
where A.Model >= %s and A.Model < %s
|
||||
and B.Model >= %s and B.Model < %s
|
||||
and A.Value1 = B.Value1
|
||||
and A.Value2 = B.Value2
|
||||
and A.Enabled > -1
|
||||
and B.Enabled > -1
|
||||
@ -641,71 +713,74 @@ class Check(object):
|
||||
""" % (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)
|
||||
RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
SqlCommand1 = """select Name from File where ID = %s""" % Record[2]
|
||||
SqlCommand2 = """select Name from File where ID = %s""" % Record[5]
|
||||
SqlCommand1 = """select Name from File where ID = %s""" % Record[3]
|
||||
SqlCommand2 = """select Name from File where ID = %s""" % Record[7]
|
||||
DscFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand1)[0][0])[0]
|
||||
FdfFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand2)[0][0])[0]
|
||||
if DscFileName != FdfFileName:
|
||||
continue
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1]):
|
||||
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])
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[3]):
|
||||
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])
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1] + '.' + Record[2]):
|
||||
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] + '.' + Record[2]), BelongsToTable='Dsc', BelongsToItem=Record[0])
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[5] + '.' + Record[6]):
|
||||
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[5] + '.' + Record[6]), BelongsToTable='Fdf', BelongsToItem=Record[4])
|
||||
|
||||
EdkLogger.quiet("Checking for duplicate PCDs defined in DEC files ...")
|
||||
SqlCommand = """
|
||||
select A.ID, A.Value2 from Dec as A, Dec as B
|
||||
select A.ID, A.Value1, A.Value2, A.Model, B.Model from Dec as A left join Dec as B
|
||||
where A.Model >= %s and A.Model < %s
|
||||
and B.Model >= %s and B.Model < %s
|
||||
and A.Value1 = B.Value1
|
||||
and A.Value2 = B.Value2
|
||||
and ((A.Arch = B.Arch) and (A.Arch != 'COMMON' or B.Arch != 'COMMON'))
|
||||
and A.ID != B.ID
|
||||
and A.Scope1 = B.Scope1
|
||||
and A.ID <> B.ID
|
||||
and A.Model = B.Model
|
||||
and A.Enabled > -1
|
||||
and B.Enabled > -1
|
||||
and A.BelongsToFile = B.BelongsToFile
|
||||
group by A.ID
|
||||
""" % (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)
|
||||
RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)
|
||||
RecordSet = EccGlobalData.gDb.TblDec.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1]):
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg="The PCD [%s] is defined duplicated in DEC file" % (Record[1]), BelongsToTable='Dec', BelongsToItem=Record[0])
|
||||
RecordCat = Record[1] + '.' + Record[2]
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, RecordCat):
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg="The PCD [%s] is defined duplicated in DEC file" % RecordCat, BelongsToTable='Dec', BelongsToItem=Record[0])
|
||||
|
||||
# Check whether PCD settings in the FDF file can only be related to flash.
|
||||
def MetaDataFileCheckPcdFlash(self):
|
||||
if EccGlobalData.gConfig.MetaDataFileCheckPcdFlash == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking only Flash related PCDs are used in FDF ...")
|
||||
SqlCommand = """
|
||||
select ID, Value2, BelongsToFile from Fdf as A
|
||||
select ID, Value1, Value2, BelongsToFile from Fdf as A
|
||||
where A.Model >= %s and Model < %s
|
||||
and A.Enabled > -1
|
||||
and A.Value2 not like '%%Flash%%'
|
||||
""" % (MODEL_PCD, MODEL_META_DATA_HEADER)
|
||||
RecordSet = EccGlobalData.gDb.TblFdf.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, Record[1]):
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, OtherMsg="The PCD [%s] defined in FDF file is not related to Flash" % (Record[1]), BelongsToTable='Fdf', BelongsToItem=Record[0])
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, Record[1] + '.' + Record[2]):
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, OtherMsg="The PCD [%s] defined in FDF file is not related to Flash" % (Record[1] + '.' + Record[2]), BelongsToTable='Fdf', BelongsToItem=Record[0])
|
||||
|
||||
# Check whether PCDs used in Inf files but not specified in Dsc or FDF files
|
||||
def MetaDataFileCheckPcdNoUse(self):
|
||||
if EccGlobalData.gConfig.MetaDataFileCheckPcdNoUse == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking for non-specified PCDs ...")
|
||||
SqlCommand = """
|
||||
select ID, Value2, BelongsToFile from Inf as A
|
||||
select ID, Value1, Value2, BelongsToFile from Inf as A
|
||||
where A.Model >= %s and Model < %s
|
||||
and A.Enabled > -1
|
||||
and A.Value2 not in
|
||||
(select Value2 from Dsc as B
|
||||
and (A.Value1, A.Value2) not in
|
||||
(select Value1, Value2 from Dsc as B
|
||||
where B.Model >= %s and B.Model < %s
|
||||
and B.Enabled > -1)
|
||||
and A.Value2 not in
|
||||
(select Value2 from Fdf as C
|
||||
and (A.Value1, A.Value2) not in
|
||||
(select Value1, Value2 from Fdf as C
|
||||
where C.Model >= %s and C.Model < %s
|
||||
and C.Enabled > -1)
|
||||
""" % (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)
|
||||
RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, Record[1]):
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, OtherMsg="The PCD [%s] defined in INF file is not specified in either DSC or FDF files" % (Record[1]), BelongsToTable='Inf', BelongsToItem=Record[0])
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, Record[1] + '.' + Record[2]):
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, OtherMsg="The PCD [%s] defined in INF file is not specified in either DSC or FDF files" % (Record[1] + '.' + Record[2]), BelongsToTable='Inf', BelongsToItem=Record[0])
|
||||
|
||||
# Check whether having duplicate guids defined for Guid/Protocol/Ppi
|
||||
def MetaDataFileCheckGuidDuplicate(self):
|
||||
@ -729,7 +804,7 @@ class Check(object):
|
||||
if EccGlobalData.gConfig.MetaDataFileCheckModuleFileNoUse == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking for no used module files ...")
|
||||
SqlCommand = """
|
||||
select upper(Path) from File where ID in (select BelongsToFile from INF where BelongsToFile != -1)
|
||||
select upper(Path) from File where ID in (select BelongsToFile from Inf where BelongsToFile != -1)
|
||||
"""
|
||||
InfPathSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
|
||||
InfPathList = []
|
||||
@ -756,15 +831,15 @@ class Check(object):
|
||||
if EccGlobalData.gConfig.MetaDataFileCheckPcdType == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking for pcd type in c code function usage ...")
|
||||
SqlCommand = """
|
||||
select ID, Model, Value1, BelongsToFile from INF where Model > %s and Model < %s
|
||||
select ID, Model, Value1, Value2, BelongsToFile from INF where Model > %s and Model < %s
|
||||
""" % (MODEL_PCD, MODEL_META_DATA_HEADER)
|
||||
PcdSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
|
||||
for Pcd in PcdSet:
|
||||
Model = Pcd[1]
|
||||
PcdName = Pcd[2]
|
||||
if len(Pcd[2].split(".")) > 1:
|
||||
PcdName = Pcd[2].split(".")[1]
|
||||
BelongsToFile = Pcd[3]
|
||||
if Pcd[3]:
|
||||
PcdName = Pcd[3]
|
||||
BelongsToFile = Pcd[4]
|
||||
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
|
||||
@ -809,9 +884,9 @@ class Check(object):
|
||||
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
|
||||
select A.ID, A.Value3, A.BelongsToFile, B.BelongsToFile from %s as A, %s as B
|
||||
where A.Value2 = 'FILE_GUID' and B.Value2 = 'FILE_GUID' and
|
||||
A.Value3 = B.Value3 and A.ID <> B.ID group by A.ID
|
||||
""" % (Table.Table, Table.Table)
|
||||
RecordSet = Table.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
@ -836,7 +911,7 @@ class Check(object):
|
||||
select A.ID, A.Value1 from %s as A, %s as B
|
||||
where A.Model = %s and B.Model = %s
|
||||
and A.Value1 = B.Value1 and A.ID <> B.ID
|
||||
and A.Arch = B.Arch
|
||||
and A.Scope1 = B.Scope1
|
||||
and A.Enabled > -1
|
||||
and B.Enabled > -1
|
||||
group by A.ID
|
||||
@ -857,16 +932,16 @@ class Check(object):
|
||||
if Model == MODEL_EFI_PPI:
|
||||
Name = 'ppi'
|
||||
SqlCommand = """
|
||||
select A.ID, A.Value2 from %s as A, %s as B
|
||||
select A.ID, A.Value1, A.Value2 from %s as A, %s as B
|
||||
where A.Model = %s and B.Model = %s
|
||||
and A.Value2 = B.Value2 and A.ID <> B.ID
|
||||
and A.Arch = B.Arch
|
||||
and A.Scope1 = B.Scope1 and A.Value1 <> B.Value1
|
||||
group by A.ID
|
||||
""" % (Table.Table, Table.Table, Model, Model)
|
||||
RecordSet = Table.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
if not EccGlobalData.gException.IsException(ErrorID, Record[1]):
|
||||
EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg="The %s value [%s] is used more than one time" % (Name.upper(), Record[1]), BelongsToTable=Table.Table, BelongsToItem=Record[0])
|
||||
for Record in RecordSet:
|
||||
if not EccGlobalData.gException.IsException(ErrorID, Record[1] + ':' + Record[2]):
|
||||
EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg="The %s value [%s] is used more than one time" % (Name.upper(), Record[2]), BelongsToTable=Table.Table, BelongsToItem=Record[0])
|
||||
|
||||
# Naming Convention Check
|
||||
def NamingConventionCheck(self):
|
||||
|
@ -100,7 +100,15 @@ class Configuration(object):
|
||||
self.HeaderCheckFile = 1
|
||||
# Check whether Function header exists
|
||||
self.HeaderCheckFunction = 1
|
||||
|
||||
# Check whether Meta data File header Comment End with '##'
|
||||
self.HeaderCheckFileCommentEnd = 1
|
||||
# Check whether C File header Comment content start with two spaces
|
||||
self.HeaderCheckCFileCommentStartSpacesNum = 1
|
||||
# Check whether C File header Comment's each reference at list should begin with a bullet character '-'
|
||||
self.HeaderCheckCFileCommentReferenceFormat = 1
|
||||
# Check whether C File header Comment have the License immediately after the ""Copyright"" line
|
||||
self.HeaderCheckCFileCommentLicenseFormat = 1
|
||||
|
||||
## C Function Layout Checking
|
||||
self.CFunctionLayoutCheckAll = 0
|
||||
|
||||
|
@ -26,9 +26,9 @@ from Table.TableFunction import TableFunction
|
||||
from Table.TablePcd import TablePcd
|
||||
from Table.TableIdentifier import TableIdentifier
|
||||
from Table.TableReport import TableReport
|
||||
from Table.TableInf import TableInf
|
||||
from Table.TableDec import TableDec
|
||||
from Table.TableDsc import TableDsc
|
||||
from MetaFileWorkspace.MetaFileTable import ModuleTable
|
||||
from MetaFileWorkspace.MetaFileTable import PackageTable
|
||||
from MetaFileWorkspace.MetaFileTable import PlatformTable
|
||||
from Table.TableFdf import TableFdf
|
||||
|
||||
##
|
||||
@ -92,9 +92,9 @@ class Database(object):
|
||||
self.TblIdentifier = TableIdentifier(self.Cur)
|
||||
self.TblPcd = TablePcd(self.Cur)
|
||||
self.TblReport = TableReport(self.Cur)
|
||||
self.TblInf = TableInf(self.Cur)
|
||||
self.TblDec = TableDec(self.Cur)
|
||||
self.TblDsc = TableDsc(self.Cur)
|
||||
self.TblInf = ModuleTable(self.Cur)
|
||||
self.TblDec = PackageTable(self.Cur)
|
||||
self.TblDsc = PlatformTable(self.Cur)
|
||||
self.TblFdf = TableFdf(self.Cur)
|
||||
|
||||
#
|
||||
|
@ -22,13 +22,17 @@ from MetaDataParser import *
|
||||
from optparse import OptionParser
|
||||
from Configuration import Configuration
|
||||
from Check import Check
|
||||
from Common.InfClassObject import Inf
|
||||
from Common.DecClassObject import Dec
|
||||
from Common.DscClassObject import Dsc
|
||||
from Common.FdfClassObject import Fdf
|
||||
|
||||
|
||||
from Common.String import NormPath
|
||||
from Common.BuildVersion import gBUILD_VERSION
|
||||
from Common import BuildToolError
|
||||
|
||||
from MetaFileWorkspace.MetaFileParser import DscParser
|
||||
from MetaFileWorkspace.MetaFileParser import DecParser
|
||||
from MetaFileWorkspace.MetaFileParser import InfParser
|
||||
from MetaFileWorkspace.MetaFileParser import Fdf
|
||||
from MetaFileWorkspace.MetaFileTable import MetaFileStorage
|
||||
import c
|
||||
import re, string
|
||||
from Exception import *
|
||||
@ -53,6 +57,7 @@ class Ecc(object):
|
||||
self.IsInit = True
|
||||
self.ScanSourceCode = True
|
||||
self.ScanMetaData = True
|
||||
self.MetaFile = ''
|
||||
|
||||
# Parse the options and args
|
||||
self.ParseOption()
|
||||
@ -124,7 +129,6 @@ class Ecc(object):
|
||||
for Root, Dirs, Files in os.walk(EccGlobalData.gTarget):
|
||||
if p.match(Root.upper()):
|
||||
continue
|
||||
|
||||
for Dir in Dirs:
|
||||
Dirname = os.path.join(Root, Dir)
|
||||
if os.path.islink(Dirname):
|
||||
@ -139,19 +143,28 @@ class Ecc(object):
|
||||
Filename = os.path.normpath(os.path.join(Root, File))
|
||||
EdkLogger.quiet("Parsing %s" % Filename)
|
||||
Op.write("%s\r" % Filename)
|
||||
Dec(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb)
|
||||
#Dec(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb)
|
||||
self.MetaFile = DecParser(Filename, MODEL_FILE_DEC, EccGlobalData.gDb.TblDec)
|
||||
self.MetaFile.Start()
|
||||
continue
|
||||
if len(File) > 4 and File[-4:].upper() == ".DSC":
|
||||
Filename = os.path.normpath(os.path.join(Root, File))
|
||||
EdkLogger.quiet("Parsing %s" % Filename)
|
||||
Op.write("%s\r" % Filename)
|
||||
Dsc(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb)
|
||||
#Dsc(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb)
|
||||
self.MetaFile = DscParser(Filename, MODEL_FILE_DSC, MetaFileStorage(EccGlobalData.gDb.TblDsc.Cur, Filename, MODEL_FILE_DSC, True))
|
||||
# alwasy do post-process, in case of macros change
|
||||
self.MetaFile.DoPostProcess()
|
||||
self.MetaFile.Start()
|
||||
self.MetaFile._PostProcess()
|
||||
continue
|
||||
if len(File) > 4 and File[-4:].upper() == ".INF":
|
||||
Filename = os.path.normpath(os.path.join(Root, File))
|
||||
EdkLogger.quiet("Parsing %s" % Filename)
|
||||
Op.write("%s\r" % Filename)
|
||||
Inf(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb)
|
||||
#Inf(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb)
|
||||
self.MetaFile = InfParser(Filename, MODEL_FILE_INF, EccGlobalData.gDb.TblInf)
|
||||
self.MetaFile.Start()
|
||||
continue
|
||||
if len(File) > 4 and File[-4:].upper() == ".FDF":
|
||||
Filename = os.path.normpath(os.path.join(Root, File))
|
||||
|
@ -13,8 +13,9 @@
|
||||
|
||||
import os
|
||||
from CommonDataClass.DataClass import *
|
||||
|
||||
|
||||
from EccToolError import *
|
||||
import EccGlobalData
|
||||
import re
|
||||
## Get the inlcude path list for a source file
|
||||
#
|
||||
# 1. Find the source file belongs to which inf file
|
||||
@ -76,3 +77,188 @@ def GetTableList(FileModelList, Table, Db):
|
||||
|
||||
return TableList
|
||||
|
||||
## ParseHeaderCommentSection
|
||||
#
|
||||
# Parse Header comment section lines, extract Abstract, Description, Copyright
|
||||
# , License lines
|
||||
#
|
||||
# @param CommentList: List of (Comment, LineNumber)
|
||||
# @param FileName: FileName of the comment
|
||||
#
|
||||
def ParseHeaderCommentSection(CommentList, FileName = None):
|
||||
|
||||
Abstract = ''
|
||||
Description = ''
|
||||
Copyright = ''
|
||||
License = ''
|
||||
EndOfLine = "\n"
|
||||
STR_HEADER_COMMENT_START = "@file"
|
||||
|
||||
#
|
||||
# used to indicate the state of processing header comment section of dec,
|
||||
# inf files
|
||||
#
|
||||
HEADER_COMMENT_NOT_STARTED = -1
|
||||
HEADER_COMMENT_STARTED = 0
|
||||
HEADER_COMMENT_FILE = 1
|
||||
HEADER_COMMENT_ABSTRACT = 2
|
||||
HEADER_COMMENT_DESCRIPTION = 3
|
||||
HEADER_COMMENT_COPYRIGHT = 4
|
||||
HEADER_COMMENT_LICENSE = 5
|
||||
HEADER_COMMENT_END = 6
|
||||
#
|
||||
# first find the last copyright line
|
||||
#
|
||||
Last = 0
|
||||
HeaderCommentStage = HEADER_COMMENT_NOT_STARTED
|
||||
for Index in xrange(len(CommentList)-1, 0, -1):
|
||||
Line = CommentList[Index][0]
|
||||
if _IsCopyrightLine(Line):
|
||||
Last = Index
|
||||
break
|
||||
|
||||
for Item in CommentList:
|
||||
Line = Item[0]
|
||||
LineNo = Item[1]
|
||||
|
||||
if not Line.startswith('#') and Line:
|
||||
SqlStatement = """ select ID from File where FullPath like '%s'""" % FileName
|
||||
ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)
|
||||
for Result in ResultSet:
|
||||
Msg = 'Comment must start with #'
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])
|
||||
Comment = CleanString2(Line)[1]
|
||||
Comment = Comment.strip()
|
||||
#
|
||||
# if there are blank lines between License or Description, keep them as they would be
|
||||
# indication of different block; or in the position that Abstract should be, also keep it
|
||||
# as it indicates that no abstract
|
||||
#
|
||||
if not Comment and HeaderCommentStage not in [HEADER_COMMENT_LICENSE, \
|
||||
HEADER_COMMENT_DESCRIPTION, HEADER_COMMENT_ABSTRACT]:
|
||||
continue
|
||||
|
||||
if HeaderCommentStage == HEADER_COMMENT_NOT_STARTED:
|
||||
if Comment.startswith(STR_HEADER_COMMENT_START):
|
||||
HeaderCommentStage = HEADER_COMMENT_ABSTRACT
|
||||
else:
|
||||
License += Comment + EndOfLine
|
||||
else:
|
||||
if HeaderCommentStage == HEADER_COMMENT_ABSTRACT:
|
||||
#
|
||||
# in case there is no abstract and description
|
||||
#
|
||||
if not Comment:
|
||||
Abstract = ''
|
||||
HeaderCommentStage = HEADER_COMMENT_DESCRIPTION
|
||||
elif _IsCopyrightLine(Comment):
|
||||
Copyright += Comment + EndOfLine
|
||||
HeaderCommentStage = HEADER_COMMENT_COPYRIGHT
|
||||
else:
|
||||
Abstract += Comment + EndOfLine
|
||||
HeaderCommentStage = HEADER_COMMENT_DESCRIPTION
|
||||
elif HeaderCommentStage == HEADER_COMMENT_DESCRIPTION:
|
||||
#
|
||||
# in case there is no description
|
||||
#
|
||||
if _IsCopyrightLine(Comment):
|
||||
Copyright += Comment + EndOfLine
|
||||
HeaderCommentStage = HEADER_COMMENT_COPYRIGHT
|
||||
else:
|
||||
Description += Comment + EndOfLine
|
||||
elif HeaderCommentStage == HEADER_COMMENT_COPYRIGHT:
|
||||
if _IsCopyrightLine(Comment):
|
||||
Copyright += Comment + EndOfLine
|
||||
else:
|
||||
#
|
||||
# Contents after copyright line are license, those non-copyright lines in between
|
||||
# copyright line will be discarded
|
||||
#
|
||||
if LineNo > Last:
|
||||
if License:
|
||||
License += EndOfLine
|
||||
License += Comment + EndOfLine
|
||||
HeaderCommentStage = HEADER_COMMENT_LICENSE
|
||||
else:
|
||||
if not Comment and not License:
|
||||
continue
|
||||
License += Comment + EndOfLine
|
||||
|
||||
if not Copyright:
|
||||
SqlStatement = """ select ID from File where FullPath like '%s'""" % FileName
|
||||
ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)
|
||||
for Result in ResultSet:
|
||||
Msg = 'Header comment section must have copyright information'
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])
|
||||
|
||||
if not License:
|
||||
SqlStatement = """ select ID from File where FullPath like '%s'""" % FileName
|
||||
ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)
|
||||
for Result in ResultSet:
|
||||
Msg = 'Header comment section must have license information'
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])
|
||||
|
||||
return Abstract.strip(), Description.strip(), Copyright.strip(), License.strip()
|
||||
|
||||
## _IsCopyrightLine
|
||||
# check whether current line is copyright line, the criteria is whether there is case insensitive keyword "Copyright"
|
||||
# followed by zero or more white space characters followed by a "(" character
|
||||
#
|
||||
# @param LineContent: the line need to be checked
|
||||
# @return: True if current line is copyright line, False else
|
||||
#
|
||||
def _IsCopyrightLine (LineContent):
|
||||
LineContent = LineContent.upper()
|
||||
Result = False
|
||||
|
||||
ReIsCopyrightRe = re.compile(r"""(^|\s)COPYRIGHT *\(""", re.DOTALL)
|
||||
if ReIsCopyrightRe.search(LineContent):
|
||||
Result = True
|
||||
|
||||
return Result
|
||||
|
||||
|
||||
## CleanString2
|
||||
#
|
||||
# Split comments in a string
|
||||
# Remove spaces
|
||||
#
|
||||
# @param Line: The string to be cleaned
|
||||
# @param CommentCharacter: Comment char, used to ignore comment content,
|
||||
# default is DataType.TAB_COMMENT_SPLIT
|
||||
#
|
||||
def CleanString2(Line, CommentCharacter='#', AllowCppStyleComment=False):
|
||||
#
|
||||
# remove whitespace
|
||||
#
|
||||
Line = Line.strip()
|
||||
#
|
||||
# Replace EDK1's comment character
|
||||
#
|
||||
if AllowCppStyleComment:
|
||||
Line = Line.replace('//', CommentCharacter)
|
||||
#
|
||||
# separate comments and statements
|
||||
#
|
||||
LineParts = Line.split(CommentCharacter, 1)
|
||||
#
|
||||
# remove whitespace again
|
||||
#
|
||||
Line = LineParts[0].strip()
|
||||
if len(LineParts) > 1:
|
||||
Comment = LineParts[1].strip()
|
||||
#
|
||||
# Remove prefixed and trailing comment characters
|
||||
#
|
||||
Start = 0
|
||||
End = len(Comment)
|
||||
while Start < End and Comment.startswith(CommentCharacter, Start, End):
|
||||
Start += 1
|
||||
while End >= 0 and Comment.endswith(CommentCharacter, Start, End):
|
||||
End -= 1
|
||||
Comment = Comment[Start:End]
|
||||
Comment = Comment.strip()
|
||||
else:
|
||||
Comment = ''
|
||||
|
||||
return Line, Comment
|
||||
|
215
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
Normal file
215
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
Normal file
@ -0,0 +1,215 @@
|
||||
## @file
|
||||
# This file is used to create/update/query/erase table for files
|
||||
#
|
||||
# Copyright (c) 2008, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import os
|
||||
|
||||
import Common.EdkLogger as EdkLogger
|
||||
from CommonDataClass import DataClass
|
||||
from CommonDataClass.DataClass import FileClass
|
||||
|
||||
## Convert to SQL required string format
|
||||
def ConvertToSqlString(StringList):
|
||||
return map(lambda s: "'" + s.replace("'", "''") + "'", StringList)
|
||||
|
||||
## TableFile
|
||||
#
|
||||
# This class defined a common table
|
||||
#
|
||||
# @param object: Inherited from object class
|
||||
#
|
||||
# @param Cursor: Cursor of the database
|
||||
# @param TableName: Name of the table
|
||||
#
|
||||
class Table(object):
|
||||
_COLUMN_ = ''
|
||||
_ID_STEP_ = 1
|
||||
_ID_MAX_ = 0x80000000
|
||||
_DUMMY_ = 0
|
||||
|
||||
def __init__(self, Cursor, Name='', IdBase=0, Temporary=False):
|
||||
self.Cur = Cursor
|
||||
self.Table = Name
|
||||
self.IdBase = int(IdBase)
|
||||
self.ID = int(IdBase)
|
||||
self.Temporary = Temporary
|
||||
|
||||
def __str__(self):
|
||||
return self.Table
|
||||
|
||||
## Create table
|
||||
#
|
||||
# Create a table
|
||||
#
|
||||
def Create(self, NewTable=True):
|
||||
if NewTable:
|
||||
self.Drop()
|
||||
|
||||
if self.Temporary:
|
||||
SqlCommand = """create temp table IF NOT EXISTS %s (%s)""" % (self.Table, self._COLUMN_)
|
||||
else:
|
||||
SqlCommand = """create table IF NOT EXISTS %s (%s)""" % (self.Table, self._COLUMN_)
|
||||
EdkLogger.debug(EdkLogger.DEBUG_8, SqlCommand)
|
||||
self.Cur.execute(SqlCommand)
|
||||
self.ID = self.GetId()
|
||||
|
||||
## Insert table
|
||||
#
|
||||
# Insert a record into a table
|
||||
#
|
||||
def Insert(self, *Args):
|
||||
self.ID = self.ID + self._ID_STEP_
|
||||
if self.ID >= (self.IdBase + self._ID_MAX_):
|
||||
self.ID = self.IdBase + self._ID_STEP_
|
||||
Values = ", ".join([str(Arg) for Arg in Args])
|
||||
SqlCommand = "insert into %s values(%s, %s)" % (self.Table, self.ID, Values)
|
||||
EdkLogger.debug(EdkLogger.DEBUG_5, SqlCommand)
|
||||
self.Cur.execute(SqlCommand)
|
||||
return self.ID
|
||||
|
||||
## Query table
|
||||
#
|
||||
# Query all records of the table
|
||||
#
|
||||
def Query(self):
|
||||
SqlCommand = """select * from %s""" % self.Table
|
||||
self.Cur.execute(SqlCommand)
|
||||
for Rs in self.Cur:
|
||||
EdkLogger.verbose(str(Rs))
|
||||
TotalCount = self.GetId()
|
||||
|
||||
## Drop a table
|
||||
#
|
||||
# Drop the table
|
||||
#
|
||||
def Drop(self):
|
||||
SqlCommand = """drop table IF EXISTS %s""" % self.Table
|
||||
self.Cur.execute(SqlCommand)
|
||||
|
||||
## Get count
|
||||
#
|
||||
# Get a count of all records of the table
|
||||
#
|
||||
# @retval Count: Total count of all records
|
||||
#
|
||||
def GetCount(self):
|
||||
SqlCommand = """select count(ID) from %s""" % self.Table
|
||||
Record = self.Cur.execute(SqlCommand).fetchall()
|
||||
return Record[0][0]
|
||||
|
||||
def GetId(self):
|
||||
SqlCommand = """select max(ID) from %s""" % self.Table
|
||||
Record = self.Cur.execute(SqlCommand).fetchall()
|
||||
Id = Record[0][0]
|
||||
if Id == None:
|
||||
Id = self.IdBase
|
||||
return Id
|
||||
|
||||
## Init the ID of the table
|
||||
#
|
||||
# Init the ID of the table
|
||||
#
|
||||
def InitID(self):
|
||||
self.ID = self.GetId()
|
||||
|
||||
## Exec
|
||||
#
|
||||
# Exec Sql Command, return result
|
||||
#
|
||||
# @param SqlCommand: The SqlCommand to be executed
|
||||
#
|
||||
# @retval RecordSet: The result after executed
|
||||
#
|
||||
def Exec(self, SqlCommand):
|
||||
EdkLogger.debug(EdkLogger.DEBUG_5, SqlCommand)
|
||||
self.Cur.execute(SqlCommand)
|
||||
RecordSet = self.Cur.fetchall()
|
||||
return RecordSet
|
||||
|
||||
def SetEndFlag(self):
|
||||
pass
|
||||
|
||||
def IsIntegral(self):
|
||||
Result = self.Exec("select min(ID) from %s" % (self.Table))
|
||||
if Result[0][0] != -1:
|
||||
return False
|
||||
return True
|
||||
|
||||
def GetAll(self):
|
||||
return self.Exec("select * from %s where ID > 0 order by ID" % (self.Table))
|
||||
|
||||
|
||||
## TableDataModel
|
||||
#
|
||||
# This class defined a table used for data model
|
||||
#
|
||||
# @param object: Inherited from object class
|
||||
#
|
||||
#
|
||||
class TableDataModel(Table):
|
||||
_COLUMN_ = """
|
||||
ID INTEGER PRIMARY KEY,
|
||||
CrossIndex INTEGER NOT NULL,
|
||||
Name VARCHAR NOT NULL,
|
||||
Description VARCHAR
|
||||
"""
|
||||
def __init__(self, Cursor):
|
||||
Table.__init__(self, Cursor, 'DataModel')
|
||||
|
||||
## Insert table
|
||||
#
|
||||
# Insert a record into table DataModel
|
||||
#
|
||||
# @param ID: ID of a ModelType
|
||||
# @param CrossIndex: CrossIndex of a ModelType
|
||||
# @param Name: Name of a ModelType
|
||||
# @param Description: Description of a ModelType
|
||||
#
|
||||
def Insert(self, CrossIndex, Name, Description):
|
||||
(Name, Description) = ConvertToSqlString((Name, Description))
|
||||
return Table.Insert(self, CrossIndex, Name, Description)
|
||||
|
||||
## Init table
|
||||
#
|
||||
# Create all default records of table DataModel
|
||||
#
|
||||
def InitTable(self):
|
||||
EdkLogger.verbose("\nInitialize table DataModel started ...")
|
||||
Count = self.GetCount()
|
||||
if Count != None and Count != 0:
|
||||
return
|
||||
for Item in DataClass.MODEL_LIST:
|
||||
CrossIndex = Item[1]
|
||||
Name = Item[0]
|
||||
Description = Item[0]
|
||||
self.Insert(CrossIndex, Name, Description)
|
||||
EdkLogger.verbose("Initialize table DataModel ... DONE!")
|
||||
|
||||
## Get CrossIndex
|
||||
#
|
||||
# Get a model's cross index from its name
|
||||
#
|
||||
# @param ModelName: Name of the model
|
||||
# @retval CrossIndex: CrossIndex of the model
|
||||
#
|
||||
def GetCrossIndex(self, ModelName):
|
||||
CrossIndex = -1
|
||||
SqlCommand = """select CrossIndex from DataModel where name = '""" + ModelName + """'"""
|
||||
self.Cur.execute(SqlCommand)
|
||||
for Item in self.Cur:
|
||||
CrossIndex = Item[0]
|
||||
|
||||
return CrossIndex
|
||||
|
1849
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
Normal file
1849
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
Normal file
File diff suppressed because it is too large
Load Diff
332
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py
Normal file
332
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py
Normal file
@ -0,0 +1,332 @@
|
||||
## @file
|
||||
# This file is used to create/update/query/erase a meta file table
|
||||
#
|
||||
# Copyright (c) 2008, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import uuid
|
||||
|
||||
import Common.EdkLogger as EdkLogger
|
||||
import EccGlobalData
|
||||
|
||||
from MetaDataTable import Table
|
||||
from MetaDataTable import ConvertToSqlString
|
||||
from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \
|
||||
MODEL_FILE_OTHERS
|
||||
|
||||
class MetaFileTable(Table):
|
||||
## Constructor
|
||||
def __init__(self, Cursor, MetaFile, FileType, TableName, Temporary = False):
|
||||
self.MetaFile = MetaFile
|
||||
self.TblFile = EccGlobalData.gDb.TblFile
|
||||
if (FileType == MODEL_FILE_INF):
|
||||
TableName = "Inf"
|
||||
if (FileType == MODEL_FILE_DSC):
|
||||
if Temporary:
|
||||
TableName = "_%s_%s" % ("Dsc", uuid.uuid4().hex)
|
||||
else:
|
||||
TableName = "Dsc"
|
||||
if (FileType == MODEL_FILE_DEC):
|
||||
TableName = "Dec"
|
||||
|
||||
Table.__init__(self, Cursor, TableName, 0, Temporary)
|
||||
self.Create(False)
|
||||
|
||||
|
||||
## Python class representation of table storing module data
|
||||
class ModuleTable(MetaFileTable):
|
||||
_COLUMN_ = '''
|
||||
ID REAL PRIMARY KEY,
|
||||
Model INTEGER NOT NULL,
|
||||
Value1 TEXT NOT NULL,
|
||||
Value2 TEXT,
|
||||
Value3 TEXT,
|
||||
Scope1 TEXT,
|
||||
Scope2 TEXT,
|
||||
BelongsToItem REAL NOT NULL,
|
||||
BelongsToFile SINGLE NOT NULL,
|
||||
StartLine INTEGER NOT NULL,
|
||||
StartColumn INTEGER NOT NULL,
|
||||
EndLine INTEGER NOT NULL,
|
||||
EndColumn INTEGER NOT NULL,
|
||||
Enabled INTEGER DEFAULT 0
|
||||
'''
|
||||
# used as table end flag, in case the changes to database is not committed to db file
|
||||
_DUMMY_ = "-1, -1, '====', '====', '====', '====', '====', -1, -1, -1, -1, -1, -1, -1"
|
||||
|
||||
## Constructor
|
||||
def __init__(self, Cursor):
|
||||
MetaFileTable.__init__(self, Cursor, '', MODEL_FILE_INF, "Inf", False)
|
||||
|
||||
## Insert a record into table Inf
|
||||
#
|
||||
# @param Model: Model of a Inf item
|
||||
# @param Value1: Value1 of a Inf item
|
||||
# @param Value2: Value2 of a Inf item
|
||||
# @param Value3: Value3 of a Inf item
|
||||
# @param Scope1: Arch of a Inf item
|
||||
# @param Scope2 Platform os a Inf item
|
||||
# @param BelongsToItem: The item belongs to which another item
|
||||
# @param StartLine: StartLine of a Inf item
|
||||
# @param StartColumn: StartColumn of a Inf item
|
||||
# @param EndLine: EndLine of a Inf item
|
||||
# @param EndColumn: EndColumn of a Inf item
|
||||
# @param Enabled: If this item enabled
|
||||
#
|
||||
def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON',
|
||||
BelongsToItem=-1, BelongsToFile = -1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0):
|
||||
(Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))
|
||||
return Table.Insert(
|
||||
self,
|
||||
Model,
|
||||
Value1,
|
||||
Value2,
|
||||
Value3,
|
||||
Scope1,
|
||||
Scope2,
|
||||
BelongsToItem,
|
||||
BelongsToFile,
|
||||
StartLine,
|
||||
StartColumn,
|
||||
EndLine,
|
||||
EndColumn,
|
||||
Enabled
|
||||
)
|
||||
|
||||
## Query table
|
||||
#
|
||||
# @param Model: The Model of Record
|
||||
# @param Arch: The Arch attribute of Record
|
||||
# @param Platform The Platform attribute of Record
|
||||
#
|
||||
# @retval: A recordSet of all found records
|
||||
#
|
||||
def Query(self, Model, Arch=None, Platform=None):
|
||||
ConditionString = "Model=%s AND Enabled>=0" % Model
|
||||
ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"
|
||||
|
||||
if Arch != None and Arch != 'COMMON':
|
||||
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch
|
||||
if Platform != None and Platform != 'COMMON':
|
||||
ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Platform
|
||||
|
||||
SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)
|
||||
return self.Exec(SqlCommand)
|
||||
|
||||
## Python class representation of table storing package data
|
||||
class PackageTable(MetaFileTable):
|
||||
_COLUMN_ = '''
|
||||
ID REAL PRIMARY KEY,
|
||||
Model INTEGER NOT NULL,
|
||||
Value1 TEXT NOT NULL,
|
||||
Value2 TEXT,
|
||||
Value3 TEXT,
|
||||
Scope1 TEXT,
|
||||
Scope2 TEXT,
|
||||
BelongsToItem REAL NOT NULL,
|
||||
BelongsToFile SINGLE NOT NULL,
|
||||
StartLine INTEGER NOT NULL,
|
||||
StartColumn INTEGER NOT NULL,
|
||||
EndLine INTEGER NOT NULL,
|
||||
EndColumn INTEGER NOT NULL,
|
||||
Enabled INTEGER DEFAULT 0
|
||||
'''
|
||||
# used as table end flag, in case the changes to database is not committed to db file
|
||||
_DUMMY_ = "-1, -1, '====', '====', '====', '====', '====', -1, -1, -1, -1, -1, -1, -1"
|
||||
|
||||
## Constructor
|
||||
def __init__(self, Cursor):
|
||||
MetaFileTable.__init__(self, Cursor, '', MODEL_FILE_DEC, "Dec", False)
|
||||
|
||||
## Insert table
|
||||
#
|
||||
# Insert a record into table Dec
|
||||
#
|
||||
# @param Model: Model of a Dec item
|
||||
# @param Value1: Value1 of a Dec item
|
||||
# @param Value2: Value2 of a Dec item
|
||||
# @param Value3: Value3 of a Dec item
|
||||
# @param Scope1: Arch of a Dec item
|
||||
# @param Scope2: Module type of a Dec item
|
||||
# @param BelongsToItem: The item belongs to which another item
|
||||
# @param StartLine: StartLine of a Dec item
|
||||
# @param StartColumn: StartColumn of a Dec item
|
||||
# @param EndLine: EndLine of a Dec item
|
||||
# @param EndColumn: EndColumn of a Dec item
|
||||
# @param Enabled: If this item enabled
|
||||
#
|
||||
def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON',
|
||||
BelongsToItem=-1, BelongsToFile = -1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0):
|
||||
(Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))
|
||||
return Table.Insert(
|
||||
self,
|
||||
Model,
|
||||
Value1,
|
||||
Value2,
|
||||
Value3,
|
||||
Scope1,
|
||||
Scope2,
|
||||
BelongsToItem,
|
||||
BelongsToFile,
|
||||
StartLine,
|
||||
StartColumn,
|
||||
EndLine,
|
||||
EndColumn,
|
||||
Enabled
|
||||
)
|
||||
|
||||
## Query table
|
||||
#
|
||||
# @param Model: The Model of Record
|
||||
# @param Arch: The Arch attribute of Record
|
||||
#
|
||||
# @retval: A recordSet of all found records
|
||||
#
|
||||
def Query(self, Model, Arch=None):
|
||||
ConditionString = "Model=%s AND Enabled>=0" % Model
|
||||
ValueString = "Value1,Value2,Value3,Scope1,ID,StartLine"
|
||||
|
||||
if Arch != None and Arch != 'COMMON':
|
||||
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch
|
||||
|
||||
SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)
|
||||
return self.Exec(SqlCommand)
|
||||
|
||||
## Python class representation of table storing platform data
|
||||
class PlatformTable(MetaFileTable):
|
||||
_COLUMN_ = '''
|
||||
ID REAL PRIMARY KEY,
|
||||
Model INTEGER NOT NULL,
|
||||
Value1 TEXT NOT NULL,
|
||||
Value2 TEXT,
|
||||
Value3 TEXT,
|
||||
Scope1 TEXT,
|
||||
Scope2 TEXT,
|
||||
BelongsToItem REAL NOT NULL,
|
||||
BelongsToFile SINGLE NOT NULL,
|
||||
FromItem REAL NOT NULL,
|
||||
StartLine INTEGER NOT NULL,
|
||||
StartColumn INTEGER NOT NULL,
|
||||
EndLine INTEGER NOT NULL,
|
||||
EndColumn INTEGER NOT NULL,
|
||||
Enabled INTEGER DEFAULT 0
|
||||
'''
|
||||
# used as table end flag, in case the changes to database is not committed to db file
|
||||
_DUMMY_ = "-1, -1, '====', '====', '====', '====', '====', -1, -1, -1, -1, -1, -1, -1, -1"
|
||||
|
||||
## Constructor
|
||||
def __init__(self, Cursor, MetaFile = '', FileType = MODEL_FILE_DSC, Temporary = False):
|
||||
MetaFileTable.__init__(self, Cursor, MetaFile, FileType, "Dsc", Temporary)
|
||||
|
||||
## Insert table
|
||||
#
|
||||
# Insert a record into table Dsc
|
||||
#
|
||||
# @param Model: Model of a Dsc item
|
||||
# @param Value1: Value1 of a Dsc item
|
||||
# @param Value2: Value2 of a Dsc item
|
||||
# @param Value3: Value3 of a Dsc item
|
||||
# @param Scope1: Arch of a Dsc item
|
||||
# @param Scope2: Module type of a Dsc item
|
||||
# @param BelongsToItem: The item belongs to which another item
|
||||
# @param FromItem: The item belongs to which dsc file
|
||||
# @param StartLine: StartLine of a Dsc item
|
||||
# @param StartColumn: StartColumn of a Dsc item
|
||||
# @param EndLine: EndLine of a Dsc item
|
||||
# @param EndColumn: EndColumn of a Dsc item
|
||||
# @param Enabled: If this item enabled
|
||||
#
|
||||
def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON', BelongsToItem=-1, BelongsToFile = -1,
|
||||
FromItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=1):
|
||||
(Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))
|
||||
return Table.Insert(
|
||||
self,
|
||||
Model,
|
||||
Value1,
|
||||
Value2,
|
||||
Value3,
|
||||
Scope1,
|
||||
Scope2,
|
||||
BelongsToItem,
|
||||
BelongsToFile,
|
||||
FromItem,
|
||||
StartLine,
|
||||
StartColumn,
|
||||
EndLine,
|
||||
EndColumn,
|
||||
Enabled
|
||||
)
|
||||
|
||||
## Query table
|
||||
#
|
||||
# @param Model: The Model of Record
|
||||
# @param Scope1: Arch of a Dsc item
|
||||
# @param Scope2: Module type of a Dsc item
|
||||
# @param BelongsToItem: The item belongs to which another item
|
||||
# @param FromItem: The item belongs to which dsc file
|
||||
#
|
||||
# @retval: A recordSet of all found records
|
||||
#
|
||||
def Query(self, Model, Scope1=None, Scope2=None, BelongsToItem=None, FromItem=None):
|
||||
ConditionString = "Model=%s AND Enabled>0" % Model
|
||||
ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"
|
||||
|
||||
if Scope1 != None and Scope1 != 'COMMON':
|
||||
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Scope1
|
||||
if Scope2 != None and Scope2 != 'COMMON':
|
||||
ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Scope2
|
||||
|
||||
if BelongsToItem != None:
|
||||
ConditionString += " AND BelongsToItem=%s" % BelongsToItem
|
||||
else:
|
||||
ConditionString += " AND BelongsToItem<0"
|
||||
|
||||
if FromItem != None:
|
||||
ConditionString += " AND FromItem=%s" % FromItem
|
||||
|
||||
SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)
|
||||
return self.Exec(SqlCommand)
|
||||
|
||||
## Factory class to produce different storage for different type of meta-file
|
||||
class MetaFileStorage(object):
|
||||
_FILE_TABLE_ = {
|
||||
MODEL_FILE_INF : ModuleTable,
|
||||
MODEL_FILE_DEC : PackageTable,
|
||||
MODEL_FILE_DSC : PlatformTable,
|
||||
MODEL_FILE_OTHERS : MetaFileTable,
|
||||
}
|
||||
|
||||
_FILE_TYPE_ = {
|
||||
".inf" : MODEL_FILE_INF,
|
||||
".dec" : MODEL_FILE_DEC,
|
||||
".dsc" : MODEL_FILE_DSC,
|
||||
}
|
||||
|
||||
## Constructor
|
||||
def __new__(Class, Cursor, MetaFile, FileType=None, Temporary=False):
|
||||
# no type given, try to find one
|
||||
if not FileType:
|
||||
if MetaFile.Type in self._FILE_TYPE_:
|
||||
FileType = Class._FILE_TYPE_[MetaFile.Type]
|
||||
else:
|
||||
FileType = MODEL_FILE_OTHERS
|
||||
|
||||
# don't pass the type around if it's well known
|
||||
if FileType == MODEL_FILE_OTHERS:
|
||||
Args = (Cursor, MetaFile, FileType, Temporary)
|
||||
else:
|
||||
Args = (Cursor, MetaFile, FileType, Temporary)
|
||||
|
||||
# create the storage object and return it to caller
|
||||
return Class._FILE_TABLE_[FileType](*Args)
|
||||
|
15
BaseTools/Source/Python/Ecc/MetaFileWorkspace/__init__.py
Normal file
15
BaseTools/Source/Python/Ecc/MetaFileWorkspace/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'Workspace' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2008 - 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
@ -2305,28 +2305,90 @@ def CheckFileHeaderDoxygenComments(FullFileName):
|
||||
""" % (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)
|
||||
PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'No File License header appear at the very beginning of file.', 'File', FileID)
|
||||
return ErrorMsgList
|
||||
|
||||
IsFoundError1 = True
|
||||
IsFoundError2 = True
|
||||
IsFoundError3 = True
|
||||
NoHeaderCommentStartFlag = True
|
||||
NoHeaderCommentEndFlag = True
|
||||
NoHeaderCommentPeriodFlag = True
|
||||
NoCopyrightFlag = True
|
||||
NoLicenseFlag = True
|
||||
NoRevReferFlag = True
|
||||
NextLineIndex = 0
|
||||
for Result in ResultSet:
|
||||
FileStartFlag = False
|
||||
CommentStrList = []
|
||||
CommentStr = Result[0].strip()
|
||||
CommentStrListTemp = CommentStr.split('\n')
|
||||
if (len(CommentStrListTemp) <= 1):
|
||||
# For Mac
|
||||
CommentStrListTemp = CommentStr.split('\r')
|
||||
# Skip the content before the file header
|
||||
for CommentLine in CommentStrListTemp:
|
||||
if CommentLine.strip().startswith('/** @file'):
|
||||
FileStartFlag = True
|
||||
if FileStartFlag == True:
|
||||
CommentStrList.append(CommentLine)
|
||||
|
||||
ID = Result[1]
|
||||
if CommentStr.startswith('/** @file'):
|
||||
IsFoundError1 = False
|
||||
if CommentStr.endswith('**/'):
|
||||
IsFoundError2 = False
|
||||
if CommentStr.find('.') != -1:
|
||||
IsFoundError3 = False
|
||||
Index = 0
|
||||
if CommentStrList and CommentStrList[0].strip().startswith('/** @file'):
|
||||
NoHeaderCommentStartFlag = False
|
||||
else:
|
||||
continue
|
||||
if CommentStrList and CommentStrList[-1].strip().endswith('**/'):
|
||||
NoHeaderCommentEndFlag = False
|
||||
else:
|
||||
continue
|
||||
|
||||
if IsFoundError1:
|
||||
for CommentLine in CommentStrList:
|
||||
Index = Index + 1
|
||||
NextLineIndex = Index
|
||||
if CommentLine.startswith('/** @file'):
|
||||
continue
|
||||
if CommentLine.startswith('**/'):
|
||||
break
|
||||
# Check whether C File header Comment content start with two spaces.
|
||||
if EccGlobalData.gConfig.HeaderCheckCFileCommentStartSpacesNum == '1' or EccGlobalData.gConfig.HeaderCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
if CommentLine.startswith('/** @file') == False and CommentLine.startswith('**/') == False and CommentLine.strip() and CommentLine.startswith(' ') == False:
|
||||
PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header comment content should start with two spaces at each line', FileTable, ID)
|
||||
|
||||
CommentLine = CommentLine.strip()
|
||||
if CommentLine.startswith('Copyright'):
|
||||
NoCopyrightFlag = False
|
||||
if CommentLine.find('All rights reserved') == -1:
|
||||
PrintErrorMsg(ERROR_HEADER_CHECK_FILE, '""All rights reserved"" announcement should be following the ""Copyright"" at the same line', FileTable, ID)
|
||||
if CommentLine.endswith('<BR>') == -1:
|
||||
PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'The ""<BR>"" at the end of the Copyright line is required', FileTable, ID)
|
||||
if NextLineIndex < len(CommentStrList) and CommentStrList[NextLineIndex].strip().startswith('Copyright') == False and CommentStrList[NextLineIndex].strip():
|
||||
NoLicenseFlag = False
|
||||
if CommentLine.startswith('@par Revision Reference:'):
|
||||
NoRevReferFlag = False
|
||||
RefListFlag = False
|
||||
for RefLine in CommentStrList[NextLineIndex:]:
|
||||
if RefLine.strip() and (NextLineIndex + 1) < len(CommentStrList) and CommentStrList[NextLineIndex+1].strip() and CommentStrList[NextLineIndex+1].strip().startswith('**/') == False:
|
||||
RefListFlag = True
|
||||
if RefLine.strip() == False or RefLine.strip().startswith('**/'):
|
||||
RefListFlag = False
|
||||
break
|
||||
# Check whether C File header Comment's each reference at list should begin with a bullet character.
|
||||
if EccGlobalData.gConfig.HeaderCheckCFileCommentReferenceFormat == '1' or EccGlobalData.gConfig.HeaderCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
if RefListFlag == True:
|
||||
if RefLine.strip() and RefLine.strip().startswith('**/') == False and RefLine.startswith(' -') == False:
|
||||
PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'Each reference on a separate line should begin with a bullet character ""-"" ', FileTable, ID)
|
||||
|
||||
if NoHeaderCommentStartFlag:
|
||||
PrintErrorMsg(ERROR_DOXYGEN_CHECK_FILE_HEADER, 'File header comment should begin with ""/** @file""', FileTable, ID)
|
||||
if IsFoundError2:
|
||||
return
|
||||
if NoHeaderCommentEndFlag:
|
||||
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)
|
||||
return
|
||||
if NoCopyrightFlag:
|
||||
PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header comment missing the ""Copyright""', FileTable, ID)
|
||||
#Check whether C File header Comment have the License immediately after the ""Copyright"" line.
|
||||
if EccGlobalData.gConfig.HeaderCheckCFileCommentLicenseFormat == '1' or EccGlobalData.gConfig.HeaderCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
if NoLicenseFlag:
|
||||
PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header comment should have the License immediately after the ""Copyright"" line', FileTable, ID)
|
||||
|
||||
def CheckFuncHeaderDoxygenComments(FullFileName):
|
||||
ErrorMsgList = []
|
||||
|
@ -97,6 +97,14 @@ HeaderCheckAll = 0
|
||||
HeaderCheckFile = 1
|
||||
# Check whether Function header exists
|
||||
HeaderCheckFunction = 1
|
||||
# Check whether Meta data File header Comment End with '##'
|
||||
HeaderCheckFileCommentEnd = 0
|
||||
# Check whether C File header Comment content start with two spaces
|
||||
HeaderCheckCFileCommentStartSpacesNum = 0
|
||||
# Check whether C File header Comment's each reference at list should begin with a bullet character '-'
|
||||
HeaderCheckCFileCommentReferenceFormat = 0
|
||||
# Check whether C File header Comment have the License immediately after the ""Copyright"" line
|
||||
HeaderCheckCFileCommentLicenseFormat = 0
|
||||
|
||||
#
|
||||
# C Function Layout Checking
|
||||
|
Reference in New Issue
Block a user