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 -d "$(BUILD_DATETIME)" +%m%d%H%M)
else
BF_BUILD_NUMBER := $(BUILD_NUMBER)
endif
PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
BUILD_ID="$(BUILD_ID)" \
BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
+ BUILD_DATETIME="$(BUILD_DATETIME_FROM_FILE)" \
BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \
BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \
PLATFORM_VERSION="$(PLATFORM_VERSION)" \
@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 -d "$(BUILD_DATETIME_FROM_FILE)"`>>$@
+ $(hide) echo ro.vendor.build.date.utc=`date -d "$(BUILD_DATETIME_FROM_FILE)" +%s`>>$@
$(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
endif
@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 -d "$(BUILD_DATETIME_FROM_FILE)"`>>$@
+ $(hide) echo ro.bootimage.build.date.utc=`date -d "$(BUILD_DATETIME_FROM_FILE)" +%s`>>$@
$(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
# -----------------------------------------------------------------
# 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 -d "$(BUILD_DATETIME)" "+%b %_d %Y" > $(OUT_DIR)/build_c_date.txt && \
+ date -d "$(BUILD_DATETIME)" +%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
$(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 -d "$(BUILD_DATETIME_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)
# 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)
# CTS-specific config.
-include cts/build/config.mk
# DEFAULT_APP_TARGET_SDK
# BUILD_ID
# BUILD_NUMBER
+# BUILD_DATETIME
#
# Look for an optional file containing overrides of the defaults,
BUILD_ID := UNKNOWN
endif
+ifeq "" "$(BUILD_DATETIME)"
+ # Used to reproduce builds by setting the same time. Must be in a
+ # format understood by `date`
+ BUILD_DATETIME := $(shell date)
+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
# 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 -d "$(BUILD_DATETIME)" +%Y%m%d.%H%M%S)
endif
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 -d \"$BUILD_DATETIME\"`"
+echo "ro.build.date.utc=`date -d \"$BUILD_DATETIME\" +%s`"
echo "ro.build.type=$TARGET_BUILD_TYPE"
echo "ro.build.user=$USER"
echo "ro.build.host=`hostname`"