* [PATCH 0/3] Automatically add compile_commands.json to ${S}
@ 2025-08-03 1:04 Anakin Childerhose
2025-08-03 1:04 ` [PATCH 1/3] clangd: add compile_commands.bbclass Anakin Childerhose
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Anakin Childerhose @ 2025-08-03 1:04 UTC (permalink / raw)
To: openembedded-core; +Cc: Anakin Childerhose
To better take advantage of Meson and Cmake's automatic generation of a
compile_commands.json file for the clangd language server, link the
${B}/compile_commands.json to ${S}/compile_commands.json.
I accidentally missed the initial commit which provided the
compile_commands.bbclass. This corrects the previous submission.
Anakin Childerhose (3):
clangd: add compile_commands.bbclass
cmake.bbclass: inherit compile_commands.bbclass
meson.bbclass: inherit compile_commands.bbclass
meta/classes-recipe/cmake.bbclass | 2 ++
meta/classes-recipe/compile_commands.bbclass | 18 ++++++++++++++++++
meta/classes-recipe/meson.bbclass | 2 +-
3 files changed, 21 insertions(+), 1 deletion(-)
create mode 100644 meta/classes-recipe/compile_commands.bbclass
--
2.50.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] clangd: add compile_commands.bbclass
2025-08-03 1:04 [PATCH 0/3] Automatically add compile_commands.json to ${S} Anakin Childerhose
@ 2025-08-03 1:04 ` Anakin Childerhose
2025-08-04 10:42 ` [OE-core] " Alexander Kanavin
2025-08-03 1:04 ` [PATCH 2/3] cmake.bbclass: inherit compile_commands.bbclass Anakin Childerhose
2025-08-03 1:04 ` [PATCH 3/3] meson.bbclass: " Anakin Childerhose
2 siblings, 1 reply; 6+ messages in thread
From: Anakin Childerhose @ 2025-08-03 1:04 UTC (permalink / raw)
To: openembedded-core; +Cc: Anakin Childerhose
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
diff --git a/meta/classes-recipe/compile_commands.bbclass b/meta/classes-recipe/compile_commands.bbclass
new file mode 100644
index 0000000000..da8795647c
--- /dev/null
+++ b/meta/classes-recipe/compile_commands.bbclass
@@ -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
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] cmake.bbclass: inherit compile_commands.bbclass
2025-08-03 1:04 [PATCH 0/3] Automatically add compile_commands.json to ${S} Anakin Childerhose
2025-08-03 1:04 ` [PATCH 1/3] clangd: add compile_commands.bbclass Anakin Childerhose
@ 2025-08-03 1:04 ` Anakin Childerhose
2025-08-03 1:04 ` [PATCH 3/3] meson.bbclass: " Anakin Childerhose
2 siblings, 0 replies; 6+ messages in thread
From: Anakin Childerhose @ 2025-08-03 1:04 UTC (permalink / raw)
To: openembedded-core; +Cc: Anakin Childerhose
cmake.bbclass generates a compile_commands.json file by default in ${B}.
To automatically configure the clangd language server, link the
compile_commands.json file to ${S} via compile_commands.bbclass.
Signed-off-by: Anakin Childerhose <anakin@childerhose.ca>
---
meta/classes-recipe/cmake.bbclass | 2 ++
1 file changed, 2 insertions(+)
diff --git a/meta/classes-recipe/cmake.bbclass b/meta/classes-recipe/cmake.bbclass
index 1488d744d4..2da4a9a6c5 100644
--- a/meta/classes-recipe/cmake.bbclass
+++ b/meta/classes-recipe/cmake.bbclass
@@ -4,6 +4,8 @@
# SPDX-License-Identifier: MIT
#
+inherit compile_commands
+
# Path to the CMake file to process.
OECMAKE_SOURCEPATH ??= "${S}"
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] meson.bbclass: inherit compile_commands.bbclass
2025-08-03 1:04 [PATCH 0/3] Automatically add compile_commands.json to ${S} Anakin Childerhose
2025-08-03 1:04 ` [PATCH 1/3] clangd: add compile_commands.bbclass Anakin Childerhose
2025-08-03 1:04 ` [PATCH 2/3] cmake.bbclass: inherit compile_commands.bbclass Anakin Childerhose
@ 2025-08-03 1:04 ` Anakin Childerhose
2 siblings, 0 replies; 6+ messages in thread
From: Anakin Childerhose @ 2025-08-03 1:04 UTC (permalink / raw)
To: openembedded-core; +Cc: Anakin Childerhose
meson.bbclass generates a compile_commands.json file by default in ${B}.
To automatically configure the clangd language server, link the
compile_commands.json file to ${S} via compile_commands.bbclass.
Signed-off-by: Anakin Childerhose <anakin@childerhose.ca>
---
meta/classes-recipe/meson.bbclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta/classes-recipe/meson.bbclass b/meta/classes-recipe/meson.bbclass
index c8b3e1ec29..4f5d7b9e5e 100644
--- a/meta/classes-recipe/meson.bbclass
+++ b/meta/classes-recipe/meson.bbclass
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: MIT
#
-inherit python3native meson-routines qemu
+inherit python3native meson-routines qemu compile_commands
DEPENDS:append = " meson-native ninja-native"
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [OE-core] [PATCH 1/3] clangd: add compile_commands.bbclass
2025-08-03 1:04 ` [PATCH 1/3] clangd: add compile_commands.bbclass Anakin Childerhose
@ 2025-08-04 10:42 ` Alexander Kanavin
2025-08-04 15:52 ` Khem Raj
0 siblings, 1 reply; 6+ messages in thread
From: Alexander Kanavin @ 2025-08-04 10:42 UTC (permalink / raw)
To: anakin; +Cc: openembedded-core
On Sun, 3 Aug 2025 at 03:04, Anakin Childerhose via
lists.openembedded.org <anakin=childerhose.ca@lists.openembedded.org>
wrote:
> 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.
I don't understand this description. What does this json file do, what
does clangd language server do, why can't it find the original file in
${S} and should that be fixed instead? Having different directories
for source and build artefacts is common, and we shouldn't be fixing
it up for others.
Alex
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [OE-core] [PATCH 1/3] clangd: add compile_commands.bbclass
2025-08-04 10:42 ` [OE-core] " Alexander Kanavin
@ 2025-08-04 15:52 ` Khem Raj
0 siblings, 0 replies; 6+ messages in thread
From: Khem Raj @ 2025-08-04 15:52 UTC (permalink / raw)
To: alex.kanavin, anakin; +Cc: openembedded-core
On 8/4/25 3:42 AM, Alexander Kanavin via lists.openembedded.org wrote:
> On Sun, 3 Aug 2025 at 03:04, Anakin Childerhose via
> lists.openembedded.org <anakin=childerhose.ca@lists.openembedded.org>
> wrote:
>> 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.
>
> I don't understand this description. What does this json file do, what
> does clangd language server do,
It will be good to summarize that it implements LSP for C/C++ and
reference to https://microsoft.github.io/language-server-protocol/
why can't it find the original file in
> ${S} and should that be fixed instead? Having different directories
> for source and build artefacts is common, and we shouldn't be fixing
> it up for others.
>
Clangd tries several search paths in S and B as well, but perhaps
something is unique about OE build structure that it is not able to
find it ?
clangd has --compile-commands-dir=<...> option which might be of
interest here
Aside from this, I think it will be good to add
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON via cmake.bbclass if someone wants
LSP at distro level.
> Alex
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#221424): https://lists.openembedded.org/g/openembedded-core/message/221424
> Mute This Topic: https://lists.openembedded.org/mt/114509177/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-08-04 15:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-03 1:04 [PATCH 0/3] Automatically add compile_commands.json to ${S} Anakin Childerhose
2025-08-03 1:04 ` [PATCH 1/3] clangd: add compile_commands.bbclass Anakin Childerhose
2025-08-04 10:42 ` [OE-core] " Alexander Kanavin
2025-08-04 15:52 ` Khem Raj
2025-08-03 1:04 ` [PATCH 2/3] cmake.bbclass: inherit compile_commands.bbclass Anakin Childerhose
2025-08-03 1:04 ` [PATCH 3/3] meson.bbclass: " Anakin Childerhose
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox