-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.py
executable file
·39 lines (30 loc) · 1021 Bytes
/
make.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
#!/usr/bin/env python3
import os # 20201011 added parallel build. Can run "python3 make.py" instead of: "make"
def err(m):
import sys
print('Error: ' + str(m)); sys.exit(1)
CC = 'g++'
CFLAGS = '-w -O3 misc.cpp'
UNAME = os.popen('uname').read().strip()
LFLAGS = '-lm -pthread -lstdc++ '
if UNAME == 'Linux':
LFLAGS += '-lc -lGL -lglut -lGLU'
elif UNAME == "Darwin":
LFLAGS += '-framework Cocoa -framework GLUT -framework openGL'
else:
err('Platform not supported: ' + str(UNAME))
f = open('make.sh', 'wb')
cf = ['knn', 'glut', 'clust_knn', 'zpr', 'pick', 'global', 'console']
for x in cf:
s = ' '.join([CC, CFLAGS, '-c', x + '.cpp']) + ' &'
f.write((s + '\n').encode()) # multithreaded compile
print(s.strip())
s = 'wait'
print(s)
f.write((s + '\n').encode()) # join threads before link step
s = ' '.join([CC, CFLAGS, (' '.join([f + '.o' for f in cf])), '-o kgc.exe', LFLAGS])
f.write((s + '\n').encode())
f.close()
print(s.strip())
a = os.system('chmod 777 make.sh')
a = os.system('./make.sh')