summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2015-09-23 13:49:56 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-24 12:46:28 -0700
commit5d138b379db251f27bd741e97119a30ba16acee1 (patch)
treee3da9d08c3f3a353f92236c2f20f19d6ce8ae1d7 /util
parent6190e15597ba0f842040abf7dbb615e0ceeefa2e (diff)
downloadchrome-ec-5d138b379db251f27bd741e97119a30ba16acee1.tar.gz
Make builds repeatable.
We have been using the time of compilation to determine the version string. This CL will keep doing that if the git repo has uncommitted changes, but if the repo is clean we'll just use the author date of the last commit. This ensures that the same source will produce bitwise-identical builds (assuming no toolchain changes, of course). BUG=chrome-os-partner:45616 BRANCH=none TEST=manual cd src/platform/ec make buildall mv build build.one make buildall md5sum build{,.one}/*/ec.bin | sort Observe that successive builds produce identical binaries. Change-Id: Ie2ef44b216586097589c9c15f12e05c87a53f991 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/302140 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/getdate.sh12
-rwxr-xr-xutil/getversion.sh14
2 files changed, 8 insertions, 18 deletions
diff --git a/util/getdate.sh b/util/getdate.sh
deleted file mode 100755
index 8099b398e8..0000000000
--- a/util/getdate.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-#
-# Generate build date information for the EC binary
-
-echo "/* This file is generated by util/getdate.sh */"
-
-echo "/* DATE is used to form build info string in common/version.c. */"
-echo "#define DATE \"$(date '+%F %T')\""
diff --git a/util/getversion.sh b/util/getversion.sh
index da31eb9428..8b32307a49 100755
--- a/util/getversion.sh
+++ b/util/getversion.sh
@@ -37,8 +37,6 @@ fi
ver="${BOARD}_${vbase}"
-gitdate=$(git log -1 --format='%ai' HEAD | cut -d ' ' -f '1 2')
-
echo "/* This file is generated by util/getversion.sh */"
echo "/* Version string for use by common/version.c */"
@@ -56,7 +54,11 @@ echo " * in common/version.c. */"
echo "#define VERSION \"${ver}\""
echo "#define BUILDER \"${USER}@`hostname`\""
-echo "/* Author date of last commit, in case compile-time is not used. */"
-echo "#ifndef DATE"
-echo "#define DATE \"${gitdate}\""
-echo "#endif"
+if [ -n "$dirty" ]; then
+ echo "/* Repo is dirty, using time of last compilation */"
+ echo "#define DATE \"$(date '+%F %T')\""
+else
+ echo "/* Repo is clean, use the author date of the last commit */"
+ gitdate=$(git log -1 --format='%ai' HEAD | cut -d ' ' -f '1 2')
+ echo "#define DATE \"${gitdate}\""
+fi