mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-23 22:41:05 +01:00
builds: fix version .sh for standard sh
This commit is contained in:
parent
df7ad9f58c
commit
fc56d08567
@ -14,29 +14,32 @@ if ! command -v git > /dev/null ; then
|
||||
VERSION=""
|
||||
else
|
||||
VERSION=$(git describe --tags --always 2>&1 | tr : _ )
|
||||
if case "$VERSION" in fatal*) true;; *) false;; esac; then
|
||||
VERSION=""
|
||||
fi
|
||||
fi
|
||||
|
||||
# ignore git stderr "fatal:*" or blank
|
||||
if [[ $VERSION != fatal* ]] && [ ! -z "$VERSION" ] ; then
|
||||
|
||||
if [ ! -z "$VERSION" ]; then
|
||||
LINE="$VERSION"
|
||||
else
|
||||
# try to get version from version.h (static)
|
||||
#echo "Git version not found, can't autogenerate version (using default)"
|
||||
|
||||
# option to output empty line instead of default version, so plugins can detect git-less builds
|
||||
if [ "$VERSION_EMPTY" == "true" ]; then
|
||||
if [ "$VERSION_EMPTY" = "true" ]; then
|
||||
LINE="/* ignored */"
|
||||
else
|
||||
LINE="$VERSION_DEFAULT"
|
||||
while IFS= read -r -u3 item; do
|
||||
COMP="#define $VERSION_NAME*"
|
||||
if [[ $item == $COMP ]] ; then
|
||||
while IFS= read -r <&3 ITEM; do
|
||||
COMP="#define $VERSION_NAME"
|
||||
if case "$ITEM" in *"$COMP"*) true;; *) false;; esac; then
|
||||
# clean "#define ..." leaving rXXXX only
|
||||
STR_REMOVE1="*$VERSION_NAME \""
|
||||
STR_REMOVE2="\"*"
|
||||
LINE=$item
|
||||
LINE=${LINE/$STR_REMOVE1/}
|
||||
LINE=${LINE/$STR_REMOVE2/}
|
||||
REGEX_REMOVE1="#define $VERSION_NAME \""
|
||||
REGEX_REMOVE2="\".*"
|
||||
LINE="$ITEM"
|
||||
LINE=$(echo $LINE | sed "s/$REGEX_REMOVE1//")
|
||||
LINE=$(echo $LINE | sed "s/$REGEX_REMOVE2//")
|
||||
fi
|
||||
done 3< "version.h"
|
||||
fi
|
||||
|
@ -14,24 +14,27 @@ if ! command -v git > /dev/null ; then
|
||||
VERSION=""
|
||||
else
|
||||
VERSION=$(git describe --tags --always 2>&1 | tr : _ )
|
||||
if case "$VERSION" in fatal*) true;; *) false;; esac; then
|
||||
VERSION=""
|
||||
fi
|
||||
fi
|
||||
|
||||
# ignore git stderr "fatal:*" or blank
|
||||
if [[ $VERSION != fatal* ]] && [ ! -z "$VERSION" ] ; then
|
||||
|
||||
if [ ! -z "$VERSION" ]; then
|
||||
LINE="#define $VERSION_NAME \"$VERSION\" /* autogenerated */"
|
||||
else
|
||||
# try to get version from version.h (static)
|
||||
echo "Git version not found, can't autogenerate version (using default)"
|
||||
|
||||
# option to output empty line instead of default version, so plugins can detect git-less builds
|
||||
if [ "$VERSION_EMPTY" == "true" ]; then
|
||||
if [ "$VERSION_EMPTY" = "true" ]; then
|
||||
LINE="/* ignored */"
|
||||
else
|
||||
LINE="#define $VERSION_NAME \"$VERSION_DEFAULT\" /* autogenerated */"
|
||||
while IFS= read -r -u3 item; do
|
||||
COMP="#define $VERSION_NAME*"
|
||||
if [[ $item == $COMP ]] ; then
|
||||
LINE="$item /* default */"
|
||||
while IFS= read -r <&3 ITEM; do
|
||||
COMP="#define $VERSION_NAME"
|
||||
if case "$ITEM" in *"$COMP"*) true;; *) false;; esac; then
|
||||
LINE="$ITEM /* default */"
|
||||
fi
|
||||
done 3< "version.h"
|
||||
fi
|
||||
@ -43,6 +46,6 @@ LINE_ORIGINAL="none"
|
||||
if test -f "version_auto.h"; then
|
||||
LINE_ORIGINAL=$(<version_auto.h)
|
||||
fi
|
||||
if [[ $LINE != $LINE_ORIGINAL ]] ; then
|
||||
if [ ! "$LINE" = "$LINE_ORIGINAL" ]; then
|
||||
echo "$LINE" > "$VERSION_FILE"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user