genversion.bat 880 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. @echo off
  2. setlocal enableextensions enabledelayedexpansion
  3. for /f %%v in ('git describe --tags --match "v*"') do set version=%%v
  4. if not "%version%"=="" goto :gotversion
  5. if exist "%~dp0..\version.mk" goto :getversion
  6. echo Git cannot be found, nor can version.mk. Generating unknown version.
  7. set version=unknown
  8. goto :gotversion
  9. :getversion
  10. for /f "delims== tokens=2" %%v in (%~dp0..\version.mk) do set version=%%v
  11. set version=!version:^"=!
  12. set version=!version: =!
  13. :gotversion
  14. set version_out=#define %2 "%version%"
  15. set version_mk=%2 = "%version%"
  16. echo %version_out%> %1_temp
  17. if %version%==unknown goto :skipgenerate
  18. echo # static version string; update manually every release.> "%~dp0..\version.mk"
  19. echo %version_mk%>> "%~dp0..\version.mk"
  20. :skipgenerate
  21. echo n | comp %1_temp %1 > NUL 2> NUL
  22. if not errorlevel 1 goto exit
  23. copy /y %1_temp %1
  24. :exit
  25. del %1_temp