summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2021-01-31 20:40:04 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-02-16 10:33:04 +0100
commit4829226ac3d52e62a3ca3e28b92a79457c7b32f2 (patch)
tree31262b8466b562c78093aa1614c7df7546c416b2 /Makefile
parent47255cfa5d358b0b138a651b63f43cb9b5e5f2e2 (diff)
downloadbarebox-4829226ac3d52e62a3ca3e28b92a79457c7b32f2.tar.gz
barebox-4829226ac3d52e62a3ca3e28b92a79457c7b32f2.tar.xz
Kbuild: add compile_commands.json target
The JSON compilation database format specification describes a compile_commands.json file that lists how translation units are compiled by a build system. This makes integration of external tools, like IDEs, LSP servers and static analyzers easier. Import the Linux bits. The database can now be manually generated with make compile_commands.json. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile16
1 files changed, 14 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index ea1d5dae1c..f3c85cff94 100644
--- a/Makefile
+++ b/Makefile
@@ -541,7 +541,7 @@ endif
# in addition to whatever we do anyway.
# Just "make" or "make all" shall build modules as well
-ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
+ifneq ($(filter all _all modules %compile_commands.json,$(MAKECMDGOALS)),)
KBUILD_MODULES := 1
endif
@@ -1104,7 +1104,7 @@ endif # CONFIG_MODULES
CLEAN_DIRS += $(MODVERDIR)
CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \
.tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \
- .tmp_kallsyms* barebox.ldr \
+ .tmp_kallsyms* barebox.ldr compile_commands.json \
scripts/bareboxenv-target barebox-flash-image \
barebox.srec barebox.s5p barebox.ubl barebox.zynq \
barebox.uimage barebox.spi barebox.kwb barebox.kwbuart \
@@ -1162,6 +1162,18 @@ distclean: mrproper
-o -name 'core' \) \
-type f -print | xargs rm -f
+# Clang Tooling
+# ---------------------------------------------------------------------------
+
+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
+ $(call if_changed,gen_compile_commands)
+
+PHONY += compile_commands.json
+
# Brief documentation of the typical targets used
# ---------------------------------------------------------------------------