From 572cd98aabbabba9e8d56116ed21e28c1c853452 Mon Sep 17 00:00:00 2001 From: fedepell Date: Tue, 25 Oct 2016 10:05:24 +0200 Subject: [PATCH] cppcheck: add possibility to use -j option for multiple parallel threads, speeds up drastically when executing on multiple source files --- waflib/extras/cppcheck.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/waflib/extras/cppcheck.py b/waflib/extras/cppcheck.py index 77f65e5b..1a0cccce 100644 --- a/waflib/extras/cppcheck.py +++ b/waflib/extras/cppcheck.py @@ -134,6 +134,10 @@ def options(opt): default='20', action='store', help='maximum preprocessor (--max-configs) define iterations (default=20)') + opt.add_option('--cppcheck-jobs', dest='cppcheck_jobs', + default='1', action='store', + help='number of jobs (-j) to do the checking work (default=1)') + def configure(conf): if conf.options.cppcheck_skip: @@ -143,6 +147,9 @@ def configure(conf): conf.env.CPPCHECK_MAX_CONFIGS = conf.options.cppcheck_max_configs conf.env.CPPCHECK_BIN_ENABLE = conf.options.cppcheck_bin_enable conf.env.CPPCHECK_LIB_ENABLE = conf.options.cppcheck_lib_enable + conf.env.CPPCHECK_JOBS = conf.options.cppcheck_jobs + if conf.options.cppcheck_jobs != '1' and ('unusedFunction' in conf.options.cppcheck_bin_enable or 'unusedFunction' in conf.options.cppcheck_lib_enable or 'all' in conf.options.cppcheck_bin_enable or 'all' in conf.options.cppcheck_lib_enable): + Logs.warn('cppcheck: unusedFunction cannot be used with multiple threads, cppcheck will disable it automatically') conf.find_program('cppcheck', var='CPPCHECK') @@ -169,10 +176,12 @@ def _tgen_create_cmd(self): max_configs = self.env.CPPCHECK_MAX_CONFIGS bin_enable = self.env.CPPCHECK_BIN_ENABLE lib_enable = self.env.CPPCHECK_LIB_ENABLE + jobs = self.env.CPPCHECK_JOBS cmd = self.env.CPPCHECK args = ['--inconclusive','--report-progress','--verbose','--xml','--xml-version=2'] args.append('--max-configs=%s' % max_configs) + args.append('-j %s' % jobs) if 'cxx' in features: args.append('--language=c++')