Added Git version generator

This commit is contained in:
Chris Moeller 2013-06-13 18:05:02 -07:00
parent 71e5f6aeb0
commit 07107c66e7
2 changed files with 54 additions and 0 deletions

View File

@ -83,6 +83,12 @@
<DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PreBuildEvent>
<Command>"$(ProjectDir)genversion.bat" "$(ProjectDir)version.h" VERSION</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generating version.h</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>

48
fb2k/genversion.bat Normal file
View File

@ -0,0 +1,48 @@
@echo off
setlocal enableextensions enabledelayedexpansion
cd /d "%~dp0"
for /f %%v in ('git describe --tags --match "r*"') do set version=%%v
if not "%version%"=="" goto :gotversion
if exist "..\version.mk" goto :getversion
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
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"
: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