diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-12-16 23:47:33 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-12-16 23:47:33 +0200 |
commit | 79dc1135f1b16045602c3cb9ed7e8cf2f073a8bb (patch) | |
tree | 5c86393193de854fd4c6e68ff84f8fdfd7232ffc | |
parent | eb2aefd0381647ff1b9d18c6504f6d8f34d581cb (diff) | |
download | meson-79dc1135f1b16045602c3cb9ed7e8cf2f073a8bb.zip meson-79dc1135f1b16045602c3cb9ed7e8cf2f073a8bb.tar.gz meson-79dc1135f1b16045602c3cb9ed7e8cf2f073a8bb.tar.bz2 |
Automatically generate compile commands db for tooling.
-rw-r--r-- | ninjabackend.py | 9 |
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. |