forked from jubatus/jubatus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
155 lines (126 loc) · 5.37 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
import Options
VERSION = '0.4.2'
APPNAME = 'jubatus'
top = '.'
out = 'build'
subdirs = ['src', 'client', 'config']
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')
opt.recurse(subdirs)
def configure(conf):
conf.env.CXXFLAGS += ['-O2', '-Wall', '-g', '-pipe']
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('src/config.hpp', guard="JUBATUS_CONFIG_HPP_", remove=False)
conf.check_cxx(lib = 'msgpack')
conf.check_cxx(lib = 'jubatus_mpio')
conf.check_cxx(lib = 'jubatus_msgpack-rpc')
conf.check_cxx(lib = 'dl')
conf.check_cfg(package = 'libglog', args = '--cflags --libs')
conf.check_cfg(package = 'pficommon', args = '--cflags --libs')
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')
conf.check_cxx(header_name = 'dlfcn.h')
if not Options.options.debug:
conf.define('NDEBUG', 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.define('BUILD_DIR', conf.bldnode.abspath())
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.recurse(subdirs)
def cpplint(ctx):
import fnmatch, tempfile
cpplint = ctx.path.find_node('tools/codestyle/cpplint/cpplint.py')
src_dir = ctx.path.find_node('src')
file_list = []
excludes = ['src/third_party/**', \
'src/server/*_server.hpp', \
'src/server/*_impl.cpp', \
'src/server/*_keeper.cpp', \
'src/server/*_client.hpp', \
'src/server/*_types.hpp']
for file in src_dir.ant_glob('**/*.cpp **/*.cc **/*.hpp **/*.h'):
file_list += [file.path_from(ctx.path)]
for exclude in excludes:
file_list = [f for f in file_list if not fnmatch.fnmatch(f, exclude)]
tmp_file = tempfile.NamedTemporaryFile(delete=True);
tmp_file.write("\n".join(file_list));
tmp_file.flush()
ctx.exec_command('cat ' + tmp_file.name + ' | xargs "' + cpplint.abspath() + '" --filter=-runtime/references,-runtime/rtti')
tmp_file.close()
def regenerate(ctx):
import os
server_node = ctx.path.find_node('src/server')
jenerator_node = ctx.path.find_node('tools/jenerator/src/jenerator')
for idl_node in server_node.ant_glob('*.idl'):
idl = idl_node.name
service_name = os.path.splitext(idl)[0]
ctx.cmd_and_log([jenerator_node.abspath(), '-l', 'server', '-o', '.', '-i', '-n', 'jubatus', '-g', 'JUBATUS_SERVER_', idl], cwd=server_node.abspath())
def regenerate_client(ctx):
import os
server_node = ctx.path.find_node('src/server')
client_node = ctx.path.find_node('client')
jenerator_node = ctx.path.find_node('tools/jenerator/src/jenerator')
for idl_node in server_node.ant_glob('*.idl'):
idl = idl_node.name
service_name = os.path.splitext(idl)[0]
ctx.cmd_and_log([jenerator_node.abspath(), '-l', 'cpp', '-o', client_node.abspath(), '-i', '-n', 'jubatus::' + service_name, '-g', 'JUBATUS_', idl], cwd=server_node.abspath())