aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbackends.py11
-rw-r--r--coredata.py1
-rwxr-xr-xenvironment.py6
3 files changed, 18 insertions, 0 deletions
diff --git a/backends.py b/backends.py
index 03869d1..43f2f5f 100755
--- a/backends.py
+++ b/backends.py
@@ -699,6 +699,15 @@ class NinjaBackend(Backend):
other_deps.append(outfilename)
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):
targetlist = [self.get_target_filename(t) for t in self.build.get_targets().values()]
elem = NinjaBuildElement('all', 'phony', targetlist)
@@ -723,3 +732,5 @@ class NinjaBackend(Backend):
elem = NinjaBuildElement(deps, 'phony', '')
elem.write(outfile)
+
+ self.generate_cppcheck_target(outfile)
diff --git a/coredata.py b/coredata.py
index fa0709f..aa846ff 100644
--- a/coredata.py
+++ b/coredata.py
@@ -68,6 +68,7 @@ forbidden_target_names = {'clean': None,
'test-valgrind': None,
'install': None,
'build.ninja': None,
+ 'cppcheck': None,
}
class MesonException(Exception):
diff --git a/environment.py b/environment.py
index 12b7f22..11274db 100755
--- a/environment.py
+++ b/environment.py
@@ -451,6 +451,12 @@ def find_valgrind():
valgrind_exe = None
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():
return platform.system().lower() == 'darwin'