1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #16052 from miri64/dist/enh/genconfig-env

makefiles/kconfig.mk: generate config file from RIOT_CONFIG_% environment variables
This commit is contained in:
Kevin "Tristate Tom" Weiss 2021-09-08 11:00:59 +02:00 committed by GitHub
commit 73e32207df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 0 deletions

View File

@ -334,6 +334,20 @@ check_no_pkg_source_local() {
| error_with_message "Don't push PKG_SOURCE_LOCAL definitions upstream" | 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() { error_on_input() {
! grep '' ! grep ''
} }
@ -353,6 +367,7 @@ all_checks() {
check_no_pseudomodules_in_makefile_dep check_no_pseudomodules_in_makefile_dep
check_no_usemodules_in_makefile_include check_no_usemodules_in_makefile_include
check_no_pkg_source_local check_no_pkg_source_local
check_no_riot_config
} }
main() { main() {

View File

@ -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) the [tests/kconfig](https://github.com/RIOT-OS/RIOT/tree/master/tests/kconfig)
application. 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 ## A note on the usage of CFLAGS
When a certain module is being configured via Kconfig the configuration macro 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 will not longer be overridable by means of CFLAGS (e.g. set on the

View File

@ -42,6 +42,11 @@ endif
# Default and user overwritten configurations # Default and user overwritten configurations
KCONFIG_USER_CONFIG = $(APPDIR)/user.config KCONFIG_USER_CONFIG = $(APPDIR)/user.config
# This file will contain configuration using the `RIOT_CONFIG_<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 # 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 # content of KCONFIG_GENERATED_AUTOCONF_HEADER_C, and it is used to load
# configuration symbols to the build system. # configuration symbols to the build system.
@ -63,6 +68,7 @@ KCONFIG_OUT_DEP = $(KCONFIG_OUT_CONFIG).d
MERGE_SOURCES += $(KCONFIG_ADD_CONFIG) MERGE_SOURCES += $(KCONFIG_ADD_CONFIG)
MERGE_SOURCES += $(wildcard $(KCONFIG_APP_CONFIG)) MERGE_SOURCES += $(wildcard $(KCONFIG_APP_CONFIG))
MERGE_SOURCES += $(wildcard $(KCONFIG_USER_CONFIG)) MERGE_SOURCES += $(wildcard $(KCONFIG_USER_CONFIG))
MERGE_SOURCES += $(KCONFIG_GENERATED_ENV_CONFIG)
# Create directory to place generated files # Create directory to place generated files
$(GENERATED_DIR): $(if $(MAKE_RESTARTS),,$(CLEAN)) $(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)}' \ printf "config %s\n\tbool\n\tdefault y\n", toupper($$0)}' \
| $(LAZYSPONGE) $(LAZYSPONGE_FLAGS) $@ | $(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_<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 # All directories in EXTERNAL_MODULES_PATHS which have a Kconfig file
EXTERNAL_MODULE_KCONFIGS ?= $(sort $(foreach dir,$(EXTERNAL_MODULE_PATHS),\ EXTERNAL_MODULE_KCONFIGS ?= $(sort $(foreach dir,$(EXTERNAL_MODULE_PATHS),\
$(wildcard $(dir)/Kconfig))) $(wildcard $(dir)/Kconfig)))