Merge pull request #15198 from leandrolanzieri/pr/kconfig/add_error_symbols

Kconfig: add error symbols and makefile check
This commit is contained in:
Cenk Gündoğan 2020-10-13 13:09:42 +02:00 committed by GitHub
commit 0741f161ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 62 additions and 1 deletions

View File

@ -12,6 +12,9 @@ rsource "kconfigs/Kconfig.consts"
# Load feature declarations
rsource "kconfigs/Kconfig.features"
# Load error symbols
rsource "kconfigs/Kconfig.errors"
# For now, get used modules as macros from this file (see kconfig.mk)
osource "$(KCONFIG_GENERATED_DEPENDENCIES)"
@ -33,6 +36,9 @@ rsource "pkg/Kconfig"
comment "RIOT is in a migration phase."
comment "Some configuration options may not be here. Use CFLAGS instead."
comment "!! ERROR: There are conflicting modules active !!"
depends on ERROR_MODULES_CONFLICT != ""
config TEST_KCONFIG
bool
default y if '$(TEST_KCONFIG)' = '1'

View File

@ -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)

View File

@ -27,3 +27,7 @@ config BOARD_STM32F4DISCOVERY
# Various other features (if any)
select HAS_ARDUINO
config ERROR_MODULES_CONFLICT
default "On stm32f4discovery boards there are the same pins for the DAC and/or SPI_0." if MODULE_PERIPH_SPI && MODULE_PERIPH_DAC
depends on BOARD_STM32F4DISCOVERY

View File

@ -68,3 +68,7 @@ config HAS_ATMEGA_PCINT3
bool
help
Indicates that the Pin Change Interrupt bank 3 is present.
config ERROR_MODULES_CONFLICT
default "On ATmega, the RTC and RTT use to the same hardware timer." if MODULE_PERIPH_RTC && MODULE_PERIPH_RTT
depends on CPU_COMMON_ATMEGA

View File

@ -37,5 +37,9 @@ config HAS_CPU_EFM32
config CPU
default "efm32" if CPU_COMMON_EFM32
config ERROR_MODULES_CONFLICT
default "On the EFM32, the RTC and RTT map to the same hardware peripheral." if MODULE_PERIPH_RTC && MODULE_PERIPH_RTT
depends on CPU_COMMON_EFM32
orsource "families/*/Kconfig"
source "$(RIOTCPU)/cortexm_common/Kconfig"

View File

@ -28,6 +28,9 @@ if CPU_COMMON_SAM0
rsource "periph/Kconfig"
config ERROR_MODULES_CONFLICT
default "On SAM0, the RTC and RTT map to the same hardware peripheral." if MODULE_PERIPH_RTC && MODULE_PERIPH_RTT
endif # CPU_COMMON_SAM0
source "$(RIOTCPU)/cortexm_common/Kconfig"

View File

@ -32,7 +32,12 @@ config HAS_BOOTLOADER_STM32
help
Indicates that the stm32 bootloader is being used.
config ERROR_MODULES_CONFLICT
default "On STM32, the RTC and RTT map to the same hardware peripheral." if MODULE_PERIPH_RTC && MODULE_PERIPH_RTT
depends on CPU_STM32
orsource "kconfig/*/Kconfig"
orsource "kconfig/*/Kconfig.lines"
orsource "kconfig/*/Kconfig.models"
source "$(RIOTCPU)/cortexm_common/Kconfig"

20
kconfigs/Kconfig.errors Normal file
View File

@ -0,0 +1,20 @@
# Copyright (c) 2020 HAW Hamburg
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
# Definition of common error symbols. To indicate an error set the default value
# to the correspondent symbol guarded with the error condition. e.g.:
#
# config ERROR_MODULES_CONFLICT
# default "On SAM0 platforms RTT and RTC cannot be set at the same time"
# depends on MODULE_PERIPH_RTC && MODULE_PERIPH_RTT && CPU_COMMON_SAM0
#
config ERROR_MODULES_CONFLICT
string
help
Used to indicate that conflicting modules (i.e. modules that can't be
active at the same time) are being used together.

View File

@ -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