mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 08:20:54 +01:00
builds: don't make .h when no git found, no .mk
This commit is contained in:
parent
d12f137470
commit
63b588709f
40
version.bat
40
version.bat
@ -1,9 +1,9 @@
|
||||
@echo off
|
||||
setlocal enableextensions enabledelayedexpansion
|
||||
|
||||
REM creates or updates version.h
|
||||
REM params (optional): $1=filename (usually [relpath]/version.h), $2=VARNAME (usually VGMSTREAM_VERSION)
|
||||
REM params: $1=filename (usually version.h), $2=VARNAME (usually VGMSTREAM_VERSION)
|
||||
|
||||
setlocal enableextensions enabledelayedexpansion
|
||||
|
||||
REM defaults
|
||||
set VERSION_DEFAULT=unknown
|
||||
@ -17,44 +17,22 @@ if not "%version%"=="" set version=!version:^:=_!
|
||||
cd /d "%~dp0"
|
||||
|
||||
|
||||
REM try dynamic version from git
|
||||
REM try get version from Git, leave original version.h untouched if not possible
|
||||
for /f %%v in ('git describe --always') do set version=%%v
|
||||
|
||||
if not "%version%"=="" set version=!version:^:=_!
|
||||
if not "%version%"=="" goto :got_version
|
||||
if exist "version.mk" goto :mk_version
|
||||
|
||||
echo Git version cannot be found, nor can version.mk. Generating unknown version.
|
||||
set version=%VERSION_DEFAULT%
|
||||
goto :got_version
|
||||
echo Git version cannot be found, can't autogenerate version.h
|
||||
goto :exit
|
||||
|
||||
|
||||
REM try static version from .mk file
|
||||
:mk_version
|
||||
for /f "delims== tokens=2" %%v in (version.mk) do set version=%%v
|
||||
set version=!version:^"=!
|
||||
set version=!version: =!
|
||||
|
||||
|
||||
REM version found, create version.h and update .mk
|
||||
REM overwrite version.h
|
||||
:got_version
|
||||
set version_out=#define %VERSION_NAME% "%version%"
|
||||
set version_mk=%VERSION_NAME% = "%version%"
|
||||
if %version%==%VERSION_DEFAULT% goto :exit
|
||||
|
||||
echo %version_out%> %VERSION_FILE%_temp
|
||||
|
||||
if %version%==%VERSION_DEFAULT% goto :skip_generate
|
||||
echo # static version string; update manually before and after every release.> "version.mk"
|
||||
echo %version_mk%>> "version.mk"
|
||||
echo #define %VERSION_NAME% "%version%" /* autogenerated */ >> %VERSION_FILE%
|
||||
|
||||
|
||||
:skip_generate
|
||||
echo n | comp %VERSION_FILE%_temp %VERSION_FILE% > NUL 2> NUL
|
||||
|
||||
if not errorlevel 1 goto exit
|
||||
|
||||
copy /y %VERSION_FILE%_temp %VERSION_FILE% > NUL 2> NUL
|
||||
|
||||
REM done
|
||||
:exit
|
||||
|
||||
del %VERSION_FILE%_temp
|
||||
|
Loading…
Reference in New Issue
Block a user