-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwscript
executable file
·348 lines (298 loc) · 13.2 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#!/usr/bin/env python3
APPNAME="janus"
VERSION="0.0"
import os
import sys
import glob
from waflib import Logs
from waflib import Options
pargs = ['--cflags', '--libs']
#BOOST_LIBS = 'BOOST_SYSTEM BOOST_FILESYSTEM BOOST_THREAD BOOST_COROUTINE'
def options(opt):
opt.load("compiler_c")
opt.load("compiler_cxx")
opt.load(['boost', 'unittest_gtest'],
tooldir=['.waf-tools'])
opt.add_option('-g', '--use-gxx', dest='cxx',
default=False, action='store_true')
opt.add_option('-c', '--use-clang', dest='clang',
default=False, action='store_true')
opt.add_option('-i', '--use-ipc', dest='ipc',
default=False, action='store_true')
opt.add_option('-p', '--enable-profiling', dest='prof',
default=False, action='store_true')
opt.add_option('', '--enable-event-timeout', dest='event_timeout',
default=False, action='store_true')
opt.add_option('-d', '--debug', dest='debug',
default=False, action='store_true')
opt.add_option('-M', '--enable-tcmalloc', dest='tcmalloc',
default=False, action='store_true')
opt.add_option('-J', '--enable-jemalloc', dest='jemalloc',
default=False, action='store_true')
opt.add_option('-s', '--enable-rpc-statistics', dest='rpc_s',
default=False, action='store_true')
opt.add_option('-P', '--enable-piece-count', dest='pc',
default=False, action='store_true')
opt.add_option('-C', '--enable-conflict-count', dest='cc',
default=False, action='store_true')
opt.add_option('-C', '--disable-reuse-coroutine', dest='disable_reuse_coroutine',
default=False, action='store_true')
opt.add_option('-r', '--enable-logging', dest='log',
default=False, action='store_true')
opt.add_option('-T', '--enable-txn-stat', dest='txn_stat',
default=False, action='store_true')
opt.add_option('-D', '--disable-check-python', dest='disable_check_python',
default=False, action='store_true')
opt.add_option('-m', '--enable-mutrace-debug', dest='mutrace',
default=False, action='store_true')
opt.add_option('-W', '--simulate-wan', dest='simulate_wan',
default=False, action='store_true')
opt.add_option('-S', '--db-checksum', dest='db_checksum',
default=False, action='store_true')
opt.add_option('-L', '--enable-leaksan', dest='leaksan',
default=False, action='store_true')
opt.parse_args();
def configure(conf):
_choose_compiler(conf)
_enable_pic(conf)
conf.load("compiler_c")
conf.load("compiler_cxx unittest_gtest")
conf.load("boost")
_enable_tcmalloc(conf)
_enable_jemalloc(conf)
_enable_cxx14(conf)
_enable_debug(conf)
_enable_profile(conf)
_enable_event_timeout(conf)
_enable_ipc(conf)
_enable_rpc_s(conf)
_enable_piece_count(conf)
_enable_txn_count(conf)
_enable_conflict_count(conf)
# _enable_snappy(conf)
#_enable_logging(conf)
_enable_reuse_coroutine(conf)
_enable_simulate_wan(conf)
_enable_db_checksum(conf)
_enable_leaksan(conf)
conf.env.append_value("CXXFLAGS", "-Wno-reorder")
conf.env.append_value("CXXFLAGS", "-Wno-comment")
conf.env.append_value("CXXFLAGS", "-Wno-unused-function")
conf.env.append_value("CXXFLAGS", "-Wno-unused-variable")
conf.env.append_value("CXXFLAGS", "-Wno-sign-compare")
conf.check_boost(lib='system filesystem context thread coroutine')
conf.env.append_value("CXXFLAGS", "-Wno-sign-compare")
conf.env.append_value('INCLUDES', ['/usr/local/include'])
# conf.check_cxx(lib='boost_system', use='BOOST_SYSTEM')
# conf.check_cxx(lib='boost_filesystem', use='BOOST_FILESYSTEM')
# conf.check_cxx(lib='boost_coroutine', use='BOOST_COROUTINE')
# in case you use linuxbrew, uncomment the following
# conf.env.append_value('INCLUDES', [os.path.expanduser('~') + '/.linuxbrew/include'])
# conf.env.append_value('LIBPATH', [os.path.expanduser('~') + '/.linuxbrew/lib'])
conf.env.LIB_PTHREAD = 'pthread'
conf.check_cfg(package='yaml-cpp', uselib_store='YAML-CPP', args=pargs)
if sys.platform != 'darwin':
conf.env.LIB_RT = 'rt'
if Options.options.disable_check_python:
pass
else:
conf.load("python")
conf.check_python_headers()
# check python modules
# conf.check_python_module('tabulate')
# conf.check_python_module('yaml')
def build(bld):
_depend("src/rrr/pylib/simplerpcgen/rpcgen.py",
"src/rrr/pylib/simplerpcgen/rpcgen.g",
"src/rrr/pylib/yapps/main.py src/rrr/pylib/simplerpcgen/rpcgen.g")
# _depend("rlog/log_service.h", "rlog/log_service.rpc",
# "bin/rpcgen rlog/log_service.rpc")
_depend("src/deptran/rcc_rpc.h src/deptran/rcc_rpc.py",
"src/deptran/rcc_rpc.rpc",
"bin/rpcgen --python --cpp src/deptran/rcc_rpc.rpc")
_gen_srpc_headers()
# _depend("old-test/benchmark_service.h", "old-test/benchmark_service.rpc",
# "bin/rpcgen --cpp old-test/benchmark_service.rpc")
bld.stlib(source=bld.path.ant_glob("extern_interface/scheduler.c"),
target="externc",
includes="",
use="")
bld.stlib(source=bld.path.ant_glob("src/rrr/base/*.cpp "
"src/rrr/misc/*.cpp "
"src/rrr/rpc/*.cpp "
"src/rrr/reactor/*.cc"),
target="rrr",
includes="src src/rrr",
uselib="BOOST",
use="PTHREAD")
# bld.stlib(source=bld.path.ant_glob("rpc/*.cc"), target="simplerpc",
# includes=". rrr rpc",
# use="base PTHREAD")
bld.stlib(source=bld.path.ant_glob("src/memdb/*.cc"), target="memdb",
includes="src src/rrr src/deptran src/base",
use="rrr PTHREAD")
bld.shlib(features="pyext",
source=bld.path.ant_glob("src/rrr/pylib/simplerpc/*.cpp"),
target="_pyrpc",
includes="src src/rrr src/rrr/rpc",
uselib="BOOST",
use="rrr simplerpc PYTHON")
bld.objects(source=bld.path.ant_glob("src/deptran/*.cc "
"src/deptran/*/*.cc "
"src/bench/*/*.cc",
excl=['src/deptran/s_main.cc', 'src/deptran/paxos_main_helper.cc']),
target="deptran_objects",
includes="src src/rrr src/deptran ",
uselib="YAML-CPP BOOST",
use="externc rrr memdb PTHREAD PROFILER RT")
bld.shlib(source=bld.path.ant_glob("src/deptran/paxos_main_helper.cc "),
target="txlog",
includes="src src/rrr src/deptran ",
uselib="YAML-CPP BOOST",
use="externc rrr memdb deptran_objects PTHREAD PROFILER RT")
bld.program(source=bld.path.ant_glob("src/deptran/s_main.cc"),
target="deptran_server",
includes="src src/rrr src/deptran ",
uselib="YAML-CPP BOOST",
use="externc rrr memdb deptran_objects PTHREAD PROFILER RT")
bld.program(source=bld.path.ant_glob("src/run.cc "
"src/deptran/paxos_main_helper.cc"),
target="microbench",
includes="src src/rrr src/deptran ",
uselib="YAML-CPP BOOST",
use="externc rrr memdb deptran_objects PTHREAD PROFILER RT")
bld.add_post_fun(post)
def post(conf):
_run_cmd("cp build/_pyrpc*.so src/rrr/pylib/simplerpc/")
#
# waf helper functions
#
def _choose_compiler(conf):
# use clang++ as default compiler (for c++11 support on mac)
if Options.options.cxx:
os.environ["CXX"] = "g++"
elif (sys.platform == 'darwin' and "CXX" not in os.environ) or Options.options.clang:
os.environ["CXX"] = "clang++"
conf.env.append_value("CXXFLAGS", "-stdlib=libc++")
conf.env.append_value("LINKFLAGS", "-stdlib=libc++")
Logs.pprint("PINK", "libc++ used")
else:
Logs.pprint("PINK", "use system default compiler")
def _enable_rpc_s(conf):
if Options.options.rpc_s:
conf.env.append_value("CXXFLAGS", "-DRPC_STATISTICS")
Logs.pprint("PINK", "RPC statistics enabled")
def _enable_piece_count(conf):
if Options.options.pc:
conf.env.append_value("CXXFLAGS", "-DPIECE_COUNT")
Logs.pprint("PINK", "Piece count enabled")
def _enable_txn_count(conf):
if Options.options.txn_stat:
conf.env.append_value("CXXFLAGS", "-DTXN_STAT")
Logs.pprint("PINK", "Txn stat enabled")
def _enable_conflict_count(conf):
if Options.options.cc:
conf.env.append_value("CXXFLAGS", "-DCONFLICT_COUNT")
Logs.pprint("PINK", "Conflict count enabled")
def _enable_logging(conf):
#if Options.options.log:
conf.check(compiler='cxx', lib='aio', mandatory=True, uselib_store="AIO")
conf.env.append_value("CXXFLAGS", "-DRECORD")
conf.env.append_value("LINKFLAGS", "-laio")
Logs.pprint("PINK", "Logging enabled")
def _enable_reuse_coroutine(conf):
if Options.options.disable_reuse_coroutine:
Logs.pprint("RED", "Disable reuse coroutine, dangerous to performance!")
else:
conf.env.append_value("CXXFLAGS", "-DREUSE_CORO")
Logs.pprint("PINK", "Reuse coroutine enabled")
def _enable_snappy(conf):
Logs.pprint("PINK", "google snappy enabled")
conf.env.append_value("LINKFLAGS", "-Wl,--no-as-needed")
conf.env.append_value("LINKFLAGS", "-lsnappy")
conf.env.append_value("LINKFLAGS", "-Wl,--as-needed")
def _enable_tcmalloc(conf):
if Options.options.tcmalloc:
Logs.pprint("PINK", "tcmalloc enabled")
conf.env.append_value("LINKFLAGS", "-Wl,--no-as-needed")
conf.env.append_value("LINKFLAGS", "-ltcmalloc")
conf.env.append_value("LINKFLAGS", "-Wl,--as-needed")
def _enable_jemalloc(conf):
if Options.options.jemalloc:
Logs.pprint("PINK", "jemalloc enabled")
conf.env.append_value("LINKFLAGS", "-Wl,--no-as-needed")
conf.env.append_value("LINKFLAGS", "-ljemalloc")
conf.env.append_value("LINKFLAGS", "-Wl,--as-needed")
def _enable_simulate_wan(conf):
if Options.options.simulate_wan:
Logs.pprint("PINK", "simulate wan")
conf.env.append_value("CXXFLAGS", "-DSIMULATE_WAN")
def _enable_db_checksum(conf):
if Options.options.db_checksum:
Logs.pprint("PINK", "db checksum")
conf.env.append_value("CXXFLAGS", "-DDB_CHECKSUM")
def _enable_leaksan(conf):
if Options.options.leaksan:
Logs.pprint("PINK", "leak sanitizer enabled")
conf.env.append_value("CXXFLAGS", "-fsanitize=leak")
def _enable_pic(conf):
conf.env.append_value("CXXFLAGS", "-fPIC")
conf.env.append_value("LINKFLAGS", "-fPIC")
def _enable_cxx14(conf):
Logs.pprint("PINK", "C++14 features enabled")
if sys.platform == "darwin":
conf.env.append_value("CXXFLAGS", "-stdlib=libc++")
conf.env.append_value("LINKFLAGS", "-stdlib=libc++")
conf.env.append_value("CXXFLAGS", "-std=c++14")
def _enable_profile(conf):
if Options.options.prof:
Logs.pprint("PINK", "CPU profiling enabled")
conf.env.append_value("CXXFLAGS", "-DCPU_PROFILE")
conf.env.LIB_PROFILER = 'profiler'
def _enable_event_timeout(conf):
if Options.options.event_timeout:
Logs.pprint("PINK", "event timeout enabled")
conf.env.append_value("CXXFLAGS", "-DEVENT_TIMEOUT_CHECK")
def _enable_ipc(conf):
if Options.options.ipc:
Logs.pprint("PINK", "Use IPC instead of network socket")
conf.env.append_value("CXXFLAGS", "-DUSE_IPC")
def _enable_debug(conf):
if Options.options.debug:
Logs.pprint("PINK", "Debug support enabled")
conf.env.append_value("CXXFLAGS", "-Wall -pthread -O0 -DNDEBUG -g "
"-ggdb -DLOG_LEVEL_AS_DEBUG -DLOG_DEBUG -rdynamic -fno-omit-frame-pointer".split())
else:
if Options.options.mutrace:
Logs.pprint("PINK", "mutrace debugging enabled")
conf.env.append_value("CXXFLAGS", "-Wall -pthread -O0 -DNDEBUG -g "
"-ggdb -DLOG_INFO -rdynamic -fno-omit-frame-pointer".split())
else:
conf.env.append_value("CXXFLAGS", "-g -pthread -O2 -DNDEBUG -DLOG_INFO".split())
def _properly_split(args):
if args == None:
return []
else:
return args.split()
def _gen_srpc_headers():
for srpc in glob.glob("deptran/*/*.rpc"):
target = os.path.splitext(srpc)[0]+'.h'
_depend(target,
srpc,
"bin/rpcgen --cpp " + srpc)
pass
def _depend(target, source, action):
target = _properly_split(target)
source = _properly_split(source)
for s in source:
if not os.path.exists(s):
Logs.pprint('RED', "'%s' not found!" % s)
exit(1)
for t in target:
if not os.path.exists(t):
_run_cmd(action)
if not target or min([os.stat(t).st_mtime for t in target]) < max([os.stat(s).st_mtime for s in source]):
_run_cmd(action)
def _run_cmd(cmd):
Logs.pprint('PINK', cmd)
os.system(cmd)