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