summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorYing Wang <wangying@google.com>2012-05-24 21:05:19 -0700
committerYing Wang <wangying@google.com>2012-06-04 18:02:55 -0700
commit71004f81351511b4873cdb09d52b7624158a4840 (patch)
treea864fd9b3b24fd388f26fe4ab595f6586e9a27ec /core
parent28a181759079c34f8776f98f553e56554b527069 (diff)
downloadbuild-71004f81351511b4873cdb09d52b7624158a4840.zip
build-71004f81351511b4873cdb09d52b7624158a4840.tar.gz
build-71004f81351511b4873cdb09d52b7624158a4840.tar.bz2
Clean common intermediate files if overlay changed
This change cleans the packages' intermediate files if their overlays changed between incremental builds. If two builds have different overlay, they will have different R classes, and so the jar files in the common intermediate dirs can not be shared. Therefore incremental build can't be applied. This change detects the overlay changes on package's base. If a package's overlay is different from the previous build, its common intermediate dir is nuked. This makes broader incremental builds possible. Change-Id: I368610ebbbbc85a80f9aecd714ab22cd78da7f12
Diffstat (limited to 'core')
-rw-r--r--core/main.mk4
-rw-r--r--core/package.mk17
-rw-r--r--core/post_clean.mk53
3 files changed, 68 insertions, 6 deletions
diff --git a/core/main.mk b/core/main.mk
index 3c64d95..8a5b407 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -466,8 +466,12 @@ subdir_makefiles := \
$(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdirs) Android.mk)
include $(subdir_makefiles)
+
endif # ONE_SHOT_MAKEFILE
+# Now with all Android.mks loaded we can do post cleaning steps.
+include $(BUILD_SYSTEM)/post_clean.mk
+
ifeq ($(stash_product_vars),true)
$(call assert-product-vars, __STASHED)
endif
diff --git a/core/package.mk b/core/package.mk
index 195b346..c689031 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -94,12 +94,14 @@ endif
ifeq (,$(LOCAL_RESOURCE_DIR))
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
endif
-LOCAL_RESOURCE_DIR := \
- $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
- $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
- $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
- $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
- $(LOCAL_RESOURCE_DIR)
+
+package_resource_overlays := $(strip \
+ $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
+ $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
+ $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
+ $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))))
+
+LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR)
all_assets := $(call find-subdir-assets,$(LOCAL_ASSET_DIR))
all_assets := $(addprefix $(LOCAL_ASSET_DIR)/,$(patsubst assets/%,%,$(all_assets)))
@@ -399,6 +401,9 @@ endif
# Save information about this package
PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources)
+ifdef package_resource_overlays
+PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_OVERLAYS := $(package_resource_overlays)
+endif
PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME)
diff --git a/core/post_clean.mk b/core/post_clean.mk
new file mode 100644
index 0000000..213c43c
--- /dev/null
+++ b/core/post_clean.mk
@@ -0,0 +1,53 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Clean steps that need global knowledge of individual modules.
+# This file must be included after all Android.mks have been loaded.
+
+# Checks the current build configurations against the previous build,
+# clean artifacts in TARGET_COMMON_OUT_ROOT if necessary.
+# If a package's resource overlay has been changed, its R class needs to be
+# regenerated.
+previous_package_overlay_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/previous_overlays.txt
+current_package_overlay_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/current_overlays.txt
+current_all_packages_config := $(dir $(current_package_overlay_config))current_packages.txt
+
+$(shell rm -rf $(current_package_overlay_config) \
+ && mkdir -p $(dir $(current_package_overlay_config)) \
+ && touch $(current_package_overlay_config))
+$(shell echo '$(PACKAGES)' > $(current_all_packages_config))
+$(foreach p, $(PACKAGES), $(if $(PACKAGES.$(p).RESOURCE_OVERLAYS), \
+ $(shell echo '$(p)' '$(PACKAGES.$(p).RESOURCE_OVERLAYS)' >> $(current_package_overlay_config))))
+
+ifneq (,$(wildcard $(previous_package_overlay_config)))
+packages_overlay_changed := $(shell build/tools/diff_package_overlays.py \
+ $(current_all_packages_config) $(current_package_overlay_config) \
+ $(previous_package_overlay_config))
+ifneq (,$(packages_overlay_changed))
+overlay_cleanup_cmd := $(strip rm -rf $(foreach p, $(packages_overlay_changed),\
+ $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/$(p)_intermediates))
+$(info *** Overlay change detected, clean shared intermediate files...)
+$(info *** $(overlay_cleanup_cmd))
+$(shell $(overlay_cleanup_cmd))
+overlay_cleanup_cmd :=
+endif
+packages_overlay_changed :=
+endif
+
+# Now current becomes previous.
+$(shell mv -f $(current_package_overlay_config) $(previous_package_overlay_config))
+
+previous_package_overlay_config :=
+current_package_overlay_config :=
+current_all_packages_config :=