new file mode 100644
@@ -0,0 +1,18 @@
+#
+# Copyright Anakin Childerhose
+#
+# SPDX-License-Identifier: MIT
+#
+
+do_generate_compile_commands[doc] = "Add compile_commands.json to S for clangd language server"
+do_generate_compile_commands() {
+ if ! [ -f "${B}/compile_commands.json" ]; then
+ bbwarn "no compile_commands.json found"
+ return
+ fi
+
+ ln -sf ${B}/compile_commands.json ${S}/compile_commands.json || {
+ bbwarn "failed to link compile_commands.json to \${S}"
+ }
+}
+addtask generate_compile_commands after do_compile
Add a class to link the ${B}/compile_commands.json file to ${S}/compile_commands.json to automatically configure the clangd language server for build systems that generate a compile_commands.json file. Signed-off-by: Anakin Childerhose <anakin@childerhose.ca> --- meta/classes-recipe/compile_commands.bbclass | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 meta/classes-recipe/compile_commands.bbclass