summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xutil/getversion.sh41
1 files changed, 35 insertions, 6 deletions
diff --git a/util/getversion.sh b/util/getversion.sh
index bb1b7c5574..83c42d88e5 100755
--- a/util/getversion.sh
+++ b/util/getversion.sh
@@ -10,6 +10,9 @@
# text.
dc=$'\001'
+# Default marker to indicate 'dirty' repositories
+dirty_marker='-dirty'
+
# This function examines the state of the current directory and attempts to
# extract its version information: the latest tag, if any, how many patches
# are there since the latest tag, the top sha1, and if there are local
@@ -25,6 +28,7 @@ dc=$'\001'
# "no_version"
get_tree_version() {
+ local dirty
local ghash
local numcommits
local tag
@@ -49,7 +53,9 @@ get_tree_version() {
# changed
git status > /dev/null 2>&1
- dirty=`sh -c "[ '$(git diff-index --name-only HEAD)' ] && echo '-dirty'"`
+ if [ -n "$(git diff-index --name-only HEAD 2>/dev/null)" ]; then
+ dirty="${dirty_marker}"
+ fi
vbase="${ver_major}.${ver_branch}.${numcommits}-${ghash}${dirty}"
else
# Fall back to the VCSID provided by the packaging system if available.
@@ -63,11 +69,34 @@ get_tree_version() {
echo "${vbase}${dc}${dirty}"
}
+
IFS="${dc}"
-values=( $(get_tree_version) )
-vbase="${values[0]}" # Retrieved version information.
-dirty="${values[1]}" # Non-zero, if the repository is 'dirty'
-ver="${BOARD}_${vbase}"
+ver="${BOARD}_"
+global_dirty= # set if any of the component repos is 'dirty'.
+dir_list=( . ) # list of component directories, always includes the EC tree
+
+case "${BOARD}" in
+ (cr50)
+ # cr50 includes sources from 4 different git trees. Shortened 'dirty' tree
+ # marker allows to keep the summary version string shorter.
+ dirty_marker='+'
+ dir_list+=( private-cr51 ../../third_party/tpm2 ../../third_party/cryptoc )
+ ;;
+esac
+
+# Create a combined version string for all component directories.
+for git_dir in ${dir_list[@]}; do
+ pushd "${git_dir}" > /dev/null
+ component="$(basename "${git_dir}")"
+ values=( $(get_tree_version) )
+ vbase="${values[0]}" # Retrieved version information.
+ global_dirty+="${values[1]}" # Non-zero, if the repository is 'dirty'
+ if [ "${component}" != "." ]; then
+ ver+=" ${component}:"
+ fi
+ ver+="${vbase}"
+ popd > /dev/null
+done
echo "/* This file is generated by util/getversion.sh */"
@@ -82,7 +111,7 @@ echo " * in common/version.c. */"
echo "#define VERSION \"${ver}\""
echo "#define BUILDER \"${USER}@`hostname`\""
-if [ -n "$dirty" ]; then
+if [ -n "$global_dirty" ]; then
echo "/* Repo is dirty, using time of last compilation */"
echo "#define DATE \"$(date '+%F %T')\""
else