vgmstream/version-make.bat
2021-08-08 18:53:59 +02:00

39 lines
898 B
Batchfile

@echo off
setlocal enableextensions enabledelayedexpansion
REM creates or updates version.h
REM params: $1=filename (usually version.h), $2=VARNAME (usually VGMSTREAM_VERSION)
REM defaults
set VERSION_DEFAULT=unknown
set VERSION_FILE=%1
set VERSION_NAME=%2
if "%~1" == "" set VERSION_FILE=version.h
if "%~2" == "" set VERSION_NAME=VGMSTREAM_VERSION
if not "%version%"=="" set version=!version:^:=_!
cd /d "%~dp0"
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
echo Git version not found, can't autogenerate version.h
goto :exit
REM overwrite version.h
:got_version
if %version%==%VERSION_DEFAULT% goto :exit
echo #define %VERSION_NAME% "%version%" /* autogenerated */ > %VERSION_FILE%
REM done
:exit