Makefile: Update build for include-what-you-use

This patch saves the output of the IWYU build into $(obj)/iwyu.txt. It
will also automatically adds -k to the MAKEFLAFGS when IWYU is selected,
so that the build doesn't halt after the first operation.

When IWYU is not selected, there is no change to the build.

This will allow us to create an automated IWYU build on jenkins.

Signed-off-by: Martin Roth <gaumless@gmail.com>
Change-Id: I0ea300d4c64bb923e9f7cc0e595885c3006ec3ca
Reviewed-on: https://review.coreboot.org/c/coreboot/+/77192
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
This commit is contained in:
Martin Roth
2023-08-15 15:57:29 -06:00
committed by Felix Held
parent 00e92f4538
commit b18726da2f

View File

@@ -316,6 +316,11 @@ $(eval $(postinclude-hooks))
# Eliminate duplicate mentions of source files in a class # Eliminate duplicate mentions of source files in a class
$(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs)))) $(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs))))
ifeq ($(CONFIG_IWYU),y)
MAKEFLAGS += -k
SAVE_IWYU_OUTPUT := 2>&1 | grep "should\|\#include\|---\|include-list\|^[[:blank:]]\?\'" | tee -a $$(obj)/iwyu.txt
endif
# Build Kconfig .ads if necessary # Build Kconfig .ads if necessary
ifeq ($(CONFIG_ROMSTAGE_ADA),y) ifeq ($(CONFIG_ROMSTAGE_ADA),y)
romstage-srcs += $(obj)/romstage/$(notdir $(KCONFIG_AUTOADS)) romstage-srcs += $(obj)/romstage/$(notdir $(KCONFIG_AUTOADS))
@@ -382,7 +387,7 @@ $$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $(KCONFIG_AUTOHEADER) $(4)
@printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n" @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
$(CC_$(1)) \ $(CC_$(1)) \
-MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -MT $$$$(@) \ -MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -MT $$$$(@) \
$(3) -c -o $$$$@ $$$$< $(3) -c -o $$$$@ $$$$< $(SAVE_IWYU_OUTPUT)
end$(EMPTY)if end$(EMPTY)if
en$(EMPTY)def en$(EMPTY)def
end$(EMPTY)if end$(EMPTY)if