From 01454188e8df2de190c94e9c58a8fccef87d802e Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Mon, 27 Jul 2020 17:52:48 +0200 Subject: [PATCH] Makefile.include: introduce TEST_KCONFIG switch This switch allows to test the module dependency modelling during the Kconfig migration. When set, it will use the symbols prefixed with CONFIG_MOD_ defined by Kconfig as the list of modules to compile. --- Makefile.include | 20 ++++++++++++++++---- makefiles/kconfig.mk | 9 ++++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Makefile.include b/Makefile.include index 20dca49fa1..7cd2c30512 100644 --- a/Makefile.include +++ b/Makefile.include @@ -212,6 +212,11 @@ include $(RIOTMAKE)/scan-build.inc.mk export RIOTBUILD_CONFIG_HEADER_C = $(BINDIR)/riotbuild/riotbuild.h +# When testing Kconfig's module modelling we need to run Kconfig +ifeq (1,$(TEST_KCONFIG)) + SHOULD_RUN_KCONFIG = 1 +endif + # Include Kconfig functionalities include $(RIOTMAKE)/kconfig.mk @@ -361,11 +366,18 @@ include $(RIOTBASE)/Makefile.features include $(RIOTMAKE)/pseudomodules.inc.mk include $(RIOTMAKE)/defaultmodules.inc.mk -# handle removal of default modules -USEMODULE += $(filter-out $(DISABLE_MODULE), $(DEFAULT_MODULE)) +# For testing, use TEST_KCONFIG as a switch between Makefile.dep and Kconfig +ifeq (1,$(TEST_KCONFIG)) + $(info === [ATTENTION] Testing Kconfig dependency modelling ===) + KCONFIG_MODULES := $(call lowercase,$(patsubst CONFIG_MOD_%,%,$(filter CONFIG_MOD_%,$(.VARIABLES)))) + USEMODULE := $(KCONFIG_MODULES) +else + # handle removal of default modules + USEMODULE += $(filter-out $(DISABLE_MODULE), $(DEFAULT_MODULE)) -# process dependencies -include $(RIOTMAKE)/dependency_resolution.inc.mk + # process dependencies + include $(RIOTMAKE)/dependency_resolution.inc.mk +endif # Include Board and CPU configuration INCLUDES += $(addprefix -I,$(wildcard $(BOARDDIR)/include)) diff --git a/makefiles/kconfig.mk b/makefiles/kconfig.mk index 341ec45a0d..4c9b1c89f4 100644 --- a/makefiles/kconfig.mk +++ b/makefiles/kconfig.mk @@ -98,6 +98,12 @@ menuconfig: $(MENUCONFIG) $(KCONFIG_OUT_CONFIG) $(Q)KCONFIG_CONFIG=$(KCONFIG_OUT_CONFIG) $(MENUCONFIG) $(KCONFIG) $(MAKE) $(KCONFIG_GENERATED_AUTOCONF_HEADER_C) +# Variable used to conditionally depend on KCONFIG_GENERATED_DEPDENDENCIES +# When testing Kconfig module modelling this file is not needed +ifneq (1, $(TEST_KCONFIG)) + GENERATED_DEPENDENCIES_DEP = $(KCONFIG_GENERATED_DEPENDENCIES) +endif + # These rules are not included when only calling `make clean` in # order to keep the $(BINDIR) directory clean. ifneq (clean, $(MAKECMDGOALS)) @@ -106,6 +112,7 @@ ifneq (clean, $(MAKECMDGOALS)) # defining symbols like 'MODULE_' or PKG_ which # default to 'y'. Then, every module and package Kconfig menu will depend on # that symbol being set to show its options. +# Do nothing when testing Kconfig module dependency modelling. $(KCONFIG_GENERATED_DEPENDENCIES): FORCE | $(GENERATED_DIR) $(Q)printf "%s " $(USEMODULE_W_PREFIX) $(USEPKG_W_PREFIX) \ | awk 'BEGIN {RS=" "}{ gsub("-", "_", $$0); \ @@ -115,7 +122,7 @@ $(KCONFIG_GENERATED_DEPENDENCIES): FORCE | $(GENERATED_DIR) # Generates a .config file by merging multiple sources specified in # MERGE_SOURCES. This will also generate KCONFIG_OUT_DEP with the list of used # Kconfig files. -$(KCONFIG_OUT_CONFIG): $(KCONFIG_GENERATED_DEPENDENCIES) $(GENCONFIG) $(MERGE_SOURCES) | $(GENERATED_DIR) +$(KCONFIG_OUT_CONFIG): $(GENERATED_DEPENDENCIES_DEP) $(GENCONFIG) $(MERGE_SOURCES) | $(GENERATED_DIR) $(Q) $(GENCONFIG) \ --config-out=$(KCONFIG_OUT_CONFIG) \ --file-list $(KCONFIG_OUT_DEP) \