log2compdb
This is a simple script to parse out compiler invocations from a build log and generate a compile_commands.json
compilation database. This might be useful on macOS or in any other case where Bear
doesn't work correctly. Theoretically any build log that contains full compiler invocations (e.g. gcc -c -o foo.o -DENABLE_SOME_FEATURE -I./include foo.c) should work, but I've only tested pretty limited cases.
Usage
log2compdb takes three arguments:
- The build log file, with
-i/--in - The path to the desired output file, with
-o/--out(defaults tocompile_commands.jsonin the current directory) - The compiler used in that build log, with
-c/--compiler— an absolute path works best, but isn't required- If your build log has multiple compilers (for example if your build includes host and cross compilation
objects), then
-ccan be specified multiple times.
- If your build log has multiple compilers (for example if your build includes host and cross compilation
objects), then
Example
Let's take the firmware repository for the Black Magic Probe
project for an example. Many build systems don't output the compiler invocations by default, requiring a variable
like BUILD_VERBOSE=1 or V=1. In Blackmagic's case, it looks like this:
$ make V=1 > build.log
It can be important that you don't pass a -j argument (other than -j1), as log2compdb uses directory change
log entries as well, which will be out of order if you build in parallel.
Non-parallel builds can take a while, so you might want to include the build output in your terminal as well with something like:
$ make V=1 | tee /dev/stdin > build.log
After that, you can run log2compdb, telling it the path to the build log, and the compiler used in the build.
In the case of the Black Magic Probe firmware, that's going to be arm-none-eabi-gcc, which on my system is in
/opt/homebrew/bin, so for me generating the compile_commands.json looks like this:
$ log2compdb -i build.log -o compile_commands.json -c /opt/homebrew/bin/arm-none-eabi-gcc
Alternatively, you can also tell log2comp2db to read from standard in, and skip the extra file:
$ make V=1 | tee /dev/stdin | log2compdb -o compile_commands.json -c /opt/homebrew/bin/arm-none-eabi/gcc
Installation
log2compdb is packaged on PyPI, and can be installed with Python
packaging tools, such as pip:
$ pip install log2compdb
Metadata
Release files for log2compdb 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| log2compdb-0.2.5.tar.gz | 5.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| log2compdb-0.2.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.9 kB
Release files / log2compdb-0.2.5.tar.gz
| Download URL | log2compdb-0.2.5.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
456b6ac354f428c0493a7fa1d4f7197bbe81b8c27ac35b5706b289d0beef76b4
|
|
BLAKE2b-256 checksum How to use checksums |
4934185ec8bae13948ce983fea8a1c73ddde3e0f5ab7aee93b1cc690a484702f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.12
|
Release files / log2compdb-0.2.5-py3-none-any.whl
| Download URL | log2compdb-0.2.5-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8cb6f1bfd09301861bdb72e0d76f407d13a23f1a4b9f42e8932c9f9d0864450f
|
|
BLAKE2b-256 checksum How to use checksums |
679ca17bb3f2bd81ad22790c12d494c7c77f9f67270f14bf4fe819fe489dc023
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.12
|
Security for log2compdb 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.