forked from WithSecureOpenSource/async
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
94 lines (86 loc) · 2.57 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
import os
import fsenv
DIRECTORIES = [
'src',
'test',
'components/async' ]
TARGET_DEFINES = {
'freebsd_amd64': ['HAVE_EXECINFO'],
'linux32': ['_FILE_OFFSET_BITS=64', 'HAVE_EXECINFO'],
'linux64': ['HAVE_EXECINFO'],
'linux_arm64': ['HAVE_EXECINFO'],
'openbsd_amd64': [],
'darwin': ['HAVE_EXECINFO']
}
TARGET_CPPPATH = {
'freebsd_amd64': [],
'linux32': [],
'linux64': [],
'linux_arm64': [],
'openbsd_amd64': ['/usr/local/include'],
'darwin': []
}
TARGET_LIBPATH = {
'freebsd_amd64': [],
'linux32': [],
'linux64': [],
'linux_arm64': [],
'openbsd_amd64': ['/usr/local/lib'],
'darwin': []
}
TARGET_LIBS = {
'freebsd_amd64': ['execinfo'],
'linux32': ['rt'],
'linux64': ['rt'],
'linux_arm64': ['rt'],
'openbsd_amd64': ['iconv'],
'darwin': ['iconv'],
}
TARGET_FLAGS = {
'freebsd_amd64': '',
'linux32': '-m32 ',
'linux64': '',
'linux_arm64': '',
'openbsd_amd64': '',
'darwin': ''
}
def construct():
ccflags = (
' -g -O2 -Wall -Wextra -Werror '
'-Wno-null-pointer-arithmetic '
'-Wno-sign-compare '
'-Wno-unknown-warning-option '
'-Wno-maybe-uninitialized '
'-Wno-unused-parameter '
)
prefix = ARGUMENTS.get('prefix', '/usr/local')
for target_arch in fsenv.target_architectures():
arch_env = Environment(
NAME='async',
ARCH=target_arch,
PREFIX=prefix,
PKG_CONFIG_LIBS=['fsdyn', 'encjson', 'fstrace', 'unixkit'],
CCFLAGS=TARGET_FLAGS[target_arch] + ccflags,
CPPDEFINES=TARGET_DEFINES[target_arch],
CPPPATH=TARGET_CPPPATH[target_arch],
LINKFLAGS=TARGET_FLAGS[target_arch],
TARGET_LIBPATH=TARGET_LIBPATH[target_arch],
TARGET_LIBS=TARGET_LIBS[target_arch],
tools=['default', 'textfile', 'fscomp', 'scons_compilation_db'])
fsenv.consider_environment_variables(arch_env)
build_dir = os.path.join(
fsenv.STAGE,
target_arch,
ARGUMENTS.get('builddir', 'build'))
arch_env.CompilationDB(
os.path.join(build_dir, "compile_commands.json"))
for directory in DIRECTORIES:
env = arch_env.Clone()
env.SetCompilationDB(arch_env.GetCompilationDB())
SConscript(dirs=directory,
exports=['env'],
duplicate=False,
variant_dir=os.path.join(build_dir, directory))
Clean('.', build_dir)
if __name__ == 'SCons.Script':
construct()