2013-06-13 18:05:02 -07:00
|
|
|
@echo off
|
2021-08-08 13:30:21 +02:00
|
|
|
setlocal enableextensions enabledelayedexpansion
|
2013-06-13 18:05:02 -07:00
|
|
|
|
2017-01-15 23:09:37 +01:00
|
|
|
REM creates or updates version.h
|
2021-08-08 13:30:21 +02:00
|
|
|
REM params: $1=filename (usually version.h), $2=VARNAME (usually VGMSTREAM_VERSION)
|
2017-01-15 23:09:37 +01:00
|
|
|
|
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
|
2021-08-07 20:41:50 +02:00
|
|
|
if "%~2" == "" set VERSION_NAME=VGMSTREAM_VERSION
|
2015-08-30 18:43:50 -07:00
|
|
|
|
2016-11-12 15:53:29 +01: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
|
|
|
|
|
|
|
|
2021-08-08 13:30:21 +02: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
|
2021-08-08 13:30:21 +02:00
|
|
|
goto :exit
|
2013-06-13 18:05:02 -07:00
|
|
|
|
|
|
|
|
2021-08-08 13:30:21 +02:00
|
|
|
REM overwrite version.h
|
2021-08-07 17:06:45 +02:00
|
|
|
:got_version
|
2021-08-08 13:30:21 +02:00
|
|
|
if %version%==%VERSION_DEFAULT% goto :exit
|
2013-06-13 18:05:02 -07:00
|
|
|
|
2021-08-08 13:30:21 +02:00
|
|
|
echo #define %VERSION_NAME% "%version%" /* autogenerated */ >> %VERSION_FILE%
|
2013-06-13 18:05:02 -07:00
|
|
|
|
|
|
|
|
2021-08-08 13:30:21 +02:00
|
|
|
REM done
|
2013-06-13 18:05:02 -07:00
|
|
|
:exit
|