mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
When the EC is built using "emerge-<board> chromeos-ec" on a developer workstation with the chromeos-ec package "cros-worked'on", put "1.1.9999-<git-sha1>" rather than "no_version" in the version string. Emerge is exporting the current git SHA-1 hash in the VCSID id but the .git repository is not available during the build. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=try the following build setups: - local emerge $ emerge-smaug chromeos-ec $ strings /build/smaug/firmware/ec.bin | grep ryu ryu_p4p5_1.1.9999-ebe18ef - local build $ make BOARD=ryu_p4p5 $ strings build/ryu_p4p5/ec.bin | grep ryu ryu_p4p5_v1.1.3127-ebe18ef-dirt - trybot build $ cbuildbot --remote -g 270554 smaug-firmware $ tar xvjf firmware_from_sources.tar.bz2 $ strings ec.bin | grep ryu ryu_p4p5_v1.1.3137-9b52578 Change-Id: I386f80d82d95b5e99a1660a1eb242c47c54d17ef Reviewed-on: https://chromium-review.googlesource.com/270554 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
63 lines
1.9 KiB
Bash
Executable File
63 lines
1.9 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}"
|
|
|
|
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 */"
|
|
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`\""
|
|
|
|
echo "/* Author date of last commit, in case compile-time is not used. */"
|
|
echo "#ifndef DATE"
|
|
echo "#define DATE \"${gitdate}\""
|
|
echo "#endif"
|