Index | Thread | Search

From:
Mikhail Pchelin <misha@freebsd.org>
Subject:
[new] devel/compiledb: compile_commands.json generator (also works with the kernel)
To:
ports@openbsd.org
Date:
Fri, 3 May 2024 11:34:54 +0300

Download raw body.

Thread
I wasn't able to google how to generate compile_commands.json file for
the kernel to make clangd/LSP/vim work.

It looks like the most used tool is a bear
(https://github.com/rizsotto/Bear), but during initial porting efforts I
found out that it doesn't work, I got constant crashes and pinsyscalls
messages in dmesg.

compiledb is a much simpler python tool which parses gmake logs and
generates compile_commands.json file, it also works fine with the
OpenBSD kernel, which was the main motivation, I also tried jumping
around emacs sources - works fine, using option 3 from the README.

Fail of option 2 for emacs is documented in make.py file of the
distribution, but I wasn't able to make the workaround fix it, given the
option 3, which works, seems not a bid deal?

Thoughts?

$ pkg_info compiledb-0.10.1
Information for inst:compiledb-0.10.1

Comment:
compile_commands.json generator

Description:
Tool for generating Clang's JSON Compilation Database file for GNU make-based
build systems.

Maintainer: The OpenBSD ports mailing-list <ports@openbsd.org>

WWW: https://github.com/nickdiego/compiledb

$ cat /usr/local/share/doc/pkg-readmes/compiledb
+-------------------------------------------------------------------------------
| Running compiledb on OpenBSD
+-------------------------------------------------------------------------------

compiledb supports only gmake for native compile_commands.json file generation,
but you can try to feed usual make output to it through a pipe, or --parse
option.

Examples:

1) To make compile_commands.json file for OpenBSD kernel use:

cd /sys/arch/$(machine)/compile/GENERIC.MP
make -n | compiledb
mv compile_commands.json /sys

2) To get compilation db for another software, which uses gmake pass -c option
for make subcommand:

cd ~/work/software
compiledb -n make -c gmake

3) Above command runs 'gmake -Bnwk' and parses output, if your software uses
autotools and enters endless ./configure stage, try removing -B switch and pipe
the output without it:

gmake -nwk | compiledb