mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-24 15:00:11 +01:00
39 lines
905 B
Batchfile
39 lines
905 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 cannot be 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
|