-
Notifications
You must be signed in to change notification settings - Fork 4
/
wscript
146 lines (124 loc) · 4.49 KB
/
wscript
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env python
# encoding: utf-8
APPNAME = 'rlncd'
VERSION = '0.1-alpha'
top = '.'
out = 'build'
def options(opt):
try:
opt.load('boost')
except ImportError as e:
pass
opt.load('compiler_cxx')
opt.add_option('--profiler', action='store_true', default=False, help='Enable google CPU profiler')
opt.add_option('--kodo', action='store', default='../kodo', help='Path to kodo checkout')
opt.add_option('--kodo_bundle', action='store', default='../kodo/bundle_dependencies', help='Path to kodo dependencies (fifi, sak, etc)')
def configure(cfg):
#
# use clang++ by default
#
cfg.add_os_flags('CXX')
if not cfg.env.CXX:
cfg.env.append_unique('CXX', ['clang++'])
cfg.load('compiler_cxx')
#
# kodo
#
cfg.start_msg('Checking kodo include path')
kodo = cfg.path.find_dir(cfg.options.kodo)
if kodo:
cfg.env.KODO = kodo.abspath() + '/src'
cfg.end_msg(cfg.env.KODO)
else:
cfg.fatal('Invalid path to kodo' + cfg.options.kodo)
#
# kodo bundle dependencies
#
bundle = cfg.path.find_dir(cfg.options.kodo_bundle)
if not bundle:
cfg.fatal('Invalid bundle path: ' + cfg.options.kodo_bundle)
#
# sak
#
cfg.start_msg('Checking sak include path')
sak = bundle.ant_glob('sak*', dir=True)
if not sak:
cfg.fatal('sak not found in bundle path: ' + cfg.options.kodo_bundle)
cfg.env.SAK = sak[-1].abspath() + '/master/src'
cfg.end_msg(cfg.env.SAK)
#
# fifi
#
cfg.start_msg('Checking fifi include path')
fifi = bundle.ant_glob('fifi*', dir=True)
if not fifi:
cfg.fatal('fifi not found in bundle path: ' + cfg.options.kodo_bundle)
cfg.env.FIFI = fifi[-1].abspath() + '/master/src'
cfg.end_msg(cfg.env.FIFI)
#
# boost
#
cfg.start_msg('Checking boost include path')
boost = bundle.ant_glob('boost*', dir=True)
if not boost:
cfg.fatal('boost not found in bundle path: ' + cfg.options.kodo_bundle)
cfg.env.BOOST = boost[-1].abspath() + '/master'
cfg.end_msg(cfg.env.BOOST)
#
# libs
#
cfg.check_boost()
cfg.check(features='cxx cxxprogram', lib='pthread', uselib_store='pthread')
cfg.check(features='cxx cxxprogram', lib='rt')
cfg.check(features='cxx cxxprogram', lib='nl-3')
cfg.check(features='cxx cxxprogram', lib='nl-genl-3')
cfg.check(features='cxx cxxprogram', lib='gflags')
cfg.check(features='cxx cxxprogram', lib='glog')
cfg.check(features='cxx cxxprogram', lib='gtest', use='pthread')
if cfg.options.profiler:
cfg.check(features='cxx cxxprogram', lib='profiler', uselib_store='profiler')
cfg.env.append_unique('LINKFLAGS', ['-lprofiler'])
cfg.env.append_unique('CXXFLAGS', ['-std=c++11',
'-g',
'-O2',
'-ftree-vectorize',
'-finline-functions'])
if 'c++' in str(cfg.env.CXX) and cfg.env.CC_VERSION <= ('4', '8', '0'):
cfg.env.append_unique('CXXFLAGS', ['-Wno-narrowing', '-D_GLIBCXX_USE_NANOSLEEP',
'-march=armv6j', '-mfpu=vfp', '-mfloat-abi=hard'])
env = cfg.get_env()
cfg.setenv('tsan', env)
cfg.env.append_unique('CXXFLAGS', ['-g', '-O1', '-fsanitize=thread', '-fPIE'])
cfg.env.append_unique('LINKFLAGS', ['-pie', '-fsanitize=thread'])
cfg.setenv('asan', env)
cfg.env.append_unique('CXXFLAGS', ['-fsanitize=address', '-fno-omit-frame-pointer', '-O1', '-g'])
cfg.env.append_unique('LINKFLAGS', ['-fsanitize=address', '-fno-omit-frame-pointer'])
def build(bld):
libdir = [bld.env.LIBDIR]
bld.read_shlib('pthread', paths=libdir)
bld.read_shlib('rt', paths=libdir)
bld.read_stlib('glog', paths=libdir)
bld.read_stlib('gflags', paths=libdir)
bld.read_shlib('gtest', paths=libdir)
if bld.env.DEST_CPU == 'arm':
bld.read_stlib('nl-3', paths=libdir)
bld.read_stlib('nl-genl-3', paths=libdir)
else:
bld.read_shlib('nl-3')
bld.read_shlib('nl-genl-3')
bld(
includes='./src',
export_includes='./src',
name='rlncd_includes'
)
bld.recurse('src')
bld.recurse('test')
from waflib.Build import BuildContext
class debug(BuildContext):
'''build with thread sanitizer'''
cmd = 'tsan'
variant = 'tsan'
class debug(BuildContext):
'''build with address sanitizer'''
cmd = 'asan'
variant = 'asan'