-
Notifications
You must be signed in to change notification settings - Fork 39
/
build_deps.bat
363 lines (268 loc) · 11.6 KB
/
build_deps.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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
@echo off
setlocal EnableDelayedExpansion
rem Initialize environment variable defaults
call :SET_DEFAULTS
rem Process command line arguments first
goto :PROCESS_ARGUMENTS
:CONTINUE_FROM_PROCESS_ARGUMENTS
rem Build the environment and bail out if it fails
call :BUILD_ENVIRONMENT
if x%environment_built% == x goto :eof
%PROJECT_DRIVE%
mkdir %BUILD_DIR%
cd %BUILD_DIR%
echo Build Dependencies - Preparing to build
rem Uncomment once parameters are read, only delete in clean mode
rem cmd /c rd %VENDOR_DIR% /s /q
call :BUILD_BOOST
call :BUILD_TURTLE
call :BUILD_GLM
call :BUILD_ZLIB
call :BUILD_MYSQL_CONNECTOR_C
call :BUILD_MYSQL_CONNECTOR_CPP
rem ----------------------------------------------------------------------------
rem --- Start of SET_DEFAULTS --------------------------------------------------
:SET_DEFAULTS
set "PROJECT_BASE=%~dp0"
set "PROJECT_DRIVE=%~d0"
set "BUILD_DIR=%PROJECT_BASE%build\deps\"
set "VENDOR_DIR=%PROJECT_BASE%vendor\"
set MSVC_VERSION=11
set BOOST_VERSION=1.54.0
set BOOST_LOG_REVISION=737
set TURTLE_VERSION=1.2.0
set GLM_VERSION=0.9.4.1
set ZLIB_VERSION=1.2.7
set MYSQL_C_VERSION=6.0.2
set "WGET=%PROJECT_BASE%tools\windows\wget.exe"
set "ZIP=%PROJECT_BASE%tools\windows\7z.exe"
set VENDOR_PACKAGE=swganh-deps-vc11.7z
goto :eof
rem --- End of SET_DEFAULTS ----------------------------------------------------
rem ----------------------------------------------------------------------------
rem ----------------------------------------------------------------------------
rem --- Start of PROCESS_ARGUMENTS ---------------------------------------------
:PROCESS_ARGUMENTS
if "%~0" == "" goto :CONTINUE_FROM_PROCESS_ARGUMENTS
if "%~0" == "-h" (
echo msvc_build.cmd Help
echo.
echo " /clean Cleans all vendor files"
echo " /package Packages the vendor directory for distribution"
)
if "%~0" == "/clean" (
call :CLEAN_BUILD
goto :eof
)
if "%~0" == "/package" (
call :PACKAGE_DEPENDENCIES
goto :eof
)
shift
goto :PROCESS_ARGUMENTS
rem --- End of PROCESS_ARGUMENTS -----------------------------------------------
rem ----------------------------------------------------------------------------
rem ----------------------------------------------------------------------------
rem --- Start of CLEAN_BUILD ---------------------------------------------------
rem --- Cleans all output created by the build process, restoring the ---
rem --- project to it's original state like a fresh checkout. ---
:CLEAN_BUILD
echo Cleaning the project dependencies
if exist "%BUILD_DIR%" rmdir /S /Q "%BUILD_DIR%"
if exist "%VENDOR_DIR%" rmdir /S /Q "%VENDOR_DIR%"
goto :eof
rem --- End of CLEAN_BUILD -----------------------------------------------------
rem ----------------------------------------------------------------------------
rem ----------------------------------------------------------------------------
rem --- Start of PACKAGE_DEPENDENCIES ------------------------------------------
rem --- Packages the project dependencies for distribution ---------------------
:PACKAGE_DEPENDENCIES
echo Packaging the project dependencies
if not exist "%VENDOR_DIR%" (
echo ***** Dependencies not built *****
exit /b 1
)
if exist "%PROJECT_BASE%%VENDOR_PACKAGE%" (
del "%PROJECT_BASE%%VENDOR_PACKAGE%"
)
%ZIP% a "%PROJECT_BASE%%VENDOR_PACKAGE%" "%VENDOR_DIR%"
goto :eof
rem --- End of PACKAGE_DEPENDENCIES --------------------------------------------
rem ----------------------------------------------------------------------------
rem ----------------------------------------------------------------------------
rem --- Start of BUILD_ENVIRONMENT ---------------------------------------------
:BUILD_ENVIRONMENT
call where git /Q | findstr /c:"git.exe" >nul && (
echo ***** Git required and not found in system PATH *****
exit /b 1
)
echo"!VS%MSVC_VERSION%0COMNTOOLS!"
echo !VS%MSVC_VERSION%0COMNTOOLS!
if not exist "!VS%MSVC_VERSION%0COMNTOOLS!" (
echo ***** Microsoft Visual Studio %MSVC_VERSION% required *****
exit /b 1
)
call "!VS%MSVC_VERSION%0COMNTOOLS!\vsvars32.bat" >NUL
set environment_built=yes
goto :eof
rem --- End of BUILD_ENVIRONMENT -----------------------------------------------
rem ----------------------------------------------------------------------------
rem ----------------------------------------------------------------------------
rem --- Start of BUILD_BOOST ---------------------------------------------------
rem --- Builds the boost library for use with this project. ---
:BUILD_BOOST
echo BUILDING: Boost %BOOST_VERSION% - http://www.boost.org/
set BOOST_VERSION_ALT=!BOOST_VERSION:.=_!
set BOOST_FILE=boost_%BOOST_VERSION_ALT%.zip
set BOOST_URL=http://downloads.sourceforge.net/project/boost/boost/%BOOST_VERSION%/%BOOST_FILE%
set BOOST_DIR=boost_%BOOST_VERSION_ALT%
if not exist %BOOST_DIR% (
if not exist %BOOST_FILE% (
%WGET% --no-check-certificate !BOOST_URL!
)
%ZIP% x -y %BOOST_FILE%
)
cd "%BOOST_DIR%"
if not exist b2.exe (
cmd /c bootstrap.bat
)
cmd /c "b2.exe" --toolset=msvc-%MSVC_VERSION%.0 --with-serialization --with-iostreams --with-program_options --with-system --with-thread --with-filesystem --with-log --with-python --with-test --with-date_time variant=debug,release link=shared runtime-link=shared threading=multi define=HAVE_ROUND define=_SCL_SECURE_NO_WARNINGS=0
if not exist %VENDOR_DIR%include\boost (
xcopy "boost" "%VENDOR_DIR%include\boost" /s /i /y
xcopy "stage/lib" "%VENDOR_DIR%lib" /s /i /y
)
cd "%BUILD_DIR%"
goto :eof
rem --- End of BUILD_BOOST -----------------------------------------------------
rem ----------------------------------------------------------------------------
rem ----------------------------------------------------------------------------
rem --- Start of BUILD_TURTLE --------------------------------------------------
rem --- Builds the turtle library for use with this project. ---
:BUILD_TURTLE
echo BUILDING: Turtle %TURTLE_VERSION% - http://turtle.sourceforge.net/
set TURTLE_FILE=turtle-%TURTLE_VERSION%.zip
set TURTLE_URL=http://downloads.sourceforge.net/project/turtle/turtle/%TURTLE_VERSION%/%TURTLE_FILE%
set TURTLE_DIR=turtle-%TURTLE_VERSION%
if not exist %TURTLE_FILE% (
%WGET% --no-check-certificate !TURTLE_URL!
)
if not exist "%VENDOR_DIR%include\turtle" (
%ZIP% x -y %TURTLE_FILE% -O%VENDOR_DIR%
del %VENDOR_DIR%README.txt
)
cd "%BUILD_DIR%"
goto :eof
rem --- End of BUILD_TURTLE ----------------------------------------------------
rem ----------------------------------------------------------------------------
rem ----------------------------------------------------------------------------
rem --- Start of BUILD_GLM -----------------------------------------------------
rem --- Builds the glm library for use with this project. ---
:BUILD_GLM
echo BUILDING: GLM %GLM_VERSION% - http://glm.g-truc.net/
set GLM_FILE=glm-%GLM_VERSION%.zip
set GLM_URL=http://downloads.sourceforge.net/project/ogl-math/glm-%GLM_VERSION%/%GLM_FILE%
set GLM_DIR=glm-%GLM_VERSION%
if not exist %GLM_FILE% (
%WGET% --no-check-certificate !GLM_URL!
)
if not exist "%VENDOR_DIR%include\glm" (
%ZIP% x -y %GLM_FILE% -Oglm
xcopy "glm\glm" "%VENDOR_DIR%include\glm" /s /i /y
)
cd "%BUILD_DIR%"
goto :eof
rem --- End of BUILD_GLM -------------------------------------------------------
rem ----------------------------------------------------------------------------
rem ----------------------------------------------------------------------------
rem --- Start of BUILD_ZLIB ----------------------------------------------------
rem --- Builds the zlib library for use with this project. ---
:BUILD_ZLIB
echo BUILDING: zlib %ZLIB_VERSION% - http://www.zlib.net/
set ZLIB_VERSION_ALT=!ZLIB_VERSION:.=!
set ZLIB_FILE=zlib%ZLIB_VERSION_ALT%.zip
set ZLIB_URL=http://downloads.sourceforge.net/project/libpng/zlib/%ZLIB_VERSION%/%ZLIB_FILE%
set ZLIB_DIR=zlib-%ZLIB_VERSION%
if not exist %ZLIB_FILE% (
%WGET% --no-check-certificate !ZLIB_URL!
)
if not exist "%ZLIB_DIR%" (
%ZIP% x -y %ZLIB_FILE%
)
cd "%ZLIB_DIR%"
cmake -G"Visual Studio %MSVC_VERSION%" .
cmake --build . --target zlib --config Debug
cmake --build . --target zlib --config Release
if not exist "%VENDOR_DIR%include\zlib.h" (
xcopy "zlib.h" "%VENDOR_DIR%include" /s /i /y
xcopy "zconf.h" "%VENDOR_DIR%include" /s /i /y
xcopy "Debug" "%VENDOR_DIR%lib\Debug" /s /i /y
xcopy "Release" "%VENDOR_DIR%lib\Release" /s /i /y
)
cd "%BUILD_DIR%"
goto :eof
rem --- End of BUILD_ZLIB ------------------------------------------------------
rem ----------------------------------------------------------------------------
rem ----------------------------------------------------------------------------
rem --- Start of BUILD_MYSQL_CONNECTOR_C ---------------------------------------
rem --- Builds the mysql connector c library for use with this project. --------
:BUILD_MYSQL_CONNECTOR_C
echo BUILDING: Mysql Connector-C %MYSQL_C_VERSION% - http://mysql.com/
set MYSQL_C_FILE=mysql-connector-c-%MYSQL_C_VERSION%.zip
set MYSQL_C_URL=http://dev.mysql.com/get/Downloads/Connector-C/%MYSQL_C_FILE%/from/http://cdn.mysql.com/
set MYSQL_C_DIR=mysql-connector-c-%MYSQL_C_VERSION%
set MYSQL_C_CMAKE=%MYSQL_C_DIR%\CMakeLists.txt
if not exist %MYSQL_C_FILE% (
%WGET% --no-check-certificate !MYSQL_C_URL!
)
if not exist "%MYSQL_C_DIR%" (
%ZIP% x -y %MYSQL_C_FILE%
set search=STRING(REPLACE "/MD"
set replacement=# STRING(REPLACE "/MD"
for /f "tokens=* delims=," %%A in ('"type %MYSQL_C_DIR%\CMakeLists.txt"') do (
set "str=%%A"
set str=!str:STRING(REPLACE "/MD=# STRING(REPLACE "/MD!
echo.!str! >> %MYSQL_C_CMAKE%.tmp
)
if exist %MYSQL_C_CMAKE%.tmp (
del %MYSQL_C_CMAKE%
move %MYSQL_C_CMAKE%.tmp %MYSQL_C_CMAKE%
)
)
cd "%MYSQL_C_DIR%"
cmake -G"Visual Studio %MSVC_VERSION%" .
cmake --build . --target libmysql/mysqlclient --config Debug
cmake --build . --target libmysql/libmysql --config Debug
cmake --build . --target libmysql/mysqlclient --config Release
cmake --build . --target libmysql/libmysql --config Release
if not exist "%VENDOR_DIR%include\mysql.h" (
xcopy "include" "%VENDOR_DIR%include" /s /i /y
xcopy "libmysql/Debug" "%VENDOR_DIR%lib/Debug" /s /i /y
xcopy "libmysql/Release" "%VENDOR_DIR%lib/Release" /s /i /y
)
cd "%BUILD_DIR%"
goto :eof
rem --- End of BUILD_MYSQL_CONNECTOR_C -----------------------------------------
rem ----------------------------------------------------------------------------
rem ----------------------------------------------------------------------------
rem --- Start of BUILD_MYSQL_CONNECTOR_CPP -------------------------------------
rem --- Builds the mysql connector c++ library for use with this project. ------
:BUILD_MYSQL_CONNECTOR_CPP
echo BUILDING: Mysql Connector-C++ - http://mysql.com/
if not exist mysql-connector-cpp (
git clone https://github.com/anhstudios/mysql-connector-cpp.git
)
cd mysql-connector-cpp
cmake -G"Visual Studio %MSVC_VERSION%" -DBOOST_ROOT=%VENDOR_DIR% -DMYSQL_INCLUDE_DIR=%VENDOR_DIR%include -DMYSQL_LIB_DIR=%VENDOR_DIR%lib/Release .
cmake --build . --target driver/mysqlcppconn --config Debug
cmake --build . --target driver/mysqlcppconn --config Release
if not exist "%VENDOR_DIR%include\cppconn" (
xcopy "cppconn" "%VENDOR_DIR%include\cppconn" /s /i /y
xcopy "driver\mysql_driver.h" "%VENDOR_DIR%include" /s /i /y
xcopy "driver\mysql_connection.h" "%VENDOR_DIR%include" /s /i /y
xcopy "driver\Debug" "%VENDOR_DIR%lib\Debug" /s /i /y
xcopy "driver\Release" "%VENDOR_DIR%lib\Release" /s /i /y
)
cd "%BUILD_DIR%"
goto :eof
rem --- End of BUILD_MYSQL_CONNECTOR_CPP ---------------------------------------
rem ----------------------------------------------------------------------------