Support for cppcheck.

This commit is contained in:
Jussi Pakkanen 2013-05-14 00:48:56 +03:00
parent 4d1ee0b8f2
commit 83f0e6744e
3 changed files with 18 additions and 0 deletions

View File

@ -699,6 +699,15 @@ class NinjaBackend(Backend):
other_deps.append(outfilename) other_deps.append(outfilename)
return (src_deps, other_deps) return (src_deps, other_deps)
def generate_cppcheck_target(self, outfile):
cppcheck_exe = environment.find_cppcheck()
if not cppcheck_exe:
return
elem = NinjaBuildElement('cppcheck', 'CUSTOM_COMMAND', [])
elem.add_item('COMMAND', [cppcheck_exe, self.environment.get_source_dir()])
elem.add_item('description', 'Running cppchecker')
elem.write(outfile)
def generate_ending(self, outfile): def generate_ending(self, outfile):
targetlist = [self.get_target_filename(t) for t in self.build.get_targets().values()] targetlist = [self.get_target_filename(t) for t in self.build.get_targets().values()]
elem = NinjaBuildElement('all', 'phony', targetlist) elem = NinjaBuildElement('all', 'phony', targetlist)
@ -723,3 +732,5 @@ class NinjaBackend(Backend):
elem = NinjaBuildElement(deps, 'phony', '') elem = NinjaBuildElement(deps, 'phony', '')
elem.write(outfile) elem.write(outfile)
self.generate_cppcheck_target(outfile)

View File

@ -68,6 +68,7 @@ forbidden_target_names = {'clean': None,
'test-valgrind': None, 'test-valgrind': None,
'install': None, 'install': None,
'build.ninja': None, 'build.ninja': None,
'cppcheck': None,
} }
class MesonException(Exception): class MesonException(Exception):

View File

@ -451,6 +451,12 @@ def find_valgrind():
valgrind_exe = None valgrind_exe = None
return valgrind_exe return valgrind_exe
def find_cppcheck():
cppcheck_exe = 'cppcheck'
if not exe_exists([cppcheck_exe, '-h']):
cppcheck_exe = None
return cppcheck_exe
def is_osx(): def is_osx():
return platform.system().lower() == 'darwin' return platform.system().lower() == 'darwin'