Commit 02049499 by Will White Committed by Konstantin Käfer

Change build script and layout to be more consistent with other node C++ modules.

parent 942b2f69
# vim: ft=javascript # vim: ft=javascript
import Options import Options
from os import unlink, symlink, system from os import unlink, system
from os.path import exists, abspath from os.path import exists, abspath
from shutil import copy2 as copy
srcdir = "." TARGET = 'sqlite3_bindings'
blddir = "build" TARGET_FILE = '%s.node' % TARGET
VERSION = "0.0.1" built = 'build/default/%s' % TARGET_FILE
dest = 'lib/%s' % TARGET_FILE
def set_options(opt): def set_options(opt):
opt.tool_options("compiler_cxx") opt.tool_options("compiler_cxx")
...@@ -15,6 +17,10 @@ def configure(conf): ...@@ -15,6 +17,10 @@ def configure(conf):
conf.check_tool("compiler_cxx") conf.check_tool("compiler_cxx")
conf.check_tool("compiler_cc") conf.check_tool("compiler_cc")
conf.check_tool("node_addon") conf.check_tool("node_addon")
if not conf.check_cfg(package='sqlite3', args='--cflags --libs', uselib_store='SQLITE3'):
if not conf.check(lib="sqlite3", libpath=['/usr/local/lib', '/opt/local/lib'], uselib_store="SQLITE3"):
conf.fatal('Missing sqlite3');
conf.env.append_value('LIBPATH_SQLITE3', '/opt/local/lib');
conf.env.append_value("LIBPATH_MPOOL", abspath("./deps/mpool-2.1.0/")) conf.env.append_value("LIBPATH_MPOOL", abspath("./deps/mpool-2.1.0/"))
conf.env.append_value("LIB_MPOOL", "mpool") conf.env.append_value("LIB_MPOOL", "mpool")
...@@ -26,28 +32,23 @@ def configure(conf): ...@@ -26,28 +32,23 @@ def configure(conf):
def build(bld): def build(bld):
system("cd deps/mpool-2.1.0/; make"); system("cd deps/mpool-2.1.0/; make");
obj = bld.new_task_gen("cxx", "shlib", "node_addon", install_path=None)
sqlite = bld.new_task_gen('cc', 'staticlib')
sqlite.ccflags = ["-g", "-fPIC", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall"]
sqlite.source = "deps/sqlite/sqlite3.c"
sqlite.target = "deps/sqlite/sqlite3-bundled"
sqlite.name = "sqlite3"
obj = bld.new_task_gen("cxx", "shlib", "node_addon")
obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall"] obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall"]
obj.target = "sqlite3_bindings" obj.target = TARGET
obj.source = "src/sqlite3_bindings.cc src/database.cc src/statement.cc" obj.source = "src/sqlite3_bindings.cc"
obj.uselib = "MPOOL" obj.source += " src/database.cc"
obj.uselib_local = "sqlite3" obj.source += " src/statement.cc"
obj.uselib = "SQLITE3 PROFILER MPOOL"
start_dir = bld.path.find_dir('lib')
# http://www.freehackers.org/~tnagy/wafbook/index.html#_installing_files
bld.install_files('${PREFIX}/lib/node/sqlite', start_dir.ant_glob('*'), cwd=start_dir, relative_trick=True)
t = 'sqlite3_bindings.node'
def shutdown(): def shutdown():
# HACK to get binding.node out of build directory.
# better way to do this?
if Options.commands['clean']: if Options.commands['clean']:
if exists(t): unlink(t) if exists(TARGET_FILE):
unlink(TARGET_FILE)
system("cd deps/mpool-2.1.0/; make clean"); system("cd deps/mpool-2.1.0/; make clean");
else: else:
if exists('build/default/' + t) and not exists(t): if exists(built):
symlink('build/default/' + t, t) copy(built, dest)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment