summaryrefslogtreecommitdiff
path: root/build/make_ver_stable.bat
blob: fd555bc0e2e8e80bcc6e1650f61a1a58dada427a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@echo off
cd /d %~dp0

for /F "tokens=2,3" %%i in (..\include\m_version.h) do if "%%i"=="MIRANDA_VERSION_FILEVERSION" (set OldVer=%%j)
for /F %%i in ('git rev-list --count HEAD') do set Revision=%%i
for /F %%i in ('git rev-parse --short HEAD') do set Hash=%%i

REM Fix building not-svn repository (e.g., Git mirror)
if "%Revision:~0,11%" == "Unversioned" (set Revision=0)
REM Fix building when svnversion tool is not installed
if "%Revision%" == "" (set Revision=0)
REM Fix trailing 'M', when the working copy contains modifications
if "%Revision:~-1%" == "M" (set Revision=%Revision:~0,-1%)

for /F "tokens=1,2,3,4 delims= " %%i in (build.no.stable) do call :WriteVer %%i %%j %%k %Revision% %Hash% %%l
goto :eof

:WriteVer
echo %1.%2.%3.%4.%5.%6
if "%OldVer%" == "%1,%2,%3,%4" (goto :eof)

for /f "delims=/ tokens=1-3" %%a in ("%DATE:~4%") do (
	for /f "delims=:. tokens=1-4" %%m in ("%TIME: =0%") do (
		set TempFileName=%TEMP%\basename-%%c-%%b-%%a-%%m%%n%%o%%p
	)
)

copy m_version.h.in "%TempFileName%"

if "%6" == "" (
  set FullVersion=%1.%2.%3
) else (
  set FullVersion=%1.%2.%3.%6
)

echo #define MIRANDA_VERSION_COREVERSION %1,%2,%3,0                                >> "%TempFileName%"
echo #define MIRANDA_VERSION_FILEVERSION %1,%2,%3,%4                               >> "%TempFileName%"
echo #define MIRANDA_VERSION_STRING      "%1.%2.%3.%4"                             >> "%TempFileName%"
echo #define MIRANDA_VERSION_DISPLAY     "%FullVersion% build #%4 (%5)"            >> "%TempFileName%"
echo #define MIRANDA_VERSION_DWORD       MIRANDA_MAKE_VERSION(%1, %2, %3, %4)      >> "%TempFileName%"
echo #define MIRANDA_VERSION_CORE        MIRANDA_MAKE_VERSION(%1, %2, %3, 0)       >> "%TempFileName%"
echo #define MIRANDA_VERSION_CORE_STRING "%FullVersion%"                           >> "%TempFileName%"
echo.                                                                              >> "%TempFileName%"
echo #endif // M_VERSION_H__                                                       >> "%TempFileName%"

move /Y "%TempFileName%" ..\include\m_version.h
goto :eof