From 699943d29707bb0a301cc5040c7f505f2c0fefff Mon Sep 17 00:00:00 2001 From: David Neto Date: Tue, 17 Jan 2017 15:41:23 -0500 Subject: [PATCH] Say why we allow override of build timestamp It's for reproducible builds. Also, fix Python formatting. --- CHANGES | 2 ++ utils/update_build_version.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 043f818..c88421c 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,8 @@ Revision history for SPIRV-Tools v2016.7-dev 2017-01-06 - Add build target spirv-tools-vimsyntax to generate spvasm.vim, a SPIR-V assembly syntax file for Vim. + - Version string: Allow overriding of wall clock timestamp with contents + of environment variable SOURCE_DATE_EPOCH. - Fixes: #508: Support compilation under CYGWIN #517: Fix validation when continue (or case) contstruct is also the head of a diff --git a/utils/update_build_version.py b/utils/update_build_version.py index db688e4..d2984d2 100755 --- a/utils/update_build_version.py +++ b/utils/update_build_version.py @@ -110,9 +110,15 @@ def describe(directory): return command_output( ['git', 'rev-parse', 'HEAD'], directory).rstrip().decode() except: - return 'unknown hash, {}'.format(datetime.date.fromtimestamp( - int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) - ).isoformat()) + # This is the fallback case where git gives us no information, + # e.g. because the source tree might not be in a git tree. + # In this case, usually use a timestamp. However, to ensure + # reproducible builds, allow the builder to override the wall + # clock time with enviornment variable SOURCE_DATE_EPOCH + # containing a (presumably) fixed timestamp. + timestamp = int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) + formatted = datetime.date.fromtimestamp(timestamp).isoformat() + return 'unknown hash, {}'.format(formatted) def main(): -- 2.7.4