mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
The git author date usually reflects the time a CL was first pushed to gerrit, not the time it lands to the tree. Therefore, the author date is misleading when used as a timestamp. Use the git commit date instead. BUG=chromium:554675 BRANCH=None TEST=Cherry-pick CL:293345 and verify date stamp is today, not last August. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I4fb042d7a706fbb86897b3e383b3242602af242b Reviewed-on: https://chromium-review.googlesource.com/313022 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
65 lines
2.0 KiB
Bash
Executable File
65 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright (c) 2012 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 version information for the EC binary
|
|
|
|
if ghash=`git rev-parse --short --verify HEAD 2>/dev/null`; then
|
|
if gdesc=`git describe --dirty --match='v*' 2>/dev/null`; then
|
|
IFS="-" fields=($gdesc)
|
|
tag="${fields[0]}"
|
|
IFS="." vernum=($tag)
|
|
numcommits=$((${vernum[2]}+${fields[1]:-0}))
|
|
ver_major="${vernum[0]}"
|
|
ver_branch="${vernum[1]}"
|
|
else
|
|
numcommits=`git rev-list HEAD | wc -l`
|
|
ver_major="v0"
|
|
ver_branch="0"
|
|
fi
|
|
# avoid putting the -dirty attribute if only the timestamp
|
|
# changed
|
|
git status > /dev/null 2>&1
|
|
|
|
dirty=`sh -c "[ '$(git diff-index --name-only HEAD)' ] && echo '-dirty'"`
|
|
vbase="${ver_major}.${ver_branch}.${numcommits}-${ghash}${dirty}"
|
|
else
|
|
# Fall back to the VCSID provided by the packaging system if available.
|
|
if ghash=${VCSID##*-}; then
|
|
vbase="1.1.9999-${ghash:0:7}"
|
|
else
|
|
# then ultimately fails to "no_version"
|
|
vbase="no_version"
|
|
fi
|
|
fi
|
|
|
|
ver="${BOARD}_${vbase}"
|
|
|
|
echo "/* This file is generated by util/getversion.sh */"
|
|
|
|
echo "/* Version string for use by common/version.c */"
|
|
echo "#ifdef SHIFT_CODE_FOR_TEST"
|
|
echo "#define CROS_EC_VERSION \"${ver}_shift\""
|
|
echo "#else"
|
|
echo "#define CROS_EC_VERSION \"${ver}\""
|
|
echo "#endif"
|
|
|
|
echo "/* Version string, truncated to 31 chars (+ terminating null = 32) */"
|
|
echo "#define CROS_EC_VERSION32 \"${ver:0:31}\""
|
|
|
|
echo "/* Sub-fields for use in Makefile.rules and to form build info string"
|
|
echo " * in common/version.c. */"
|
|
echo "#define VERSION \"${ver}\""
|
|
echo "#define BUILDER \"${USER}@`hostname`\""
|
|
|
|
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 commit date of the last commit */"
|
|
gitdate=$(git log -1 --format='%ci' HEAD | cut -d ' ' -f '1 2')
|
|
echo "#define DATE \"${gitdate}\""
|
|
fi
|