From 4b683bed42937d54a3b20386997a139913bf1936 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 10 May 2021 17:10:57 +0200 Subject: [PATCH 1/4] sys/bus: move to sys/sys_bus Matching folder and module names make live easier --- sys/Makefile | 2 +- sys/{bus => sys_bus}/Makefile | 2 -- sys/{bus => sys_bus}/sys_bus_init.c | 0 3 files changed, 1 insertion(+), 3 deletions(-) rename sys/{bus => sys_bus}/Makefile (65%) rename sys/{bus => sys_bus}/sys_bus_init.c (100%) diff --git a/sys/Makefile b/sys/Makefile index fc5c0633c238..46fbc9265298 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -165,7 +165,7 @@ ifneq (,$(filter suit%,$(USEMODULE))) DIRS += suit endif ifneq (,$(filter sys_bus,$(USEMODULE))) - DIRS += bus + DIRS += sys_bus endif ifneq (,$(filter tcp,$(USEMODULE))) DIRS += net/transport_layer/tcp diff --git a/sys/bus/Makefile b/sys/sys_bus/Makefile similarity index 65% rename from sys/bus/Makefile rename to sys/sys_bus/Makefile index d66bde0cec91..48422e909a47 100644 --- a/sys/bus/Makefile +++ b/sys/sys_bus/Makefile @@ -1,3 +1 @@ -MODULE = sys_bus - include $(RIOTBASE)/Makefile.base diff --git a/sys/bus/sys_bus_init.c b/sys/sys_bus/sys_bus_init.c similarity index 100% rename from sys/bus/sys_bus_init.c rename to sys/sys_bus/sys_bus_init.c From 1769b6ff02dff7ea30459a53c182ecf371447102 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 10 May 2021 17:25:05 +0200 Subject: [PATCH 2/4] build-system: auto-locate modules by name This commit introduces the MODULE_DIRS variable that works just like EXTERNAL_MODULE_DIRS, but it is intended for internal modules. The major difference is that external modules can have the same name as an internal module, in which case the external module is used instead of the internal one. This allows to provide drop-in replacements of internal modules, which can be useful during development e.g. to quickly benchmark different implementations. --- Makefile.include | 10 +++++++-- drivers/Makefile | 2 -- makefiles/dependency_resolution.inc.mk | 4 ---- makefiles/locate_modules.inc.mk | 11 ++++++++++ sys/Makefile | 29 -------------------------- sys/Makefile.dep | 1 + 6 files changed, 20 insertions(+), 37 deletions(-) create mode 100644 makefiles/locate_modules.inc.mk diff --git a/Makefile.include b/Makefile.include index 0e66ee4a6e49..2b27ef195f49 100644 --- a/Makefile.include +++ b/Makefile.include @@ -46,6 +46,8 @@ RIOTCPU ?= $(RIOTBASE)/cpu # Deprecated to set RIOTBOARD, use EXTERNAL_BOARD_DIRS RIOTBOARD ?= $(RIOTBASE)/boards EXTERNAL_BOARD_DIRS ?= +MODULE_DIRS := $(RIOTBASE)/drivers +MODULE_DIRS += $(RIOTBASE)/sys RIOTMAKE ?= $(RIOTBASE)/makefiles RIOTPKG ?= $(RIOTBASE)/pkg RIOTTOOLS ?= $(RIOTBASE)/dist/tools @@ -149,6 +151,7 @@ EXTERNAL_BOARD_DIRS := $(foreach dir,\ EXTERNAL_MODULE_DIRS := $(foreach dir,\ $(EXTERNAL_MODULE_DIRS),\ $(abspath $(dir))) +MODULE_DIRS := $(foreach dir,$(MODULE_DIRS),$(abspath $(dir))) # Ensure that all directories are set and don't contain spaces. ifneq (, $(filter-out 1, $(foreach v,$(__DIRECTORY_VARIABLES),$(words $($(v)))))) @@ -415,6 +418,9 @@ else # process dependencies include $(RIOTMAKE)/dependency_resolution.inc.mk + + # auto-locate modules + include $(RIOTMAKE)/locate_modules.inc.mk endif # Include Board and CPU configuration @@ -619,8 +625,8 @@ endif # We assume $(LINK) to be gcc-like. Use `LINKFLAGPREFIX :=` for ld-like linker options. LINKFLAGPREFIX ?= -Wl, -# Also build external modules -DIRS += $(EXTERNAL_MODULE_PATHS) +# Also build automatically located modules +DIRS += $(EXTERNAL_MODULE_PATHS) $(MODULE_PATHS) # Define dependencies required for building (headers, downloading source files,) BUILDDEPS += $(RIOTBUILD_CONFIG_HEADER_C) diff --git a/drivers/Makefile b/drivers/Makefile index 13612d5cdb3c..3d513f9ea069 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -1,5 +1,3 @@ -DIRS += $(dir $(wildcard $(addsuffix /Makefile, $(USEMODULE)))) - ifneq (,$(filter saul_init_devs,$(USEMODULE))) DIRS += saul/init_devs endif diff --git a/makefiles/dependency_resolution.inc.mk b/makefiles/dependency_resolution.inc.mk index a3a76223c223..7b15ea2ef109 100644 --- a/makefiles/dependency_resolution.inc.mk +++ b/makefiles/dependency_resolution.inc.mk @@ -2,10 +2,6 @@ # 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))))) - # Back up current state to detect changes OLD_STATE := $(USEMODULE) $(USEPKG) $(FEATURES_USED) diff --git a/makefiles/locate_modules.inc.mk b/makefiles/locate_modules.inc.mk new file mode 100644 index 000000000000..21d64af768d6 --- /dev/null +++ b/makefiles/locate_modules.inc.mk @@ -0,0 +1,11 @@ +# Only locate non-pseudo-modules +MODS2LOCATE := $(filter-out $(PSEUDOMODULES) $(NO_AUTOLOCATE),\ + $(USEMODULE)) $(filter $(NO_PSEUDOMODULES),$(USEMODULE)) +EXTERNAL_MODULE_PATHS := $(sort $(foreach dir,$(EXTERNAL_MODULE_DIRS),\ +$(foreach mod,$(MODS2LOCATE),$(dir $(wildcard $(dir)/$(mod)/Makefile))))) + +# Ignore modules already located as external modules +MODS2LOCATE := $(filter-out $(basename $(EXTERNAL_MODULE_PATHS)),$(MODS2LOCATE)) + +MODULE_PATHS := $(sort $(foreach dir,$(MODULE_DIRS),\ + $(foreach mod,$(MODS2LOCATE),$(dir $(wildcard $(dir)/$(mod)/Makefile))))) diff --git a/sys/Makefile b/sys/Makefile index 46fbc9265298..68c536451260 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -23,9 +23,6 @@ endif ifneq (,$(filter cord_lc,$(USEMODULE))) DIRS += net/application_layer/cord/lc endif -ifneq (,$(filter cpp11-compat,$(USEMODULE))) - DIRS += cpp11-compat -endif ifneq (,$(filter credman,$(USEMODULE))) DIRS += net/credman endif @@ -41,9 +38,6 @@ endif ifneq (,$(filter dummy_thread,$(USEMODULE))) DIRS += test_utils/dummy_thread endif -ifneq (,$(filter eepreg,$(USEMODULE))) - DIRS += eepreg -endif ifneq (,$(filter emcute,$(USEMODULE))) DIRS += net/application_layer/emcute endif @@ -89,9 +83,6 @@ endif ifneq (,$(filter l2util,$(USEMODULE))) DIRS += net/link_layer/l2util endif -ifneq (,$(filter log_%,$(USEMODULE))) - DIRS += log -endif ifneq (,$(filter nanocoap,$(USEMODULE))) DIRS += net/application_layer/nanocoap endif @@ -110,12 +101,6 @@ endif ifneq (,$(filter netstats_neighbor,$(USEMODULE))) DIRS += net/netstats endif -ifneq (,$(filter sema,$(USEMODULE))) - DIRS += sema -endif -ifneq (,$(filter sema_inv,$(USEMODULE))) - DIRS += sema_inv -endif ifneq (,$(filter sixlowpan,$(USEMODULE))) DIRS += net/network_layer/sixlowpan endif @@ -131,9 +116,6 @@ endif ifneq (,$(filter sock_util,$(USEMODULE))) DIRS += net/sock endif -ifneq (,$(filter oneway_malloc,$(USEMODULE))) - DIRS += oneway-malloc -endif ifneq (,$(filter posix_inet,$(USEMODULE))) DIRS += posix/inet endif @@ -161,12 +143,6 @@ endif ifneq (,$(filter shell_commands,$(USEMODULE))) DIRS += shell/commands endif -ifneq (,$(filter suit%,$(USEMODULE))) - DIRS += suit -endif -ifneq (,$(filter sys_bus,$(USEMODULE))) - DIRS += sys_bus -endif ifneq (,$(filter tcp,$(USEMODULE))) DIRS += net/transport_layer/tcp endif @@ -188,10 +164,5 @@ endif ifneq (,$(filter ztimer_core,$(USEMODULE))) DIRS += ztimer endif -ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) - FILTER += xtimer -endif - -DIRS += $(dir $(wildcard $(addsuffix /Makefile, $(filter-out $(FILTER), $(USEMODULE))))) include $(RIOTBASE)/Makefile.base diff --git a/sys/Makefile.dep b/sys/Makefile.dep index 73b0fa818b61..92d85de4cfef 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -698,6 +698,7 @@ ifneq (,$(filter xtimer,$(USEMODULE))) endif else # ztimer_xtimer_compat is used, all of *xtimer's API will be mapped on ztimer.* + NO_AUTOLOCATE += xtimer endif endif From 74bd5afa4fc5d2e60bfb0131f322553d1d3a64eb Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Tue, 11 May 2021 10:58:42 +0200 Subject: [PATCH 3/4] fixup! build-system: auto-locate modules by name --- Makefile.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.include b/Makefile.include index 2b27ef195f49..250328479dd5 100644 --- a/Makefile.include +++ b/Makefile.include @@ -418,11 +418,11 @@ else # process dependencies include $(RIOTMAKE)/dependency_resolution.inc.mk - - # auto-locate modules - include $(RIOTMAKE)/locate_modules.inc.mk endif +# auto-locate modules +include $(RIOTMAKE)/locate_modules.inc.mk + # Include Board and CPU configuration INCLUDES += $(addprefix -I,$(wildcard $(BOARDDIR)/include)) include $(BOARDDIR)/Makefile.include From 3d2fca212160e47fb8d84a33297b6ba9f624e6d8 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Tue, 11 May 2021 12:20:31 +0200 Subject: [PATCH 4/4] fixup! build-system: auto-locate modules by name --- Makefile.include | 5 ++--- makefiles/dependency_resolution.inc.mk | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile.include b/Makefile.include index 250328479dd5..f5515c2ceaff 100644 --- a/Makefile.include +++ b/Makefile.include @@ -406,6 +406,8 @@ ifeq (1,$(TEST_KCONFIG)) USEMODULE := $(KCONFIG_MODULES) KCONFIG_PACKAGES := $(call lowercase,$(patsubst CONFIG_PACKAGE_%,%,$(filter CONFIG_PACKAGE_%,$(.VARIABLES)))) USEPKG := $(KCONFIG_PACKAGES) + # auto-locate modules + include $(RIOTMAKE)/locate_modules.inc.mk else # check if required features are provided and update $(FEATURES_USED) include $(RIOTMAKE)/features_check.inc.mk @@ -420,9 +422,6 @@ else include $(RIOTMAKE)/dependency_resolution.inc.mk endif -# auto-locate modules -include $(RIOTMAKE)/locate_modules.inc.mk - # Include Board and CPU configuration INCLUDES += $(addprefix -I,$(wildcard $(BOARDDIR)/include)) include $(BOARDDIR)/Makefile.include diff --git a/makefiles/dependency_resolution.inc.mk b/makefiles/dependency_resolution.inc.mk index 7b15ea2ef109..b740a3f3745f 100644 --- a/makefiles/dependency_resolution.inc.mk +++ b/makefiles/dependency_resolution.inc.mk @@ -2,6 +2,9 @@ # until no new modules, pkgs, or features are pull in order to catch all # transient dependencies +# auto-locate modules +include $(RIOTMAKE)/locate_modules.inc.mk + # Back up current state to detect changes OLD_STATE := $(USEMODULE) $(USEPKG) $(FEATURES_USED)