@@ -464,6 +464,20 @@ do_compile_kernelmodules() {
}
addtask compile_kernelmodules after do_compile before do_strip
+do_generate_compile_commands[doc] = "Generate compile_commands.json for the clangd language server"
+do_generate_compile_commands() {
+ if ! [ -f "${S}/scripts/clang-tools/gen_compile_commands.py" ]; then
+ bbwarn "no gen_compile_commands.py script, cannot generate compile_commands.json"
+ return
+ fi
+
+ cd ${B} && ${S}/scripts/clang-tools/gen_compile_commands.py \
+ --output "${S}/compile_commands.json" || {
+ bbwarn "failed to generate compile_commands.json"
+ }
+}
+addtask generate_compile_commands after do_compile_kernelmodules
+
kernel_do_install() {
#
# First install the modules
Add do_generate_compile_commands() task after compiling to have the clangd language server be configured correctly for the kernel by default. Signed-off-by: Anakin Childerhose <anakin@childerhose.ca> Upstream-Status: Pending --- meta/classes-recipe/kernel.bbclass | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.50.1