From 34d84ad8c63a7fa11465c5a5a42d29b88d23a8e1 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Fri, 9 Oct 2020 18:01:33 +0200 Subject: [PATCH] makefile: add check for ERROR_ Kconfig symbols This adds a check in the build process to verify that no ERROR_ Kconfig symbols are set. These symbols indicate invalid conditions in the Kconfig configuration. --- Makefile.include | 2 +- makefiles/kconfig.mk | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile.include b/Makefile.include index 3f7ef5cab0..43f2d2f33d 100644 --- a/Makefile.include +++ b/Makefile.include @@ -644,7 +644,7 @@ endif ..compiler-check: $(call check_cmd,$(CC),Compiler) -..build-message: +..build-message: $(if $(SHOULD_RUN_KCONFIG), check-kconfig-errors) @$(COLOR_ECHO) '$(COLOR_GREEN)Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".$(COLOR_RESET)' @$(COLOR_ECHO) diff --git a/makefiles/kconfig.mk b/makefiles/kconfig.mk index 1aa1788731..0069c71271 100644 --- a/makefiles/kconfig.mk +++ b/makefiles/kconfig.mk @@ -168,4 +168,19 @@ $(KCONFIG_GENERATED_AUTOCONF_HEADER_C): $(KCONFIG_OUT_CONFIG) $(GENERATED_DIR_DE # Try to load the list of Kconfig files used -include $(KCONFIG_OUT_DEP) +# capture all ERROR_ prefixed Kconfig symbols +_KCONFIG_ERROR_VARS = $(filter CONFIG_ERROR_%,$(.VARIABLES)) +_KCONFIG_ERRORS = $(foreach v,$(_KCONFIG_ERROR_VARS),$($(v))) + +# this checks that no Kconfig error symbols are set. These symbols are used +# to indicate invalid conditions +check-kconfig-errors: $(KCONFIG_OUT_CONFIG) $(KCONFIG_GENERATED_AUTOCONF_HEADER_C) +ifneq (,$(_KCONFIG_ERRORS)) + @$(COLOR_ECHO) "$(COLOR_RED) !! There are ERRORS in the configuration !! $(COLOR_RESET)" + @for err in $(_KCONFIG_ERRORS); do \ + echo "- $$err"; \ + done + @false +endif + endif