From 14da1424e0e8d96aee66676b8735001dbe6bd86b Mon Sep 17 00:00:00 2001 From: Shinichiro Hamaji Date: Tue, 21 Jul 2015 07:28:39 +0900 Subject: [PATCH] Do not update previous_XXX.mk when there is no change I'm adding a rule which regenerates ninja files to kati: https://github.com/shinh/kati/commit/8666cfba20bf4ff0e59053dcfa7bcac9896bcf16 With this regeneration rule, unnecessary re-generation will happen when these .mk files are updated even if there are no changes in their contents. With this patch, these .mk files are updated only when the contents will be actually changed. Change-Id: I4c796f9454502f6bb25019b3806ca577ea5258c1 --- core/cleanbuild.mk | 14 ++++++++++---- core/post_clean.mk | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk index 938242ca8..c2386a423 100644 --- a/core/cleanbuild.mk +++ b/core/cleanbuild.mk @@ -105,11 +105,10 @@ else _crs_new_cmd := steps := endif -CURRENT_CLEAN_BUILD_VERSION := -CURRENT_CLEAN_STEPS := # Write the new state to the file. # +ifneq ($(CURRENT_CLEAN_BUILD_VERSION)-$(CURRENT_CLEAN_STEPS),$(INTERNAL_CLEAN_BUILD_VERSION)-$(INTERNAL_CLEAN_STEPS)) $(shell \ mkdir -p $(dir $(clean_steps_file)) && \ echo "CURRENT_CLEAN_BUILD_VERSION := $(INTERNAL_CLEAN_BUILD_VERSION)" > \ @@ -117,7 +116,10 @@ $(shell \ echo "CURRENT_CLEAN_STEPS := $(INTERNAL_CLEAN_STEPS)" >> \ $(clean_steps_file) \ ) +endif +CURRENT_CLEAN_BUILD_VERSION := +CURRENT_CLEAN_STEPS := clean_steps_file := INTERNAL_CLEAN_STEPS := INTERNAL_CLEAN_BUILD_VERSION := @@ -164,7 +166,6 @@ ifdef PREVIOUS_BUILD_CONFIG endif endif endif # else, this is the first build, so no need to clean. -PREVIOUS_BUILD_CONFIG := ifdef PREVIOUS_SANITIZE_TARGET ifneq "$(current_sanitize_target)" "$(PREVIOUS_SANITIZE_TARGET)" @@ -172,10 +173,10 @@ ifdef PREVIOUS_SANITIZE_TARGET force_objclean := true endif endif # else, this is the first build, so no need to clean. -PREVIOUS_SANITIZE_TARGET := # Write the new state to the file. # +ifneq ($(PREVIOUS_BUILD_CONFIG)-$(PREVIOUS_SANITIZE_TARGET),$(current_build_config)-$(current_sanitize_target)) $(shell \ mkdir -p $(dir $(previous_build_config_file)) && \ echo "PREVIOUS_BUILD_CONFIG := $(current_build_config)" > \ @@ -183,6 +184,9 @@ $(shell \ echo "PREVIOUS_SANITIZE_TARGET := $(current_sanitize_target)" >> \ $(previous_build_config_file) \ ) +endif +PREVIOUS_BUILD_CONFIG := +PREVIOUS_SANITIZE_TARGET := previous_build_config_file := current_build_config := @@ -305,10 +309,12 @@ endif endif # else, this is the first build, so no need to clean. # Write the new state to the file. +ifneq ($(PREVIOUS_PREBUILT_TOOLS),$(current_prebuilt_tools)) $(shell \ mkdir -p $(dir $(previous_prebuilt_tools_config_file)) && \ echo "PREVIOUS_PREBUILT_TOOLS:=$(current_prebuilt_tools)" > \ $(previous_prebuilt_tools_config_file)) +endif ifeq ($(force_tools_clean),true) # For this list of prebuilt tools, see prebuilts/sdk/tools/Android.mk. diff --git a/core/post_clean.mk b/core/post_clean.mk index 0273ff207..7fafe4a5e 100644 --- a/core/post_clean.mk +++ b/core/post_clean.mk @@ -88,7 +88,7 @@ MODULES_WITH_AIDL_FILES := $(sort $(MODULES_WITH_AIDL_FILES) $(modules_with_aidl $(shell echo 'MODULES_WITH_AIDL_FILES := $(MODULES_WITH_AIDL_FILES)' >> $(current_aidl_config)) # Now current becomes previous. -$(shell mv -f $(current_aidl_config) $(previous_aidl_config)) +$(shell cmp $(current_aidl_config) $(previous_aidl_config) > /dev/null 2>&1 || mv -f $(current_aidl_config) $(previous_aidl_config)) MODULES_WITH_AIDL_FILES := modules_with_aidl_files := -- 2.11.0