forked from jubatus/jubatus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
230 lines (191 loc) · 8.4 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
# -*- python -*-
from waflib import Options
from waflib.Errors import TaskNotReady
import os
import sys
VERSION = '1.0.3'
ABI_VERSION = VERSION
APPNAME = 'jubatus'
JUBATUS_ENGINES = [
'anomaly',
'bandit',
'burst',
'classifier',
'clustering',
'graph',
'nearest_neighbor',
'recommender',
'regression',
'stat',
'weight',
]
top = '.'
out = 'build'
subdirs = ['config', 'man', 'jubatus', 'plugin']
def options(opt):
opt.load('compiler_cxx')
opt.load('unittest_gtest')
opt.load('gnu_dirs')
opt.add_option('--enable-debug',
action='store_true', default=False,
dest='debug', help='build for debug')
opt.add_option('--enable-zookeeper',
action='store_true', default=False, # dest='nozk',
help='use ZooKeeper')
opt.add_option('--enable-gcov',
action='store_true', default=False,
dest='gcov', help='only for debug')
opt.add_option('--enable-zktest',
action='store_true', default=False,
dest='zktest', help='zk should run in localhost:2181')
# use (base + 10) ports for RPC module tests
opt.add_option('--rpc-test-port-base',
default=61023, type=int,
help='base port number for RPC module tests: [1024,' + str(65535-10) + ']')
opt.add_option('--fsanitize',
action='store', default="",
dest='fsanitize', help='specify sanitizer')
opt.recurse(subdirs)
def configure(conf):
conf.env.CXXFLAGS += ['-O2', '-Wall', '-g', '-pipe', '-pthread'];
conf.env.LINKFLAGS += ['-pthread']
conf.load('compiler_cxx')
conf.load('unittest_gtest')
conf.load('gnu_dirs')
# Generate config.hpp
conf.env.JUBATUS_PLUGIN_DIR = conf.env['LIBDIR'] + '/jubatus/plugin'
conf.define('JUBATUS_VERSION', VERSION)
conf.define('JUBATUS_APPNAME', APPNAME)
conf.define('JUBATUS_PLUGIN_DIR', conf.env.JUBATUS_PLUGIN_DIR)
conf.write_config_header('jubatus/config.hpp', guard="JUBATUS_CONFIG_HPP_", remove=False)
# Version constants
conf.env.VERSION = VERSION
conf.env.ABI_VERSION = ABI_VERSION
conf.env.JUBATUS_ENGINES = JUBATUS_ENGINES
conf.check_cxx(lib = 'msgpack')
conf.check_cxx(lib = 'jubatus_mpio')
conf.check_cxx(lib = 'jubatus_msgpack-rpc')
# pkg-config tests
conf.find_program('pkg-config') # make sure that pkg-config command exists
try:
conf.check_cfg(package = 'liblog4cxx', args = '--cflags --libs')
conf.check_cfg(package = 'jubatus_core', args = '--cflags --libs')
except conf.errors.ConfigurationError:
e = sys.exc_info()[1]
conf.to_log("PKG_CONFIG_PATH: " + os.environ.get('PKG_CONFIG_PATH', ''))
conf.fatal("Failed to find the library. Please confirm that PKG_CONFIG_PATH environment variable is correctly set.", e)
conf.check_cxx(header_name = 'unistd.h')
conf.check_cxx(header_name = 'sys/types.h')
conf.check_cxx(header_name = 'sys/wait.h')
conf.check_cxx(header_name = 'sys/stat.h')
conf.check_cxx(header_name = 'cxxabi.h')
conf.check_cxx(header_name = 'sys/socket.h net/if.h')
conf.check_cxx(header_name = 'sys/ioctl.h')
conf.check_cxx(header_name = 'fcntl.h')
conf.check_cxx(header_name = 'netinet/in.h')
conf.check_cxx(header_name = 'arpa/inet.h')
if Options.options.debug:
"""
You can compile "debug-enabled" version of Jubatus by ``./waf configure --enable-debug ...``.
In debug-enabled Jubatus, DEBUG-level logs and assertions are enabled.
In addition, if you want to enable Glibc C++ debugging feature (useful to debug STL-related
issues), you can uncomment the following line. Note that dependency libraries (log4cxx and
jubatus_core) and optional library (ux-trie) must be recompiled with this option.
"""
# conf.define('_GLIBCXX_DEBUG', 1)
pass
else:
# Disable DEBUG logs and standard assertions
conf.define('NDEBUG', 1)
# Disable Jubatus specific assertions
conf.define('JUBATUS_DISABLE_ASSERTIONS', 1)
if Options.options.enable_zookeeper:
if (conf.check_cxx(header_name = 'c-client-src/zookeeper.h',
define_name = 'HAVE_ZOOKEEPER_H',
mandatory = False)):
conf.define('ZOOKEEPER_HEADER', 'c-client-src/zookeeper.h')
else:
conf.check_cxx(header_name = 'zookeeper/zookeeper.h',
define_name = 'HAVE_ZOOKEEPER_H',
errmsg = 'ZooKeeper c-binding is not found. Please install c-binding.',
mandatory = True)
conf.define('ZOOKEEPER_HEADER', 'zookeeper/zookeeper.h')
conf.check_cxx(lib = 'zookeeper_mt', errmsg = 'ZK not found')
if Options.options.zktest:
conf.env.INTEGRATION_TEST = True
if Options.options.gcov:
conf.env.append_value('CXXFLAGS', '-fprofile-arcs')
conf.env.append_value('CXXFLAGS', '-ftest-coverage')
conf.env.append_value('LINKFLAGS', '-lgcov')
conf.env.append_value('LINKFLAGS', '--coverage')
if Options.options.rpc_test_port_base:
if Options.options.rpc_test_port_base < 1024 or (65535-10) < Options.options.rpc_test_port_base:
conf.fatal("rpc_test_port_base out of range")
conf.define('JUBATUS_RPC_TEST_PORT_BASE', int(Options.options.rpc_test_port_base))
conf.define('BUILD_DIR', conf.bldnode.abspath())
sanitizer_names = Options.options.fsanitize
if len(sanitizer_names) > 0:
conf.env.append_unique('CXXFLAGS', '-fsanitize=' + sanitizer_names)
conf.env.append_unique('LINKFLAGS', '-fsanitize=' + sanitizer_names)
conf.recurse(subdirs)
def build(bld):
bld(source = 'jubatus.pc.in',
prefix = bld.env['PREFIX'],
exec_prefix = '${prefix}',
libdir = bld.env['LIBDIR'],
includedir = '${prefix}/include',
PACKAGE = APPNAME,
VERSION = VERSION)
bld(source = 'jubatus-client.pc.in',
prefix = bld.env['PREFIX'],
exec_prefix = '${prefix}',
libdir = bld.env['LIBDIR'],
includedir = '${prefix}/include',
PACKAGE = APPNAME,
VERSION = VERSION)
bld(name = 'server_headers', export_includes = './')
bld(name = 'client_headers', export_includes = './')
bld.recurse(subdirs)
bld.install_files('${PREFIX}/share/jubatus/example/log', 'log4cxx.xml')
def cpplint(ctx):
sys.stderr.write('Running cpplint...\n')
ctx.cmd_and_log(['tools/codestyle/run_cpplint.sh'] + subdirs)
def regenerate(ctx):
server_node = ctx.path.find_node('jubatus/server/server')
jenerator_node = ctx.path.find_node('tools/jenerator/src/jenerator')
if not jenerator_node:
raise TaskNotReady('jenerator is not built yet')
for idl_node in server_node.ant_glob('*.idl'):
idl = idl_node.name
service_name = os.path.splitext(idl)[0]
jenerator_command = [jenerator_node.abspath(), '-l', 'server', '-o', '.', '-i', '-n', 'jubatus', '-g', 'JUBATUS_SERVER_SERVER_', idl]
try:
idl_hash = ctx.cmd_and_log(['git', 'log', '-1', '--format=%H', '--', idl], cwd=server_node.abspath()).strip()
idl_ver = ctx.cmd_and_log(['git', 'describe', idl_hash], cwd=server_node.abspath()).strip()
jenerator_command += ['--idl-version', idl_ver]
except Exception:
pass
ctx.cmd_and_log(jenerator_command, cwd=server_node.abspath())
print()
if not service_name in ['graph', 'anomaly']:
server_node.find_node('%s_client.hpp' % service_name).delete()
def regenerate_client(ctx):
server_node = ctx.path.find_node('jubatus/server/server')
client_node = ctx.path.find_node('jubatus/client')
jenerator_node = ctx.path.find_node('tools/jenerator/src/jenerator')
if not jenerator_node:
raise TaskNotReady('jenerator is not built yet')
for idl_node in server_node.ant_glob('*.idl'):
idl = idl_node.name
service_name = os.path.splitext(idl)[0]
jenerator_command = [jenerator_node.abspath(), '-l', 'cpp', '-o', client_node.abspath(), '-i', '-n', 'jubatus::' + service_name, '-g', 'JUBATUS_CLIENT_', idl]
try:
idl_hash = ctx.cmd_and_log(['git', 'log', '-1', '--format=%H', '--', idl], cwd=server_node.abspath()).strip()
idl_ver = ctx.cmd_and_log(['git', 'describe', idl_hash], cwd=server_node.abspath()).strip()
jenerator_command += ['--idl-version', idl_ver]
except Exception:
pass
ctx.cmd_and_log(jenerator_command, cwd=server_node.abspath())
print()
def check_cmath(ctx):
ctx.cmd_and_log('tools/codestyle/cmath_finder.sh')