-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwscript
More file actions
102 lines (84 loc) · 2.99 KB
/
wscript
File metadata and controls
102 lines (84 loc) · 2.99 KB
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
#!/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()
jsonc_root = cwd + '/deps/json-c-0.9'
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')
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
os.chdir(jsonc_root)
args = ['./configure', '--disable-shared', '--enable-static', '--with-pic', '--with-gnu-ld']
subprocess.check_call(args)
conf.env.append_value('CPPPATH', jsonc_root)
conf.env.append_value('LIBPATH', jsonc_root)
os.chdir(cwd)
conf.env['USE_DEBUG'] = o.debug
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(['./dev/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 'jshint: ' + f
subprocess.call(['jshint', os.path.join(dirname, f)])
dirname = cwd + '/test'
for f in os.listdir(dirname):
print 'jshint: ' + f
subprocess.call(['jshint', os.path.join(dirname, f)])
def build(bld):
obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
os.chdir(jsonc_root)
subprocess.check_call(['make', '-j', '3'])
subprocess.check_call(['ar', 'rcus', 'libjsonc.a',
'arraylist.o',
'debug.o',
'json_object.o',
'json_tokener.o',
'json_util.o',
'linkhash.o',
'printbuf.o'])
os.chdir(cwd)
obj.staticlib = "jsonc"
obj.target = 'node_db_native'
obj.source = './src/db_index.cc '
obj.name = "node-db"
obj.defines = ['NODE_DB_REVISION="' + REVISION + '"']
def test(ctx):
system('node test/test_basic.js')
system('node test/test_fixtures.js')
def distclean(ctx):
os.chdir(jsonc_root)
os.popen('make distclean 2>&1 > /dev/null')
os.chdir(cwd)
os.popen('rm -rf .lock-wscript build')