Skip to content

Commit

Permalink
buildsystem/pkg: expand paths early
Browse files Browse the repository at this point in the history
  • Loading branch information
NikLeberg authored and fjmolinas committed Jan 30, 2022
1 parent 4aa173d commit 140824e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Makefile.base
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ compile-commands: | $(DIRS:%=COMPILE-COMMANDS--%)
$(file >>$(BINDIR)/$(MODULE)/compile_cmds.txt,TARGET_ARCH: $(TARGET_ARCH))
$(file >>$(BINDIR)/$(MODULE)/compile_cmds.txt,TARGET_ARCH_LLVM: $(TARGET_ARCH_LLVM))

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

GENOBJC := $(GENSRC:%.c=%.o)
OBJC_LTO := $(SRC:%.c=$(BINDIR)/$(MODULE)/%.o)
Expand Down
2 changes: 1 addition & 1 deletion Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ include $(RIOTBASE)/drivers/Makefile.dep
-include $(sort $(USEMODULE:%=$(RIOTBASE)/drivers/%/Makefile.dep))

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

ifneq (,$(filter mpu_stack_guard,$(USEMODULE)))
FEATURES_REQUIRED += cortexm_mpu
Expand Down
25 changes: 14 additions & 11 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ ifeq (1,$(TEST_KCONFIG))
USEMODULE := $(KCONFIG_MODULES)
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),\
$(foreach pkg,$(USEPKG),$(dir $(wildcard $(dir)/$(pkg)/Makefile)))))
else
# always select provided architecture features
FEATURES_REQUIRED += $(filter arch_%,$(FEATURES_PROVIDED))
Expand Down Expand Up @@ -570,8 +574,8 @@ include $(RIOTBASE)/sys/Makefile.include
# include Makefile.includes of each driver modules if they exist
-include $(USEMODULE:%=$(RIOTBASE)/drivers/%/Makefile.include)

# include Makefile.includes for packages in $(USEPKG)
-include $(USEPKG:%=$(RIOTPKG)/%/Makefile.include)
# include Makefile.includes for packages in $(PKG_PATHS)
-include $(PKG_PATHS:%=%Makefile.include)

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

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

pkg-build: $(USEPKG:%=pkg-build-%)
pkg-build-%: $(BUILDDEPS)
$(QQ)"$(MAKE)" -C $(RIOTPKG)/$*
pkg-build: $(BUILDDEPS)
$(foreach dir,$(PKG_PATHS),$(QQ)"$(MAKE)" -C $(dir) $(NEWLINE))

clean:
ifndef MAKE_RESTARTS
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i clean ; done
-@$(foreach dir,$(PKG_PATHS),"$(MAKE)" -C $(dir) clean $(NEWLINE))
-@rm -rf $(BINDIR)
-@rm -rf $(SCANBUILD_OUTPUTDIR)
endif

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

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

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

# Include PROGRAMMER_FLASH/PROGRAMMER_RESET variables
Expand Down
4 changes: 4 additions & 0 deletions makefiles/dependency_resolution.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
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),\
$(foreach pkg,$(USEPKG),$(dir $(wildcard $(dir)/$(pkg)/Makefile)))))

# Back up current state to detect changes
OLD_STATE := $(USEMODULE) $(USEPKG) $(FEATURES_USED)

Expand Down
1 change: 1 addition & 0 deletions makefiles/vars.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export BINDIR # This is the folder where the application should b
export CARGO_TARGET_DIR # This is the folder where Rust parts of the application should be built in.
export BUILD_DIR # This is the base folder to store common build files and artifacts, e.g. test results.
export APPDIR # The base folder containing the application
export PKG_PATHS # List of absolute paths where packages of $(USEPKG) can be found
export PKGDIRBASE # The base folder for building packages

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

0 comments on commit 140824e

Please sign in to comment.