Skip to content

Instantly share code, notes, and snippets.

@willcl-ark
Created September 30, 2025 08:52
Show Gist options
  • Save willcl-ark/89981c05a56a996ff7d1c1c7bc4b2fdb to your computer and use it in GitHub Desktop.
Save willcl-ark/89981c05a56a996ff7d1c1c7bc4b2fdb to your computer and use it in GitHub Desktop.
commit ba0491319977a3825f6d2145c6f23b7b05da4ca1
Author: will <[email protected]>
Date: Tue Sep 30 09:35:14 2025 +0100
detect depends recipe changes
diff --git a/depends/funcs.mk b/depends/funcs.mk
index 28baf47147a..33bd3764922 100644
--- a/depends/funcs.mk
+++ b/depends/funcs.mk
@@ -117,6 +117,7 @@ $(1)_built=$$($(1)_build_dir)/.stamp_built
$(1)_configured=$(host_prefix)/.$(1)_stamp_configured
$(1)_staged=$$($(1)_staging_dir)/.stamp_staged
$(1)_postprocessed=$$($(1)_staging_prefix_dir)/.stamp_postprocessed
+$(1)_recipe_valid=$(BASE_CACHE)/$(host)/$(1)/.stamp_recipe_valid_$($(1)_recipe_hash)
$(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path))
@@ -283,7 +284,18 @@ $($(1)_postprocessed): | $($(1)_staged)
echo Postprocessing $(1)...
cd $($(1)_staging_prefix_dir); $($(1)_postprocess_cmds)
touch $$@
-$($(1)_cached): | $($(1)_dependencies) $($(1)_postprocessed)
+$($(1)_recipe_valid):
+ @if [ -f $($(1)_cached) ]; then \
+ current_hash="$($(1)_recipe_hash)"; \
+ cached_hash="$$(echo $($(1)_cached) | grep -o '[0-9a-f]\{$(HASH_LENGTH)\}' | tail -1)"; \
+ if [ "$$current_hash" != "$$cached_hash" ]; then \
+ echo "Recipe hash mismatch for $(1): current=$$current_hash cached=$$cached_hash. Forcing rebuild.."; \
+ rm -f $($(1)_cached) $($(1)_cached_checksum); \
+ fi \
+ fi
+ @mkdir -p $$(@D)
+ touch $$@
+$($(1)_cached): | $($(1)_dependencies) $($(1)_postprocessed) $($(1)_recipe_valid)
echo Caching $(1)...
cd $$($(1)_staging_dir)/$(host_prefix); \
find . ! -name '.stamp_postprocessed' -print0 | TZ=UTC xargs -0r $(build_TOUCH); \
@@ -298,11 +310,11 @@ $($(1)_cached_checksum): $($(1)_cached)
.PHONY: $(1)
$(1): | $($(1)_cached_checksum)
-.SECONDARY: $($(1)_cached) $($(1)_postprocessed) $($(1)_staged) $($(1)_built) $($(1)_configured) $($(1)_preprocessed) $($(1)_extracted) $($(1)_fetched)
+.SECONDARY: $($(1)_cached) $($(1)_postprocessed) $($(1)_staged) $($(1)_built) $($(1)_configured) $($(1)_preprocessed) $($(1)_extracted) $($(1)_fetched) $($(1)_recipe_valid)
endef
-stages = fetched extracted preprocessed configured built staged postprocessed cached cached_checksum
+stages = fetched extracted preprocessed configured built staged postprocessed recipe_valid cached cached_checksum
define ext_add_stages
$(foreach stage,$(stages),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment