am e6510750: Merge "Use repeatable timestamps"

* commit 'e65107508adbea88fcc1ec51dcf28d4216365753':
  Use repeatable timestamps
This commit is contained in:
Dan Willemsen 2015-08-18 03:35:44 +00:00 committed by Android Git Automerger
commit 05fae7e0be
6 changed files with 49 additions and 10 deletions

View File

@ -114,7 +114,7 @@ ifeq (,$(strip $(BUILD_FINGERPRINT)))
ifneq ($(filter eng.%,$(BUILD_NUMBER)),)
# Trim down BUILD_FINGERPRINT: the default BUILD_NUMBER makes it easily exceed
# the Android system property length limit (PROPERTY_VALUE_MAX=92).
BF_BUILD_NUMBER := $(USER)$(shell date +%m%d%H%M)
BF_BUILD_NUMBER := $(USER)$(shell $(DATE) +%m%d%H%M)
else
BF_BUILD_NUMBER := $(BUILD_NUMBER)
endif
@ -197,6 +197,7 @@ endif
PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
BUILD_ID="$(BUILD_ID)" \
BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
DATE="$(DATE_FROM_FILE)" \
BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \
BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \
PLATFORM_VERSION="$(PLATFORM_VERSION)" \
@ -246,8 +247,8 @@ $(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
@echo Target vendor buildinfo: $@
@mkdir -p $(dir $@)
$(hide) echo > $@
$(hide) echo ro.vendor.build.date=`date`>>$@
$(hide) echo ro.vendor.build.date.utc=`date +%s`>>$@
$(hide) echo ro.vendor.build.date=`$(DATE_FROM_FILE)`>>$@
$(hide) echo ro.vendor.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
$(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
endif
@ -262,8 +263,8 @@ $(INSTALLED_BOOTIMAGE_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
@echo Target bootimage buildinfo: $@
@mkdir -p $(dir $@)
$(hide) echo > $@
$(hide) echo ro.bootimage.build.date=`date`>>$@
$(hide) echo ro.bootimage.build.date.utc=`date +%s`>>$@
$(hide) echo ro.bootimage.build.date=`$(DATE_FROM_FILE)`>>$@
$(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
$(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
# -----------------------------------------------------------------

View File

@ -157,6 +157,23 @@ endif
# are specific to the user's build configuration.
include $(BUILD_SYSTEM)/envsetup.mk
# ---------------------------------------------------------------
# Allow the C/C++ macros __DATE__ and __TIME__ to be set to the
# build date and time, so that a build may be repeated.
# Write the date and time to a file so that the command line
# doesn't change every time, which would cause ninja to rebuild
# the files.
$(shell mkdir -p $(OUT_DIR) && \
$(DATE) "+%b %_d %Y" > $(OUT_DIR)/build_c_date.txt && \
$(DATE) +%T > $(OUT_DIR)/build_c_time.txt)
BUILD_DATETIME_C_DATE := $$(cat $(OUT_DIR)/build_c_date.txt)
BUILD_DATETIME_C_TIME := $$(cat $(OUT_DIR)/build_c_time.txt)
ifeq ($(OVERRIDE_C_DATE_TIME),true)
COMMON_GLOBAL_CFLAGS += -Wno-builtin-macro-redefined -D__DATE__="\"$(BUILD_DATETIME_C_DATE)\"" -D__TIME__=\"$(BUILD_DATETIME_C_TIME)\"
COMMON_GLOBAL_CPPFLAGS += -Wno-builtin-macro-redefined -D__DATE__="\"$(BUILD_DATETIME_C_DATE)\"" -D__TIME__=\"$(BUILD_DATETIME_C_TIME)\"
endif
# The build system exposes several variables for where to find the kernel
# headers:
# TARGET_DEVICE_KERNEL_HEADERS is automatically created for the current

View File

@ -132,7 +132,7 @@ droiddoc := \
$(full_target): PRIVATE_DOCLETPATH := $(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
$(full_target): PRIVATE_CURRENT_BUILD := -hdf page.build $(BUILD_ID)-$(BUILD_NUMBER_FROM_FILE)
$(full_target): PRIVATE_CURRENT_TIME := -hdf page.now "$$(date "+%d %b %Y %k:%M")"
$(full_target): PRIVATE_CURRENT_TIME := -hdf page.now "$$($(DATE_FROM_FILE) "+%d %b %Y %k:%M")"
$(full_target): PRIVATE_CUSTOM_TEMPLATE_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)
$(full_target): PRIVATE_IN_CUSTOM_ASSET_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR)
$(full_target): PRIVATE_OUT_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_ASSET_DIR)

View File

@ -102,8 +102,16 @@ else # !USE_NINJA
# Write the build number to a file so it can be read back in
# without changing the command line every time. Avoids rebuilds
# when using ninja.
$(shell mkdir -p $(OUT_DIR) && echo -n $(BUILD_NUMBER) > $(OUT_DIR)/build_number.txt)
$(shell mkdir -p $(OUT_DIR) && \
echo -n $(BUILD_NUMBER) > $(OUT_DIR)/build_number.txt && \
echo -n $(BUILD_DATETIME) > $(OUT_DIR)/build_date.txt)
BUILD_NUMBER_FROM_FILE := $$(cat $(OUT_DIR)/build_number.txt)
BUILD_DATETIME_FROM_FILE := $$(cat $(OUT_DIR)/build_date.txt)
ifeq ($(HOST_OS),darwin)
DATE_FROM_FILE := date -r $(BUILD_DATETIME_FROM_FILE)
else
DATE_FROM_FILE := date -d @$(BUILD_DATETIME_FROM_FILE)
endif
# CTS-specific config.
-include cts/build/config.mk

View File

@ -24,6 +24,7 @@
# DEFAULT_APP_TARGET_SDK
# BUILD_ID
# BUILD_NUMBER
# BUILD_DATETIME
#
# Look for an optional file containing overrides of the defaults,
@ -89,6 +90,18 @@ ifeq "" "$(BUILD_ID)"
BUILD_ID := UNKNOWN
endif
ifeq "" "$(BUILD_DATETIME)"
# Used to reproduce builds by setting the same time. Must be the number
# of seconds since the Epoch.
BUILD_DATETIME := $(shell date +%s)
endif
ifneq (,$(findstring Darwin,$(shell uname -sm)))
DATE := date -r $(BUILD_DATETIME)
else
DATE := date -d @$(BUILD_DATETIME)
endif
ifeq "" "$(BUILD_NUMBER)"
# BUILD_NUMBER should be set to the source control value that
# represents the current state of the source code. E.g., a
@ -99,5 +112,5 @@ ifeq "" "$(BUILD_NUMBER)"
# If no BUILD_NUMBER is set, create a useful "I am an engineering build
# from this date/time" value. Make it start with a non-digit so that
# anyone trying to parse it as an integer will probably get "0".
BUILD_NUMBER := eng.$(USER).$(shell date +%Y%m%d.%H%M%S)
BUILD_NUMBER := eng.$(USER).$(shell $(DATE) +%Y%m%d.%H%M%S)
endif

View File

@ -10,8 +10,8 @@ echo "ro.build.version.sdk=$PLATFORM_SDK_VERSION"
echo "ro.build.version.codename=$PLATFORM_VERSION_CODENAME"
echo "ro.build.version.all_codenames=$PLATFORM_VERSION_ALL_CODENAMES"
echo "ro.build.version.release=$PLATFORM_VERSION"
echo "ro.build.date=`date`"
echo "ro.build.date.utc=`date +%s`"
echo "ro.build.date=`$DATE`"
echo "ro.build.date.utc=`$DATE +%s`"
echo "ro.build.type=$TARGET_BUILD_TYPE"
echo "ro.build.user=$USER"
echo "ro.build.host=`hostname`"