Ying Wang | 71004f8 | 2012-05-24 21:05:19 -0700 | [diff] [blame] | 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 | |
Ying Wang | 1a5ada1 | 2014-07-07 15:01:15 -0700 | [diff] [blame] | 18 | ####################################################### |
Ying Wang | 71004f8 | 2012-05-24 21:05:19 -0700 | [diff] [blame] | 19 | # Checks the current build configurations against the previous build, |
| 20 | # clean artifacts in TARGET_COMMON_OUT_ROOT if necessary. |
| 21 | # If a package's resource overlay has been changed, its R class needs to be |
| 22 | # regenerated. |
| 23 | previous_package_overlay_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/previous_overlays.txt |
| 24 | current_package_overlay_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/current_overlays.txt |
| 25 | current_all_packages_config := $(dir $(current_package_overlay_config))current_packages.txt |
| 26 | |
| 27 | $(shell rm -rf $(current_package_overlay_config) \ |
| 28 | && mkdir -p $(dir $(current_package_overlay_config)) \ |
| 29 | && touch $(current_package_overlay_config)) |
| 30 | $(shell echo '$(PACKAGES)' > $(current_all_packages_config)) |
| 31 | $(foreach p, $(PACKAGES), $(if $(PACKAGES.$(p).RESOURCE_OVERLAYS), \ |
| 32 | $(shell echo '$(p)' '$(PACKAGES.$(p).RESOURCE_OVERLAYS)' >> $(current_package_overlay_config)))) |
| 33 | |
| 34 | ifneq (,$(wildcard $(previous_package_overlay_config))) |
| 35 | packages_overlay_changed := $(shell build/tools/diff_package_overlays.py \ |
| 36 | $(current_all_packages_config) $(current_package_overlay_config) \ |
| 37 | $(previous_package_overlay_config)) |
| 38 | ifneq (,$(packages_overlay_changed)) |
| 39 | overlay_cleanup_cmd := $(strip rm -rf $(foreach p, $(packages_overlay_changed),\ |
| 40 | $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/$(p)_intermediates)) |
| 41 | $(info *** Overlay change detected, clean shared intermediate files...) |
| 42 | $(info *** $(overlay_cleanup_cmd)) |
| 43 | $(shell $(overlay_cleanup_cmd)) |
| 44 | overlay_cleanup_cmd := |
| 45 | endif |
| 46 | packages_overlay_changed := |
| 47 | endif |
| 48 | |
| 49 | # Now current becomes previous. |
| 50 | $(shell mv -f $(current_package_overlay_config) $(previous_package_overlay_config)) |
| 51 | |
| 52 | previous_package_overlay_config := |
| 53 | current_package_overlay_config := |
| 54 | current_all_packages_config := |
Ying Wang | 1a5ada1 | 2014-07-07 15:01:15 -0700 | [diff] [blame] | 55 | |
| 56 | ####################################################### |
| 57 | # Check if we need to delete obsolete aidl-generated java files. |
| 58 | # When an aidl file gets deleted (or renamed), the generated java file is obsolete. |
| 59 | previous_aidl_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/previous_aidl_config.mk |
| 60 | current_aidl_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/current_aidl_config.mk |
| 61 | |
Ying Wang | 3abc2a3 | 2014-07-08 22:11:06 -0700 | [diff] [blame] | 62 | $(shell rm -rf $(current_aidl_config) \ |
| 63 | && mkdir -p $(dir $(current_aidl_config))\ |
| 64 | && touch $(current_aidl_config)) |
Ying Wang | 1a5ada1 | 2014-07-07 15:01:15 -0700 | [diff] [blame] | 65 | -include $(previous_aidl_config) |
| 66 | |
| 67 | intermediates_to_clean := |
Ying Wang | 3abc2a3 | 2014-07-08 22:11:06 -0700 | [diff] [blame] | 68 | modules_with_aidl_files := |
Ying Wang | 1a5ada1 | 2014-07-07 15:01:15 -0700 | [diff] [blame] | 69 | $(foreach p, $(ALL_MODULES), \ |
| 70 | $(if $(ALL_MODULES.$(p).AIDL_FILES),\ |
Ying Wang | 3abc2a3 | 2014-07-08 22:11:06 -0700 | [diff] [blame] | 71 | $(eval modules_with_aidl_files += $(p))\ |
Ying Wang | 1a5ada1 | 2014-07-07 15:01:15 -0700 | [diff] [blame] | 72 | $(shell echo 'AIDL_FILES.$(p) := $(ALL_MODULES.$(p).AIDL_FILES)' >> $(current_aidl_config)))\ |
| 73 | $(if $(filter-out $(ALL_MODULES.$(p).AIDL_FILES),$(AIDL_FILES.$(p))),\ |
| 74 | $(eval intermediates_to_clean += $(ALL_MODULES.$(p).INTERMEDIATE_SOURCE_DIR)))) |
Ying Wang | af9757e | 2014-07-17 21:24:42 -0700 | [diff] [blame] | 75 | intermediates_to_clean := $(strip $(intermediates_to_clean)) |
Ying Wang | 1a5ada1 | 2014-07-07 15:01:15 -0700 | [diff] [blame] | 76 | ifdef intermediates_to_clean |
| 77 | $(info *** Obsolete aidl-generated files detected, clean intermediate files...) |
| 78 | $(info *** rm -rf $(intermediates_to_clean)) |
| 79 | $(shell rm -rf $(intermediates_to_clean)) |
| 80 | intermediates_to_clean := |
| 81 | endif |
| 82 | |
Ying Wang | 3abc2a3 | 2014-07-08 22:11:06 -0700 | [diff] [blame] | 83 | # For modules not loaded by the current build (e.g. you are running mm/mmm), |
| 84 | # we copy the info from the previous bulid. |
Ying Wang | da2da1d | 2014-08-23 09:45:31 -0700 | [diff] [blame] | 85 | $(foreach p, $(filter-out $(ALL_MODULES),$(MODULES_WITH_AIDL_FILES)),\ |
Ying Wang | 3abc2a3 | 2014-07-08 22:11:06 -0700 | [diff] [blame] | 86 | $(shell echo 'AIDL_FILES.$(p) := $(AIDL_FILES.$(p))' >> $(current_aidl_config))) |
| 87 | MODULES_WITH_AIDL_FILES := $(sort $(MODULES_WITH_AIDL_FILES) $(modules_with_aidl_files)) |
| 88 | $(shell echo 'MODULES_WITH_AIDL_FILES := $(MODULES_WITH_AIDL_FILES)' >> $(current_aidl_config)) |
| 89 | |
Ying Wang | 1a5ada1 | 2014-07-07 15:01:15 -0700 | [diff] [blame] | 90 | # Now current becomes previous. |
Shinichiro Hamaji | 14da142 | 2015-07-21 07:28:39 +0900 | [diff] [blame] | 91 | $(shell cmp $(current_aidl_config) $(previous_aidl_config) > /dev/null 2>&1 || mv -f $(current_aidl_config) $(previous_aidl_config)) |
Ying Wang | 1a5ada1 | 2014-07-07 15:01:15 -0700 | [diff] [blame] | 92 | |
Ying Wang | 3abc2a3 | 2014-07-08 22:11:06 -0700 | [diff] [blame] | 93 | MODULES_WITH_AIDL_FILES := |
| 94 | modules_with_aidl_files := |
Ying Wang | 1a5ada1 | 2014-07-07 15:01:15 -0700 | [diff] [blame] | 95 | previous_aidl_config := |
| 96 | current_aidl_config := |