[PATCH v2025.09.y 51/58] Makefile: include scripts/ in compile_commands.json

Ahmad Fatoum a.fatoum at pengutronix.de
Fri Mar 13 06:25:35 PDT 2026


From: Jonas Rebmann <jre at pengutronix.de>

Although in many cases, C files in scripts/ would, because they rely on
the host toolchain and no unusual compiler flags, work fine in clangd
without a compile commands database, the (typically cross) compile
commands of the first entry in compile_commands.json are applied as
defaults once generated via `make compile_commands.json`.

As valid .cmd files are already present in scripts/ and
gen_compile_commands.py supports reading all cmd files in a subtree
recursively, simply add scripts to the gen_compile_commands.py
invocation. All enabled code in scripts/ is now properly covered by
compile_commands.json

(cherry picked from commit 8292499af8e917ed414ec57c36369068cfb98e13)

Signed-off-by: Jonas Rebmann <jre at pengutronix.de>
Link: https://lore.barebox.org/20260217-scripts-compile-commands-hack-v1-1-85afb2af566b@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 8606a6576194..28056c7d3d5e 100644
--- a/Makefile
+++ b/Makefile
@@ -1349,7 +1349,7 @@ quiet_cmd_gen_compile_commands = GEN     $@
       cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
 
 compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
-	$(BAREBOX_OBJS) $(if $(CONFIG_PBL_IMAGE),$(BAREBOX_PBL_OBJS),) FORCE
+	$(BAREBOX_OBJS) $(if $(CONFIG_PBL_IMAGE),$(BAREBOX_PBL_OBJS),) scripts/ FORCE
 	$(call if_changed,gen_compile_commands)
 
 PHONY += compile_commands.json
-- 
2.47.3




More information about the barebox mailing list