2013-02-16 09:23:32 +01:00
|
|
|
@echo off
|
|
|
|
|
|
|
|
setlocal enableextensions enabledelayedexpansion
|
|
|
|
|
2013-12-21 14:40:43 +01:00
|
|
|
for /f %%v in ('git --git-dir="%~dp0..\.git" describe --tags --match "v*"') do set version=%%v
|
2013-02-16 09:23:32 +01:00
|
|
|
|
|
|
|
if not "%version%"=="" goto :gotversion
|
|
|
|
|
|
|
|
if exist "%~dp0..\version.mk" goto :getversion
|
|
|
|
|
|
|
|
echo Git cannot be found, nor can version.mk. Generating unknown version.
|
|
|
|
|
|
|
|
set version=unknown
|
|
|
|
|
|
|
|
goto :gotversion
|
|
|
|
|
|
|
|
:getversion
|
|
|
|
|
2013-12-21 14:40:43 +01:00
|
|
|
for /f "delims== tokens=2" %%v in (%~dps0..\version.mk) do set version=%%v
|
2013-02-16 09:23:32 +01:00
|
|
|
|
|
|
|
set version=!version:^"=!
|
|
|
|
set version=!version: =!
|
|
|
|
|
|
|
|
:gotversion
|
|
|
|
|
|
|
|
set version_out=#define %2 "%version%"
|
|
|
|
set version_mk=%2 = "%version%"
|
|
|
|
|
2013-12-21 14:40:43 +01:00
|
|
|
echo %version_out%> "%1_temp"
|
2013-02-16 09:23:32 +01:00
|
|
|
|
|
|
|
if %version%==unknown goto :skipgenerate
|
|
|
|
|
|
|
|
echo # static version string; update manually every release.> "%~dp0..\version.mk"
|
|
|
|
echo %version_mk%>> "%~dp0..\version.mk"
|
|
|
|
|
|
|
|
:skipgenerate
|
|
|
|
|
2013-12-21 14:40:43 +01:00
|
|
|
echo n | comp "%1_temp" "%1" > NUL 2> NUL
|
2013-02-16 09:23:32 +01:00
|
|
|
|
|
|
|
if not errorlevel 1 goto exit
|
|
|
|
|
2013-12-21 14:40:43 +01:00
|
|
|
copy /y "%1_temp" "%1"
|
2013-02-16 09:23:32 +01:00
|
|
|
|
|
|
|
:exit
|
|
|
|
|
2013-12-21 14:40:43 +01:00
|
|
|
del "%1_temp"
|