forked from shuaimu/rococo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
executable file
·258 lines (214 loc) · 9.19 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
#!/usr/bin/env python
APPNAME="rococo"
VERSION="0.0"
import os
import sys
from waflib import Logs
from waflib import Options
pargs = ['--cflags', '--libs']
def options(opt):
opt.load("compiler_cxx")
#opt.load("eclipse")
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.parse_args();
def configure(conf):
_choose_compiler(conf)
conf.load("compiler_cxx")
conf.load("python")
conf.load("boost")
conf.check_python_headers()
_enable_tcmalloc(conf)
_enable_pic(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-sign-compare")
conf.check_cfg(package='apr-1', uselib_store='APR', args=pargs)
conf.check_cfg(package='apr-util-1', uselib_store='APR-UTIL', args=pargs)
conf.check_boost()
conf.env.append_value("CXXFLAGS", "-Wno-sign-compare")
conf.env.append_value('INCLUDES', ['/usr/local/include'])
conf.env.append_value("CXXFLAGS", "-Wno-sign-compare")
conf.env.LIB_PTHREAD = 'pthread'
if sys.platform != 'darwin':
conf.env.LIB_RT = 'rt'
# check python modules
conf.check_python_module('tabulate')
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")
_depend("test/benchmark_service.h", "test/benchmark_service.rpc",
"bin/rpcgen --cpp test/benchmark_service.rpc")
bld.stlib(source=bld.path.ant_glob("rrr/base/*.cpp "
"rrr/misc/*.cpp "
"rrr/rpc/*.cpp"),
target="rrr",
includes=". rrr",
use="PTHREAD APR APR-UTIL")
# bld.stlib(source=bld.path.ant_glob("rpc/*.cc"), target="simplerpc",
# includes=". rrr rpc",
# use="base PTHREAD APR APR-UTIL")
bld.stlib(source=bld.path.ant_glob("memdb/*.cc"), target="memdb",
includes=". rrr deptran base",
use="rrr PTHREAD APR APR-UTIL")
# 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/*.cc"),
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.program(source=bld.path.ant_glob("test/test*.cc"),
target="testharness",
includes=". rrr bench deptran",
use="rrr memdb deptran PTHREAD RT")
bld.program(source=bld.path.ant_glob("deptran/s_main.cc"),
target="deptran_server",
includes=". rrr bench deptran",
use="rrr memdb deptran PTHREAD PROFILER RT")
bld.program(source=bld.path.ant_glob("deptran/c_main.cc"),
target="deptran_client",
includes=". rrr bench deptran",
use="rrr memdb deptran PTHREAD RT")
# bld.program(source="test/rpcbench.cc test/benchmark_service.cc",
# target="rpcbench",
# includes=". rrr deptran test",
# 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 APR APR-UTIL")
bld.stlib(source=bld.path.ant_glob("deptran/*.cc "
"deptran/*.cpp "
"deptran/util/*.cc "
"bench/tpca/*.cc "
"bench/tpcc/*.cc "
"bench/tpcc/*.cpp "
"bench/tpcc_real_dist/*.cc "
"bench/tpcc_dist/*.cc "
"bench/rw_benchmark/*.cc "
"bench/micro/*.cc"),
target="deptran",
includes=". rrr memdb bench deptran",
use="PTHREAD APR APR-UTIL base simplerpc memdb")
#
# waf helper functions
#
def _choose_compiler(conf):
# use clang++ as default compiler (for c++11 support on mac)
if sys.platform == 'darwin' and "CXX" not in os.environ:
os.environ["CXX"] = "clang++"
if Options.options.cxx:
os.environ["CXX"] = "g++"
elif Options.options.clang:
os.environ["CXX"] = "clang++"
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++0x")
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_DEBUG -rdynamic -fno-omit-frame-pointer".split())
else:
conf.env.append_value("CXXFLAGS", "-Wall -pthread -O2 -DNDEBUG".split())
def _properly_split(args):
if args == None:
return []
else:
return args.split()
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)