Home | History | Annotate | Download | only in win32
      1 @echo off
      2 
      3 setlocal enableextensions enabledelayedexpansion
      4 
      5 for /f %%v in ('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 (%~dp0..\version.mk) do set version=%%v
     20 
     21 set version=!version:^"=!
     22 set version=!version: =!
     23 
     24 :gotversion
     25 
     26 set version_out=#define %2 "%version%"
     27 set version_mk=%2 = "%version%"
     28 
     29 echo %version_out%> %1_temp
     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 
     38 echo n | comp %1_temp %1 > NUL 2> NUL
     39 
     40 if not errorlevel 1 goto exit
     41 
     42 copy /y %1_temp %1
     43 
     44 :exit
     45 
     46 del %1_temp
     47