-
Notifications
You must be signed in to change notification settings - Fork 0
/
requirements.py
97 lines (77 loc) · 2.64 KB
/
requirements.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
import subprocess
import os
import shutil
import sys
def compile_it():
if (sys.platform == 'win32'):
subprocess.call(['cmake', '-G', 'Ninja', '..'])
subprocess.call(['ninja'])
else:
subprocess.call(['cmake', '..'])
subprocess.call(['make'])
def get_extension():
if (sys.platform == 'linux') or (sys.platform == 'linux2'):
extension = "so"
elif (sys.platform == 'darwin'):
extension = "dylib"
elif (sys.platform == 'win32'):
extension = "dll"
else:
raise Exception("Unexpected platform: {0}".format(sys.platform))
return extension
def nfsim():
os.chdir('nfsim')
try:
os.mkdir('lib')
except OSError:
pass
os.chdir('lib')
compile_it()
os.chdir('..')
os.chdir('..')
def nfsim_lib():
os.chdir('nfsimCInterface')
try:
os.mkdir('lib')
except OSError:
pass
os.chdir('lib')
extension = get_extension()
if (sys.platform == 'win32'):
subprocess.call(['cmd', '/c', 'mklink', '.\libNFsim.{0}'.format(extension), os.path.join('..', '..', 'nfsim', 'lib', 'libNFsim.{0}'.format(extension))])
os.chdir('..')
subprocess.call(['cmd', '/c', 'mklink', '/D', '.\include', os.path.join('..', 'nfsim', 'include')])
else:
subprocess.call(['ln', '-s', os.path.join('..', '..', 'nfsim', 'lib', 'libNFsim.{0}'.format(extension))])
os.chdir('..')
subprocess.call(['ln', '-s', os.path.join('..', 'nfsim', 'include')])
try:
os.mkdir('build')
except OSError:
pass
os.chdir('build')
compile_it()
os.chdir('..')
os.chdir('..')
def copy_library_files():
try:
os.mkdir('build/lib')
except OSError:
pass
os.chdir('build')
extension = get_extension()
# XXX: For some reason, Windows will build MCell with the files in
# ./build/lib but will fail at runtime if they aren't in the same directory
# as the executable itself (i.e. the libs must be in ./build at runtime)
if (sys.platform == 'win32'):
shutil.copy(os.path.join('..', 'nfsim', 'lib', 'libNFsim.{0}'.format(extension)), ".")
shutil.copy(os.path.join('..', 'nfsimCInterface', 'build', 'libnfsim_c.{0}'.format(extension)), ".")
shutil.copy(os.path.join('..', 'nfsim', 'lib', 'libNFsim.{0}'.format(extension)), "lib")
shutil.copy(os.path.join('..', 'nfsimCInterface', 'build', 'libnfsim_c.{0}'.format(extension)), "lib")
if __name__ == "__main__":
subprocess.call(['git', 'submodule', 'init'])
subprocess.call(['git', 'submodule', 'update'])
os.chdir("..")
nfsim()
nfsim_lib()
copy_library_files()