Skip to content

Commit

Permalink
Makefile.dep: use features.modules.mk
Browse files Browse the repository at this point in the history
Adds modules to USEMODULE that implement provided features.

Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
  • Loading branch information
fjmolinas and maribu committed Mar 17, 2020
1 parent 22eb90c commit 4192724
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
27 changes: 4 additions & 23 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -1062,18 +1062,6 @@ FEATURES_OPTIONAL += periph_pm
# always select provided architecture features
FEATURES_REQUIRED += $(filter arch_%,$(FEATURES_PROVIDED))

# all periph features correspond to a periph submodule
# FEATURES_USED is defined in Makefile.features
USEMODULE += $(filter periph_%,$(FEATURES_USED))

# select cpu_check_address pseudomodule if the corresponding feature is used
USEMODULE += $(filter cpu_check_address, $(FEATURES_USED))

# include periph_common if any periph_* driver is used
ifneq (,$(filter periph_%, $(USEMODULE)))
USEMODULE += periph_common
endif

ifneq (,$(filter ecc_%,$(USEMODULE)))
USEMODULE += ecc
endif
Expand All @@ -1084,23 +1072,16 @@ USEPKG := $(sort $(USEPKG))
ifneq ($(OLD_USEMODULE) $(OLD_USEPKG),$(USEMODULE) $(USEPKG))
include $(RIOTBASE)/Makefile.dep
else
# set all USED periph_% init modules as DEFAULT_MODULE
ifneq (,$(filter periph_init, $(USEMODULE)))
DEFAULT_MODULE += $(subst periph_,periph_init_,$(filter periph_%,$(USEMODULE)))
endif
# translate used features into used module, where needed
include $(RIOTBASE)/makefiles/features.modules.mk

# Add auto_init_% DEFAULT_MODULES. This is done after the recursive cach since
# none of these modules can trigger dependency resolution.
DEFAULT_MODULE := $(sort $(DEFAULT_MODULE))
ifneq (,$(filter auto_init,$(USEMODULE)))
USEMODULE += $(filter auto_init_%,$(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE)))
endif

# Add auto_init_periph_% to DEFAULT_MODULES. This is done after the recursive
# cach since none of these modules can trigger dependency resolution.
ifneq (,$(filter periph_init,$(USEMODULE)))
USEMODULE += $(filter periph_init_%,$(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE)))
endif

# Sort and remove duplicates
DEFAULT_MODULE := $(sort $(DEFAULT_MODULE))
USEMODULE := $(sort $(USEMODULE))
endif
35 changes: 35 additions & 0 deletions makefiles/features.modules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Add modules implementing used features
#
# This is done after the regular dependency resolution in Makefile.dep, as
# feature resolution depends on the used modules. As these modules however have
# no dependencies(except for periph_common), no dependency resolution is needed.

PERIPH_FEATURES := $(filter periph_%,$(FEATURES_USED))
# all periph features correspond to a periph submodule
# FEATURES_USED is defined in Makefile.features
USEMODULE += $(PERIPH_FEATURES)

# select cpu_check_address pseudomodule if the corresponding feature is used
USEMODULE += $(filter cpu_check_address, $(FEATURES_USED))

# include periph_common if any periph_* driver is used
ifneq (,$(filter periph_%, $(USEMODULE)))
USEMODULE += periph_common
endif

# set all USED periph_% init modules as DEFAULT_MODULE
ifneq (,$(filter periph_init, $(USEMODULE)))
# To enable adding periph_% modules through the environment we cant used
# PERIPH_FEATURES since the MODULE might be have added directly as USEMODULE
PERIPH_MODULES_NO_INIT = periph_init periph_common
PERIPH_MODULES = $(filter periph_%,$(USEMODULE))
PERIPH_INIT_MODULES = $(subst periph_,periph_init_,\
$(filter-out $(PERIPH_MODULES_NO_INIT),$(PERIPH_MODULES)))
DEFAULT_MODULE += $(PERIPH_INIT_MODULES)
endif

# add periph_init_% modules to USEMODULE unless disabled
ifneq (,$(filter periph_init, $(USEMODULE)))
USEMODULE += $(filter $(PERIPH_INIT_MODULES),\
$(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE)))
endif

0 comments on commit 4192724

Please sign in to comment.