diff --git a/Kconfig b/Kconfig index 694c37d85f..935a7f61f6 100644 --- a/Kconfig +++ b/Kconfig @@ -34,9 +34,13 @@ rsource "sys/Kconfig" rsource "pkg/Kconfig" menu "External Modules" -osource "$(KCONFIG_EXTERNAL_CONFIGS)" +osource "$(KCONFIG_EXTERNAL_MODULE_CONFIGS)" endmenu # External Modules +menu "External Packages" +osource "$(KCONFIG_EXTERNAL_PKG_CONFIGS)" +endmenu # External Packages + comment "RIOT is in a migration phase." comment "Some configuration options may not be here. Use CFLAGS instead." diff --git a/Makefile.include b/Makefile.include index dd83db28a0..fc16d2dcac 100644 --- a/Makefile.include +++ b/Makefile.include @@ -49,6 +49,7 @@ EXTERNAL_BOARD_DIRS ?= RIOTMAKE ?= $(RIOTBASE)/makefiles RIOTKCONFIG ?= $(RIOTBASE)/kconfigs RIOTPKG ?= $(RIOTBASE)/pkg +EXTERNAL_PKG_DIRS ?= RIOTTOOLS ?= $(RIOTBASE)/dist/tools RIOTPROJECT ?= $(shell git rev-parse --show-toplevel 2>/dev/null || pwd) BUILD_DIR ?= $(RIOTBASE)/build @@ -98,6 +99,9 @@ ifeq ($(INSIDE_DOCKER),0) ifeq ($(origin EXTERNAL_MODULE_DIRS),command line) $(error EXTERNAL_MODULE_DIRS must be passed as environment variable, and not as command line argument) endif + ifeq ($(origin EXTERNAL_PKG_DIRS),command line) + $(error EXTERNAL_PKG_DIRS must be passed as environment variable, and not as command line argument) + endif endif # Deprecation of configuring 'RIOTBOARD' @@ -142,6 +146,9 @@ EXTERNAL_BOARD_DIRS := $(foreach dir,\ EXTERNAL_MODULE_DIRS := $(foreach dir,\ $(EXTERNAL_MODULE_DIRS),\ $(abspath $(dir))) +EXTERNAL_PKG_DIRS := $(foreach dir,\ + $(EXTERNAL_PKG_DIRS),\ + $(abspath $(dir))) # Ensure that all directories are set and don't contain spaces. ifneq (, $(filter-out 1, $(foreach v,$(__DIRECTORY_VARIABLES),$(words $($(v)))))) @@ -428,8 +435,9 @@ ifeq (1,$(TEST_KCONFIG)) KCONFIG_PACKAGES := $(call lowercase,$(patsubst CONFIG_PACKAGE_%,%,$(filter CONFIG_PACKAGE_%,$(.VARIABLES)))) USEPKG := $(KCONFIG_PACKAGES) - # Locate used packages in $(RIOTPKG). - PKG_PATHS := $(sort $(foreach dir,$(RIOTPKG),\ + # Locate used packages in $(RIOTPKG) or $(EXTERNAL_PKG_DIRS). + PKGDIRS := $(RIOTPKG) $(EXTERNAL_PKG_DIRS) + PKG_PATHS := $(sort $(foreach dir,$(PKGDIRS),\ $(foreach pkg,$(USEPKG),$(dir $(wildcard $(dir)/$(pkg)/Makefile))))) EXTERNAL_MODULE_PATHS := $(dir $(EXTERNAL_MODULE_KCONFIGS)) diff --git a/makefiles/dependency_resolution.inc.mk b/makefiles/dependency_resolution.inc.mk index 55a142076c..9fde1a7212 100644 --- a/makefiles/dependency_resolution.inc.mk +++ b/makefiles/dependency_resolution.inc.mk @@ -6,8 +6,9 @@ EXTERNAL_MODULE_PATHS := $(sort $(foreach dir,$(EXTERNAL_MODULE_DIRS),\ $(foreach mod,$(USEMODULE),$(dir $(wildcard $(dir)/$(mod)/Makefile))))) -# Locate used packages in $(RIOTPKG). -PKG_PATHS := $(sort $(foreach dir,$(RIOTPKG),\ +# Locate used packages in $(RIOTPKG) or $(EXTERNAL_PKG_DIRS). +PKGDIRS := $(RIOTPKG) $(EXTERNAL_PKG_DIRS) +PKG_PATHS := $(sort $(foreach dir,$(PKGDIRS),\ $(foreach pkg,$(USEPKG),$(dir $(wildcard $(dir)/$(pkg)/Makefile))))) # Back up current state to detect changes diff --git a/makefiles/kconfig.mk b/makefiles/kconfig.mk index c64f1f6ebb..20a94d1f86 100644 --- a/makefiles/kconfig.mk +++ b/makefiles/kconfig.mk @@ -27,7 +27,10 @@ export KCONFIG_AUTOHEADER_HEADER export KCONFIG_GENERATED_DEPENDENCIES = $(GENERATED_DIR)/Kconfig.dep # This file will contain external module configurations -export KCONFIG_EXTERNAL_CONFIGS = $(GENERATED_DIR)/Kconfig.external_modules +export KCONFIG_EXTERNAL_MODULE_CONFIGS = $(GENERATED_DIR)/Kconfig.external_modules + +# This file will contain external package configurations +export KCONFIG_EXTERNAL_PKG_CONFIGS = $(GENERATED_DIR)/Kconfig.external_pkgs # Add configurations that only work when running the Kconfig test so far, # because they activate modules. @@ -183,8 +186,8 @@ EXTERNAL_MODULE_KCONFIGS ?= $(sort $(foreach dir,$(EXTERNAL_MODULE_DIRS),\ $(wildcard $(dir)/*/Kconfig))) # Build a Kconfig file that source all external modules configuration # files. Every EXTERNAL_MODULE_DIRS with a Kconfig file is written to -# KCONFIG_EXTERNAL_CONFIGS as 'osource dir/Kconfig' -$(KCONFIG_EXTERNAL_CONFIGS): FORCE | $(GENERATED_DIR) +# KCONFIG_EXTERNAL_MODULE_CONFIGS as 'osource dir/Kconfig' +$(KCONFIG_EXTERNAL_MODULE_CONFIGS): FORCE | $(GENERATED_DIR) $(Q)\ if [ -n "$(EXTERNAL_MODULE_KCONFIGS)" ] ; then \ printf "%s\n" $(EXTERNAL_MODULE_KCONFIGS) \ @@ -195,6 +198,24 @@ $(KCONFIG_EXTERNAL_CONFIGS): FORCE | $(GENERATED_DIR) | $(LAZYSPONGE) $(LAZYSPONGE_FLAGS) $@ ; \ fi +# All directories in EXTERNAL_PKG_DIRS which have a subdirectory containing a +# Kconfig file. +EXTERNAL_PKG_KCONFIGS ?= $(sort $(foreach dir,$(EXTERNAL_PKG_DIRS),\ + $(wildcard $(dir)/*/Kconfig))) +# Build a Kconfig file that sources all external packages configuration +# files. Every directory with a Kconfig file is written to KCONFIG_PKG_CONFIGS +# as 'osource dir/Kconfig' +$(KCONFIG_EXTERNAL_PKG_CONFIGS): FORCE | $(GENERATED_DIR) + $(Q)\ + if [ -n "$(EXTERNAL_PKG_KCONFIGS)" ] ; then \ + printf "%s\n" $(EXTERNAL_PKG_KCONFIGS) \ + | awk '{ printf "osource \"%s\"\n", $$0 }' \ + | $(LAZYSPONGE) $(LAZYSPONGE_FLAGS) $@ ; \ + else \ + printf "# no external packages" \ + | $(LAZYSPONGE) $(LAZYSPONGE_FLAGS) $@ ; \ + fi + # When the 'clean' target is called, the files inside GENERATED_DIR should be # regenerated. For that, we conditionally change GENERATED_DIR from an 'order # only' requisite to a normal one. @@ -211,7 +232,7 @@ GENERATED_DIR_DEP := $(if $(CLEAN),,|) $(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_EXTERNAL_CONFIGS) +$(KCONFIG_OUT_CONFIG): $(KCONFIG_EXTERNAL_MODULE_CONFIGS) $(KCONFIG_EXTERNAL_PKG_CONFIGS) $(KCONFIG_OUT_CONFIG): $(GENERATED_DEPENDENCIES_DEP) $(GENCONFIG) $(MERGE_SOURCES) $(GENERATED_DIR_DEP) $(Q) $(GENCONFIG) \ --config-out=$(KCONFIG_OUT_CONFIG) \ diff --git a/tests/external_pkg_dirs/app.config.test b/tests/external_pkg_dirs/app.config.test new file mode 100644 index 0000000000..0f5d4c5ae9 --- /dev/null +++ b/tests/external_pkg_dirs/app.config.test @@ -0,0 +1 @@ +CONFIG_PACKAGE_EXTERNAL_PKG=y