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

View File

@ -2,15 +2,13 @@
setlocal enableextensions enabledelayedexpansion
REM creates or updates version_auto.h
REM params: $1=filename (usually version_auto.h), $2=VARNAME (usually VGMSTREAM_VERSION)
REM defaults
set VERSION_EMPTY=%1
set VERSION_FILE=%2
set VERSION_NAME=%3
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_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:^:=_!
cd /d "%~dp0"
@ -29,12 +27,17 @@ goto :got_version
REM try to get version from version.h (static)
:get_version_h
echo Git version not found, can't autogenerate version (using default)
set LINE=#define %VERSION_NAME% "%VERSION_DEFAULT%" /* autogenerated */
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
REM option to output empty line instead of default version, so plugins can detect git-less builds
if "%VERSION_EMPTY%"=="true" (
set LINE=/* ignored */
) else (
set LINE=#define %VERSION_NAME% "%VERSION_DEFAULT%" /* autogenerated */
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

View File

@ -1,10 +1,13 @@
#!/bin/sh
# 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_NAME=VGMSTREAM_VERSION
VERSION_FILE=version_auto.h
# try get version from Git (dynamic), including lightweight tags
if ! command -v git > /dev/null ; then
@ -19,14 +22,19 @@ if [[ $VERSION != fatal* ]] && [ ! -z "$VERSION" ] ; then
else
# 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"
# option to output empty line instead of default version, so plugins can detect git-less builds
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 */"
fi
done 3< "version.h"
fi
fi