-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSConstruct
113 lines (84 loc) · 2.7 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
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
import platforms # site_scons
def wrapup_conscript(self, libs=[], headers=[]):
return (libs, headers)
options = Variables('custom.py')
options.Add(
'platform',
f'Target platform: {",".join(platforms.target_platforms)}.',
'',
)
options.Add(
'js',
'Command for the JavaScript interpreter.',
'node',
)
options.Add(BoolVariable(
'debug',
'Build with debugging information. Will use `-g` if true.',
True
))
env = Environment(variables=options)
env.AddMethod(wrapup_conscript)
# use user PATH
env.PrependENVPath('PATH', os.getenv('PATH'))
# allow for e.g. asdf to work
env['ENV']['HOME'] = os.getenv('HOME')
env.Tool('reflex')
if env.WhereIs('bison') is None:
print('Required `bison` not found in PATH.')
Exit(1)
if env.WhereIs('reflex') is None:
print('Required `reflex` not found in PATH.')
Exit(1)
platform = platforms.get_platform(env)
platforms.setup_for(env, platform)
variant_dir = Dir(f'#build/{platform}')
headers_dir = f'{variant_dir.abspath}/include'
private_libs_dir = f'{variant_dir.abspath}/privlib'
libs_dir = f'{variant_dir.abspath}/lib'
env.Append(LIBPATH=private_libs_dir)
print('Building for platform', platform, 'at', variant_dir.relpath)
print('Headers will be left at', headers_dir)
print('Libraries will be left at', libs_dir)
env['BUILDERS']['TokiwenStaticLibJoin'] = platforms.static_lib_join_builder(env, platform)
env['BUILDERS']['TokiwenSharedLib'] = platforms.shared_lib_builder(env, platform)
include = [
variant_dir,
'#thirdparty/RE-flex/include',
]
env.Append(CPPPATH=include)
env.Prepend(CXXFLAGS=['-std=gnu++2b', '-fPIC'])
if env['debug']:
env.Prepend(CXXFLAGS=['-g'])
env.Tool("compilation_db")
env.CompilationDatabase()
Export('env', 'headers_dir', 'private_libs_dir', 'libs_dir')
libs = []
headers = []
thirdparty_variant_dir = f'{variant_dir}/thirdparty'
thirdparty_libs, thirdparty_headers = \
SConscript('thirdparty/SConscript', variant_dir=thirdparty_variant_dir)
libs.extend(thirdparty_libs)
headers.extend(thirdparty_headers)
conscript_dirs = ['common', 'parser', 'synthesis']
for conscript_dir in conscript_dirs:
conscript_file = f'{conscript_dir}/SConscript'
variant_sub_dir = f'{variant_dir}/{conscript_dir}'
new_libs, new_headers = SConscript(conscript_file, variant_dir=variant_sub_dir)
libs.extend(new_libs)
headers.extend(new_headers)
tokiwen_lib = env.TokiwenStaticLibJoin(
f'{private_libs_dir}/tokiwen',
libs,
)
tokiwen_shlib = env.TokiwenSharedLib(
f'{private_libs_dir}/tokiwen',
libs,
)
env.Install(headers_dir, headers)
env.Install(private_libs_dir, libs)
env.Install(libs_dir, tokiwen_shlib + tokiwen_lib)
tests_variant_dir = f'{variant_dir}/tests'
SConscript('tests/SConscript', variant_dir=tests_variant_dir)
print()