Skip to content

Commit 140824e

Browse files
NikLebergfjmolinas
authored andcommitted
buildsystem/pkg: expand paths early
1 parent 4aa173d commit 140824e

5 files changed

+22
-14
lines changed

Makefile.base

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ compile-commands: | $(DIRS:%=COMPILE-COMMANDS--%)
9797
$(file >>$(BINDIR)/$(MODULE)/compile_cmds.txt,TARGET_ARCH: $(TARGET_ARCH))
9898
$(file >>$(BINDIR)/$(MODULE)/compile_cmds.txt,TARGET_ARCH_LLVM: $(TARGET_ARCH_LLVM))
9999

100-
# include makefile snippets for packages in $(USEPKG) that modify GENSRC:
101-
-include $(USEPKG:%=$(RIOTPKG)/%/Makefile.gensrc)
100+
# include makefile snippets for packages in $(PKG_PATHS) that modify GENSRC:
101+
-include $(PKG_PATHS:%=%Makefile.gensrc)
102102

103103
GENOBJC := $(GENSRC:%.c=%.o)
104104
OBJC_LTO := $(SRC:%.c=$(BINDIR)/$(MODULE)/%.o)

Makefile.dep

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ include $(RIOTBASE)/drivers/Makefile.dep
2020
-include $(sort $(USEMODULE:%=$(RIOTBASE)/drivers/%/Makefile.dep))
2121

2222
# pull dependencies from packages
23-
-include $(USEPKG:%=$(RIOTPKG)/%/Makefile.dep)
23+
-include $(PKG_PATHS:%=%Makefile.dep)
2424

2525
ifneq (,$(filter mpu_stack_guard,$(USEMODULE)))
2626
FEATURES_REQUIRED += cortexm_mpu

Makefile.include

+14-11
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ ifeq (1,$(TEST_KCONFIG))
427427
USEMODULE := $(KCONFIG_MODULES)
428428
KCONFIG_PACKAGES := $(call lowercase,$(patsubst CONFIG_PACKAGE_%,%,$(filter CONFIG_PACKAGE_%,$(.VARIABLES))))
429429
USEPKG := $(KCONFIG_PACKAGES)
430+
431+
# Locate used packages in $(RIOTPKG).
432+
PKG_PATHS := $(sort $(foreach dir,$(RIOTPKG),\
433+
$(foreach pkg,$(USEPKG),$(dir $(wildcard $(dir)/$(pkg)/Makefile)))))
430434
else
431435
# always select provided architecture features
432436
FEATURES_REQUIRED += $(filter arch_%,$(FEATURES_PROVIDED))
@@ -570,8 +574,8 @@ include $(RIOTBASE)/sys/Makefile.include
570574
# include Makefile.includes of each driver modules if they exist
571575
-include $(USEMODULE:%=$(RIOTBASE)/drivers/%/Makefile.include)
572576

573-
# include Makefile.includes for packages in $(USEPKG)
574-
-include $(USEPKG:%=$(RIOTPKG)/%/Makefile.include)
577+
# include Makefile.includes for packages in $(PKG_PATHS)
578+
-include $(PKG_PATHS:%=%Makefile.include)
575579

576580
# include external modules configuration
577581
-include $(EXTERNAL_MODULE_PATHS:%=%/Makefile.include)
@@ -771,31 +775,30 @@ endif
771775
# The `clean` needs to be serialized before everything else.
772776
all $(BASELIBS) $(ARCHIVES) $(BUILDDEPS) ..in-docker-container: | $(CLEAN)
773777

774-
.PHONY: pkg-prepare pkg-build pkg-build-%
778+
.PHONY: pkg-prepare pkg-build
775779
pkg-prepare:
776-
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i prepare ; done
780+
-@$(foreach dir,$(PKG_PATHS),"$(MAKE)" -C $(dir) prepare $(NEWLINE))
777781

778-
pkg-build: $(USEPKG:%=pkg-build-%)
779-
pkg-build-%: $(BUILDDEPS)
780-
$(QQ)"$(MAKE)" -C $(RIOTPKG)/$*
782+
pkg-build: $(BUILDDEPS)
783+
$(foreach dir,$(PKG_PATHS),$(QQ)"$(MAKE)" -C $(dir) $(NEWLINE))
781784

782785
clean:
783786
ifndef MAKE_RESTARTS
784-
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i clean ; done
787+
-@$(foreach dir,$(PKG_PATHS),"$(MAKE)" -C $(dir) clean $(NEWLINE))
785788
-@rm -rf $(BINDIR)
786789
-@rm -rf $(SCANBUILD_OUTPUTDIR)
787790
endif
788791

789792
# Remove intermediates, but keep the .elf, .hex and .map etc.
790793
clean-intermediates:
791-
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done
794+
-@$(foreach dir,$(PKG_PATHS),"$(MAKE)" -C $(dir) distclean $(NEWLINE))
792795
-@rm -rf $(BINDIR)/*.a $(BINDIR)/*/
793796

794797
clean-pkg:
795-
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done
798+
-@$(foreach dir,$(PKG_PATHS),"$(MAKE)" -C $(dir) distclean $(NEWLINE))
796799

797800
distclean:
798-
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done
801+
-@$(foreach dir,$(PKG_PATHS),"$(MAKE)" -C $(dir) distclean $(NEWLINE))
799802
-@rm -rf $(BINDIRBASE)
800803

801804
# Include PROGRAMMER_FLASH/PROGRAMMER_RESET variables

makefiles/dependency_resolution.inc.mk

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
EXTERNAL_MODULE_PATHS := $(sort $(foreach dir,$(EXTERNAL_MODULE_DIRS),\
77
$(foreach mod,$(USEMODULE),$(dir $(wildcard $(dir)/$(mod)/Makefile)))))
88

9+
# Locate used packages in $(RIOTPKG).
10+
PKG_PATHS := $(sort $(foreach dir,$(RIOTPKG),\
11+
$(foreach pkg,$(USEPKG),$(dir $(wildcard $(dir)/$(pkg)/Makefile)))))
12+
913
# Back up current state to detect changes
1014
OLD_STATE := $(USEMODULE) $(USEPKG) $(FEATURES_USED)
1115

makefiles/vars.inc.mk

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export BINDIR # This is the folder where the application should b
4545
export CARGO_TARGET_DIR # This is the folder where Rust parts of the application should be built in.
4646
export BUILD_DIR # This is the base folder to store common build files and artifacts, e.g. test results.
4747
export APPDIR # The base folder containing the application
48+
export PKG_PATHS # List of absolute paths where packages of $(USEPKG) can be found
4849
export PKGDIRBASE # The base folder for building packages
4950

5051
export PYTHONPATH # Python default search path for module filesi, with RIOT specific packages

0 commit comments

Comments
 (0)