Package: compiledb
Compilation Database GeneratorTool for generatingClang's JSON Compilation Databasefile for GNUmake-based build systems.It's aimed mainly at non-cmake (cmake already generates compilation database)
large codebases. Inspired by projects likeYCM-GeneratorandBear,
but faster (mainly with large projects), since in most cases itdoesn't need a clean
build(as the mentioned tools do) to generate the compilation database file, to
achieve this it uses the make options such as-n/--dry-runand-k/--keep-goingto extract the compile commands. Also, it's morecross-compiling friendlythan
YCM-generator's fake-toolchanin approach.Installation# pip install compiledbSupports Python 2.x and 3.x (for now, tested only with 2.7 and 3.6 versions)For bash completion support, add the content ofsh-completion/compiledb.bashfile
to your.bashrcfile, for example.ZSH completion coming soon :)Usagecompiledbprovides amakepython wrapper script which, besides to execute the make
build command, updates the JSON compilation database file corresponding to that build,
resulting in a command-line interface similar toBear.To generatecompile_commands.jsonfile using compiledb's "make wrapper" script,
executing Makefile targetall:$compiledbmakecompiledbforwards all the options/arguments passed aftermakesubcommand to GNU Make,
so one can, for example, generatecompile_commands.jsonusingcore/main.mkas main makefile (-fflag), starting the build frombuilddirectory (-Cflag):$compiledbmake-fcore/main.mk-CbuildBy default,compiledb makegenerates the compilation database and runs the actual build
command requested (acting as a make wrapper), the build step can be skipped using the-nor--no-buildoptions.$compiledb-nmakecompiledbbase command has been designed so that it can be used to parse compile commands
from arbitrary text files (or stdin), assuming it has a build log (ideally generated usingmake -Bnwkcommand), and generates the corresponding JSON Compilation database.For example, to generate the compilation database frombuild-log.txtfile, use the following
command.$compiledb--parsebuild-log.txtor its equivalent:$compiledb<build-log.txtOr even, to pipe make's output and print the compilation database to the standard output:$make-Bnwk|compiledb-o-By defaultcompiledbgenerates a JSON compilation database in the "arguments" listformat. The "command" string
format is also supported through the use of the--command-styleflag:$compiledb--command-stylemakeTesting / ContributingI've implemented this tool because I needed to index someAOSP's modules for navigating
and studying purposes (after having no satisfatory results with current tools available by the
time such asYCM-GeneratorandBear). So I've reworked YCM-Generator, which resulted
in the initial version ofcompiledb/parser.pyand used successfully to generatecompile_commands.jsonfor some AOSP modules in ~1min running in aDockercontainer and then
could use it with some great tools, such as:Vim+YouCompleteMe+rtags+chromatica.nvimNeovim+LanguageClient-neovim+cquery+deopleteNeovim+ALE+cclsNotice:Windows: tested on Windows 10 with cmd, wsl(Ubuntu), mingw32Linux: tested only on Arch Linux and Ubuntu 18 so farMac: tested on macOS 10.13 and 10.14Patches are always welcome :)LicenseGNU GPLv3