Decentralizes cleanspecs.
After this change, you should add-clean-step at the end of CleanSpec.mk
in your project, instead of the centralized cleanspecs.mk in build/core.
diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk
index a753554..7e68d6f 100644
--- a/core/cleanbuild.mk
+++ b/core/cleanbuild.mk
@@ -16,28 +16,40 @@
INTERNAL_CLEAN_STEPS :=
# Builds up a list of clean steps. Creates a unique
-# id for each step by taking INTERNAL_CLEAN_BUILD_VERSION
+# id for each step by taking makefile path, INTERNAL_CLEAN_BUILD_VERSION
# and appending an increasing number of '@' characters.
#
# $(1): shell command to run
+# $(2): indicate to not use makefile path as part of step id if not empty.
+# $(2) should only be used in build/core/cleanspec.mk: just for compatibility.
define _add-clean-step
$(if $(strip $(INTERNAL_CLEAN_BUILD_VERSION)),, \
$(error INTERNAL_CLEAN_BUILD_VERSION not set))
- $(eval _acs_id := $(strip $(lastword $(INTERNAL_CLEAN_STEPS))))
- $(if $(_acs_id),,$(eval _acs_id := $(INTERNAL_CLEAN_BUILD_VERSION)))
- $(eval _acs_id := $(_acs_id)@)
+ $(eval _acs_makefile_prefix := $(lastword $(MAKEFILE_LIST)))
+ $(eval _acs_makefile_prefix := $(subst /,_,$(_acs_makefile_prefix)))
+ $(eval _acs_makefile_prefix := $(subst .,-,$(_acs_makefile_prefix)))
+ $(eval _acs_makefile_prefix := $(_acs_makefile_prefix)_acs)
+ $(if $($(_acs_makefile_prefix)),,\
+ $(eval $(_acs_makefile_prefix) := $(INTERNAL_CLEAN_BUILD_VERSION)))
+ $(eval $(_acs_makefile_prefix) := $($(_acs_makefile_prefix))@)
+ $(if $(strip $(2)),$(eval _acs_id := $($(_acs_makefile_prefix))),\
+ $(eval _acs_id := $(_acs_makefile_prefix)$($(_acs_makefile_prefix))))
$(eval INTERNAL_CLEAN_STEPS += $(_acs_id))
$(eval INTERNAL_CLEAN_STEP.$(_acs_id) := $(1))
$(eval _acs_id :=)
+ $(eval _acs_makefile_prefix :=)
endef
define add-clean-step
-$(if $(call _add-clean-step,$(1)),)
+$(eval # for build/core/cleanspec.mk, dont use makefile path as part of step id) \
+$(if $(filter %/cleanspec.mk,$(lastword $(MAKEFILE_LIST))),\
+ $(eval $(call _add-clean-step,$(1),true)),\
+ $(eval $(call _add-clean-step,$(1))))
endef
# Defines INTERNAL_CLEAN_BUILD_VERSION and the individual clean steps.
# cleanspec.mk is outside of the core directory so that more people
# can have permission to touch it.
-include build/cleanspec.mk
+include $(BUILD_SYSTEM)/cleanspec.mk
INTERNAL_CLEAN_BUILD_VERSION := $(strip $(INTERNAL_CLEAN_BUILD_VERSION))
# If the clean_steps.mk file is missing (usually after a clean build)
diff --git a/cleanspec.mk b/core/cleanspec.mk
similarity index 96%
rename from cleanspec.mk
rename to core/cleanspec.mk
index 6151fd1..c95dda6 100644
--- a/cleanspec.mk
+++ b/core/cleanspec.mk
@@ -15,7 +15,11 @@
# Just bump this if you want to force a clean build.
# **********************************************************************
-# WHEN DOING SO, DELETE ANY "add-clean-step" ENTRIES THAT HAVE PILED UP.
+# WHEN DOING SO
+# 1. DELETE ANY "add-clean-step" ENTRIES THAT HAVE PILED UP IN THIS FILE.
+# 2. REMOVE ALL FILES NAMED CleanSpec.mk.
+# 3. BUMP THE VERSION.
+# IDEALLY, THOSE STEPS SHOULD BE DONE ATOMICALLY.
# **********************************************************************
#
INTERNAL_CLEAN_BUILD_VERSION := 3
@@ -160,3 +164,8 @@
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
+
+subdir_cleanspecs := \
+ $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git . CleanSpec.mk)
+include $(subdir_cleanspecs)
+subdir_cleanspecs :=