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

buildsystem: implement EXTERNAL_PKG_DIRS feature

This commit is contained in:
NikLeberg 2022-01-31 10:38:03 +00:00
parent 242d9ed30d
commit a411841322
5 changed files with 44 additions and 9 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1 @@
CONFIG_PACKAGE_EXTERNAL_PKG=y