mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 00:20:47 +01:00
0b14f9a446
- version.h is now static (should increase on new releases) - if compiler flag is passed, will try to use version_auto.h (autogen) (auto only on compiler flag to avoid include'ing a non-existant file) - avoid clobbered version.h as may force recompiles
49 lines
1.2 KiB
Batchfile
49 lines
1.2 KiB
Batchfile
@echo off
|
|
setlocal enableextensions enabledelayedexpansion
|
|
|
|
REM creates or updates version_auto.h
|
|
REM params: $1=filename (usually version_auto.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_auto.h
|
|
if "%~2" == "" set VERSION_NAME=VGMSTREAM_VERSION
|
|
|
|
if not "%VERSION%"=="" set VERSION=!VERSION:^:=_!
|
|
|
|
cd /d "%~dp0"
|
|
|
|
|
|
REM try get version from Git (dynamic)
|
|
:get_version_git
|
|
for /f %%v in ('git describe --always') do set VERSION=%%v
|
|
if not "%VERSION%"=="" set VERSION=!VERSION:^:=_!
|
|
if "%VERSION%"=="" goto :get_version_h
|
|
if %VERSION%==%VERSION_DEFAULT% goto :get_version_h
|
|
set LINE=#define %VERSION_NAME% "%VERSION%" /* autogenerated */
|
|
echo %LINE% > %VERSION_FILE%
|
|
goto :exit
|
|
|
|
|
|
REM try to get version from version.h (static)
|
|
:get_version_h
|
|
echo Git version not found, can't autogenerate version_auto.h
|
|
set LINE=#define %VERSION_NAME% "%VERSION_DEFAULT%" /* autogenerated */
|
|
if exist "version.h" (
|
|
for /F "tokens=*" %%v in (version.h) do (
|
|
set TOKEN=%%v
|
|
REM set COMP=#define %VERSION_NAME% #todo
|
|
if /i "!TOKEN:~0,25!"=="#define VGMSTREAM_VERSION" set LINE=%%v
|
|
)
|
|
)
|
|
|
|
echo %LINE% > %VERSION_FILE%
|
|
goto :exit
|
|
|
|
|
|
REM done
|
|
:exit
|