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