1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-18 21:06:00 +00:00
mpv/version.sh
wm4 dbf21467f0 build: always regenerate version hash
Until now, it only used the hash from the previous configure run,
instead of trying to get the latest hash. The "old" build system did
this correctly - we just have to use the existing logic in version.sh.

Since waf supports separate build dirs, extend version.sh with an
argument for setting the path of version.h.
2015-06-30 15:56:26 +02:00

61 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
export LC_ALL=C
version_h="version.h"
for ac_option do
ac_arg=$(echo $ac_option | cut -d '=' -f 2-)
case "$ac_option" in
--extra=*)
extra="-$ac_arg"
;;
--versionh=*)
version_h="$ac_arg"
;;
--print)
print=yes
;;
*)
echo "Unknown parameter: $ac_option" >&2
exit 1
;;
esac
done
# Extract revision number from file used by daily tarball snapshots
# or from "git describe" output
git_revision=$(cat snapshot_version 2> /dev/null)
test "$git_revision" || test ! -e .git || git_revision="$(git rev-parse --short HEAD)"
test "$git_revision" && git_revision="git-$git_revision"
version="$git_revision"
# releases extract the version number from the VERSION file
releaseversion="$(cat VERSION 2> /dev/null)"
if test "$releaseversion" ; then
test "$version" && version="-$version"
version="$releaseversion$version"
fi
test "$version" || version=UNKNOWN
VERSION="${version}${extra}"
if test "$print" = yes ; then
echo "$VERSION"
exit 0
fi
NEW_REVISION="#define VERSION \"${VERSION}\""
OLD_REVISION=$(head -n 1 "$version_h" 2> /dev/null)
BUILDDATE="#define BUILDDATE \"$(date)\""
# Update version.h only on revision changes to avoid spurious rebuilds
if test "$NEW_REVISION" != "$OLD_REVISION"; then
cat <<EOF > "$version_h"
$NEW_REVISION
$BUILDDATE
EOF
fi