vgmstream/version-make.bat

39 lines
899 B
Batchfile
Raw Normal View History

2013-06-13 18:05:02 -07:00
@echo off
setlocal enableextensions enabledelayedexpansion
2013-06-13 18:05:02 -07:00
REM creates or updates version.h
REM params: $1=filename (usually version.h), $2=VARNAME (usually VGMSTREAM_VERSION)
2013-06-13 18:05:02 -07:00
2021-08-07 17:06:45 +02:00
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
2015-08-30 18:43:50 -07:00
if not "%version%"=="" set version=!version:^:=_!
2013-06-13 18:05:02 -07:00
2021-08-07 17:06:45 +02:00
cd /d "%~dp0"
2013-06-13 18:05:02 -07:00
REM try get version from Git, leave original version.h untouched if not possible
2021-08-07 17:06:45 +02:00
for /f %%v in ('git describe --always') do set version=%%v
2013-06-13 18:05:02 -07:00
2021-08-07 17:06:45 +02:00
if not "%version%"=="" set version=!version:^:=_!
if not "%version%"=="" goto :got_version
2013-06-13 18:05:02 -07:00
2021-08-08 14:00:58 +02:00
echo Git version not found, can't autogenerate version.h
goto :exit
2013-06-13 18:05:02 -07:00
REM overwrite version.h
2021-08-07 17:06:45 +02:00
:got_version
if %version%==%VERSION_DEFAULT% goto :exit
2013-06-13 18:05:02 -07:00
echo #define %VERSION_NAME% "%version%" /* autogenerated */ >> %VERSION_FILE%
2013-06-13 18:05:02 -07:00
REM done
2013-06-13 18:05:02 -07:00
:exit