How do you create compilation database for kernel & world?

Linux has
Code:
gen_compile_commands.py
After successful build script generates compilation database usable e.g. from clangd/nvim and such.

Do we have anything similar in FreeBSD? Or, how do you guys prepare/create that database to enable indexation for the whole /usr/src?

Thank you!
 
I had to search the web for this first ... so, some "standardized" format containing every single full command that was used for the build?

Not sure there is existing tooling, but if you build with meta-mode, it shouldn't be too hard to create it from the generated .meta-files, for example have a look at this:
Code:
➜ head -n2 /usr/obj/usr/src/amd64.amd64/bin/cp/utils.o.meta
# Meta data file /usr/obj/usr/src/amd64.amd64/bin/cp/utils.o.meta
CMD cc -target x86_64-unknown-freebsd13.2 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin  -O2 -pipe -fno-common   -D_ACL_PRIVATE -DNDEBUG -fPIE -g -std=gnu99 -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-variable  -Qunused-arguments    -c /usr/src/bin/cp/utils.c -o utils.o

Just out of curiosity, what's your usecase for that? Some plugins offering autocompletion etc?
 
Just out of curiosity, what's your usecase for that? Some plugins offering autocompletion etc?

Not only auto-completion, also jumping to definitions, finding references to functions/variables, sane refactoring... I use neovim with LSP backed by clangd language server. Works amazingly well.
 
Back
Top