2008-05-18 08:16:56 +02:00
|
|
|
#!/bin/sh
|
2019-09-02 20:42:00 +02:00
|
|
|
|
2021-08-10 23:51:48 +02:00
|
|
|
# echo current git version (doesn't make version_auto.h)
|
2021-08-15 19:57:56 +02:00
|
|
|
VERSION_EMPTY=$1
|
|
|
|
#VERSION_FILE=--
|
|
|
|
VERSION_NAME=$2
|
|
|
|
if [ -z "$VERSION_EMPTY" ]; then VERSION_EMPTY=false; fi
|
|
|
|
#if [ -z "$VERSION_FILE" ]; then VERSION_FILE=version_auto.h; fi
|
|
|
|
if [ -z "$VERSION_NAME" ]; then VERSION_NAME=VGMSTREAM_VERSION; fi
|
2021-08-15 19:15:56 +02:00
|
|
|
VERSION_DEFAULT=unknown
|
2021-08-07 17:06:45 +02:00
|
|
|
|
2021-08-15 16:32:53 +02:00
|
|
|
# try get version from Git (dynamic), including lightweight tags
|
2021-08-15 19:15:56 +02:00
|
|
|
if ! command -v git > /dev/null ; then
|
|
|
|
VERSION=""
|
2021-08-07 17:06:45 +02:00
|
|
|
else
|
2021-08-15 16:32:53 +02:00
|
|
|
VERSION=$(git describe --tags --always 2>&1 | tr : _ )
|
2021-08-15 21:22:43 +02:00
|
|
|
if case "$VERSION" in fatal*) true;; *) false;; esac; then
|
|
|
|
VERSION=""
|
|
|
|
fi
|
2021-08-07 17:06:45 +02:00
|
|
|
fi
|
2019-09-02 20:42:00 +02:00
|
|
|
|
2021-08-15 21:22:43 +02:00
|
|
|
|
|
|
|
if [ ! -z "$VERSION" ]; then
|
2021-08-15 19:15:56 +02:00
|
|
|
LINE="$VERSION"
|
2019-09-02 20:42:00 +02:00
|
|
|
else
|
2021-08-15 19:15:56 +02:00
|
|
|
# try to get version from version.h (static)
|
|
|
|
#echo "Git version not found, can't autogenerate version (using default)"
|
|
|
|
|
2021-08-15 19:57:56 +02:00
|
|
|
# option to output empty line instead of default version, so plugins can detect git-less builds
|
2021-08-15 21:22:43 +02:00
|
|
|
if [ "$VERSION_EMPTY" = "true" ]; then
|
2021-08-15 19:57:56 +02:00
|
|
|
LINE="/* ignored */"
|
|
|
|
else
|
|
|
|
LINE="$VERSION_DEFAULT"
|
2021-08-15 21:22:43 +02:00
|
|
|
while IFS= read -r <&3 ITEM; do
|
|
|
|
COMP="#define $VERSION_NAME"
|
|
|
|
if case "$ITEM" in *"$COMP"*) true;; *) false;; esac; then
|
2021-08-15 19:57:56 +02:00
|
|
|
# clean "#define ..." leaving rXXXX only
|
2021-08-15 21:22:43 +02:00
|
|
|
REGEX_REMOVE1="#define $VERSION_NAME \""
|
|
|
|
REGEX_REMOVE2="\".*"
|
|
|
|
LINE="$ITEM"
|
|
|
|
LINE=$(echo $LINE | sed "s/$REGEX_REMOVE1//")
|
|
|
|
LINE=$(echo $LINE | sed "s/$REGEX_REMOVE2//")
|
2021-08-15 19:57:56 +02:00
|
|
|
fi
|
|
|
|
done 3< "version.h"
|
|
|
|
fi
|
2021-08-15 19:15:56 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# final print
|
|
|
|
echo "$LINE"
|