-
Notifications
You must be signed in to change notification settings - Fork 8
/
wscript
143 lines (124 loc) · 4.51 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
#!/usr/bin/env python
import os, subprocess, sys
import Options, Utils
from os import unlink, symlink, chdir, popen, system
from os.path import exists, join
VERSION = '0.1'
REVISION = popen("git log | head -n1 | awk '{printf \"%s\", $2}'").readline()
cwd = os.getcwd()
bdb_root = cwd + '/deps/db-5.1.25'
bdb_bld_dir = bdb_root + '/build_unix'
srcdir = '.'
blddir = 'build'
sys.path.append(cwd + '/tools')
def set_options(opt):
opt.tool_options("compiler_cxx")
opt.tool_options("compiler_cc")
opt.tool_options('misc')
opt.add_option('--debug',
action='store',
default=False,
help='Enable debug variant [Default: False]',
dest='debug')
opt.add_option('--shared-bdb-includes',
action='store',
default=False,
help='Directory containing bdb header files',
dest='shared_bdb_includes')
opt.add_option('--shared-bdb-libpath',
action='store',
default=False,
help='A directory to search for the shared BDB DLL',
dest='shared_bdb_libpath')
def configure(conf):
conf.check_tool('compiler_cxx')
if not conf.env.CXX: conf.fatal('c++ compiler not found')
conf.check_tool("compiler_cc")
if not conf.env.CC: conf.fatal('c compiler not found')
conf.check_tool('node_addon')
o = Options.options
conf.env['USE_DEBUG'] = o.debug
conf.env['USE_SHARED_BDB'] = o.shared_bdb_includes or o.shared_bdb_libpath
if conf.env['USE_SHARED_BDB']:
bdb_includes = []
bdb_libpath = []
if o.shared_bdb_includes: bdb_includes.append(o.shared_bdb_includes)
if o.shared_bdb_libpath: bdb_libpath.append(o.shared_bdb_libpath)
conf.check_cxx(lib='db-5',
header_name="db.h",
use_libstore='BDB',
includes=bdb_includes,
libpath=bdb_libpath,
mandatory=True)
conf.env.append_value('CPPPATH', o.shared_bdb_includes)
conf.env.append_value('LIBPATH', o.shared_bdb_libpath)
else:
os.chdir(bdb_bld_dir)
args = ['../dist/configure',
'--with-cryptography=yes',
'--disable-shared',
'--disable-replication',
'--enable-cxx=no',
'--enable-java=no',
'--enable-sql=no',
'--enable-tcl=no',
'--with-pic=yes']
if o.debug:
args.append('--enable-debug=yes')
if sys.platform.startswith("sunos") or sys.platform.startswith("darwin"):
args.append('--enable-dtrace')
args.append('--enable-perfmon-statistics')
subprocess.check_call(args)
conf.env.append_value('CPPPATH', bdb_bld_dir)
conf.env.append_value('LIBPATH', bdb_bld_dir)
os.chdir(cwd)
conf.env.append_value('CXXFLAGS', ['-D_FILE_OFFSET_BITS=64',
'-D_LARGEFILE_SOURCE',
'-Wall',
'-fPIC',
'-Werror'])
if o.debug:
conf.env.append_value('CXXFLAGS', ["-g"])
else:
conf.env.append_value('CXXFLAGS', ['-O3'])
def lint(ctx):
dirname = cwd + '/src'
for f in os.listdir(dirname):
subprocess.check_call(['./tools/cpplint.py',
'--filter=-build/include,-build/header_guard,-runtime/rtti',
os.path.join(dirname, f)])
dirname = cwd + '/lib'
for f in os.listdir(dirname):
print 'jslint: ' + f
subprocess.call(['jslint', os.path.join(dirname, f)])
dirname = cwd + '/test'
for f in os.listdir(dirname):
print 'jslint: ' + f
subprocess.call(['jslint', os.path.join(dirname, f)])
def build(bld):
obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
obj.target = 'bdb_bindings'
obj.source = './src/bdb_object.cc ./src/bdb_bindings.cc '
obj.source += './src/bdb_env.cc ./src/bdb_db.cc '
obj.name = "node-bdb"
obj.defines = ['NODE_BDB_REVISION="' + REVISION + '"']
if not bld.env['USE_SHARED_BDB']:
os.chdir(bdb_bld_dir)
subprocess.check_call(['make', '-j', '3'])
os.chdir(cwd)
obj.staticlib = "db-5.1"
else:
obj.lib = "db-5"
def test(ctx):
system('node test/test_open.js')
system('node test/test_put.js')
system('node test/test_get.js')
system('node test/test_del.js')
system('node test/test_concurrent.js')
system('node test/test_cursor.js')
def distclean(ctx):
os.chdir(bdb_bld_dir)
os.popen('make distclean 2>&1 > /dev/null')
os.chdir(cwd)
os.popen('rm -rf .lock-wscript build')
os.popen('rm -rf ' + bdb_bld_dir + '/*')