forked from kmammou/v-hacd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
executable file
·44 lines (36 loc) · 1.26 KB
/
run.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
#!/usr/bin/env python
import sys
import os
import shutil
import subprocess
def cmake(platform_dir, src_dir, arg):
if not(os.path.exists(platform_dir)):
os.mkdir(platform_dir)
os.chdir(platform_dir) # go to platform directory
cmd = "cmake " + arg + " ../" + src_dir
print("cmd")
subprocess.call(cmd, shell=True) # run cmake
def clean(platform_dir):
if os.path.exists(platform_dir):
shutil.rmtree(platform_dir)
if __name__ == '__main__':
src_dir = '../src/' # source code directory
bin_dir = '../build/' # binary directory
if not(os.path.exists(bin_dir)): # binary directory is created if not found
print("Creating bin directory: " + bin_dir)
os.mkdir(bin_dir)
platform = sys.platform
cmd = ""
if (platform == 'darwin'): # platform directory is created if not found
platform = 'mac'
cmd = '-G Xcode'
platform_dir = bin_dir + platform
if len(sys.argv) == 1:
print("Invalid arguments to run: please specify --cmake or --clean")
sys.exit(-1)
else:
for arg in sys.argv:
if (arg == '--cmake'):
cmake(platform_dir, src_dir, cmd)
elif (arg == '--clean'):
clean(platform_dir)