Generates compilation databases by capturing standard output from Make
Project description
Compile Commands Database GENerator
About
A Python script to generate a compile_commands.json database
by capturing the output of make. This script was originally created to provide
compilation databases for make based C/C++ projects in Visual Studio Code.
Installation
pip install ccdgen
Usage
python3 -m ccdgen --extensions <arguments...> -- <your build command>
Arguments:
| Option | Default | Description |
|---|---|---|
-h, --help |
Show help message and exit | |
-c, --compiler |
(auto detect) | Specify compiler |
-d, --dir |
./ | Working directory to run make from |
-e, --extensions |
Extension(s) for source files | |
-o, --output |
./compile_commands.json | Output file |
For example, to run make all as the build command for a C project:
python3 -m ccdgen --extensions .c -- make all
Example Visual Studio Code task:
{
"version": "2.0.0",
"tasks": [
{
"label": "ccdgen",
"type": "shell",
"command": "python",
"osx": {
"command": "python3"
},
"args": [
"-m", "ccdgen",
"--extensions", ".c",
"--", "make", "all"
]
}
]
}
Limitations
- The script relies on the Python standard library modules
argparse,json,os,subprocessandsys. - This script relies on
makeechoing the compiler commands it runs to stdout. If compiler commands are prefixed in the Makefile with@ormakeis run in silent mode, the output cannot be captured. - The build must succeed to generate a full compilation database, though warnings are not a problem.
- Currently only tested with Python 3.10 on macOS Ventura and Windows 10.
Other Tools
- CMake (since version 2.8.5) can be used as is to generate
compile_commands.jsonby adding-DCMAKE_EXPORT_COMPILE_COMMANDS=ONwhen calling it. This only works for Unix Makefile builds. - Bear is much more advanced tool for
generating compilation databases for
clangtooling. macOS, Linux and FreeBSD are currently supported.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ccdgen-0.0.11-py3-none-any.whl.
File metadata
- Download URL: ccdgen-0.0.11-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e62685e88edf71b6afe629df5d8b92c14aee493df00f507e12ebca827181d10
|
|
| MD5 |
8e40426199ef1c186edff4d67e395d9c
|
|
| BLAKE2b-256 |
5aa1dc0b7f64ce6c6939792745ea8f6a84fba4bb33b81914ef0a186c9620b54b
|