vgmstream/version.bat

54 lines
1.0 KiB
Batchfile
Raw Normal View History

2013-06-14 03:05:02 +02:00
@echo off
REM creates or updates version.h
REM params: $1=filename (usually version.h), $2=VARNAME (usually VERSION)
2013-06-14 03:05:02 +02:00
setlocal enableextensions enabledelayedexpansion
cd /d "%~dp0"
2015-08-31 03:43:50 +02:00
for /f %%v in ('git describe --always --tag') do set version=%%v
if not "%version%"=="" set version=!version:^:=_!
2013-06-14 03:05:02 +02:00
if not "%version%"=="" goto :gotversion
if exist "version.mk" goto :getversion
2013-06-14 03:05:02 +02:00
echo Git cannot be found, nor can version.mk. Generating unknown version.
set version=unknown
goto :gotversion
:getversion
for /f "delims== tokens=2" %%v in (version.mk) do set version=%%v
2013-06-14 03:05:02 +02:00
set version=!version:^"=!
set version=!version: =!
:gotversion
set version_out=#define %2 "%version%"
set version_mk=%2 = "%version%"
echo %version_out%> %1_temp
if %version%==unknown goto :skipgenerate
echo # static version string; update manually before and after every release.> "version.mk"
echo %version_mk%>> "version.mk"
2013-06-14 03:05:02 +02:00
:skipgenerate
echo n | comp %1_temp %1 > NUL 2> NUL
if not errorlevel 1 goto exit
copy /y %1_temp %1 > NUL 2> NUL
:exit
del %1_temp