forked from JKKDY/vulkan-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_dependencies_examples.py
More file actions
114 lines (92 loc) · 3.98 KB
/
setup_dependencies_examples.py
File metadata and controls
114 lines (92 loc) · 3.98 KB
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
import os
from subprocess import call
from urllib .request import urlretrieve
from shutil import copytree
import zipfile
windows = os.name == 'nt'
# urls & paths
# if windows:
url_cmake = 'https://github.com/Kitware/CMake/releases/download/v3.13.2/cmake-3.13.2-win64-x64.zip'
url_glfw32 = 'https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.bin.WIN32.zip'
url_glfw64 = 'https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.bin.WIN64.zip'
dirname = os.path.dirname(__file__)
path_assimp = os.path.join(dirname, 'assimp')
path_glfw = os.path.join(dirname, 'glfw')
path_cmake_exe = os.path.join(dirname, os.path.basename(url_cmake)[:-4], 'bin', 'cmake.exe')
git_glm = 'https://github.com/g-truc/glm.git'
git_stb = 'https://github.com/nothings/stb.git'
git_gli = 'https://github.com/g-truc/gli.git'
git_glfw = 'https://github.com/glfw/glfw.git'
git_assimp = 'https://github.com/assimp/assimp.git'
def maybe_mkdir(path):
if not os.path.exists(path):
os.mkdir(path)
def git_clone(repo, directory):
real_dir = os.path.join(directory, os.path.basename(repo)[0:-4])
if not os.path.exists(real_dir):
os.mkdir(real_dir)
if len(os.listdir(real_dir)) == 0:
try:
import git
except ImportError:
if windows:
call(['git', 'clone', repo, real_dir])
else:
git.Git(directory).clone(repo)
return os.path.basename(repo)[0:-4]
git_clone(git_glm, dirname)
print("Downloaded glm")
git_clone(git_stb, dirname)
print("Downloaded stb")
git_clone(git_gli, dirname)
print("Downloaded gli")
if windows:
def maybe_copy(src, dst):
if not os.path.exists(dst):
copytree(src, dst)
def maybe_download(url, dst):
if not os.path.exists(dst):
urlretrieve(url, dst)
# cmake
maybe_download(url_cmake, os.path.join(dirname, os.path.basename(url_cmake)))
print("Downloaded cmake")
if not os.path.exists(os.path.join(dirname, os.path.basename(url_cmake)[:-4])):
with zipfile.ZipFile(os.path.join(dirname, os.path.basename(url_cmake)), 'r') as zip_ref:
zip_ref.extractall(dirname)
print("Extracted cmake")
# glfw
maybe_mkdir(path_glfw)
extract32 = os.path.join(path_glfw, 'glfw-3.2.1.bin.WIN32')
extract64 = os.path.join(path_glfw, 'glfw-3.2.1.bin.WIN64')
maybe_download(url_glfw32, extract32 + '.zip')
maybe_download(url_glfw64, extract64 + '.zip')
print("Downloaded glfw")
# unzip
if not os.path.exists(extract32):
with zipfile.ZipFile(extract32 + '.zip', 'r') as zip_ref:
zip_ref.extractall(path_glfw)
if not os.path.exists(extract64):
with zipfile.ZipFile(extract64 + '.zip', 'r') as zip_ref:
zip_ref.extractall(path_glfw)
print("Extracted glfw")
# copy libraries and headers
maybe_copy(os.path.join(extract32, 'include/GLFW'), os.path.join(path_glfw, 'include', 'glfw'))
maybe_copy(os.path.join(extract32, 'lib-vc2015'), os.path.join(path_glfw, 'Win32'))
maybe_copy(os.path.join(extract64, 'lib-vc2015'), os.path.join(path_glfw, 'x64'))
print("Copied glfw files")
# assimp
assimp_name = git_clone(git_assimp, path_assimp)
print("Downloaded assimp")
# copy headers
maybe_copy(os.path.join(path_assimp, assimp_name, 'include', 'assimp'),
os.path.join(path_assimp, 'include', 'assimp'))
print("copied assimp header files")
# build
maybe_mkdir(os.path.join(path_assimp, 'build'))
maybe_mkdir(os.path.join(path_assimp, 'build64'))
if len(os.listdir(os.path.join(path_assimp, 'build'))) == 0:
call([path_cmake_exe, '-S', os.path.join(path_assimp, assimp_name), '-B', os.path.join(path_assimp, 'build')])
if len(os.listdir(os.path.join(path_assimp, 'build64'))) == 0:
call([path_cmake_exe, '-G', 'Visual Studio 15 2017 Win64', '-S', os.path.join(path_assimp, assimp_name),
'-B', os.path.join(path_assimp, 'build64')])
print("Built Visual Studio solution for assimp")