# Compilation Database Generator
[![CircleCI branch](https://img.shields.io/circleci/project/github/nickdiego/compiledb/master.svg)](https://circleci.com/gh/nickdiego/compiledb)
[![PyPI](https://img.shields.io/pypi/v/compiledb.svg)](https://pypi.org/project/compiledb/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/compiledb.svg)](https://pypi.org/project/compiledb)
[![GitHub](https://img.shields.io/github/license/nickdiego/compiledb.svg)](https://github.com/nickdiego/compiledb/blob/master/LICENSE)
Tool for generating [Clang's JSON Compilation Database][compdb] file for GNU
`make`-based build systems.
It's aimed mainly at non-cmake (cmake already generates compilation database)
large codebases. Inspired by projects like [YCM-Generator][ycm-gen] and [Bear][bear],
but faster (mainly with large projects), since in most cases it **doesn'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-run` and `-k`/`--keep-going`
to extract the compile commands. Also, it's more **cross-compiling friendly** than
YCM-generator's fake-toolchanin approach.
## Note
This project is a fork of [compiledb](https://github.com/nickdiego/compiledb) maintained
by [Nick Yamane](https://github.com/nickdiego). Since the PRs to the origin were pending and inactive for quite a long
time, here is an attempt to patch the origin project with this new package name called `compiledb-plus`.
We express our gratitude to the original author(s) for their valuable contribution which made this fork possible. Any
issues, questions, or contributions pertaining to the additions in this fork should be directed to this repository, not
to the original author(s).
## Changes from Original
- Support non-recursive make
## Installation
```
# pip install compiledb-plus
```
- Supports Python 2.x and 3.x (for now, tested only with 2.7 and 3.6 versions)
## Usage
`compiledb-plus` provides a `make` python 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 to [Bear][bear].
To generate `compile_commands.json` file using compiledb-plus's "make wrapper" script,
executing Makefile target `all`:
```bash
$ compiledb-plus make
```
`compiledb-plus` forwards all the options/arguments passed after `make` subcommand to GNU Make,
so one can, for example, generate `compile_commands.json` using `core/main.mk`
as main makefile (`-f` flag), starting the build from `build` directory (`-C` flag):
```bash
$ compiledb-plus make -f core/main.mk -C build
```
By default, `compiledb-plus make` generates the compilation database and runs the actual build
command requested (acting as a make wrapper), the build step can be skipped using the `-n`
or `--no-build` options.
```bash
$ compiledb-plus -n make
```
`compiledb-plus` base 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 using
`make -Bnwk` command), and generates the corresponding JSON Compilation database.
For example, to generate the compilation database from `build-log.txt` file, use the following
command.
```bash
$ compiledb-plus --parse build-log.txt
```
or its equivalent:
```bash
$ compiledb-plus < build-log.txt
```
Or even, to pipe make's output and print the compilation database to the standard output:
```bash
$ make -Bnwk | compiledb-plus -o-
```
By default `compiledb-plus` generates a JSON compilation database in the "arguments" list
[format](https://clang.llvm.org/docs/JSONCompilationDatabase.html). The "command" string
format is also supported through the use of the `--command-style` flag:
```bash
$ compiledb-plus --command-style make
```
## Testing / Contributing
I've implemented this tool because I needed to index some [AOSP][aosp]'s modules for navigating
and studying purposes (after having no satisfatory results with current tools available by the
time such as [YCM-Generator][ycm] and [Bear][bear]). So I've reworked YCM-Generator, which resulted
in the initial version of [compiledb/parser.py](compiledb/parser.py) and used successfully to generate
`compile_commands.json` for some AOSP modules in ~1min running in a [Docker][docker] container and then
could use it with some great tools, such as:
- [Vim][vim] + [YouCompleteMe][ycm] + [rtags][rtags] + [chromatica.nvim][chrom]
- [Neovim][neovim] + [LanguageClient-neovim][lsp] + [cquery][cquery] + [deoplete][deoplete]
- [Neovim][neovim] + [ALE][ale] + [ccls][ccls]
Notice:
- _Windows: tested on Windows 10 with cmd, wsl(Ubuntu), mingw32_
- _Linux: tested only on Arch Linux and Ubuntu 18 so far_
- _Mac: tested on macOS 10.13 and 10.14_
Patches are always welcome :)
## License
GNU GPLv3
[compdb]: https://clang.llvm.org/docs/JSONCompilationDatabase.html
[ycm]: https://github.com/Valloric/YouCompleteMe
[rtags]: https://github.com/Andersbakken/rtags
[chrom]: https://github.com/arakashic/chromatica.nvim
[ycm-gen]: https://github.com/rdnetto/YCM-Generator
[bear]: https://github.com/rizsotto/Bear
[aosp]: https://source.android.com/
[docker]: https://www.docker.com/
[vim]: https://www.vim.org/
[neovim]: https://neovim.io/
[lsp]: https://github.com/autozimu/LanguageClient-neovim
[cquery]: https://github.com/cquery-project/cquery
[deoplete]: https://github.com/Shougo/deoplete.nvim
[ccls]: https://github.com/MaskRay/ccls
[ale]: https://github.com/w0rp/ale
Raw data
{
"_id": null,
"home_page": "https://github.com/maxnilz/compiledb-plus",
"name": "compiledb-plus",
"maintainer": "",
"docs_url": null,
"requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*",
"maintainer_email": "",
"keywords": "compilation-database clang c cpp makefile rtags completion",
"author": "maxnilz",
"author_email": "maxnilz@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/dc/63/f6e094ea27903c86389d829fe2c746e157725d75cd2c3882c7b2140f12aa/compiledb-plus-1.0.0.tar.gz",
"platform": null,
"description": "# Compilation Database Generator\n\n[![CircleCI branch](https://img.shields.io/circleci/project/github/nickdiego/compiledb/master.svg)](https://circleci.com/gh/nickdiego/compiledb)\n[![PyPI](https://img.shields.io/pypi/v/compiledb.svg)](https://pypi.org/project/compiledb/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/compiledb.svg)](https://pypi.org/project/compiledb)\n[![GitHub](https://img.shields.io/github/license/nickdiego/compiledb.svg)](https://github.com/nickdiego/compiledb/blob/master/LICENSE)\n\nTool for generating [Clang's JSON Compilation Database][compdb] file for GNU\n`make`-based build systems.\n\nIt's aimed mainly at non-cmake (cmake already generates compilation database)\nlarge codebases. Inspired by projects like [YCM-Generator][ycm-gen] and [Bear][bear],\nbut faster (mainly with large projects), since in most cases it **doesn't need a clean\nbuild** (as the mentioned tools do) to generate the compilation database file, to\nachieve this it uses the make options such as `-n`/`--dry-run` and `-k`/`--keep-going`\nto extract the compile commands. Also, it's more **cross-compiling friendly** than\nYCM-generator's fake-toolchanin approach.\n\n## Note\n\nThis project is a fork of [compiledb](https://github.com/nickdiego/compiledb) maintained\nby [Nick Yamane](https://github.com/nickdiego). Since the PRs to the origin were pending and inactive for quite a long\ntime, here is an attempt to patch the origin project with this new package name called `compiledb-plus`.\n\nWe express our gratitude to the original author(s) for their valuable contribution which made this fork possible. Any\nissues, questions, or contributions pertaining to the additions in this fork should be directed to this repository, not\nto the original author(s).\n\n## Changes from Original\n\n- Support non-recursive make\n\n## Installation\n\n```\n# pip install compiledb-plus\n```\n\n- Supports Python 2.x and 3.x (for now, tested only with 2.7 and 3.6 versions)\n\n## Usage\n\n`compiledb-plus` provides a `make` python wrapper script which, besides to execute the make\nbuild command, updates the JSON compilation database file corresponding to that build,\nresulting in a command-line interface similar to [Bear][bear].\n\nTo generate `compile_commands.json` file using compiledb-plus's \"make wrapper\" script,\nexecuting Makefile target `all`:\n\n```bash\n$ compiledb-plus make\n```\n\n`compiledb-plus` forwards all the options/arguments passed after `make` subcommand to GNU Make,\nso one can, for example, generate `compile_commands.json` using `core/main.mk`\nas main makefile (`-f` flag), starting the build from `build` directory (`-C` flag):\n\n```bash\n$ compiledb-plus make -f core/main.mk -C build\n```\n\nBy default, `compiledb-plus make` generates the compilation database and runs the actual build\ncommand requested (acting as a make wrapper), the build step can be skipped using the `-n`\nor `--no-build` options.\n\n```bash\n$ compiledb-plus -n make\n```\n\n`compiledb-plus` base command has been designed so that it can be used to parse compile commands\nfrom arbitrary text files (or stdin), assuming it has a build log (ideally generated using\n`make -Bnwk` command), and generates the corresponding JSON Compilation database.\n\nFor example, to generate the compilation database from `build-log.txt` file, use the following\ncommand.\n\n```bash\n$ compiledb-plus --parse build-log.txt\n```\n\nor its equivalent:\n\n```bash\n$ compiledb-plus < build-log.txt\n```\n\nOr even, to pipe make's output and print the compilation database to the standard output:\n\n```bash\n$ make -Bnwk | compiledb-plus -o-\n```\n\nBy default `compiledb-plus` generates a JSON compilation database in the \"arguments\" list\n[format](https://clang.llvm.org/docs/JSONCompilationDatabase.html). The \"command\" string\nformat is also supported through the use of the `--command-style` flag:\n\n```bash\n$ compiledb-plus --command-style make\n```\n\n## Testing / Contributing\n\nI've implemented this tool because I needed to index some [AOSP][aosp]'s modules for navigating\nand studying purposes (after having no satisfatory results with current tools available by the\ntime such as [YCM-Generator][ycm] and [Bear][bear]). So I've reworked YCM-Generator, which resulted\nin the initial version of [compiledb/parser.py](compiledb/parser.py) and used successfully to generate\n`compile_commands.json` for some AOSP modules in ~1min running in a [Docker][docker] container and then\ncould use it with some great tools, such as:\n\n- [Vim][vim] + [YouCompleteMe][ycm] + [rtags][rtags] + [chromatica.nvim][chrom]\n- [Neovim][neovim] + [LanguageClient-neovim][lsp] + [cquery][cquery] + [deoplete][deoplete]\n- [Neovim][neovim] + [ALE][ale] + [ccls][ccls]\n\nNotice:\n\n- _Windows: tested on Windows 10 with cmd, wsl(Ubuntu), mingw32_\n- _Linux: tested only on Arch Linux and Ubuntu 18 so far_\n- _Mac: tested on macOS 10.13 and 10.14_\n\nPatches are always welcome :)\n\n## License\n\nGNU GPLv3\n\n[compdb]: https://clang.llvm.org/docs/JSONCompilationDatabase.html\n\n[ycm]: https://github.com/Valloric/YouCompleteMe\n\n[rtags]: https://github.com/Andersbakken/rtags\n\n[chrom]: https://github.com/arakashic/chromatica.nvim\n\n[ycm-gen]: https://github.com/rdnetto/YCM-Generator\n\n[bear]: https://github.com/rizsotto/Bear\n\n[aosp]: https://source.android.com/\n\n[docker]: https://www.docker.com/\n\n[vim]: https://www.vim.org/\n\n[neovim]: https://neovim.io/\n\n[lsp]: https://github.com/autozimu/LanguageClient-neovim\n\n[cquery]: https://github.com/cquery-project/cquery\n\n[deoplete]: https://github.com/Shougo/deoplete.nvim\n\n[ccls]: https://github.com/MaskRay/ccls\n\n[ale]: https://github.com/w0rp/ale\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "Tool for generating Clang JSON Compilation Database files for make-based build systems. A fork of https://github.com/nickdiego/compiledb",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/maxnilz/compiledb-plus",
"Issue Tracking": "https://github.com/maxnilz/compiledb/issues"
},
"split_keywords": [
"compilation-database",
"clang",
"c",
"cpp",
"makefile",
"rtags",
"completion"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5398f2a097628e24241825f9959e9ce0a6195939eb19f7b4cc54099bab09017b",
"md5": "0a593c1f0db129f6c18ca8fcc356cf20",
"sha256": "2e124e07ac032b4d4295f51a105a93fd3ac20a519e6fe740c516f337d9a4657d"
},
"downloads": -1,
"filename": "compiledb_plus-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0a593c1f0db129f6c18ca8fcc356cf20",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*",
"size": 27558,
"upload_time": "2023-07-20T03:17:07",
"upload_time_iso_8601": "2023-07-20T03:17:07.610410Z",
"url": "https://files.pythonhosted.org/packages/53/98/f2a097628e24241825f9959e9ce0a6195939eb19f7b4cc54099bab09017b/compiledb_plus-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dc63f6e094ea27903c86389d829fe2c746e157725d75cd2c3882c7b2140f12aa",
"md5": "e93ba011e9bfc77fe731a5f9a8292769",
"sha256": "056a386594a04368dee776c3d3af45ced9ba05fd184b1bf4c9afbf93cd0fd2bb"
},
"downloads": -1,
"filename": "compiledb-plus-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "e93ba011e9bfc77fe731a5f9a8292769",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*",
"size": 25989,
"upload_time": "2023-07-20T03:17:09",
"upload_time_iso_8601": "2023-07-20T03:17:09.951943Z",
"url": "https://files.pythonhosted.org/packages/dc/63/f6e094ea27903c86389d829fe2c746e157725d75cd2c3882c7b2140f12aa/compiledb-plus-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-20 03:17:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "maxnilz",
"github_project": "compiledb-plus",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"circle": true,
"tox": true,
"lcname": "compiledb-plus"
}