blob: a9b9353a71ebfa2b64b2a40753f2dc624f768ce9 [file] [log] [blame]
Alexandre Lision744f7422013-09-25 11:39:37 -04001@echo off
2
3setlocal enableextensions enabledelayedexpansion
4
Alexandre Lision85382382014-01-27 15:54:16 -05005for /f %%v in ('git --git-dir="%~dp0..\.git" describe --tags --match "v*"') do set version=%%v
Alexandre Lision744f7422013-09-25 11:39:37 -04006
7if not "%version%"=="" goto :gotversion
8
9if exist "%~dp0..\version.mk" goto :getversion
10
11echo Git cannot be found, nor can version.mk. Generating unknown version.
12
13set version=unknown
14
15goto :gotversion
16
17:getversion
18
Alexandre Lision85382382014-01-27 15:54:16 -050019for /f "delims== tokens=2" %%v in (%~dps0..\version.mk) do set version=%%v
Alexandre Lision744f7422013-09-25 11:39:37 -040020
21set version=!version:^"=!
22set version=!version: =!
23
24:gotversion
25
26set version_out=#define %2 "%version%"
27set version_mk=%2 = "%version%"
28
Alexandre Lision85382382014-01-27 15:54:16 -050029echo %version_out%> "%1_temp"
Alexandre Lision744f7422013-09-25 11:39:37 -040030
31if %version%==unknown goto :skipgenerate
32
33echo # static version string; update manually every release.> "%~dp0..\version.mk"
34echo %version_mk%>> "%~dp0..\version.mk"
35
36:skipgenerate
37
Alexandre Lision85382382014-01-27 15:54:16 -050038echo n | comp "%1_temp" "%1" > NUL 2> NUL
Alexandre Lision744f7422013-09-25 11:39:37 -040039
40if not errorlevel 1 goto exit
41
Alexandre Lision85382382014-01-27 15:54:16 -050042copy /y "%1_temp" "%1"
Alexandre Lision744f7422013-09-25 11:39:37 -040043
44:exit
45
Alexandre Lision85382382014-01-27 15:54:16 -050046del "%1_temp"