1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/makefiles/dependency_resolution.inc.mk
Francisco Molina 25e670e263 makefiles/dependency_resolution: add outer loop for DEFAULT_MODULE deps
Some DEFAULT_MODULEs in tree have dependencies of their own. This is
usually done for aliases of init modules, and do not have dependencies
themselves.

This adds the final stage to dependency resolutions where DEFAULT_MODULEs
dependencies MAY be included. These included modules MUST NOT have
dependencies themselves.

This allows for modules to disable DEFAULT_MODULEs during dependencies
resolution independent of the inclusion order.

auto_init and periph_init modules are moved to this outer-loop, allowing
therefore for modules to disable them during the dependency resolution
2022-02-14 12:59:31 +01:00

71 lines
2.7 KiB
Makefile

# Perform a recursive dependency resolution: Include $(RIOTBASE)/Makefile.dep
# until no new modules, pkgs, or features are pull in order to catch all
# transient dependencies
# Locate used modules in $(EXTERNAL_MODULE_DIRS).
EXTERNAL_MODULE_PATHS := $(sort $(foreach dir,$(EXTERNAL_MODULE_DIRS),\
$(foreach mod,$(USEMODULE),$(dir $(wildcard $(dir)/$(mod)/Makefile)))))
# 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
OLD_STATE := $(USEMODULE) $(USEPKG) $(FEATURES_USED)
# pull in dependencies of the currently used modules and pkgs
include $(RIOTBASE)/Makefile.dep
# check if required features are provided and update $(FEATURES_USED)
include $(RIOTMAKE)/features_check.inc.mk
# translate used features into used module, where needed
include $(RIOTMAKE)/features_modules.inc.mk
# sort and de-duplicate used modules, pkgs, and features for comparison
USEMODULE := $(sort $(USEMODULE))
USEPKG := $(sort $(USEPKG))
FEATURES_USED := $(sort $(FEATURES_USED))
NEW_STATE := $(USEMODULE) $(USEPKG) $(FEATURES_USED)
# If set of used modules, pkgs, and features has changed during last run, run
# again to recursively catch transitive dependencies
ifneq ($(OLD_STATE),$(NEW_STATE))
include $(RIOTMAKE)/dependency_resolution.inc.mk
else
# Include late allowing them to have been disabled during dependency resolution
DEFAULT_MODULE += auto_init periph_init
USEMODULE += $(filter-out $(DISABLE_MODULE),auto_init periph_init)
# If module auto_init is not used, silently disable all of its submodules
ifeq (,$(filter auto_init,$(USEMODULE)))
DISABLE_MODULE += auto_init_%
endif
# If module periph_init is not used, silently disable all of its submodules
ifeq (,$(filter periph_init,$(USEMODULE)))
DISABLE_MODULE += periph_init_%
endif
# Add default modules again, as $(DEFAULT_MODULE) might have been extended
# during dependency resolution
USEMODULE += $(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE))
# Include eventual dependencies for default modules
include $(RIOTMAKE)/default_modules.deps.mk
# Sort and de-duplicate used modules and default modules for readability
USEMODULE := $(sort $(USEMODULE))
DEFAULT_MODULE := $(sort $(DEFAULT_MODULE))
# Warn about used deprecated modules
include $(RIOTMAKE)/deprecated_modules.inc.mk
DEPRECATED_MODULES_USED := $(sort $(filter $(DEPRECATED_MODULES),$(USEMODULE)))
ifneq (,$(DEPRECATED_MODULES_USED))
$(shell $(COLOR_ECHO) "$(COLOR_RED)Deprecated modules are in use:$(COLOR_RESET)"\
"$(DEPRECATED_MODULES_USED)" 1>&2)
endif
endif