From 6e64c14ce917805bdbd4bfe3595fc111892395fe Mon Sep 17 00:00:00 2001 From: Po Hu Date: Tue, 9 Mar 2021 10:48:37 +0800 Subject: [PATCH] Fix kati regen due to build_number.txt Do NOT touch build_number.txt if BUILD_NUMBER is explicitly set but not changed from last build. Bug: 182221512 Test: BUILD_NUMBER=123 m nothing Change-Id: Ic88f6e0d2b9767d84e1ec5c826018d1ea08c0fc0 --- core/main.mk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/main.mk b/core/main.mk index efa603122..2291740c1 100644 --- a/core/main.mk +++ b/core/main.mk @@ -41,7 +41,12 @@ include $(BUILD_SYSTEM)/clang/config.mk # without changing the command line every time. Avoids rebuilds # when using ninja. $(shell mkdir -p $(SOONG_OUT_DIR) && \ - echo -n $(BUILD_NUMBER) > $(SOONG_OUT_DIR)/build_number.txt) + echo -n $(BUILD_NUMBER) > $(SOONG_OUT_DIR)/build_number.tmp; \ + if ! cmp -s $(SOONG_OUT_DIR)/build_number.tmp $(SOONG_OUT_DIR)/build_number.txt; then \ + mv $(SOONG_OUT_DIR)/build_number.tmp $(SOONG_OUT_DIR)/build_number.txt; \ + else \ + rm $(SOONG_OUT_DIR)/build_number.tmp; \ + fi) BUILD_NUMBER_FILE := $(SOONG_OUT_DIR)/build_number.txt .KATI_READONLY := BUILD_NUMBER_FILE $(KATI_obsolete_var BUILD_NUMBER,See https://android.googlesource.com/platform/build/+/master/Changes.md#BUILD_NUMBER)