{"id":7103,"library":"compiledb","title":"compiledb","description":"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.","status":"active","version":"0.10.7","language":"en","source_language":"en","source_url":"https://github.com/nickdiego/compiledb.git","tags":["build tools","clang","compilation database","make","C++"],"install":[{"cmd":"pip install compiledb","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for parsing shell commands from make output.","package":"bashlex","optional":false},{"reason":"Used for building the command-line interface.","package":"click","optional":false}],"imports":[],"quickstart":{"code":"# Assuming you have a Makefile in the current directory\n# This command will execute 'make' and generate 'compile_commands.json'\ncompiledb make\n\n# To skip the actual build and only generate the database from make's dry run:\n# compiledb -n make\n\n# To parse an existing build log file:\n# make -Bnwk > build.log\n# compiledb --parse build.log","lang":"bash","description":"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."},"warnings":[{"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.","message":"When dealing with recursive `make` patterns or complex AOSP verbose logs, `compile_commands.json` can sometimes be empty even after a successful build process.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Parsing errors can occur with complex `make` output, especially when commands involve quoted macros, non-standard directory changes within `make`, or unconventional shell syntax.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"On Windows, backslashes in include paths within the `make` output may not be processed correctly by `compiledb`, leading to invalid paths in `compile_commands.json`.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"For 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"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.","cause":"`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.","error":"FileNotFoundError"},{"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`.","cause":"`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`.","error":"Failed to parse build command [Details: (<class 'bashlex.errors.ParsingError'>) unexpected token ...]"},{"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.","cause":"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.","error":"Different results betweent \"compiledb make\" and \"make | compiledb\""}]}