diff --git a/dist/tools/buildsystem_sanity_check/check.sh b/dist/tools/buildsystem_sanity_check/check.sh index 99fb11f786..17b1398998 100755 --- a/dist/tools/buildsystem_sanity_check/check.sh +++ b/dist/tools/buildsystem_sanity_check/check.sh @@ -334,6 +334,20 @@ check_no_pkg_source_local() { | error_with_message "Don't push PKG_SOURCE_LOCAL definitions upstream" } +check_no_riot_config() { + local patterns=() + local pathspec=() + + patterns+=(-e 'RIOT_CONFIG_.*') + + pathspec+=('Makefile*') + pathspec+=('**/Makefile*') + pathspec+=('**/*.mk') + pathspec+=(':!makefiles/kconfig.mk') + git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \ + | error_with_message "Don't push RIOT_CONFIG_* definitions upstream. Rather define configuration via Kconfig" +} + error_on_input() { ! grep '' } @@ -353,6 +367,7 @@ all_checks() { check_no_pseudomodules_in_makefile_dep check_no_usemodules_in_makefile_include check_no_pkg_source_local + check_no_riot_config } main() { diff --git a/doc/doxygen/src/kconfig/kconfig.md b/doc/doxygen/src/kconfig/kconfig.md index ede41f9c67..b5323cbce6 100644 --- a/doc/doxygen/src/kconfig/kconfig.md +++ b/doc/doxygen/src/kconfig/kconfig.md @@ -86,6 +86,23 @@ be placed in the application's folder. For an example of this you can check the [tests/kconfig](https://github.com/RIOT-OS/RIOT/tree/master/tests/kconfig) application. +## Configuration via environment variables {#env-config-kconfig} +For easy debugging of configuration or testing new modules by compiling them +into existing applications, one can also use environment variables prefixed by +`RIOT_CONFIG_`. To achieve the same configuration exemplified in +@ref configure-using-files, e.g., you could also use + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.sh} +RIOT_CONFIG_KCONFIG_MODULE_SOCK_UTIL=1 \ +RIOT_CONFIG_SOCK_UTIL_SCHEME_MAXLEN=24 \ + make +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +All the checks that apply for `.config` files also are done with this approach. + +Mind that this is only meant to be used during development. In production, +please set the configuration via `.config` files. + ## A note on the usage of CFLAGS When a certain module is being configured via Kconfig the configuration macro will not longer be overridable by means of CFLAGS (e.g. set on the diff --git a/makefiles/kconfig.mk b/makefiles/kconfig.mk index d61e115218..c29f15d177 100644 --- a/makefiles/kconfig.mk +++ b/makefiles/kconfig.mk @@ -42,6 +42,11 @@ endif # Default and user overwritten configurations KCONFIG_USER_CONFIG = $(APPDIR)/user.config +# This file will contain configuration using the `RIOT_CONFIG_` +# environment variables. Used to enforce a rerun of GENCONFIG when environment +# changes. +KCONFIG_GENERATED_ENV_CONFIG = $(GENERATED_DIR)/env.config + # This is the output of the generated configuration. It always mirrors the # content of KCONFIG_GENERATED_AUTOCONF_HEADER_C, and it is used to load # configuration symbols to the build system. @@ -63,6 +68,7 @@ KCONFIG_OUT_DEP = $(KCONFIG_OUT_CONFIG).d MERGE_SOURCES += $(KCONFIG_ADD_CONFIG) MERGE_SOURCES += $(wildcard $(KCONFIG_APP_CONFIG)) MERGE_SOURCES += $(wildcard $(KCONFIG_USER_CONFIG)) +MERGE_SOURCES += $(KCONFIG_GENERATED_ENV_CONFIG) # Create directory to place generated files $(GENERATED_DIR): $(if $(MAKE_RESTARTS),,$(CLEAN)) @@ -155,6 +161,14 @@ $(KCONFIG_GENERATED_DEPENDENCIES): FORCE | $(GENERATED_DIR) printf "config %s\n\tbool\n\tdefault y\n", toupper($$0)}' \ | $(LAZYSPONGE) $(LAZYSPONGE_FLAGS) $@ +KCONFIG_ENV_CONFIG = $(patsubst RIOT_%,%,$(foreach v,$(filter RIOT_CONFIG_%,$(.VARIABLES)),$(v)=$($(v)))) + +# Build an intermediate file based on the `RIOT_CONFIG_` environment +# variables +$(KCONFIG_GENERATED_ENV_CONFIG): FORCE | $(GENERATED_DIR) + $(Q)printf "%s\n" $(KCONFIG_ENV_CONFIG) \ + | $(LAZYSPONGE) $(LAZYSPONGE_FLAGS) $@ + # All directories in EXTERNAL_MODULES_PATHS which have a Kconfig file EXTERNAL_MODULE_KCONFIGS ?= $(sort $(foreach dir,$(EXTERNAL_MODULE_PATHS),\ $(wildcard $(dir)/Kconfig)))