Registry / devops / compiledb

compiledb

JSON →
library0.10.7pypypiunverified

compiledb is a Python tool designed for generating Clang's JSON Compilation Database files, primarily for GNU make-based build systems. It targets large codebases that do not use CMake, which typically generates its own compilation database. The library is currently at version 0.10.7 and is actively maintained, with releases occurring as needed rather than on a strict schedule.

pip install compiledb
INSTALL
IMPORT
SIG · COMPILEDB
C
compiledb
devopspythonv0.10.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

The primary usage of compiledb is as a wrapper around your `make` command. It executes your build while intercepting and parsing the compilation commands to produce the `compile_commands.json` file. You can also generate the database from an existing build log.

# Assuming you have a Makefile in the current directory # This command will execute 'make' and generate 'compile_commands.json' compiledb make # To skip the actual build and only generate the database from make's dry run: # compiledb -n make # To parse an existing build log file: # make -Bnwk > build.log # compiledb --parse build.log
compiledb --version
Debug
Known issues
gotchaWhen dealing with recursive `make` patterns or complex AOSP verbose logs, `compile_commands.json` can sometimes be empty even after a successful build process.
fix
Try generating a verbose build log using `make -Bnwk > build.log` and then parsing it explicitly with `compiledb --parse build.log`. Simplify the `Makefile` structure if possible.
affects: All versions
gotchaParsing errors can occur with complex `make` output, especially when commands involve quoted macros, non-standard directory changes within `make`, or unconventional shell syntax.
fix
Inspect the `make` output for problematic lines. Consider simplifying the shell commands within your `Makefile` or pre-processing the build log to remove lines that cause `bashlex` parsing issues. For Windows, ensure paths are handled correctly.
affects: All versions
gotchaOn Windows, backslashes in include paths within the `make` output may not be processed correctly by `compiledb`, leading to invalid paths in `compile_commands.json`.
fix
Manually adjust include paths in your `Makefile` to use forward slashes where possible, or post-process the generated `compile_commands.json` to normalize path separators.
affects: All versions
gotchaFor VS Code users, `compiledb` might not group `-D` (defines) and `-I` (include paths) options consistently. VS Code's C/C++ extension prefers these options to be grouped, which can affect IntelliSense accuracy.
fix
Currently, there is no direct configuration within `compiledb` to enforce this grouping. You might need to use a post-processing script on `compile_commands.json` to reorder or merge these arguments for optimal VS Code integration.
affects: All versions
Errors
Common errors & fixes
FileNotFoundError
`compiledb` cannot locate source files or other build artifacts referenced in the `make` output, often due to an incorrect working directory or issues during path resolution.
fix
Ensure that `compiledb` is run from the correct build directory. If `make` commands change directories, consider using `compiledb --build-dir <path>` or `compiledb --parse` with a log that has absolute paths.
Failed to parse build command [Details: (<class 'bashlex.errors.ParsingError'>) unexpected token ...]
`compiledb` uses the `bashlex` library to parse shell commands from `make` output. This error indicates that `bashlex` encountered unexpected syntax, often from highly complex, non-standard, or malformed shell commands within your `Makefile`.
fix
Examine the `make` output around the indicated line number for unusual shell constructs. Try to simplify the `Makefile` command that causes the error or, if possible, use `make -Bnwk` to generate a log and manually clean up problematic lines before using `compiledb --parse`.
Different results betweent "compiledb make" and "make | compiledb"
The behavior of piping `make` output to `compiledb` might differ from `compiledb` directly wrapping `make`. This is often due to differences in how shell redirects and environment variables are handled, or `make` changing its behavior when its output is not a TTY.
fix
Prefer using `compiledb make` as it's the intended wrapper behavior. If direct parsing is necessary, ensure `make -Bnwk` is used to produce a verbose, non-building log, and be aware that some build systems might behave differently when their output is redirected.
Upgrade
Version history
0.10.7latest on PyPI · released Mar 23, 2025
Audit
Dependencies
bashlexrequiredUsed for parsing shell commands from make output.
clickrequiredUsed for building the command-line interface.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
compiledb — pip install compiledb · libregistry