summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Kconfig6
-rw-r--r--toolchain.inc15
2 files changed, 21 insertions, 0 deletions
diff --git a/src/Kconfig b/src/Kconfig
index 0d3879ecbf..c1afe26e5f 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -114,6 +114,12 @@ config CCACHE
For details see https://ccache.samba.org.
+config IWYU
+ bool "Test platform with include-what-you-use"
+ help
+ This runs each source file through the include-what-you-use tool
+ to check the header includes.
+
config FMD_GENPARSER
bool "Generate flashmap descriptor parser using flex and bison"
default n
diff --git a/toolchain.inc b/toolchain.inc
index 893f7d1a11..47c5fe9b85 100644
--- a/toolchain.inc
+++ b/toolchain.inc
@@ -32,6 +32,21 @@ HOSTCC:=CCC_CC="$(HOSTCC)" $(CC)
HOSTCXX:=CCC_CXX="$(HOSTCXX)" $(CXX)
endif
+# include-what-you-use integration
+ifeq ($(CONFIG_IWYU),y)
+
+IWYU:=$(word 1,$(wildcard $(addsuffix /iwyu,$(subst :, ,$(PATH)))))
+ifeq ($(IWYU),)
+$(error include-what-you-use selected, but not found in PATH)
+endif
+
+$(foreach arch,$(ARCH_SUPPORTED), \
+ $(eval CC_$(arch):=$(IWYU) ))
+
+CFLAGS_common := -Xiwyu --prefix_header_includes=remove -Xiwyu --no_comments -Xiwyu --no_fwd_decls $(CFLAGS_common)
+NOCOMPILE := 1
+endif
+
COREBOOT_STANDARD_STAGES := decompressor bootblock verstage romstage ramstage
MAP-decompressor := bootblock