forked from NYU-NEWS/janus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
executable file
·290 lines (246 loc) · 10.7 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
#!/usr/bin/env python3
APPNAME="rococo"
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_cxx") # removed unittest_gtest
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('-p', '--enable-profiling', dest='prof',
default=False, action='store_true')
opt.add_option('-d', '--debug', dest='debug',
default=False, action='store_true')
opt.add_option('-t', '--enable-tcmalloc', dest='tcmalloc',
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('-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.parse_args();
def configure(conf):
_choose_compiler(conf)
_enable_pic(conf)
conf.load("compiler_cxx") # removed unittest_gtest
# conf.load("boost")
_enable_tcmalloc(conf)
_enable_cxx11(conf)
_enable_debug(conf)
_enable_profile(conf)
_enable_rpc_s(conf)
_enable_piece_count(conf)
_enable_txn_count(conf)
_enable_conflict_count(conf)
# _enable_snappy(conf)
#_enable_logging(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 coroutine')
conf.env.append_value("CXXFLAGS", "-Wno-sign-compare")
conf.env.append_value('INCLUDES', ['/usr/local/include'])
# in case you use linuxbrew
conf.env.append_value('INCLUDES', [os.path.expanduser('~') + '/.linuxbrew/include'])
conf.env.append_value('LIBPATH', [os.path.expanduser('~') + '/.linuxbrew/lib'])
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')
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("rrr/pylib/simplerpcgen/rpcgen.py",
"rrr/pylib/simplerpcgen/rpcgen.g",
"rrr/pylib/yapps/main.py rrr/pylib/simplerpcgen/rpcgen.g")
# _depend("rlog/log_service.h", "rlog/log_service.rpc",
# "bin/rpcgen rlog/log_service.rpc")
_depend("deptran/rcc_rpc.h deptran/rcc_rpc.py",
"deptran/rcc_rpc.rpc",
"bin/rpcgen --python --cpp 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("rrr/base/*.cpp "
"rrr/misc/*.cpp "
"rrr/rpc/*.cpp "
"rrr/coroutine/*.cc"),
target="rrr",
includes=". rrr",
uselib=BOOST_LIBS,
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("memdb/*.cc"), target="memdb",
includes=". rrr deptran base",
use="rrr PTHREAD")
# bld.stlib(source="rlog/rlog.cc", target="rlog",
# includes=". rrr rlog rpc",
# use="simplerpc base PTHREAD")
bld.shlib(features="pyext",
source=bld.path.ant_glob("rrr/pylib/simplerpc/*.cpp"),
target="_pyrpc",
includes=". rrr rrr/rpc",
use="rrr simplerpc PYTHON")
# bld.program(source=bld.path.ant_glob("rlog/*.cc", excl="rlog/rlog.cc"),
# target="rlogserver",
# includes=". rrr",
# use="base simplerpc PTHREAD")
# bld.stlib(source=bld.path.ant_glob("deptran/*.cc "
# "deptran/*/*.cc "
# "bench/*/*.cc ",
# excl="deptran/*_main.c*"),
# target="deptran",
# includes=". rrr deptran ",
# uselib="BOOST BOOST_SYSTEM BOOST_COROUTINE YAML-CPP",
# use="PTHREAD memdb base simplerpc memdb PROFILER RT")
#
# bld.program(source=bld.path.ant_glob("test/*.cc"),
# target="tests",
# features="gtest",
# includes=". rrr deptran test memdb",
# uselib="BOOST BOOST_SYSTEM BOOST_COROUTINE YAML-CPP",
# use="PTHREAD rrr memdb deptran PROFILER RT")
bld.program(source=bld.path.ant_glob("deptran/*.cc "
"deptran/*/*.cc "
"bench/*/*.cc"),
target="deptran_server",
includes=". rrr deptran ",
uselib="YAML-CPP " + BOOST_LIBS,
use="rrr memdb PTHREAD PROFILER RT")
# bld.program(source=bld.path.ant_glob("deptran/c_main.cc"),
# target="deptran_client",
# includes=". rrr bench deptran deptran/ro6 deptran/rcc deptran/tpl deptran/brq deptran/none",
# use="rrr memdb deptran YAML-CPP PTHREAD RT")
# bld.program(source="old-test/rpcbench.cc old-test/benchmark_service.cc",
# target="rpcbench",
# includes=". rrr deptran old-test",
# uselib="BOOST BOOST_SYSTEM BOOST_COROUTINE YAML-CPP",
# use="rrr PTHREAD")
# bld.program(source="test/rpc_microbench.cc test/benchmark_service.cc",
# target="rpc_microbench",
# includes=". rrr deptran test",
# use="rrr PTHREAD RT")
#
#
#
# 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_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_pic(conf):
conf.env.append_value("CXXFLAGS", "-fPIC")
conf.env.append_value("LINKFLAGS", "-fPIC")
def _enable_cxx11(conf):
Logs.pprint("PINK", "C++11 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++11")
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_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:
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)