blob: cd1d4dce6ed8f5486ee31a3f5a14dab8bc038e0c [file] [log] [blame]
Vignesh Venkatasubramanian2bd8b542014-02-20 10:50:35 -08001@echo off
2
3setlocal enableextensions enabledelayedexpansion
4
5for /f %%v in ('git --git-dir="%~dp0..\.git" describe --tags --match "v*"') do set version=%%v
6
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
19for /f "delims== tokens=2" %%v in (%~dps0..\version.mk) do set version=%%v
20
21set version=!version:^"=!
22set version=!version: =!
23
24:gotversion
25
flimc91ee5b2016-01-26 14:33:44 +010026set version_out=#define %~2 "%version%"
27set version_mk=%~2 = "%version%"
Vignesh Venkatasubramanian2bd8b542014-02-20 10:50:35 -080028
flimc91ee5b2016-01-26 14:33:44 +010029echo %version_out%> "%~1_temp"
Vignesh Venkatasubramanian2bd8b542014-02-20 10:50:35 -080030
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
flimc91ee5b2016-01-26 14:33:44 +010038echo n | comp "%~1_temp" "%~1" > NUL 2> NUL
Vignesh Venkatasubramanian2bd8b542014-02-20 10:50:35 -080039
40if not errorlevel 1 goto exit
41
flimc91ee5b2016-01-26 14:33:44 +010042copy /y "%~1_temp" "%~1"
Vignesh Venkatasubramanian2bd8b542014-02-20 10:50:35 -080043
44:exit
45
flimc91ee5b2016-01-26 14:33:44 +010046del "%~1_temp"