From cba6f12b8b878f87bd04cfcf76e0e42d6a69c29a Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Mon, 29 Jan 2024 15:56:52 +0100 Subject: [PATCH 1/3] make: pkg/: add git-cache-rs support --- pkg/pkg.mk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/pkg.mk b/pkg/pkg.mk index 6cf59d5b7254..900e65aedcfc 100644 --- a/pkg/pkg.mk +++ b/pkg/pkg.mk @@ -128,7 +128,12 @@ $(PKG_DOWNLOADED): $(MAKEFILE_LIST) | $(PKG_SOURCE_DIR)/.git fi $(Q)echo $(PKG_VERSION) > $@ -ifeq ($(GIT_CACHE_DIR),$(wildcard $(GIT_CACHE_DIR))) +ifneq (,$(GIT_CACHE_RS)) +$(PKG_SOURCE_DIR)/.git: | $(PKG_CUSTOM_PREPARED) + $(if $(QUIETER),,$(info [INFO] cloning $(PKG_NAME))) + $(Q)rm -Rf $(PKG_SOURCE_DIR) + $(Q)$(GIT_CACHE_RS) clone --commit $(PKG_VERSION) $(addprefix --sparse-add ,$(PKG_SPARSE_PATHS)) -- $(PKG_URL) $(PKG_SOURCE_DIR) +else ifeq ($(GIT_CACHE_DIR),$(wildcard $(GIT_CACHE_DIR))) $(PKG_SOURCE_DIR)/.git: | $(PKG_CUSTOM_PREPARED) $(if $(QUIETER),,$(info [INFO] cloning $(PKG_NAME))) $(Q)rm -Rf $(PKG_SOURCE_DIR) From 2bb2016e2343266ad10586ebc525fb0bc3265518 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Mon, 29 Jan 2024 15:57:25 +0100 Subject: [PATCH 2/3] pkg/cmsis: add `PKG_SPARSE_PATHS` for NN and DSP sub-pkgs --- pkg/cmsis/Makefile | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/pkg/cmsis/Makefile b/pkg/cmsis/Makefile index d503dc71e224..162569573405 100644 --- a/pkg/cmsis/Makefile +++ b/pkg/cmsis/Makefile @@ -3,10 +3,6 @@ PKG_URL=https://github.com/ARM-software/CMSIS_5 PKG_VERSION=2b7495b8535bdcb306dac29b9ded4cfb679d7e5c # 5.9.0 PKG_LICENSE=Apache-2.0 -include $(RIOTBASE)/pkg/pkg.mk - -CFLAGS += -Wno-cast-align - CMSIS_NN_MODULES = \ cmsis-nn_activationfunctions \ cmsis-nn_convolutionfunctions \ @@ -16,13 +12,6 @@ CMSIS_NN_MODULES = \ cmsis-nn_softmaxfunctions \ # -DIR_activationfunctions := ActivationFunctions -DIR_convolutionfunctions := ConvolutionFunctions -DIR_fullyconnectedfunctions := FullyConnectedFunctions -DIR_nnsupportfunctions := NNSupportFunctions -DIR_poolingfunctions := PoolingFunctions -DIR_softmaxfunctions := SoftmaxFunctions - CMSIS_DSP_MODULES = \ cmsis-dsp_basicmathfunctions \ cmsis-dsp_commontables \ @@ -36,6 +25,32 @@ CMSIS_DSP_MODULES = \ cmsis-dsp_transformfunctions \ # +CMSIS_DSP_MODULES_USED = $(filter $(CMSIS_DSP_MODULES),$(USEMODULE)) +CMSIS_NN_MODULES_USED = $(filter $(CMSIS_NN_MODULES),$(USEMODULE)) +CMSIS_MODULES_USED = $(CMSIS_DSP_MODULES_USED) $(CMSIS_NN_MODULES_USED) + +PKG_SPARSE_PATHS=CMSIS/Core/Include + +ifneq (, $(CMSIS_NN_MODULES_USED)) + PKG_SPARSE_PATHS+=CMSIS/NN + CMSIS_DSP_NEEDED=1 +endif +ifneq (, $(CMSIS_DSP_MODULES_USED)$(CMSIS_DSP_NEEDED)) + PKG_SPARSE_PATHS+=CMSIS/DSP +endif + + +include $(RIOTBASE)/pkg/pkg.mk + +CFLAGS += -Wno-cast-align + +DIR_activationfunctions := ActivationFunctions +DIR_convolutionfunctions := ConvolutionFunctions +DIR_fullyconnectedfunctions := FullyConnectedFunctions +DIR_nnsupportfunctions := NNSupportFunctions +DIR_poolingfunctions := PoolingFunctions +DIR_softmaxfunctions := SoftmaxFunctions + DIR_basicmathfunctions := BasicMathFunctions DIR_commontables := CommonTables DIR_complexmathfunctions := ComplexMathFunctions @@ -49,8 +64,6 @@ DIR_transformfunctions := TransformFunctions .PHONY: cmsis-dsp_% cmsis-nn_% -CMSIS_MODULES_USED = $(filter $(CMSIS_DSP_MODULES) $(CMSIS_NN_MODULES),$(USEMODULE)) - all: $(CMSIS_MODULES_USED) cmsis-dsp_%: From f9afdf86d0ac156c990a20b2b3a8630e0c3af47b Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Mon, 29 Jan 2024 23:10:22 +0100 Subject: [PATCH 3/3] pkg: ensure "dynamic sparse paths" are up-to-date --- pkg/pkg.mk | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/pkg.mk b/pkg/pkg.mk index 900e65aedcfc..7a21f9006d96 100644 --- a/pkg/pkg.mk +++ b/pkg/pkg.mk @@ -128,8 +128,24 @@ $(PKG_DOWNLOADED): $(MAKEFILE_LIST) | $(PKG_SOURCE_DIR)/.git fi $(Q)echo $(PKG_VERSION) > $@ +# This snippet ensures that for packages that have dynamic sparse paths (e.g., +# pkg/cmsis), the sparse paths of the time of checkout are the same as needed +# now. +# E.g., build a) only needs CMSIS/Core. Build b) also needs CMSIS/DSP. +# If b) is built after a) and the cmsis checkout does not contain CMSIS/DSP, +# the sources need to be checked out again. +# (Inside, this is doing an ad-hoc "|$(LAZYSPONGE)", but using the python version turned out +# to be significantly slower). +ifneq (, $(PKG_SPARSE_PATHS)) +PKG_SPARSE_TAG = $(PKG_SOURCE_DIR).sparse +$(PKG_SPARSE_TAG): FORCE + $(Q)if test -f $@; then \ + test "$$(cat $@)" = "$(PKG_SPARSE_PATHS)" && exit 0; \ + fi ; mkdir -p $$(dirname $@) && echo "$(PKG_SPARSE_PATHS)" > $@ +endif + ifneq (,$(GIT_CACHE_RS)) -$(PKG_SOURCE_DIR)/.git: | $(PKG_CUSTOM_PREPARED) +$(PKG_SOURCE_DIR)/.git: $(PKG_SPARSE_TAG) | $(PKG_CUSTOM_PREPARED) $(if $(QUIETER),,$(info [INFO] cloning $(PKG_NAME))) $(Q)rm -Rf $(PKG_SOURCE_DIR) $(Q)$(GIT_CACHE_RS) clone --commit $(PKG_VERSION) $(addprefix --sparse-add ,$(PKG_SPARSE_PATHS)) -- $(PKG_URL) $(PKG_SOURCE_DIR)