Merge "Mark BUILD_NUMBER as obsolete, more vars as readonly"

This commit is contained in:
Treehugger Robot 2018-10-26 15:42:36 +00:00 committed by Gerrit Code Review
commit 43930504e1
2 changed files with 21 additions and 0 deletions

View File

@ -1,5 +1,22 @@
# Build System Changes for Android.mk Writers # Build System Changes for Android.mk Writers
## `BUILD_NUMBER` removal from Android.mk {#BUILD_NUMBER}
`BUILD_NUMBER` should not be used directly in Android.mk files, as it would
trigger them to be re-read every time the `BUILD_NUMBER` changes (which it does
on every build server build). If possible, just remove the use so that your
builds are more reproducible. If you do need it, use `BUILD_NUMBER_FROM_FILE`:
``` make
$(LOCAL_BUILT_MODULE):
mytool --build_number $(BUILD_NUMBER_FROM_FILE) -o $@
```
That will expand out to a subshell that will read the current `BUILD_NUMBER`
whenever it's run. It will not re-run your command if the build number has
changed, so incremental builds will have the build number from the last time
the particular output was rebuilt.
## `DIST_DIR`, `dist_goal`, and `dist-for-goals` {#dist} ## `DIST_DIR`, `dist_goal`, and `dist-for-goals` {#dist}
`DIST_DIR` and `dist_goal` are no longer available when reading Android.mk `DIST_DIR` and `dist_goal` are no longer available when reading Android.mk

View File

@ -66,12 +66,15 @@ include $(BUILD_SYSTEM)/clang/config.mk
$(shell mkdir -p $(OUT_DIR) && \ $(shell mkdir -p $(OUT_DIR) && \
echo -n $(BUILD_NUMBER) > $(OUT_DIR)/build_number.txt) echo -n $(BUILD_NUMBER) > $(OUT_DIR)/build_number.txt)
BUILD_NUMBER_FILE := $(OUT_DIR)/build_number.txt BUILD_NUMBER_FILE := $(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)
ifeq ($(HOST_OS),darwin) ifeq ($(HOST_OS),darwin)
DATE_FROM_FILE := date -r $(BUILD_DATETIME_FROM_FILE) DATE_FROM_FILE := date -r $(BUILD_DATETIME_FROM_FILE)
else else
DATE_FROM_FILE := date -d @$(BUILD_DATETIME_FROM_FILE) DATE_FROM_FILE := date -d @$(BUILD_DATETIME_FROM_FILE)
endif endif
.KATI_READONLY := DATE_FROM_FILE
# Pick a reasonable string to use to identify files. # Pick a reasonable string to use to identify files.
ifeq ($(strip $(HAS_BUILD_NUMBER)),false) ifeq ($(strip $(HAS_BUILD_NUMBER)),false)
@ -81,6 +84,7 @@ ifeq ($(strip $(HAS_BUILD_NUMBER)),false)
else else
FILE_NAME_TAG := $(file <$(BUILD_NUMBER_FILE)) FILE_NAME_TAG := $(file <$(BUILD_NUMBER_FILE))
endif endif
.KATI_READONLY := FILE_NAME_TAG
# Make an empty directory, which can be used to make empty jars # Make an empty directory, which can be used to make empty jars
EMPTY_DIRECTORY := $(OUT_DIR)/empty EMPTY_DIRECTORY := $(OUT_DIR)/empty