ref: 9322362b1ba88aa1a0216bd7dea3c2fb1e5cdca9
parent: 9a35da465900363e610700a53401ea8e400f1db1
author: Chris Moeller <[email protected]>
date: Thu Aug 16 05:16:18 EDT 2012
Updated Win32 genversion.bat to generate version.mk if Git is found, use it if it isn't, and produce unknown version and leave it untouched if it isn't already found
--- a/win32/genversion.bat
+++ b/win32/genversion.bat
@@ -1,10 +1,38 @@
@echo off
+setlocal enableextensions enabledelayedexpansion
+
for /f %%v in ('git describe --tags --match "v*"') do set version=%%v
+if not "%version%"=="" goto :gotversion
+
+if exist "%~dp0..\version.mk" goto :getversion
+
+echo Git cannot be found, nor can version.mk. Generating unknown version.
+
+set version=unknown
+
+goto :gotversion
+
+:getversion
+
+for /f "delims== tokens=2" %%v in (%~dp0..\version.mk) do set version=%%v
+
+set version=!version:^"=!
+set version=!version: =!
+
+:gotversion
+
set version_out=#define %2 "%version%"
+set version_mk=%2 = "%version%"
-echo %version_out% > %1_temp
+echo %version_out%> %1_temp
+
+if %version%==unknown goto :skipgenerate
+
+echo %version_mk%> "%~dp0..\version.mk"
+
+:skipgenerate
echo n | comp %1_temp %1 > NUL 2> NUL