mirror of https://gitlab.com/ita1024/waf.git
Whitespace and Options.options for cppcheck
This commit is contained in:
parent
2197dbdff1
commit
9332a9c24d
|
@ -5,12 +5,12 @@
|
|||
"""
|
||||
Tool Description
|
||||
================
|
||||
This module provides a waf wrapper (i.e. waftool) around the C/C++ source code
|
||||
This module provides a waf wrapper (i.e. waftool) around the C/C++ source code
|
||||
checking tool 'cppcheck'.
|
||||
|
||||
See http://cppcheck.sourceforge.net/ for more information on the cppcheck tool
|
||||
itself.
|
||||
Note that many linux distributions already provide a ready to install version
|
||||
itself.
|
||||
Note that many linux distributions already provide a ready to install version
|
||||
of cppcheck. On fedora, for instance, it can be installed using yum:
|
||||
|
||||
'sudo yum install cppcheck'
|
||||
|
@ -18,7 +18,7 @@ of cppcheck. On fedora, for instance, it can be installed using yum:
|
|||
|
||||
Usage
|
||||
=====
|
||||
In order to use this waftool simply add it to the 'options' and 'configure'
|
||||
In order to use this waftool simply add it to the 'options' and 'configure'
|
||||
functions of your main waf script as shown in the example below:
|
||||
|
||||
def options(opt):
|
||||
|
@ -26,12 +26,12 @@ functions of your main waf script as shown in the example below:
|
|||
|
||||
def configure(conf):
|
||||
conf.load('cppcheck')
|
||||
|
||||
Note that example shown above assumes that the cppcheck waftool is located in
|
||||
|
||||
Note that example shown above assumes that the cppcheck waftool is located in
|
||||
the sub directory named 'waftools'.
|
||||
|
||||
When configured as shown in the example above, cppcheck will automatically
|
||||
perform a source code analysis on all C/C++ build tasks that have been
|
||||
When configured as shown in the example above, cppcheck will automatically
|
||||
perform a source code analysis on all C/C++ build tasks that have been
|
||||
defined in your waf build system.
|
||||
|
||||
The example shown below for a C program will be used as input for cppcheck when
|
||||
|
@ -40,16 +40,16 @@ building the task.
|
|||
def build(bld):
|
||||
bld.program(name='foo', src='foobar.c')
|
||||
|
||||
The result of the source code analysis will be stored both as xml and html
|
||||
files in the build location for the task. Should any error be detected by
|
||||
The result of the source code analysis will be stored both as xml and html
|
||||
files in the build location for the task. Should any error be detected by
|
||||
cppcheck the build will be aborted and a link to the html report will be shown.
|
||||
|
||||
When needed source code checking by cppcheck can be disabled per task, per
|
||||
detected error or warning for a particular task. It can be also be disabled for
|
||||
When needed source code checking by cppcheck can be disabled per task, per
|
||||
detected error or warning for a particular task. It can be also be disabled for
|
||||
all tasks.
|
||||
|
||||
In order to exclude a task from source code checking add the skip option to the
|
||||
task as shown below:
|
||||
task as shown below:
|
||||
|
||||
def build(bld):
|
||||
bld.program(
|
||||
|
@ -58,8 +58,8 @@ task as shown below:
|
|||
cppcheck_skip=True
|
||||
)
|
||||
|
||||
When needed problems detected by cppcheck may be suppressed using a file
|
||||
containing a list of suppression rules. The relative or absolute path to this
|
||||
When needed problems detected by cppcheck may be suppressed using a file
|
||||
containing a list of suppression rules. The relative or absolute path to this
|
||||
file can be added to the build task as shown in the example below:
|
||||
|
||||
bld.program(
|
||||
|
@ -68,27 +68,27 @@ file can be added to the build task as shown in the example below:
|
|||
cppcheck_suppress='bar.suppress'
|
||||
)
|
||||
|
||||
A cppcheck suppress file should contain one suppress rule per line. Each of
|
||||
A cppcheck suppress file should contain one suppress rule per line. Each of
|
||||
these rules will be passed as an '--suppress=<rule>' argument to cppcheck.
|
||||
|
||||
Dependencies
|
||||
================
|
||||
This waftool depends on the python pygments module, it is used for source code
|
||||
syntax highlighting when creating the html reports. see http://pygments.org/ for
|
||||
This waftool depends on the python pygments module, it is used for source code
|
||||
syntax highlighting when creating the html reports. see http://pygments.org/ for
|
||||
more information on this package.
|
||||
|
||||
Remarks
|
||||
================
|
||||
The generation of the html report is originally based on the cppcheck-htmlreport.py
|
||||
The generation of the html report is originally based on the cppcheck-htmlreport.py
|
||||
script that comes shipped with the cppcheck tool.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import xml.etree.ElementTree as ElementTree
|
||||
from waflib import Task, TaskGen, Logs, Context
|
||||
from waflib import Task, TaskGen, Logs, Context, Options
|
||||
|
||||
PYGMENTS_EXC_MSG= '''
|
||||
The required module 'pygments' could not be found. Please install it using your
|
||||
The required module 'pygments' could not be found. Please install it using your
|
||||
platform package manager (e.g. apt-get or yum), using 'pip' or 'easy_install',
|
||||
see 'http://pygments.org/download/' for installation instructions.
|
||||
'''
|
||||
|
@ -102,36 +102,36 @@ except ImportError as e:
|
|||
|
||||
|
||||
def options(opt):
|
||||
opt.add_option('--cppcheck-skip', dest='cppcheck_skip',
|
||||
default=False, action='store_true',
|
||||
opt.add_option('--cppcheck-skip', dest='cppcheck_skip',
|
||||
default=False, action='store_true',
|
||||
help='do not check C/C++ sources (default=False)')
|
||||
|
||||
opt.add_option('--cppcheck-err-resume', dest='cppcheck_err_resume',
|
||||
default=False, action='store_true',
|
||||
opt.add_option('--cppcheck-err-resume', dest='cppcheck_err_resume',
|
||||
default=False, action='store_true',
|
||||
help='continue in case of errors (default=False)')
|
||||
|
||||
opt.add_option('--cppcheck-bin-enable', dest='cppcheck_bin_enable',
|
||||
opt.add_option('--cppcheck-bin-enable', dest='cppcheck_bin_enable',
|
||||
default='warning,performance,portability,style,unusedFunction', action='store',
|
||||
help="cppcheck option '--enable=' for binaries (default=warning,performance,portability,style,unusedFunction)")
|
||||
|
||||
opt.add_option('--cppcheck-lib-enable', dest='cppcheck_lib_enable',
|
||||
default='warning,performance,portability,style', action='store',
|
||||
opt.add_option('--cppcheck-lib-enable', dest='cppcheck_lib_enable',
|
||||
default='warning,performance,portability,style', action='store',
|
||||
help="cppcheck option '--enable=' for libraries (default=warning,performance,portability,style)")
|
||||
|
||||
opt.add_option('--cppcheck-std-c', dest='cppcheck_std_c',
|
||||
default='c99', action='store',
|
||||
default='c99', action='store',
|
||||
help='cppcheck standard to use when checking C (default=c99)')
|
||||
|
||||
opt.add_option('--cppcheck-std-cxx', dest='cppcheck_std_cxx',
|
||||
default='c++03', action='store',
|
||||
default='c++03', action='store',
|
||||
help='cppcheck standard to use when checking C++ (default=c++03)')
|
||||
|
||||
opt.add_option('--cppcheck-check-config', dest='cppcheck_check_config',
|
||||
default=False, action='store_true',
|
||||
opt.add_option('--cppcheck-check-config', dest='cppcheck_check_config',
|
||||
default=False, action='store_true',
|
||||
help='forced check for missing buildin include files, e.g. stdio.h (default=False)')
|
||||
|
||||
opt.add_option('--cppcheck-max-configs', dest='cppcheck_max_configs',
|
||||
default='20', action='store',
|
||||
default='20', action='store',
|
||||
help='maximum preprocessor (--max-configs) define iterations (default=20)')
|
||||
|
||||
|
||||
|
@ -149,14 +149,14 @@ def configure(conf):
|
|||
@TaskGen.feature('c')
|
||||
@TaskGen.feature('cxx')
|
||||
def cppcheck_execute(self):
|
||||
if len(self.env.CPPCHECK_SKIP) or self.bld.options.cppcheck_skip:
|
||||
if len(self.env.CPPCHECK_SKIP) or Options.options.cppcheck_skip:
|
||||
return
|
||||
if getattr(self, 'cppcheck_skip', False):
|
||||
return
|
||||
task = self.create_task('cppcheck')
|
||||
task.cmd = _tgen_create_cmd(self)
|
||||
task.fatal = []
|
||||
if not self.bld.options.cppcheck_err_resume:
|
||||
if not Options.options.cppcheck_err_resume:
|
||||
task.fatal.append('error')
|
||||
|
||||
|
||||
|
@ -179,7 +179,7 @@ def _tgen_create_cmd(self):
|
|||
args.append('--language=c')
|
||||
args.append('--std=%s' % std_c)
|
||||
|
||||
if self.bld.options.cppcheck_check_config:
|
||||
if Options.options.cppcheck_check_config:
|
||||
args.append('--check-config')
|
||||
|
||||
if set(['cprogram','cxxprogram']) & set(features):
|
||||
|
@ -251,7 +251,7 @@ class cppcheck(Task.Task):
|
|||
sources[name] = [defect]
|
||||
else:
|
||||
sources[name].append(defect)
|
||||
|
||||
|
||||
files = {}
|
||||
css_style_defs = None
|
||||
bpath = self.generator.path.get_bld().abspath()
|
||||
|
@ -352,7 +352,7 @@ class cppcheck(Task.Task):
|
|||
node.write(css)
|
||||
|
||||
def _errors_evaluate(self, errors, http_index):
|
||||
name = self.generator.get_name()
|
||||
name = self.generator.get_name()
|
||||
fatal = self.fatal
|
||||
severity = [err['severity'] for err in errors]
|
||||
problems = [err for err in errors if err['severity'] != 'information']
|
||||
|
@ -418,7 +418,7 @@ CPPCHECK_HTML_FILE = """
|
|||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div id="page-footer"> </div>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue