2021-08-08 14:00:58 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2021-08-10 23:51:48 +02:00
|
|
|
# make current git version (overwrites version_auto.h)
|
2021-08-11 23:57:36 +02:00
|
|
|
VERSION_DEFAULT=unknown
|
2021-08-08 14:00:58 +02:00
|
|
|
VERSION_NAME=VGMSTREAM_VERSION
|
2021-08-10 23:51:48 +02:00
|
|
|
VERSION_FILE=version_auto.h
|
2021-08-08 14:00:58 +02:00
|
|
|
|
|
|
|
|
2021-08-11 23:57:36 +02:00
|
|
|
# try get version from Git (dynamic)
|
2021-08-08 14:00:58 +02:00
|
|
|
if ! command -v git > /dev/null ; then
|
|
|
|
VERSION=""
|
|
|
|
else
|
|
|
|
VERSION=$(git describe --always 2>&1 | tr : _ )
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# ignore git stderr "fatal:*" or blank
|
|
|
|
if [[ $VERSION != fatal* ]] && [ ! -z "$VERSION" ] ; then
|
2021-08-11 23:57:36 +02:00
|
|
|
LINE="#define $VERSION_NAME \"$VERSION\" /* autogenerated */"
|
2021-08-08 14:00:58 +02:00
|
|
|
else
|
2021-08-11 23:57:36 +02:00
|
|
|
# try to get version from version.h (static)
|
|
|
|
echo "Git version not found, can't autogenerate version (using default)"
|
|
|
|
LINE="#define $VERSION_NAME \"$VERSION_DEFAULT\" /* autogenerated */"
|
|
|
|
|
|
|
|
while IFS= read -r -u3 item; do
|
|
|
|
COMP="#define $VERSION_NAME*"
|
|
|
|
if [[ $item == $COMP ]] ; then
|
|
|
|
LINE=$item
|
|
|
|
fi
|
|
|
|
done 3< "version.h"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# avoid overwritting if contents are the same, as some systems rebuild on timestamp
|
|
|
|
LINE_ORIGINAL="none"
|
|
|
|
if test -f "version_auto.h"; then
|
|
|
|
LINE_ORIGINAL=$(<version_auto.h)
|
|
|
|
fi
|
|
|
|
if [[ $LINE != $LINE_ORIGINAL ]] ; then
|
|
|
|
echo "$LINE" > "$VERSION_FILE"
|
|
|
|
fi
|