The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | # Copyright (C) 2007 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| 15 | |
| 16 | INTERNAL_CLEAN_STEPS := |
| 17 | |
| 18 | # Builds up a list of clean steps. Creates a unique |
| 19 | # id for each step by taking INTERNAL_CLEAN_BUILD_VERSION |
| 20 | # and appending an increasing number of '@' characters. |
| 21 | # |
| 22 | # $(1): shell command to run |
| 23 | define _add-clean-step |
| 24 | $(if $(strip $(INTERNAL_CLEAN_BUILD_VERSION)),, \ |
| 25 | $(error INTERNAL_CLEAN_BUILD_VERSION not set)) |
| 26 | $(eval _acs_id := $(strip $(lastword $(INTERNAL_CLEAN_STEPS)))) |
| 27 | $(if $(_acs_id),,$(eval _acs_id := $(INTERNAL_CLEAN_BUILD_VERSION))) |
| 28 | $(eval _acs_id := $(_acs_id)@) |
| 29 | $(eval INTERNAL_CLEAN_STEPS += $(_acs_id)) |
| 30 | $(eval INTERNAL_CLEAN_STEP.$(_acs_id) := $(1)) |
| 31 | $(eval _acs_id :=) |
| 32 | endef |
| 33 | define add-clean-step |
| 34 | $(if $(call _add-clean-step,$(1)),) |
| 35 | endef |
| 36 | |
| 37 | # Defines INTERNAL_CLEAN_BUILD_VERSION and the individual clean steps. |
| 38 | # cleanspec.mk is outside of the core directory so that more people |
| 39 | # can have permission to touch it. |
| 40 | include build/cleanspec.mk |
| 41 | INTERNAL_CLEAN_BUILD_VERSION := $(strip $(INTERNAL_CLEAN_BUILD_VERSION)) |
| 42 | |
| 43 | # If the clean_steps.mk file is missing (usually after a clean build) |
| 44 | # then we won't do anything. |
| 45 | CURRENT_CLEAN_BUILD_VERSION := $(INTERNAL_CLEAN_BUILD_VERSION) |
| 46 | CURRENT_CLEAN_STEPS := $(INTERNAL_CLEAN_STEPS) |
| 47 | |
| 48 | # Read the current state from the file, if present. |
| 49 | # Will set CURRENT_CLEAN_BUILD_VERSION and CURRENT_CLEAN_STEPS. |
| 50 | # |
| 51 | clean_steps_file := $(PRODUCT_OUT)/clean_steps.mk |
| 52 | -include $(clean_steps_file) |
| 53 | |
| 54 | ifneq ($(CURRENT_CLEAN_BUILD_VERSION),$(INTERNAL_CLEAN_BUILD_VERSION)) |
| 55 | # The major clean version is out-of-date. Do a full clean, and |
| 56 | # don't even bother with the clean steps. |
| 57 | $(info *** A clean build is required because of a recent change.) |
| 58 | $(shell rm -rf $(OUT_DIR)) |
| 59 | $(info *** Done with the cleaning, now starting the real build.) |
| 60 | else |
| 61 | # The major clean version is correct. Find the list of clean steps |
| 62 | # that we need to execute to get up-to-date. |
| 63 | steps := \ |
| 64 | $(filter-out $(CURRENT_CLEAN_STEPS),$(INTERNAL_CLEAN_STEPS)) |
| 65 | $(foreach step,$(steps), \ |
| 66 | $(info Clean step: $(INTERNAL_CLEAN_STEP.$(step))) \ |
| 67 | $(shell $(INTERNAL_CLEAN_STEP.$(step))) \ |
| 68 | ) |
| 69 | steps := |
| 70 | endif |
| 71 | CURRENT_CLEAN_BUILD_VERSION := |
| 72 | CURRENT_CLEAN_STEPS := |
| 73 | |
| 74 | # Write the new state to the file. |
| 75 | # |
| 76 | $(shell \ |
| 77 | mkdir -p $(dir $(clean_steps_file)) && \ |
| 78 | echo "CURRENT_CLEAN_BUILD_VERSION := $(INTERNAL_CLEAN_BUILD_VERSION)" > \ |
| 79 | $(clean_steps_file) ;\ |
| 80 | echo "CURRENT_CLEAN_STEPS := $(INTERNAL_CLEAN_STEPS)" >> \ |
| 81 | $(clean_steps_file) \ |
| 82 | ) |
| 83 | |
| 84 | clean_steps_file := |
| 85 | INTERNAL_CLEAN_STEPS := |
| 86 | INTERNAL_CLEAN_BUILD_VERSION := |