forked from creationix/node-leveldb
-
Notifications
You must be signed in to change notification settings - Fork 12
/
wscript
115 lines (100 loc) · 2.91 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
from os import system, remove
from os.path import abspath, exists, join
from shutil import rmtree
import Utils
srcdir = abspath(".")
blddir = "build"
VERSION = "0.0.1"
leveldb_dir = join(srcdir, "deps/leveldb")
leveldb_src = ["deps/leveldb" + path for path in [
"/db/builder.cc",
"/db/c.cc",
"/db/db_impl.cc",
"/db/db_iter.cc",
"/db/filename.cc",
"/db/dbformat.cc",
"/db/log_reader.cc",
"/db/log_writer.cc",
"/db/memtable.cc",
"/db/repair.cc",
"/db/table_cache.cc",
"/db/version_edit.cc",
"/db/version_set.cc",
"/db/write_batch.cc",
"/port/port_posix.cc",
"/table/block.cc",
"/table/block_builder.cc",
"/table/format.cc",
"/table/iterator.cc",
"/table/merger.cc",
"/table/table.cc",
"/table/table_builder.cc",
"/table/two_level_iterator.cc",
"/util/arena.cc",
"/util/cache.cc",
"/util/coding.cc",
"/util/comparator.cc",
"/util/crc32c.cc",
"/util/env.cc",
"/util/env_posix.cc",
"/util/hash.cc",
"/util/histogram.cc",
"/util/logging.cc",
"/util/options.cc",
"/util/status.cc"
]]
snappy_dir = join(srcdir, "deps/snappy")
snappy_src = ["deps/snappy/" + path for path in [
"snappy.cc",
"snappy-sinksource.cc",
"snappy-stubs-internal.cc",
"snappy-c.cc"
]]
node_leveldb_src = ["src/cpp/" + path for path in [
"batch.cc",
"binding.cc",
"comparator.cc",
"handle.cc",
"iterator.cc"
]]
build_config = join(leveldb_dir, 'build_config.mk')
def set_options(opt):
opt.tool_options("compiler_cxx")
opt.tool_options("compiler_cc")
def parse_build_config(env):
f = open(build_config)
for line in f:
if '#' in line:
line, comment = line.split('#', 1)
if '=' in line:
option, value = line.split('=', 1)
option = option.strip()
value = value.strip()
env[option] = value
f.close()
def configure(conf):
conf.check_tool("compiler_cxx")
conf.check_tool("compiler_cc")
conf.check_tool("node_addon")
if not exists('./deps/snappy/Makefile'):
Utils.exec_command('./configure', cwd = './deps/snappy')
if not exists(build_config):
system('cd %s && sh build_detect_platform' % leveldb_dir)
parse_build_config(conf.env)
def clean(ctx):
if exists('build'): rmtree('build')
if exists(build_config): remove(build_config)
if exists('./deps/snappy/Makefile'):
Utils.exec_command('make distclean', cwd = './deps/snappy')
def build_post(bld):
module_path = bld.path.find_resource('leveldb.node').abspath(bld.env)
system('mkdir -p lib')
system('cp %r lib/leveldb.node' % module_path)
def build(bld):
node_leveldb = bld.new_task_gen("cxx", "shlib", "node_addon")
node_leveldb.source = snappy_src + leveldb_src + node_leveldb_src
node_leveldb.name = "node_leveldb"
node_leveldb.target = "leveldb"
node_leveldb.includes = [snappy_dir, leveldb_dir, leveldb_dir + '/include']
node_leveldb.cxxflags = ['-Wall', '-O2', '-DSNAPPY'] + bld.env.PORT_CFLAGS.split(' ') + bld.env.PLATFORM_CFLAGS.split(' ')
bld.add_post_fun(build_post)