1# Copyright (C) 2012 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# Clean steps that need global knowledge of individual modules. 16# This file must be included after all Android.mks have been loaded. 17 18# Checks the current build configurations against the previous build, 19# clean artifacts in TARGET_COMMON_OUT_ROOT if necessary. 20# If a package's resource overlay has been changed, its R class needs to be 21# regenerated. 22previous_package_overlay_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/previous_overlays.txt 23current_package_overlay_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/current_overlays.txt 24current_all_packages_config := $(dir $(current_package_overlay_config))current_packages.txt 25 26$(shell rm -rf $(current_package_overlay_config) \ 27 && mkdir -p $(dir $(current_package_overlay_config)) \ 28 && touch $(current_package_overlay_config)) 29$(shell echo '$(PACKAGES)' > $(current_all_packages_config)) 30$(foreach p, $(PACKAGES), $(if $(PACKAGES.$(p).RESOURCE_OVERLAYS), \ 31 $(shell echo '$(p)' '$(PACKAGES.$(p).RESOURCE_OVERLAYS)' >> $(current_package_overlay_config)))) 32 33ifneq (,$(wildcard $(previous_package_overlay_config))) 34packages_overlay_changed := $(shell build/tools/diff_package_overlays.py \ 35 $(current_all_packages_config) $(current_package_overlay_config) \ 36 $(previous_package_overlay_config)) 37ifneq (,$(packages_overlay_changed)) 38overlay_cleanup_cmd := $(strip rm -rf $(foreach p, $(packages_overlay_changed),\ 39 $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/$(p)_intermediates)) 40$(info *** Overlay change detected, clean shared intermediate files...) 41$(info *** $(overlay_cleanup_cmd)) 42$(shell $(overlay_cleanup_cmd)) 43overlay_cleanup_cmd := 44endif 45packages_overlay_changed := 46endif 47 48# Now current becomes previous. 49$(shell mv -f $(current_package_overlay_config) $(previous_package_overlay_config)) 50 51previous_package_overlay_config := 52current_package_overlay_config := 53current_all_packages_config := 54