forked from treefrogframework/treefrog-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.bat
234 lines (210 loc) · 6.89 KB
/
configure.bat
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
@echo OFF
@setlocal
set VERSION=1.29.0
set TFDIR=C:\TreeFrog\%VERSION%
set MONBOC_VERSION=1.9.5
set LZ4_VERSION=1.9.2
set BASEDIR=%~dp0
:parse_loop
if "%1" == "" goto :start
if /i "%1" == "--prefix" goto :prefix
if /i "%1" == "--enable-debug" goto :enable_debug
if /i "%1" == "--enable-gui-mod" goto :enable_gui_mod
if /i "%1" == "--help" goto :help
if /i "%1" == "-h" goto :help
goto :help
:continue
shift
goto :parse_loop
:help
echo Usage: %0 [OPTION]... [VAR=VALUE]...
echo;
echo Configuration:
echo -h, --help display this help and exit
echo --enable-debug compile with debugging information
echo --enable-gui-mod compile and link with QtGui module
echo;
echo Installation directories:
echo --prefix=PREFIX install files in PREFIX [%TFDIR%]
goto :exit
:prefix
shift
if "%1" == "" goto :help
set TFDIR=%1
goto :continue
:enable_debug
set DEBUG=yes
goto :continue
:enable_gui_mod
set USE_GUI=use_gui=1
goto :continue
:start
if "%DEBUG%" == "yes" (
set OPT="CONFIG+=debug"
) else (
set OPT="CONFIG+=release"
)
::
:: Generates tfenv.bat
::
for %%I in (qmake.exe) do if exist %%~$path:I set QMAKE=%%~$path:I
for %%I in (cmake.exe) do if exist %%~$path:I set CMAKE=%%~$path:I
for %%I in (cl.exe) do if exist %%~$path:I set MSCOMPILER=%%~$path:I
for %%I in (devenv.exe) do if exist %%~$path:I set DEVENV=%%~$path:I
if "%QMAKE%" == "" (
echo Qt environment not found
exit /b
)
if "%CMAKE%" == "" (
echo CMake not found
exit /b
)
if "%MSCOMPILER%" == "" if "%DEVENV%" == "" (
echo MSVC Compiler not found
exit /b
)
:: get qt install prefix
for /f usebackq %%I in (`qtpaths.exe --install-prefix`) do (
set QT_INSTALL_PREFIX=%%I
goto :break
)
:break
:: vcvarsall.bat setup
set MAKE=nmake
if /i "%Platform%" == "x64" (
set VCVARSOPT=amd64
set BUILDTARGET=x64
set ENVSTR=Environment to build for 64-bit executable MSVC / Qt
) else (
set VCVARSOPT=x86
set BUILDTARGET=win32
set ENVSTR=Environment to build for 32-bit executable MSVC / Qt
)
echo %QT_INSTALL_PREFIX% | find "msvc2015" >NUL
if not ERRORLEVEL 1 (
set VSVER=2015
if /i "%Platform%" == "x64" (
set CMAKEOPT=Visual Studio 14 2015 Win64
) else (
set CMAKEOPT=Visual Studio 14 2015
)
) else (
set VSVER=2017
if /i "%Platform%" == "x64" (
set CMAKEOPT=Visual Studio 15 2017 Win64
) else (
set CMAKEOPT=Visual Studio 15 2017
)
)
SET /P X="%ENVSTR%"<NUL
qtpaths.exe --qt-version
for %%I in (qtenv2.bat) do if exist %%~$path:I set QTENV=%%~$path:I
set TFENV=tfenv.bat
echo @echo OFF> %TFENV%
echo ::>> %TFENV%
echo :: This file is generated by configure.bat>> %TFENV%
echo ::>> %TFENV%
echo;>> %TFENV%
echo set TFDIR=%TFDIR%>> %TFENV%
echo set TreeFrog_DIR=%TFDIR%>> %TFENV%
echo set QTENV="%QTENV%">> %TFENV%
echo set QMAKESPEC=%QMAKESPEC%>> %TFENV%
echo set VCVARSBAT="">> %TFENV%
echo set VSVER=%VSVER%>> %TFENV%
echo set VSWHERE="%%ProgramFiles(x86)%%\Microsoft Visual Studio\Installer\vswhere.exe">> %TFENV%
echo;>> %TFENV%
echo if exist %%QTENV%% call %%QTENV%%>> %TFENV%
echo if exist %%VSWHERE%% ^(>> %TFENV%
echo for /f "usebackq tokens=*" %%%%i in ^(`%%VSWHERE%% -find **\vcvarsall.bat`^) do ^(>> %TFENV%
echo echo %%%%i ^| find "%%VSVER%%" ^>NUL>> %TFENV%
echo if not ERRORLEVEL 1 ^(>> %TFENV%
echo set VCVARSBAT="%%%%i">> %TFENV%
echo goto :break>> %TFENV%
echo ^)>> %TFENV%
echo ^)>> %TFENV%
echo ^)>> %TFENV%
echo :break>> %TFENV%
echo if not exist %%VCVARSBAT%% ^(>> %TFENV%
echo if not "%%VS140COMNTOOLS%%" == "" ^(>> %TFENV%
echo set VCVARSBAT="%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat">> %TFENV%
echo ^) else if not "%%VS120COMNTOOLS%%" == "" ^(>> %TFENV%
echo set VCVARSBAT="%%VS120COMNTOOLS%%..\..\VC\vcvarsall.bat">> %TFENV%
echo ^) else ^(>> %TFENV%
echo set VCVARSBAT="">> %TFENV%
echo ^)>> %TFENV%
echo ^)>> %TFENV%
echo if exist %%VCVARSBAT%% ^(>> %TFENV%
echo echo Setting up environment for MSVC usage...>> %TFENV%
echo call %%VCVARSBAT%% %VCVARSOPT%>> %TFENV%
echo ^)>> %TFENV%
echo set PATH=%%TFDIR^%%\bin;%%PATH%%>> %TFENV%
echo echo Setup a TreeFrog/Qt environment.>> %TFENV%
echo echo -- TFDIR set to %%TFDIR%%>> %TFENV%
echo cd /D %%HOMEDRIVE%%%%HOMEPATH%%>> %TFENV%
set TFDIR=%TFDIR:\=/%
del /f /q .qmake.stash src\.qmake.stash tools\.qmake.stash >nul 2>&1
:: Builds MongoDB driver
cd /d %BASEDIR%3rdparty
rd /s /q mongo-driver >nul 2>&1
del /f /q mongo-driver >nul 2>&1
mklink /j mongo-driver mongo-c-driver-%MONBOC_VERSION% >nul 2>&1
cd %BASEDIR%3rdparty\mongo-driver\src\libbson
del /f /q CMakeCache.txt cmake_install.cmake CMakeFiles Makefile >nul 2>&1
cmake -G"%CMAKEOPT%" -DCMAKE_CONFIGURATION_TYPES=Release -DENABLE_STATIC=ON -DENABLE_TESTS=OFF .
echo Compiling BSON library ...
devenv libbson.sln /project bson_static /rebuild Release >nul 2>&1
if ERRORLEVEL 1 (
:: Shows error
devenv libbson.sln /project bson_static /build Release
echo;
echo Build failed.
echo MongoDB driver not available.
exit /b
)
cd %BASEDIR%3rdparty\mongo-driver
del /f /q CMakeCache.txt cmake_install.cmake CMakeFiles Makefile >nul 2>&1
echo cmake -G"%CMAKEOPT%" -DCMAKE_CONFIGURATION_TYPES=Release -DENABLE_STATIC=ON -DENABLE_SSL=OFF -DENABLE_SNAPPY=OFF -DENABLE_SRV=OFF -DENABLE_SASL=OFF -DENABLE_ZLIB=OFF -DENABLE_TESTS=OFF .
cmake -G"%CMAKEOPT%" -DCMAKE_CONFIGURATION_TYPES=Release -DENABLE_STATIC=ON -DENABLE_SSL=OFF -DENABLE_SNAPPY=OFF -DENABLE_SRV=OFF -DENABLE_SASL=OFF -DENABLE_ZLIB=OFF -DENABLE_TESTS=OFF .
echo Compiling MongoDB driver library ...
devenv libmongoc.sln /project mongoc_static /rebuild Release >nul 2>&1
if ERRORLEVEL 1 (
:: Shows error
devenv libmongoc.sln /project mongoc_static /build Release
echo;
echo Build failed.
echo MongoDB driver not available.
exit /b
)
:: Builds LZ4
cd %BASEDIR%3rdparty
echo Compiling LZ4 library ...
rd /s /q lz4 >nul 2>&1
del /f /q lz4 >nul 2>&1
mklink /j lz4 lz4-%LZ4_VERSION% >nul 2>&1
for /F %%i in ('qtpaths.exe --install-prefix') do echo %%i | find "msvc2015" >NUL
if not ERRORLEVEL 1 (
set VS=VS2015
) else (
set VS=VS2017
)
devenv lz4\visual\%VS%\lz4.sln /project liblz4 /rebuild "Release|%BUILDTARGET%" >nul 2>&1
if ERRORLEVEL 1 (
:: Shows error
devenv lz4\visual\%VS%\lz4.sln /project liblz4 /build "Release|%BUILDTARGET%"
echo;
echo Build failed.
echo LZ4 not available.
exit /b
)
cd %BASEDIR%src
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )
qmake %OPT% target.path='%TFDIR%/bin' header.path='%TFDIR%/include' %USE_GUI%
cd %BASEDIR%tools
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )
qmake -recursive %OPT% target.path='%TFDIR%/bin' header.path='%TFDIR%/include' datadir='%TFDIR%'
%MAKE% qmake
echo;
echo First, run "%MAKE% install" in src directory.
echo Next, run "%MAKE% install" in tools directory.
:exit
exit /b