-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathgetrev2.cmd
56 lines (46 loc) · 1.95 KB
/
getrev2.cmd
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
48
49
50
51
52
53
54
55
56
@echo off
:: Some SVN clients can use localized messages (e.g. SlikSVN), force English
set LC_ALL=C
set svn_revision=
set use_svn_versions=
set version_cpp=
for /f "tokens=2" %%i in ('svn info ^| find /I "Revision:"') do set svn_revision=%%i
if "%svn_revision%"=="" (
set svn_revision=UNKNOWN
echo Unknown SVN revision. SVN missing in PATH or not a working copy.
) else (
echo SVN Revision: %svn_revision%
)
echo.
echo #define SVN_REVISION "%svn_revision%">src\svn_revision.h
:: Get values of USE_SVN_VERSIONS & DEVELOPMENT_VERSION & VERSION
for /f "tokens=3" %%j in ('type src\version.cpp ^| find /I "#define USE_SVN_VERSIONS"') do set use_svn_versions=%%j
for /f "tokens=3" %%k in ('type src\version.cpp ^| find /I "#define DEVELOPMENT_VERSION"') do set development_version=%%k
for /f "tokens=3" %%l in ('type src\version.cpp ^| find /I "#define VERSION"') do set version_cpp=%%l
:: Remove quotes
setlocal enableDelayedExpansion
for /f "delims=" %%A in ("!use_svn_versions!") do endlocal & set "use_svn_versions=%%~A"
setlocal enableDelayedExpansion
for /f "delims=" %%A in ("!development_version!") do endlocal & set "development_version=%%~A"
setlocal enableDelayedExpansion
for /f "delims=" %%A in ("!version_cpp!") do endlocal & set "version_cpp=%%~A"
:: Verify svn revision & version are actually numbers and version has at least ver_major.ver_minor.ver_build
if defined development_version (
echo %svn_revision%|findstr /r /c:"^[0-9][0-9]*$" >nul
if errorlevel 1 (set development_version=)
)
if defined version_cpp (
echo %version_cpp%|findstr /r /c:"^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$" >nul
if errorlevel 1 (set version_cpp=)
)
if defined version_cpp (
if [%development_version%]==[1] (
echo %version_cpp%.%svn_revision%>setup\scripts\pkg_version
) else (
echo %version_cpp%>setup\scripts\pkg_version
)
)
set svn_revision=
set development_version=
set use_svn_versions=
set version_cpp=