Vignesh Venkatasubramanian | 2bd8b54 | 2014-02-20 10:50:35 -0800 | [diff] [blame] | 1 | @echo off |
| 2 | |
| 3 | setlocal enableextensions enabledelayedexpansion |
| 4 | |
| 5 | for /f %%v in ('git --git-dir="%~dp0..\.git" describe --tags --match "v*"') do set version=%%v |
| 6 | |
| 7 | if not "%version%"=="" goto :gotversion |
| 8 | |
| 9 | if exist "%~dp0..\version.mk" goto :getversion |
| 10 | |
| 11 | echo Git cannot be found, nor can version.mk. Generating unknown version. |
| 12 | |
| 13 | set version=unknown |
| 14 | |
| 15 | goto :gotversion |
| 16 | |
| 17 | :getversion |
| 18 | |
| 19 | for /f "delims== tokens=2" %%v in (%~dps0..\version.mk) do set version=%%v |
| 20 | |
| 21 | set version=!version:^"=! |
| 22 | set version=!version: =! |
| 23 | |
| 24 | :gotversion |
| 25 | |
flim | c91ee5b | 2016-01-26 14:33:44 +0100 | [diff] [blame] | 26 | set version_out=#define %~2 "%version%" |
| 27 | set version_mk=%~2 = "%version%" |
Vignesh Venkatasubramanian | 2bd8b54 | 2014-02-20 10:50:35 -0800 | [diff] [blame] | 28 | |
flim | c91ee5b | 2016-01-26 14:33:44 +0100 | [diff] [blame] | 29 | echo %version_out%> "%~1_temp" |
Vignesh Venkatasubramanian | 2bd8b54 | 2014-02-20 10:50:35 -0800 | [diff] [blame] | 30 | |
| 31 | if %version%==unknown goto :skipgenerate |
| 32 | |
| 33 | echo # static version string; update manually every release.> "%~dp0..\version.mk" |
| 34 | echo %version_mk%>> "%~dp0..\version.mk" |
| 35 | |
| 36 | :skipgenerate |
| 37 | |
flim | c91ee5b | 2016-01-26 14:33:44 +0100 | [diff] [blame] | 38 | echo n | comp "%~1_temp" "%~1" > NUL 2> NUL |
Vignesh Venkatasubramanian | 2bd8b54 | 2014-02-20 10:50:35 -0800 | [diff] [blame] | 39 | |
| 40 | if not errorlevel 1 goto exit |
| 41 | |
flim | c91ee5b | 2016-01-26 14:33:44 +0100 | [diff] [blame] | 42 | copy /y "%~1_temp" "%~1" |
Vignesh Venkatasubramanian | 2bd8b54 | 2014-02-20 10:50:35 -0800 | [diff] [blame] | 43 | |
| 44 | :exit |
| 45 | |
flim | c91ee5b | 2016-01-26 14:33:44 +0100 | [diff] [blame] | 46 | del "%~1_temp" |