builds: batch tweaks

Added option to not set VGMSTREAM_VERSION on git-less builds so plugins can put their own default
This commit is contained in:
bnnm 2021-08-15 19:57:56 +02:00
parent 4d582b09de
commit dfaa7644e6
3 changed files with 58 additions and 38 deletions

View File

@ -1,10 +1,13 @@
#!/bin/sh #!/bin/sh
# echo current git version (doesn't make version_auto.h) # echo current git version (doesn't make version_auto.h)
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
VERSION_DEFAULT=unknown VERSION_DEFAULT=unknown
VERSION_NAME=VGMSTREAM_VERSION
#VERSION_FILE=version_auto.h
# try get version from Git (dynamic), including lightweight tags # try get version from Git (dynamic), including lightweight tags
if ! command -v git > /dev/null ; then if ! command -v git > /dev/null ; then
@ -19,18 +22,24 @@ if [[ $VERSION != fatal* ]] && [ ! -z "$VERSION" ] ; then
else else
# try to get version from version.h (static) # try to get version from version.h (static)
#echo "Git version not found, can't autogenerate version (using default)" #echo "Git version not found, can't autogenerate version (using default)"
LINE="$VERSION_DEFAULT"
while IFS= read -r -u3 item; do # option to output empty line instead of default version, so plugins can detect git-less builds
COMP="#define $VERSION_NAME*" if [ "$VERSION_EMPTY" == "true" ]; then
if [[ $item == $COMP ]] ; then LINE="/* ignored */"
STR_REM1="*$VERSION_NAME \"" else
STR_REM2="\"*" LINE="$VERSION_DEFAULT"
LINE=$item while IFS= read -r -u3 item; do
LINE=${LINE/$STR_REM1/} COMP="#define $VERSION_NAME*"
LINE=${LINE/$STR_REM2/} if [[ $item == $COMP ]] ; then
fi # clean "#define ..." leaving rXXXX only
done 3< "version.h" STR_REMOVE1="*$VERSION_NAME \""
STR_REMOVE2="\"*"
LINE=$item
LINE=${LINE/$STR_REMOVE1/}
LINE=${LINE/$STR_REMOVE2/}
fi
done 3< "version.h"
fi
fi fi

View File

@ -2,15 +2,13 @@
setlocal enableextensions enabledelayedexpansion setlocal enableextensions enabledelayedexpansion
REM creates or updates version_auto.h REM creates or updates version_auto.h
REM params: $1=filename (usually version_auto.h), $2=VARNAME (usually VGMSTREAM_VERSION) set VERSION_EMPTY=%1
set VERSION_FILE=%2
set VERSION_NAME=%3
REM defaults if "%~1" == "" set VERSION_EMPTY=false
if "%~2" == "" set VERSION_FILE=version_auto.h
if "%~3" == "" set VERSION_NAME=VGMSTREAM_VERSION
set VERSION_DEFAULT=unknown set VERSION_DEFAULT=unknown
set VERSION_FILE=%1
set VERSION_NAME=%2
if "%~1" == "" set VERSION_FILE=version_auto.h
if "%~2" == "" set VERSION_NAME=VGMSTREAM_VERSION
if not "%VERSION%"=="" set VERSION=!VERSION:^:=_! if not "%VERSION%"=="" set VERSION=!VERSION:^:=_!
cd /d "%~dp0" cd /d "%~dp0"
@ -29,12 +27,17 @@ goto :got_version
REM try to get version from version.h (static) REM try to get version from version.h (static)
:get_version_h :get_version_h
echo Git version not found, can't autogenerate version (using default) echo Git version not found, can't autogenerate version (using default)
set LINE=#define %VERSION_NAME% "%VERSION_DEFAULT%" /* autogenerated */ REM option to output empty line instead of default version, so plugins can detect git-less builds
if exist "version.h" ( if "%VERSION_EMPTY%"=="true" (
for /F "tokens=*" %%v in (version.h) do ( set LINE=/* ignored */
set TOKEN=%%v ) else (
REM set COMP=#define %VERSION_NAME% #todo set LINE=#define %VERSION_NAME% "%VERSION_DEFAULT%" /* autogenerated */
if /i "!TOKEN:~0,25!"=="#define VGMSTREAM_VERSION" set LINE=%%v if exist "version.h" (
for /F "tokens=*" %%v in (version.h) do (
set TOKEN=%%v
REM set COMP=#define %VERSION_NAME% #todo
if /i "!TOKEN:~0,25!"=="#define VGMSTREAM_VERSION" set LINE=%%v /* default */
)
) )
) )
goto :got_version goto :got_version

View File

@ -1,10 +1,13 @@
#!/bin/sh #!/bin/sh
# make current git version (overwrites version_auto.h) # make current git version (overwrites version_auto.h)
VERSION_EMPTY=$1
VERSION_FILE=$2
VERSION_NAME=$3
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
VERSION_DEFAULT=unknown VERSION_DEFAULT=unknown
VERSION_NAME=VGMSTREAM_VERSION
VERSION_FILE=version_auto.h
# try get version from Git (dynamic), including lightweight tags # try get version from Git (dynamic), including lightweight tags
if ! command -v git > /dev/null ; then if ! command -v git > /dev/null ; then
@ -19,14 +22,19 @@ if [[ $VERSION != fatal* ]] && [ ! -z "$VERSION" ] ; then
else else
# try to get version from version.h (static) # try to get version from version.h (static)
echo "Git version not found, can't autogenerate version (using default)" 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 # option to output empty line instead of default version, so plugins can detect git-less builds
COMP="#define $VERSION_NAME*" if [ "$VERSION_EMPTY" == "true" ]; then
if [[ $item == $COMP ]] ; then LINE="/* ignored */"
LINE=$item else
fi LINE="#define $VERSION_NAME \"$VERSION_DEFAULT\" /* autogenerated */"
done 3< "version.h" while IFS= read -r -u3 item; do
COMP="#define $VERSION_NAME*"
if [[ $item == $COMP ]] ; then
LINE="$item /* default */"
fi
done 3< "version.h"
fi
fi fi