aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-12-16 23:47:33 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2015-12-16 23:47:33 +0200
commit79dc1135f1b16045602c3cb9ed7e8cf2f073a8bb (patch)
tree5c86393193de854fd4c6e68ff84f8fdfd7232ffc
parenteb2aefd0381647ff1b9d18c6504f6d8f34d581cb (diff)
downloadmeson-79dc1135f1b16045602c3cb9ed7e8cf2f073a8bb.zip
meson-79dc1135f1b16045602c3cb9ed7e8cf2f073a8bb.tar.gz
meson-79dc1135f1b16045602c3cb9ed7e8cf2f073a8bb.tar.bz2
Automatically generate compile commands db for tooling.
-rw-r--r--ninjabackend.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/ninjabackend.py b/ninjabackend.py
index f8038d6..d8b9e8f 100644
--- a/ninjabackend.py
+++ b/ninjabackend.py
@@ -22,6 +22,7 @@ from meson_install import InstallData
from build import InvalidArguments
from coredata import MesonException
import os, sys, pickle, re
+import subprocess
if mesonlib.is_windows():
quote_char = '"'
@@ -159,6 +160,14 @@ class NinjaBackend(backends.Backend):
# fully created.
outfile.close()
os.replace(tempfilename, outfilename)
+ self.generate_compdb()
+
+ # http://clang.llvm.org/docs/JSONCompilationDatabase.html
+ def generate_compdb(self):
+ ninja_exe = environment.detect_ninja()
+ builddir = self.environment.get_build_dir()
+ jsondb = subprocess.check_output([ninja_exe, '-t', 'compdb', 'c_COMPILER', 'cpp_COMPILER'], cwd=builddir)
+ open(os.path.join(builddir, 'compile_commands.json'), 'wb').write(jsondb)
# Get all generated headers. Any source file might need them so
# we need to add an order dependency to them.