mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 18:11:05 +00:00
Previously the version string was special cased in the USB stack because the build system prevented the inclusion of ec_version.h in any file other than common/version.c. This lead to common/version.c being the only place that the USB version string could be computed and thus the special case of filling in the version string descriptor at run time. This made the USB stack more complex, and lead to the common/version.c file including usb.h, which is actually STM32 specific. Now, the portion of ec_version.h that is deterministic is only updated when something in the tree actually changes (by way of a conditional in the makefile), and ec_version.h no longer has to depend on all object files (other than the special version.o). This allows anyone to include ec_version.h as needed. In particular, each board that wants to define a USB version string can directly include ec_version.h and do so. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j touch files and verify rebuilds happen correctly Change-Id: Ic84d0b9da90f82ebb4630fb550ec841071e25a49 Reviewed-on: https://chromium-review.googlesource.com/227211 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
50 lines
1.5 KiB
Bash
Executable File
50 lines
1.5 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
|
|
vbase="no_version"
|
|
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`\""
|