mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-21 04:48:21 +01:00
build: fix rebuild then version doesn't change
This commit is contained in:
parent
fefc40dcf7
commit
ad21706fcb
@ -13,7 +13,6 @@ if "%~1" == "" set VERSION_FILE=version_auto.h
|
||||
if "%~2" == "" set VERSION_NAME=VGMSTREAM_VERSION
|
||||
|
||||
if not "%VERSION%"=="" set VERSION=!VERSION:^:=_!
|
||||
|
||||
cd /d "%~dp0"
|
||||
|
||||
|
||||
@ -24,13 +23,12 @@ if not "%VERSION%"=="" set VERSION=!VERSION:^:=_!
|
||||
if "%VERSION%"=="" goto :get_version_h
|
||||
if %VERSION%==%VERSION_DEFAULT% goto :get_version_h
|
||||
set LINE=#define %VERSION_NAME% "%VERSION%" /* autogenerated */
|
||||
echo %LINE% > %VERSION_FILE%
|
||||
goto :exit
|
||||
goto :got_version
|
||||
|
||||
|
||||
REM try to get version from version.h (static)
|
||||
:get_version_h
|
||||
echo Git version not found, can't autogenerate version_auto.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 (
|
||||
@ -39,10 +37,27 @@ if exist "version.h" (
|
||||
if /i "!TOKEN:~0,25!"=="#define VGMSTREAM_VERSION" set LINE=%%v
|
||||
)
|
||||
)
|
||||
goto :got_version
|
||||
|
||||
echo %LINE% > %VERSION_FILE%
|
||||
|
||||
REM avoid overwritting if contents are the same, as some systems rebuild on timestamp
|
||||
:got_version
|
||||
set LINE_ORIGINAL=none
|
||||
if exist %VERSION_FILE% set /p LINE_ORIGINAL=<%VERSION_FILE%
|
||||
if not "%LINE%"=="%LINE_ORIGINAL%" (
|
||||
REM no spaces!
|
||||
echo %LINE%>%VERSION_FILE%
|
||||
)
|
||||
goto :exit
|
||||
|
||||
REM * alt full file comp test
|
||||
REM echo %LINE% > %VERSION_FILE%_temp
|
||||
REM echo n | comp %VERSION_FILE%_temp %VERSION_FILE% > NUL 2> NUL
|
||||
REM if not errorlevel 1 goto :got_version_done
|
||||
REM copy /y %VERSION_FILE%_temp %VERSION_FILE% > NUL 2> NUL
|
||||
REM :got_version_done
|
||||
REM del %VERSION_FILE%_temp
|
||||
REM :exit
|
||||
|
||||
REM done
|
||||
:exit
|
||||
|
@ -1,11 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# make current git version (overwrites version_auto.h)
|
||||
VERSION_DEFAULT=unknown
|
||||
VERSION_NAME=VGMSTREAM_VERSION
|
||||
VERSION_FILE=version_auto.h
|
||||
|
||||
|
||||
# test if git exists
|
||||
# try get version from Git (dynamic)
|
||||
if ! command -v git > /dev/null ; then
|
||||
VERSION=""
|
||||
else
|
||||
@ -15,7 +16,26 @@ fi
|
||||
|
||||
# ignore git stderr "fatal:*" or blank
|
||||
if [[ $VERSION != fatal* ]] && [ ! -z "$VERSION" ] ; then
|
||||
echo "#define $VERSION_NAME \"$VERSION\" /* autogenerated */" > $VERSION_FILE
|
||||
LINE="#define $VERSION_NAME \"$VERSION\" /* autogenerated */"
|
||||
else
|
||||
echo "Git version not found, can't autogenerate version_auto.h"
|
||||
fi;
|
||||
# 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user