-
Notifications
You must be signed in to change notification settings - Fork 1
/
SConstruct
84 lines (65 loc) · 1.99 KB
/
SConstruct
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
import os
env = Environment()
obj_file_path = 'build/obj'
exe_bin_path = 'build/run'
protocol_path = 'wayland/protocols'
debug_symbols = True
libs = [
'wayland-server',
'X11',
'EGL',
'GL',
'xkbcommon-x11',
'xkbcommon',
'GLU',
'GLEW',
'SOIL',
'gbm',
'udev',
'evdev',
'libinput',
'drm',
]
pkg_config_libs = [
'libdrm',
'libevdev',
]
env.Append(
CCFLAGS = [
'-g' if debug_symbols else None,
'-Wall',
],
LINKFLAGS = [
]
)
for lib in pkg_config_libs:
env.ParseConfig('pkg-config --cflags --libs ' + lib);
def get_contents_of_dir(base):
return [ os.path.abspath(os.path.join(base, i)) for i in os.listdir(base) if not i.startswith('.') ]
def get_subdirs(base):
return [ i for i in get_contents_of_dir(base) if os.path.isdir(i) ]
def get_all_subdirs(base):
return [base] + [i for j in get_subdirs(base) for i in get_all_subdirs(j)]
def has_extension(base, extensions):
if type(extensions) != type([]):
raise TypeError('has_extension must be sent a path and an array of extensions')
for extension in extensions:
if base.endswith(extension):
return True
return False
def get_all_files(base):
return [ path for subdir in get_all_subdirs(base) for path in get_contents_of_dir(subdir) if os.path.isfile(path) ]
def get_all_files_with_extension(base, extensions):
return [ path for path in get_all_files(base) if has_extension(path, extensions) ]
def get_all_cpp_files():
return get_all_files_with_extension('.', ['.cpp', '.c'])
if get_all_files_with_extension(protocol_path, ['.h']) != get_all_files_with_extension(protocol_path, ['.xml']):
os.system('python3 ' + protocol_path + '/gen_headers.py ' + protocol_path)
sources = get_all_cpp_files()
objects = []
for source in sources:
#obj_name = '.obj/' + source.path.split('/', 1)[1].rsplit('.', 1)[0] + '.o'
obj_path = os.path.join(obj_file_path, os.path.relpath(source.rsplit('.', 1)[0] + '.o'))
obj = env.Object(target=obj_path, source=source)
objects.append(obj)
program = env.Program(target=exe_bin_path, source=objects, LIBS=libs)