This repository was archived by the owner on Mar 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinstall_3rdparty-win.py
353 lines (292 loc) · 12.1 KB
/
install_3rdparty-win.py
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
#!/usr/bin/env python
import os, sys, subprocess, inspect, shutil, glob, optparse
ROOTDIR = os.path.abspath(os.path.dirname(inspect.getframeinfo(inspect.currentframe())[0]))
WAFPATH = os.path.join(ROOTDIR, 'var', 'waf')
LIBDIR = ''
INCLUDEDIR = ''
BINDIR = ''
PREFIX = ROOTDIR
ARCH = ''
MSVC = ''
def log(msg):
sys.stdout.write(msg)
sys.stdout.flush()
def get_msvctarget():
global ARCH
vctarget = ''
if ARCH == 'x64': vctarget='x86_amd64' # use cross-compiler for compatibility
elif ARCH == 'x86': vctarget='x86'
return vctarget
def get_msvccompiler():
global MSVC
compilers = {'9': 'msvc 9.0', '10': 'msvc 10.0', '11': 'msvc 11.0', '12': 'msvc 12.0'}
return compilers[MSVC]
def install_lua():
lua_srcfiles = {\
'x86-vc12': 'http://sourceforge.net/projects/luabinaries/files/5.2.1/Windows%20Libraries/Dynamic/lua-5.2.1_Win32_dll12_lib.zip/download',
'x64-vc12': 'http://sourceforge.net/projects/luabinaries/files/5.2.1/Windows%20Libraries/Dynamic/lua-5.2.1_Win64_dll12_lib.zip/download',
'x64-vc11': 'http://sourceforge.net/projects/luabinaries/files/5.2.1/Windows%20Libraries/Dynamic/lua-5.2.1_Win64_dll11_lib.zip/download',
'x86-vc11': 'http://sourceforge.net/projects/luabinaries/files/5.2.1/Windows%20Libraries/Dynamic/lua-5.2.1_Win32_dll11_lib.zip/download',
'x86-vc9': 'http://sourceforge.net/projects/luabinaries/files/5.2.1/Windows%20Libraries/Dynamic/lua-5.2.1_Win32_dll9_lib.zip/download',
'x64-vc9': 'http://sourceforge.net/projects/luabinaries/files/5.2.1/Windows%20Libraries/Dynamic/lua-5.2.1_Win64_dll9_lib.zip/download',
'x64-vc10': 'http://sourceforge.net/projects/luabinaries/files/5.2.1/Windows%20Libraries/Dynamic/lua-5.2.1_Win64_dll10_lib.zip/download',
'x86-vc10': 'http://sourceforge.net/projects/luabinaries/files/5.2.1/Windows%20Libraries/Dynamic/lua-5.2.1_Win32_dll10_lib.zip/download'
}
luadir = os.path.join(ROOTDIR, '3rdparty', 'tmp', 'lua')
libfile = os.path.join(LIBDIR, 'lua.lib')
log('looking for lua...')
if os.path.isfile(libfile):
log('\t\tfound\n')
return True
log('\t\tnot found\n')
url = lua_srcfiles[ARCH + '-vc' + MSVC]
log('downloading lua binaries from "http://sourceforge.net/projects/luabinaries"...\n')
log('')
os.makedirs(luadir, exist_ok=True)
os.chdir(luadir)
if os.system('wget -N --no-check-certificate {0}'.format(url)) != 0:
os.chdir(ROOTDIR)
return False
# extract file name from url
urlsplit = url.split('/')
filename = ''
for u in urlsplit:
if '.zip' in u:
filename = u
break
if os.system('unzip -o ' + filename) != 0:
os.chdir(ROOTDIR)
return False
# copy important files
shutil.copyfile('lua52.dll', os.path.join(BINDIR, 'lua52.dll'))
shutil.copyfile('lua52.lib', os.path.join(LIBDIR, 'lua.lib'))
# headers
includes = os.path.join(INCLUDEDIR, 'lua')
headers = glob.glob('include/*.h')
os.makedirs(includes, exist_ok=True)
for header in headers:
shutil.copyfile(header, os.path.join(includes, os.path.basename(header)))
os.chdir(ROOTDIR)
return True
def install_assimp():
log('looking for assimp...')
if os.path.isfile(os.path.join(LIBDIR, 'assimp.lib')):
log('\t\tfound\n')
return True
log('\t\tnot found\n')
url = 'http://sourceforge.net/projects/assimp/files/assimp-3.1/assimp-3.1.1-win-binaries.zip/download'
log('downloading assimp binaries from "http://sourceforge.net/projects/assimp"...\n')
assimpdir = os.path.join(ROOTDIR, '3rdparty', 'tmp', 'assimp')
os.makedirs(assimpdir, exist_ok=True)
os.chdir(assimpdir)
if os.system('wget -N --no-check-certificate {0}'.format(url)) != 0:
os.chdir(ROOTDIR)
return False
# extract file name from url
urlsplit = url.split('/')
filename = ''
for u in urlsplit:
if '.zip' in u:
filename = u
break
if os.system('unzip -o ' + filename) != 0:
os.chdir(ROOTDIR)
return False
os.chdir('assimp-3.1.1-win-binaries')
# copy important files
# libs
bindirs = {'x64': 'bin64', 'x86': 'bin32'}
libdirs = {'x64': 'lib64', 'x64': 'lib32'}
dlls = glob.glob(os.path.join(bindirs[ARCH], '*.dll'))
libs = glob.glob(os.path.join(libdirs[ARCH], '*.lib'))
print()
for lib in libs:
shutil.copyfile(lib, os.path.join(LIBDIR, os.path.basename(lib)))
for dll in dlls:
shutil.copyfile(dll, os.path.join(BINDIR, os.path.basename(dll)))
# headers
includes = os.path.join(INCLUDEDIR, 'assimp')
headers = glob.glob('include/assimp/*')
os.makedirs(includes, exist_ok=True)
for header in headers:
if os.path.isfile(header):
shutil.copyfile(header, os.path.join(includes, os.path.basename(header)))
os.makedirs(os.path.join(includes, 'Compiler'), exist_ok=True)
headers = glob.glob('include/assimp/Compiler/*')
for header in headers:
shutil.copyfile(header, os.path.join(includes, 'Compiler', os.path.basename(header)))
os.chdir(ROOTDIR)
return True
def install_glfw():
log('looking for glfw...')
if os.path.isfile(os.path.join(LIBDIR, 'glfw.lib')) and \
os.path.isfile(os.path.join(BINDIR, 'glfw3.dll')):
log('\t\tfound\n')
return True
log('\t\tnot found\n')
urls = {\
'x86': 'http://sourceforge.net/projects/glfw/files/glfw/3.0.4/glfw-3.0.4.bin.WIN32.zip/download',
'x64': 'http://sourceforge.net/projects/glfw/files/glfw/3.0.4/glfw-3.0.4.bin.WIN64.zip/download'}
log('downloading glfw binaries from "http://www.glfw.org"...\n')
glfwdir = os.path.join(ROOTDIR, '3rdparty', 'tmp', 'glfw')
os.makedirs(glfwdir, exist_ok=True)
os.chdir(glfwdir)
if os.system('wget -N --no-check-certificate {0}'.format(urls[ARCH])) != 0:
os.chdir(ROOTDIR)
return False
# extract file name from url
urlsplit = urls[ARCH].split('/')
filename = ''
for u in urlsplit:
if '.zip' in u:
filename = u
break
if os.system('unzip -o %s' % filename) != 0:
os.chdir(ROOTDIR)
return False
dirname = os.path.splitext(filename)[0]
os.chdir(dirname)
# copy important files
# libs
shutil.copyfile('lib-msvc%s0/glfw3.dll' % MSVC, os.path.join(BINDIR, 'glfw3.dll'))
shutil.copyfile('lib-msvc%s0/glfw3dll.lib' % MSVC, os.path.join(LIBDIR, 'glfw.lib'))
# headers
includes = os.path.join(INCLUDEDIR, 'GLFW')
headers = glob.glob('include/GLFW/*.h')
os.makedirs(includes, exist_ok=True)
for header in headers:
shutil.copyfile(header, os.path.join(includes, os.path.basename(header)))
os.chdir(ROOTDIR)
return True
def install_glew():
log('looking for glew...')
if os.path.isfile(os.path.join(LIBDIR, 'glew.lib')):
log('\t\tfound\n')
return True
log('\t\tnot found\n')
url = 'https://sourceforge.net/projects/glew/files/glew/1.10.0/glew-1.10.0-win32.zip/download'
log('downloading glew binaries from "https://sourceforge.net/projects/glew"...\n')
glewdir = os.path.join(ROOTDIR, '3rdparty', 'tmp', 'glew')
os.makedirs(glewdir, exist_ok=True)
os.chdir(glewdir)
if os.system('wget -N --no-check-certificate {0}'.format(url)) != 0:
os.chdir(ROOTDIR)
return False
# extract file name from url
urlsplit = url.split('/')
filename = ''
for u in urlsplit:
if '.zip' in u:
filename = u
break
if os.system('unzip -o ' + filename) != 0:
os.chdir(ROOTDIR)
return False
dirs = glob.glob('*')
for d in dirs:
if os.path.isdir(d):
os.chdir(d)
break
# copy important files
dirs = {'x64': 'x64', 'x86': 'Win32'}
d = dirs[ARCH]
# libs
shutil.copyfile(os.path.join('bin', 'Release', d, 'glew32.dll'),
os.path.join(BINDIR, 'glew32.dll'))
shutil.copyfile(os.path.join('lib', 'Release', d, 'glew32.lib'),
os.path.join(LIBDIR, 'glew.lib'))
# headers
includes = os.path.join(INCLUDEDIR, 'GL')
headers = glob.glob('include/GL/*.h')
os.makedirs(includes, exist_ok=True)
for header in headers:
shutil.copyfile(header, os.path.join(includes, os.path.basename(header)))
os.chdir(ROOTDIR)
return True
def install_efsw():
log('looking for efsw...')
if os.path.isfile(os.path.join(LIBDIR, 'efsw.lib')) and \
os.path.isfile(os.path.join(BINDIR, 'efsw.dll')):
log('\t\tfound\n')
return True
log('\t\tnot found\n')
url = 'https://bitbucket.org/sepul/efsw/get/5de4baca1a60.zip'
log('downloading efsw source from "https://bitbucket.org/sepul/efsw"...\n')
efswdir = os.path.join(ROOTDIR, '3rdparty', 'tmp', 'efsw')
os.makedirs(efswdir, exist_ok=True)
os.chdir(efswdir)
if os.system('wget -N --no-check-certificate {0}'.format(url)) != 0:
os.chdir(ROOTDIR)
return False
if os.system('unzip -o ' + os.path.basename(url)) != 0:
os.chdir(ROOTDIR)
return False
name = os.path.splitext(os.path.basename(url))[0]
dirname = 'sepul-efsw-' + name
os.chdir(dirname)
if os.system('python {0} configure --msvc_version="{1}" --msvc_targets={2}'.format(\
WAFPATH, get_msvccompiler(), ARCH)) != 0:
if os.system('python {0} configure --msvc_version="{1}" --msvc_targets={2}'.format(\
WAFPATH, get_msvccompiler(), get_msvctarget())) != 0:
os.chdir(ROOTDIR)
return False
if os.system('python {0} build install'.format(WAFPATH)) != 0:
os.chdir(ROOTDIR)
return False
# copy important files
# libs
shutil.copyfile('bin/efsw.dll', os.path.join(BINDIR, 'efsw.dll'))
shutil.copyfile('build/release/efsw.lib', os.path.join(LIBDIR, 'efsw.lib'))
# headers
includes = os.path.join(INCLUDEDIR, 'efsw')
headers = glob.glob('include/efsw/*.h*')
os.makedirs(includes, exist_ok=True)
for header in headers:
shutil.copyfile(header, os.path.join(includes, os.path.basename(header)))
os.chdir(ROOTDIR)
return True
def main():
parser = optparse.OptionParser()
parser.add_option('--prefix', action='store', type='string', dest='PREFIX',
help='prefix path for existing and to be installed libs', default='')
parser.add_option('--msvc', action='store', type='choice', choices=['9', '10', '11', '12'],
dest='MSVC', help='define visual studio version (active compiler)')
parser.add_option('--arch', action='store', type='choice', choices=['x86', 'x64'],
dest='ARCH', help='define target architecture that you want to build')
(options, args) = parser.parse_args()
if not options.ARCH:
parser.error('--arch argument is not given')
if not options.MSVC:
parser.error('--msvc argument is not given')
global LIBDIR, INCLUDEDIR, PREFIX, MSVC, ARCH, BINDIR
PREFIX = os.path.abspath(options.PREFIX)
LIBDIR = os.path.join(PREFIX, 'lib')
INCLUDEDIR = os.path.join(PREFIX, 'include')
BINDIR = os.path.join(PREFIX, 'bin')
ARCH = options.ARCH
MSVC = options.MSVC
log('library install path: ' + LIBDIR + '\n')
log('library install path: ' + BINDIR + '\n')
log('include install path: ' + INCLUDEDIR + '\n')
os.makedirs(INCLUDEDIR, exist_ok=True)
os.makedirs(LIBDIR, exist_ok=True)
os.makedirs(BINDIR, exist_ok=True)
if not install_lua():
log('error: could not install lua\n')
return False
if not install_assimp():
log('error: could not install assimp\n')
return False
if not install_glfw():
log('error: could not install glfw\n')
return False
if not install_glew():
log('error: could not install glew\n')
return False
if not install_efsw():
log('error: could not install efsw\n')
return False
log('ok, ready for build.\n')
r = main()
if r: sys.exit(0)
else: sys.exit(-1)