forked from attugit/cxxjson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwscript
140 lines (110 loc) · 3.26 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
#!/usr/bin/env python
# encoding: utf-8
from waflib.Tools import waf_unit_test
from waflib.Build import BuildContext
import os
VERSION = '0.1'
APPNAME = 'cxxjson'
top = '.'
out = 'build'
def init(ctx):
ctx.load('build_logs')
def options(ctx):
ctx.load('compiler_cxx')
ctx.load('gnu_dirs')
ctx.load('waf_unit_test')
def configure(ctx):
ctx.env.DEFINES = os.environ.get('DEFINES', '').split()
ctx.load('compiler_cxx')
ctx.load('gnu_dirs')
ctx.load('clang_compilation_database')
ctx.load('waf_unit_test')
ctx.msg('Used CXXFLAGS', ' '.join(ctx.env.CXXFLAGS))
ctx.msg('Used LINKFLAGS', ' '.join(ctx.env.LINKFLAGS))
ctx.msg('Used DEFINES', ' '.join(ctx.env.DEFINES))
ctx.env.INCLUDES = [ctx.path.abspath(), './inc']
def cxx(ctx):
incs = ctx.path.find_dir('inc')
ctx.install_files(
'${INCLUDEDIR}',
incs.ant_glob('**/*.(h|hpp)'),
cwd=incs,
relative_trick=True
)
ctx.objects(
source=ctx.path.ant_glob(['src/**/*.(c|cpp)']),
target='SRCLIB',
features='cxx',
)
ctx(
target=APPNAME,
features='cxx cxxshlib',
vnum=VERSION,
use=['SRCLIB'],
install_path='${LIBDIR}',
)
def build(ctx):
cxx(ctx)
ctx(
source=ctx.path.ant_glob(['test/test_main.cpp']),
target='test_main',
features='cxx',
includes=['test'],
)
for suite in ctx.path.ant_glob(
['test/**/*.(c|cpp)'],
excl=['test/test_main.cpp']):
target, _ = suite.name.split('.')
ctx(
source=suite,
target='ut_' + target,
features='cxx cxxprogram test',
use=['test_main', 'SRCLIB'],
lib=['pthread'],
install_path=None,
)
ctx.add_post_fun(waf_unit_test.summary)
ctx.add_post_fun(waf_unit_test.set_exit_code)
def benchmark(ctx):
cxx(ctx)
for suite in ctx.path.ant_glob(
['benchmark/**/*.(c|cpp)']):
target, _ = suite.name.split('.')
ctx(
source=suite,
target='benchmark_' + target,
features='cxx cxxprogram test',
use=['SRCLIB'],
lib=['pthread', 'benchmark', 'benchmark_main'],
install_path=None
)
def summary(bld):
from waflib import Logs
lst = getattr(bld, 'utest_results', [])
for(f, code, out, err)in (lst or []):
Logs.pprint('CYAN', '<<=== %s ===>>' % f)
out = out.decode('utf-8')
Logs.pprint('CYAN', str(out))
Logs.pprint('CYAN', '')
ctx.add_post_fun(summary)
ctx.add_post_fun(waf_unit_test.set_exit_code)
def fuzzer(ctx):
ctx.env.CXXFLAGS.extend(['-g', '-fsanitize=fuzzer,address,undefined'])
ctx.env.LINKFLAGS.extend(['-g', '-fsanitize=fuzzer,address,undefined'])
cxx(ctx)
for suite in ctx.path.ant_glob(
['fuzzer/**/*.(c|cpp)']):
target, _ = suite.name.split('.')
ctx(
source=suite,
target='fuzzer_' + target,
features='cxx cxxprogram',
use=['SRCLIB'],
install_path=None
)
class Benchmark(BuildContext):
cmd = 'benchmark'
fun = 'benchmark'
class Fuzzer(BuildContext):
cmd = 'fuzzer'
fun = 'fuzzer'