Skip to content

Commit

Permalink
pkg: ensure "dynamic sparse paths" are up-to-date
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 committed Jan 30, 2024
1 parent 2bb2016 commit f9afdf8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pkg/pkg.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f9afdf8

Please sign in to comment.