The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [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 | |
Ying Wang | 50e52fa | 2013-02-22 18:15:29 -0800 | [diff] [blame] | 16 | # Don't bother with the cleanspecs if you are running mm/mmm |
Ying Wang | ad7fd29 | 2013-08-08 16:34:29 -0700 | [diff] [blame] | 17 | ifeq ($(ONE_SHOT_MAKEFILE)$(dont_bother),) |
Ying Wang | 50e52fa | 2013-02-22 18:15:29 -0800 | [diff] [blame] | 18 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 19 | INTERNAL_CLEAN_STEPS := |
| 20 | |
| 21 | # Builds up a list of clean steps. Creates a unique |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 22 | # id for each step by taking makefile path, INTERNAL_CLEAN_BUILD_VERSION |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 23 | # and appending an increasing number of '@' characters. |
| 24 | # |
| 25 | # $(1): shell command to run |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 26 | # $(2): indicate to not use makefile path as part of step id if not empty. |
| 27 | # $(2) should only be used in build/core/cleanspec.mk: just for compatibility. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 28 | define _add-clean-step |
| 29 | $(if $(strip $(INTERNAL_CLEAN_BUILD_VERSION)),, \ |
| 30 | $(error INTERNAL_CLEAN_BUILD_VERSION not set)) |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 31 | $(eval _acs_makefile_prefix := $(lastword $(MAKEFILE_LIST))) |
| 32 | $(eval _acs_makefile_prefix := $(subst /,_,$(_acs_makefile_prefix))) |
| 33 | $(eval _acs_makefile_prefix := $(subst .,-,$(_acs_makefile_prefix))) |
| 34 | $(eval _acs_makefile_prefix := $(_acs_makefile_prefix)_acs) |
| 35 | $(if $($(_acs_makefile_prefix)),,\ |
| 36 | $(eval $(_acs_makefile_prefix) := $(INTERNAL_CLEAN_BUILD_VERSION))) |
| 37 | $(eval $(_acs_makefile_prefix) := $($(_acs_makefile_prefix))@) |
| 38 | $(if $(strip $(2)),$(eval _acs_id := $($(_acs_makefile_prefix))),\ |
| 39 | $(eval _acs_id := $(_acs_makefile_prefix)$($(_acs_makefile_prefix)))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 40 | $(eval INTERNAL_CLEAN_STEPS += $(_acs_id)) |
| 41 | $(eval INTERNAL_CLEAN_STEP.$(_acs_id) := $(1)) |
| 42 | $(eval _acs_id :=) |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 43 | $(eval _acs_makefile_prefix :=) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 44 | endef |
| 45 | define add-clean-step |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 46 | $(eval # for build/core/cleanspec.mk, dont use makefile path as part of step id) \ |
| 47 | $(if $(filter %/cleanspec.mk,$(lastword $(MAKEFILE_LIST))),\ |
| 48 | $(eval $(call _add-clean-step,$(1),true)),\ |
| 49 | $(eval $(call _add-clean-step,$(1)))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 50 | endef |
| 51 | |
| 52 | # Defines INTERNAL_CLEAN_BUILD_VERSION and the individual clean steps. |
| 53 | # cleanspec.mk is outside of the core directory so that more people |
| 54 | # can have permission to touch it. |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 55 | include $(BUILD_SYSTEM)/cleanspec.mk |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 56 | INTERNAL_CLEAN_BUILD_VERSION := $(strip $(INTERNAL_CLEAN_BUILD_VERSION)) |
Ying Wang | eadaa95 | 2015-08-04 12:11:54 -0700 | [diff] [blame] | 57 | INTERNAL_CLEAN_STEPS := $(strip $(INTERNAL_CLEAN_STEPS)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 58 | |
| 59 | # If the clean_steps.mk file is missing (usually after a clean build) |
| 60 | # then we won't do anything. |
| 61 | CURRENT_CLEAN_BUILD_VERSION := $(INTERNAL_CLEAN_BUILD_VERSION) |
| 62 | CURRENT_CLEAN_STEPS := $(INTERNAL_CLEAN_STEPS) |
| 63 | |
| 64 | # Read the current state from the file, if present. |
| 65 | # Will set CURRENT_CLEAN_BUILD_VERSION and CURRENT_CLEAN_STEPS. |
| 66 | # |
| 67 | clean_steps_file := $(PRODUCT_OUT)/clean_steps.mk |
| 68 | -include $(clean_steps_file) |
| 69 | |
| 70 | ifneq ($(CURRENT_CLEAN_BUILD_VERSION),$(INTERNAL_CLEAN_BUILD_VERSION)) |
| 71 | # The major clean version is out-of-date. Do a full clean, and |
| 72 | # don't even bother with the clean steps. |
| 73 | $(info *** A clean build is required because of a recent change.) |
| 74 | $(shell rm -rf $(OUT_DIR)) |
| 75 | $(info *** Done with the cleaning, now starting the real build.) |
| 76 | else |
| 77 | # The major clean version is correct. Find the list of clean steps |
| 78 | # that we need to execute to get up-to-date. |
| 79 | steps := \ |
| 80 | $(filter-out $(CURRENT_CLEAN_STEPS),$(INTERNAL_CLEAN_STEPS)) |
| 81 | $(foreach step,$(steps), \ |
| 82 | $(info Clean step: $(INTERNAL_CLEAN_STEP.$(step))) \ |
| 83 | $(shell $(INTERNAL_CLEAN_STEP.$(step))) \ |
| 84 | ) |
Ying Wang | f6268b8 | 2014-06-18 12:07:48 -0700 | [diff] [blame] | 85 | |
| 86 | # Rewrite the clean step for the second arch. |
| 87 | ifdef TARGET_2ND_ARCH |
| 88 | # $(1): the clean step cmd |
| 89 | # $(2): the prefix to search for |
| 90 | # $(3): the prefix to replace with |
| 91 | define -cs-rewrite-cleanstep |
| 92 | $(if $(filter $(2)/%,$(1)),\ |
| 93 | $(eval _crs_new_cmd := $(patsubst $(2)/%,$(3)/%,$(1)))\ |
| 94 | $(info Clean step: $(_crs_new_cmd))\ |
| 95 | $(shell $(_crs_new_cmd))) |
| 96 | endef |
| 97 | $(foreach step,$(steps), \ |
| 98 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_INTERMEDIATES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES))\ |
| 99 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_SHARED_LIBRARIES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES))\ |
| 100 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_VENDOR_SHARED_LIBRARIES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES))\ |
| 101 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES),$(TARGET_OUT_INTERMEDIATES))\ |
| 102 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES),$(TARGET_OUT_SHARED_LIBRARIES))\ |
| 103 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES),$(TARGET_OUT_VENDOR_SHARED_LIBRARIES))\ |
| 104 | ) |
| 105 | endif |
| 106 | _crs_new_cmd := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 107 | steps := |
| 108 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 109 | |
| 110 | # Write the new state to the file. |
Ying Wang | 50e52fa | 2013-02-22 18:15:29 -0800 | [diff] [blame] | 111 | # |
Ying Wang | eadaa95 | 2015-08-04 12:11:54 -0700 | [diff] [blame] | 112 | rewrite_clean_steps_file := |
Shinichiro Hamaji | 14da142 | 2015-07-21 07:28:39 +0900 | [diff] [blame] | 113 | ifneq ($(CURRENT_CLEAN_BUILD_VERSION)-$(CURRENT_CLEAN_STEPS),$(INTERNAL_CLEAN_BUILD_VERSION)-$(INTERNAL_CLEAN_STEPS)) |
Ying Wang | eadaa95 | 2015-08-04 12:11:54 -0700 | [diff] [blame] | 114 | rewrite_clean_steps_file := true |
| 115 | endif |
| 116 | ifeq ($(wildcard $(clean_steps_file)),) |
| 117 | # This is the first build. |
| 118 | rewrite_clean_steps_file := true |
| 119 | endif |
| 120 | ifeq ($(rewrite_clean_steps_file),true) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 121 | $(shell \ |
| 122 | mkdir -p $(dir $(clean_steps_file)) && \ |
| 123 | echo "CURRENT_CLEAN_BUILD_VERSION := $(INTERNAL_CLEAN_BUILD_VERSION)" > \ |
| 124 | $(clean_steps_file) ;\ |
Shinichiro Hamaji | 1326f65 | 2016-01-27 14:59:56 +0900 | [diff] [blame] | 125 | echo "CURRENT_CLEAN_STEPS := $(wordlist 1,500,$(INTERNAL_CLEAN_STEPS))" >> $(clean_steps_file) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 126 | ) |
Shinichiro Hamaji | 1326f65 | 2016-01-27 14:59:56 +0900 | [diff] [blame] | 127 | define -cs-write-clean-steps-if-arg1-not-empty |
| 128 | $(if $(1),$(shell echo "CURRENT_CLEAN_STEPS += $(1)" >> $(clean_steps_file))) |
| 129 | endef |
| 130 | $(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 501,1000,$(INTERNAL_CLEAN_STEPS))) |
| 131 | $(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 1001,1500,$(INTERNAL_CLEAN_STEPS))) |
| 132 | $(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 1501,2000,$(INTERNAL_CLEAN_STEPS))) |
| 133 | $(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 2001,2500,$(INTERNAL_CLEAN_STEPS))) |
| 134 | $(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 2501,3000,$(INTERNAL_CLEAN_STEPS))) |
| 135 | $(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 3001,99999,$(INTERNAL_CLEAN_STEPS))) |
Shinichiro Hamaji | 14da142 | 2015-07-21 07:28:39 +0900 | [diff] [blame] | 136 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 137 | |
Shinichiro Hamaji | 14da142 | 2015-07-21 07:28:39 +0900 | [diff] [blame] | 138 | CURRENT_CLEAN_BUILD_VERSION := |
| 139 | CURRENT_CLEAN_STEPS := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 140 | clean_steps_file := |
Ying Wang | eadaa95 | 2015-08-04 12:11:54 -0700 | [diff] [blame] | 141 | rewrite_clean_steps_file := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 142 | INTERNAL_CLEAN_STEPS := |
| 143 | INTERNAL_CLEAN_BUILD_VERSION := |
| 144 | |
Ying Wang | ad7fd29 | 2013-08-08 16:34:29 -0700 | [diff] [blame] | 145 | endif # if not ONE_SHOT_MAKEFILE dont_bother |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 146 | |
| 147 | # Since products and build variants (unfortunately) share the same |
| 148 | # PRODUCT_OUT staging directory, things can get out of sync if different |
| 149 | # build configurations are built in the same tree. The following logic |
| 150 | # will notice when the configuration has changed and remove the files |
| 151 | # necessary to keep things consistent. |
| 152 | |
| 153 | previous_build_config_file := $(PRODUCT_OUT)/previous_build_config.mk |
| 154 | |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 155 | # A change in the list of aapt configs warrants an installclean, too. |
Dianne Hackborn | a0f464a | 2011-10-14 19:37:57 -0700 | [diff] [blame] | 156 | aapt_config_list := $(strip $(PRODUCT_AAPT_CONFIG) $(PRODUCT_AAPT_PREF_CONFIG)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 157 | |
| 158 | current_build_config := \ |
Ying Wang | 961096f | 2015-01-06 16:49:20 -0800 | [diff] [blame] | 159 | $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)-{$(aapt_config_list)} |
Evgenii Stepanov | a36223e | 2015-06-11 17:36:06 -0700 | [diff] [blame] | 160 | current_sanitize_target := $(strip $(SANITIZE_TARGET)) |
| 161 | ifeq (,$(current_sanitize_target)) |
| 162 | current_sanitize_target := false |
| 163 | endif |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 164 | aapt_config_list := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 165 | force_installclean := false |
Evgenii Stepanov | a36223e | 2015-06-11 17:36:06 -0700 | [diff] [blame] | 166 | force_objclean := false |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 167 | |
| 168 | # Read the current state from the file, if present. |
| 169 | # Will set PREVIOUS_BUILD_CONFIG. |
| 170 | # |
| 171 | PREVIOUS_BUILD_CONFIG := |
Evgenii Stepanov | a36223e | 2015-06-11 17:36:06 -0700 | [diff] [blame] | 172 | PREVIOUS_SANITIZE_TARGET := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 173 | -include $(previous_build_config_file) |
| 174 | PREVIOUS_BUILD_CONFIG := $(strip $(PREVIOUS_BUILD_CONFIG)) |
Evgenii Stepanov | a36223e | 2015-06-11 17:36:06 -0700 | [diff] [blame] | 175 | PREVIOUS_SANITIZE_TARGET := $(strip $(PREVIOUS_SANITIZE_TARGET)) |
| 176 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 177 | ifdef PREVIOUS_BUILD_CONFIG |
| 178 | ifneq "$(current_build_config)" "$(PREVIOUS_BUILD_CONFIG)" |
| 179 | $(info *** Build configuration changed: "$(PREVIOUS_BUILD_CONFIG)" -> "$(current_build_config)") |
| 180 | ifneq ($(DISABLE_AUTO_INSTALLCLEAN),true) |
| 181 | force_installclean := true |
| 182 | else |
| 183 | $(info DISABLE_AUTO_INSTALLCLEAN is set; skipping auto-clean. Your tree may be in an inconsistent state.) |
| 184 | endif |
| 185 | endif |
| 186 | endif # else, this is the first build, so no need to clean. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 187 | |
Evgenii Stepanov | a36223e | 2015-06-11 17:36:06 -0700 | [diff] [blame] | 188 | ifdef PREVIOUS_SANITIZE_TARGET |
| 189 | ifneq "$(current_sanitize_target)" "$(PREVIOUS_SANITIZE_TARGET)" |
| 190 | $(info *** SANITIZE_TARGET changed: "$(PREVIOUS_SANITIZE_TARGET)" -> "$(current_sanitize_target)") |
| 191 | force_objclean := true |
| 192 | endif |
| 193 | endif # else, this is the first build, so no need to clean. |
Evgenii Stepanov | a36223e | 2015-06-11 17:36:06 -0700 | [diff] [blame] | 194 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 195 | # Write the new state to the file. |
| 196 | # |
Shinichiro Hamaji | 14da142 | 2015-07-21 07:28:39 +0900 | [diff] [blame] | 197 | ifneq ($(PREVIOUS_BUILD_CONFIG)-$(PREVIOUS_SANITIZE_TARGET),$(current_build_config)-$(current_sanitize_target)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 198 | $(shell \ |
| 199 | mkdir -p $(dir $(previous_build_config_file)) && \ |
| 200 | echo "PREVIOUS_BUILD_CONFIG := $(current_build_config)" > \ |
Evgenii Stepanov | a36223e | 2015-06-11 17:36:06 -0700 | [diff] [blame] | 201 | $(previous_build_config_file) && \ |
| 202 | echo "PREVIOUS_SANITIZE_TARGET := $(current_sanitize_target)" >> \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 203 | $(previous_build_config_file) \ |
| 204 | ) |
Shinichiro Hamaji | 14da142 | 2015-07-21 07:28:39 +0900 | [diff] [blame] | 205 | endif |
| 206 | PREVIOUS_BUILD_CONFIG := |
| 207 | PREVIOUS_SANITIZE_TARGET := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 208 | previous_build_config_file := |
| 209 | current_build_config := |
| 210 | |
| 211 | # |
| 212 | # installclean logic |
| 213 | # |
| 214 | |
| 215 | # The files/dirs to delete during an installclean. This includes the |
| 216 | # non-common APPS directory, which may contain the wrong resources. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 217 | # |
| 218 | # Deletes all of the files that change between different build types, |
| 219 | # like "make user" vs. "make sdk". This lets you work with different |
| 220 | # build types without having to do a full clean each time. E.g.: |
| 221 | # |
| 222 | # $ make -j8 all |
| 223 | # $ make installclean |
| 224 | # $ make -j8 user |
| 225 | # $ make installclean |
| 226 | # $ make -j8 sdk |
| 227 | # |
| 228 | installclean_files := \ |
Ying Wang | 096bb3d | 2011-01-04 12:55:14 -0800 | [diff] [blame] | 229 | $(HOST_OUT)/obj/NOTICE_FILES \ |
| 230 | $(HOST_OUT)/sdk \ |
| 231 | $(PRODUCT_OUT)/*.img \ |
Ji-Hwan Lee | 0a5b178 | 2014-05-15 20:59:01 +0900 | [diff] [blame] | 232 | $(PRODUCT_OUT)/*.ini \ |
Ying Wang | 096bb3d | 2011-01-04 12:55:14 -0800 | [diff] [blame] | 233 | $(PRODUCT_OUT)/*.txt \ |
| 234 | $(PRODUCT_OUT)/*.xlb \ |
| 235 | $(PRODUCT_OUT)/*.zip \ |
Ying Wang | 949c4eb | 2013-08-01 15:41:53 -0700 | [diff] [blame] | 236 | $(PRODUCT_OUT)/kernel \ |
Ying Wang | 096bb3d | 2011-01-04 12:55:14 -0800 | [diff] [blame] | 237 | $(PRODUCT_OUT)/data \ |
Ji-Hwan Lee | 0a5b178 | 2014-05-15 20:59:01 +0900 | [diff] [blame] | 238 | $(PRODUCT_OUT)/skin \ |
Ying Wang | 096bb3d | 2011-01-04 12:55:14 -0800 | [diff] [blame] | 239 | $(PRODUCT_OUT)/obj/APPS \ |
| 240 | $(PRODUCT_OUT)/obj/NOTICE_FILES \ |
| 241 | $(PRODUCT_OUT)/obj/PACKAGING \ |
| 242 | $(PRODUCT_OUT)/recovery \ |
| 243 | $(PRODUCT_OUT)/root \ |
| 244 | $(PRODUCT_OUT)/system \ |
Alex Light | 4e358ab | 2016-06-16 14:47:10 -0700 | [diff] [blame] | 245 | $(PRODUCT_OUT)/system_other \ |
Ying Wang | 4221873 | 2014-07-18 09:56:13 -0700 | [diff] [blame] | 246 | $(PRODUCT_OUT)/vendor \ |
| 247 | $(PRODUCT_OUT)/oem \ |
Ying Wang | 096bb3d | 2011-01-04 12:55:14 -0800 | [diff] [blame] | 248 | $(PRODUCT_OUT)/dex_bootjars \ |
Dima Zavin | 7dac590 | 2011-10-11 15:54:10 -0700 | [diff] [blame] | 249 | $(PRODUCT_OUT)/obj/JAVA_LIBRARIES \ |
Ying Wang | fab7605 | 2012-09-21 14:11:41 -0700 | [diff] [blame] | 250 | $(PRODUCT_OUT)/obj/FAKE \ |
| 251 | $(PRODUCT_OUT)/obj/EXECUTABLES/adbd_intermediates \ |
Sami Tolvanen | e018f60 | 2016-02-10 10:41:26 -0800 | [diff] [blame] | 252 | $(PRODUCT_OUT)/obj/EXECUTABLES/logd_intermediates \ |
Paul Lawrence | a6a0435 | 2014-10-08 15:05:21 -0700 | [diff] [blame] | 253 | $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libfs_mgr_intermediates \ |
repo sync | d3e01c1 | 2013-03-26 17:21:01 -0700 | [diff] [blame] | 254 | $(PRODUCT_OUT)/obj/EXECUTABLES/init_intermediates \ |
William Roberts | a8b3d54 | 2013-03-26 14:51:18 -0700 | [diff] [blame] | 255 | $(PRODUCT_OUT)/obj/ETC/mac_permissions.xml_intermediates \ |
Adam Hampson | 57afaa5 | 2014-03-07 15:53:44 -0800 | [diff] [blame] | 256 | $(PRODUCT_OUT)/obj/ETC/sepolicy_intermediates \ |
Nick Kralevich | 133e1e1 | 2016-02-27 10:41:41 -0800 | [diff] [blame] | 257 | $(PRODUCT_OUT)/obj/ETC/sepolicy.recovery_intermediates \ |
Adam Hampson | 57afaa5 | 2014-03-07 15:53:44 -0800 | [diff] [blame] | 258 | $(PRODUCT_OUT)/obj/ETC/init.environ.rc_intermediates |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 259 | |
| 260 | # The files/dirs to delete during a dataclean, which removes any files |
| 261 | # in the staging and emulator data partitions. |
| 262 | dataclean_files := \ |
Ying Wang | 096bb3d | 2011-01-04 12:55:14 -0800 | [diff] [blame] | 263 | $(PRODUCT_OUT)/data/* \ |
| 264 | $(PRODUCT_OUT)/data-qemu/* \ |
| 265 | $(PRODUCT_OUT)/userdata-qemu.img |
| 266 | |
Evgenii Stepanov | a36223e | 2015-06-11 17:36:06 -0700 | [diff] [blame] | 267 | # The files/dirs to delete during an objclean, which removes any files |
| 268 | # in the staging and emulator data partitions. |
| 269 | objclean_files := \ |
| 270 | $(TARGET_OUT_INTERMEDIATES) \ |
| 271 | $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES) |
| 272 | |
Ying Wang | 096bb3d | 2011-01-04 12:55:14 -0800 | [diff] [blame] | 273 | # make sure *_OUT is set so that we won't result in deleting random parts |
| 274 | # of the filesystem. |
| 275 | ifneq (2,$(words $(HOST_OUT) $(PRODUCT_OUT))) |
| 276 | $(error both HOST_OUT and PRODUCT_OUT should be set at this point.) |
| 277 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 278 | |
| 279 | # Define the rules for commandline invocation. |
| 280 | .PHONY: dataclean |
| 281 | dataclean: FILES := $(dataclean_files) |
| 282 | dataclean: |
| 283 | $(hide) rm -rf $(FILES) |
| 284 | @echo "Deleted emulator userdata images." |
| 285 | |
| 286 | .PHONY: installclean |
| 287 | installclean: FILES := $(installclean_files) |
| 288 | installclean: dataclean |
| 289 | $(hide) rm -rf $(FILES) |
| 290 | @echo "Deleted images and staging directories." |
| 291 | |
Evgenii Stepanov | a36223e | 2015-06-11 17:36:06 -0700 | [diff] [blame] | 292 | .PHONY: objclean |
| 293 | objclean: FILES := $(objclean_files) |
| 294 | objclean: |
| 295 | $(hide) rm -rf $(FILES) |
| 296 | @echo "Deleted images and staging directories." |
| 297 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 298 | ifeq "$(force_installclean)" "true" |
| 299 | $(info *** Forcing "make installclean"...) |
Ying Wang | 096bb3d | 2011-01-04 12:55:14 -0800 | [diff] [blame] | 300 | $(info *** rm -rf $(dataclean_files) $(installclean_files)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 301 | $(shell rm -rf $(dataclean_files) $(installclean_files)) |
| 302 | $(info *** Done with the cleaning, now starting the real build.) |
| 303 | endif |
| 304 | force_installclean := |
Yohann Roussel | f09e59e | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 305 | |
Evgenii Stepanov | a36223e | 2015-06-11 17:36:06 -0700 | [diff] [blame] | 306 | ifeq "$(force_objclean)" "true" |
| 307 | $(info *** Forcing cleanup of intermediate files...) |
| 308 | $(info *** rm -rf $(objclean_files)) |
| 309 | $(shell rm -rf $(objclean_files)) |
| 310 | $(info *** Done with the cleaning, now starting the real build.) |
| 311 | endif |
| 312 | force_objclean := |
| 313 | |
Ying Wang | d37b540 | 2015-04-14 14:10:46 -0700 | [diff] [blame] | 314 | ########################################################### |
Ying Wang | d37b540 | 2015-04-14 14:10:46 -0700 | [diff] [blame] | 315 | |
Yohann Roussel | f09e59e | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 316 | .PHONY: clean-jack-files |
| 317 | clean-jack-files: clean-dex-files |
| 318 | $(hide) find $(OUT_DIR) -name "*.jack" | xargs rm -f |
| 319 | $(hide) find $(OUT_DIR) -type d -name "jack" | xargs rm -rf |
| 320 | @echo "All jack files have been removed." |
| 321 | |
| 322 | .PHONY: clean-dex-files |
| 323 | clean-dex-files: |
| 324 | $(hide) find $(OUT_DIR) -name "*.dex" ! -path "*/jack-incremental/*" | xargs rm -f |
| 325 | $(hide) for i in `find $(OUT_DIR) -name "*.jar" -o -name "*.apk"` ; do ((unzip -l $$i 2> /dev/null | \ |
| 326 | grep -q "\.dex$$" && rm -f $$i) || continue ) ; done |
| 327 | @echo "All dex files and archives containing dex files have been removed." |
| 328 | |
| 329 | .PHONY: clean-jack-incremental |
| 330 | clean-jack-incremental: |
| 331 | $(hide) find $(OUT_DIR) -name "jack-incremental" -type d | xargs rm -rf |
| 332 | @echo "All jack incremental dirs have been removed." |