1
mirror of https://github.com/mpv-player/mpv synced 2024-10-18 10:25:02 +02:00
mpv/version.sh
Uoti Urpala 1dba61a670 build: Generate version numbers for git
Update the version.sh script for git so it'll generate version numbers
more useful than "UNKNOWN". At the moment it only generates the short
SHA1 name, but adding a tag as a starting point should allow more
useful output. Rather than update the Makefile logic that tried to
guess whether the svn revision had changed since the last version.h
update, just run the version.sh script from configure so the version
is updated at least at that time.
2009-11-23 06:22:15 +02:00

27 lines
870 B
Bash
Executable File

#!/bin/sh
test "$1" && extra="-$1"
# Extract revision number from file used by daily tarball snapshots
# or from the places different Subversion versions have it.
git_revision=$(cat snapshot_version 2> /dev/null)
test $git_revision || test -d .git && git_revision=`git describe --always`
test $git_revision && git_revision=git-$git_revision
test $git_revision || git_revision=UNKNOWN
# releases extract the version number from the VERSION file
version=$(cat VERSION 2> /dev/null)
test $version || version=$git_revision
NEW_REVISION="#define VERSION \"${version}${extra}\""
OLD_REVISION=$(head -n 1 version.h 2> /dev/null)
TITLE='#define MP_TITLE "%s "VERSION" (C) 2000-2009 MPlayer Team\n"'
# Update version.h only on revision changes to avoid spurious rebuilds
if test "$NEW_REVISION" != "$OLD_REVISION"; then
cat <<EOF > version.h
$NEW_REVISION
$TITLE
EOF
fi