Commit a7de57a9 by Dane Springmeyer

default to building against internal version of sqlite, and allow disabling by…

default to building against internal version of sqlite, and allow disabling by passing option to --with-sqlite3. Also update to latest sqlite version for internal copy - closes #43
parent 11453823
...@@ -15,55 +15,84 @@ TARGET_FILE = '%s.node' % TARGET ...@@ -15,55 +15,84 @@ TARGET_FILE = '%s.node' % TARGET
built = 'build/default/%s' % TARGET_FILE built = 'build/default/%s' % TARGET_FILE
dest = 'lib/%s' % TARGET_FILE dest = 'lib/%s' % TARGET_FILE
BUNDLED_SQLITE3_VERSION = '3070701' BUNDLED_SQLITE3_VERSION = '3070800'
BUNDLED_SQLITE3 = 'sqlite-autoconf-%s' % BUNDLED_SQLITE3_VERSION BUNDLED_SQLITE3 = 'sqlite-autoconf-%s' % BUNDLED_SQLITE3_VERSION
BUNDLED_SQLITE3_TAR = 'sqlite-autoconf-%s.tar.gz' % BUNDLED_SQLITE3_VERSION BUNDLED_SQLITE3_TAR = 'sqlite-autoconf-%s.tar.gz' % BUNDLED_SQLITE3_VERSION
SQLITE3_TARGET = 'deps/%s' % BUNDLED_SQLITE3 SQLITE3_TARGET = 'deps/%s' % BUNDLED_SQLITE3
sqlite3_test_program = '''
#include "stdio.h"
#ifdef __cplusplus
extern "C" {
#endif
#include <sqlite3.h>
#ifdef __cplusplus
}
#endif
int
main() {
return 0;
}
'''
def set_options(opt): def set_options(opt):
opt.tool_options("compiler_cxx") opt.tool_options("compiler_cxx")
opt.add_option( '--with-sqlite3'
opt.add_option( '--internal-sqlite' , action='store'
, action='store_true' , default=None
, default=False , help='Directory prefix containing sqlite "lib" and "include" files (default is to compile against internal copy of sqlite v%s' % BUNDLED_SQLITE3_VERSION
, help='Build dynamically against external install of libsqlite3 (default False - build uses internal copy)' , dest='sqlite3_dir'
, dest='internal_sqlite'
) )
def _conf_exit(conf,msg):
conf.fatal('\n\n' + msg + '\n...check the build/config.log for details')
def _build_paths(conf,prefix):
if not os.path.exists(prefix):
_conf_exit(conf,'configure path of %s not found' % prefix)
norm_path = os.path.normpath(os.path.realpath(prefix))
if norm_path.endswith('lib') or norm_path.endswith('include'):
norm_path = os.path.dirname(norm_path)
return os.path.join('%s' % norm_path,'lib'),os.path.join('%s' % norm_path,'include')
def configure(conf): def configure(conf):
conf.check_tool("compiler_cxx") conf.check_tool("compiler_cxx")
conf.check_tool("node_addon") conf.check_tool("node_addon")
if not Options.options.internal_sqlite:
try: o = Options.options
conf.check_cfg(package="sqlite3", args='--libs --cflags',
uselib_store="SQLITE3", mandatory=True)
except ConfigurationError:
conf.check(lib="sqlite3", libpath=['/usr/local/lib', '/opt/local/lib'],
uselib_store="SQLITE3", mandatory=True)
Utils.pprint('YELLOW','Note: pass --internal-sqlite to compile and link against bundled sqlite (version %s)' % BUNDLED_SQLITE3_VERSION) if not o.sqlite3_dir:
configure_internal_sqlite3(conf)
else: else:
configure_interal_sqlite3(conf) lib, include = _build_paths(conf,o.sqlite3_dir)
if conf.check_cxx(lib='sqlite3',
fragment=sqlite3_test_program,
uselib_store='SQLITE3',
libpath=lib,
msg='Checking for libsqlite3 at %s' % lib,
includes=include):
Utils.pprint('GREEN', 'Sweet, found viable sqlite3 dependency at: %s ' % o.sqlite3_dir)
else:
_conf_exit(conf,'sqlite3 libs/headers not found at %s' % o.sqlite3_dir)
linkflags = [] linkflags = []
if os.environ.has_key('LINKFLAGS'): if os.environ.has_key('LINKFLAGS'):
linkflags.extend(os.environ['LINKFLAGS'].split(' ')) linkflags.extend(os.environ['LINKFLAGS'].split(' '))
if Options.options.internal_sqlite and Options.platform == 'darwin': if not o.sqlite3_dir and Options.platform == 'darwin':
linkflags.append('-Wl,-search_paths_first') linkflags.append('-Wl,-search_paths_first')
conf.env.append_value("LINKFLAGS", linkflags) conf.env.append_value("LINKFLAGS", linkflags)
def configure_interal_sqlite3(conf): def configure_internal_sqlite3(conf):
Utils.pprint('GREEN','Using internal sqlite3!') Utils.pprint('GREEN','Note: will build against internal copy of sqlite3 v%s\n(pass --with-sqlite3=/usr/local to build against an external version)' % BUNDLED_SQLITE3_VERSION)
os.chdir('deps') os.chdir('deps')
if not os.path.exists(BUNDLED_SQLITE3): if not os.path.exists(BUNDLED_SQLITE3):
os.system('tar xvf %s' % BUNDLED_SQLITE3_TAR) os.system('tar xf %s' % BUNDLED_SQLITE3_TAR)
os.chdir(BUNDLED_SQLITE3) os.chdir(BUNDLED_SQLITE3)
cxxflags = '' cxxflags = ''
if os.environ.has_key('CFLAGS'): if os.environ.has_key('CFLAGS'):
...@@ -73,14 +102,17 @@ def configure_interal_sqlite3(conf): ...@@ -73,14 +102,17 @@ def configure_interal_sqlite3(conf):
cxxflags += os.environ['CXXFLAGS'] cxxflags += os.environ['CXXFLAGS']
# LINKFLAGS appear to be picked up automatically... # LINKFLAGS appear to be picked up automatically...
if not os.path.exists('config.status'): if not os.path.exists('config.status'):
os.system("CFLAGS='%s -DSQLITE_ENABLE_RTREE=1 -fPIC -O3 -DNDEBUG' ./configure --disable-dependency-tracking --enable-static --disable-shared" % cxxflags) cmd = "CFLAGS='%s -DSQLITE_ENABLE_RTREE=1 -fPIC -O3 -DNDEBUG' ./configure --enable-static --disable-shared" % cxxflags
if Options.platform == 'darwin':
cmd += ' --disable-dependency-tracking'
os.system(cmd)
os.chdir('../../') os.chdir('../../')
conf.env.append_value("CPPPATH_SQLITE3", ['../deps/%s' % BUNDLED_SQLITE3]) conf.env.append_value("CPPPATH_SQLITE3", ['../deps/%s' % BUNDLED_SQLITE3])
conf.env.append_value("LINKFLAGS", ['-L../deps/%s/.libs' % BUNDLED_SQLITE3, '-lsqlite3']) conf.env.append_value("LINKFLAGS", ['-L../deps/%s/.libs' % BUNDLED_SQLITE3, '-lsqlite3'])
def build_internal_sqlite3(): def build_internal_sqlite3(bld):
if not Options.commands['clean'] and Options.options.internal_sqlite: if not Options.commands['clean'] and '../deps' in bld.env['CPPPATH_SQLITE3'][0]:
if not os.path.exists(SQLITE3_TARGET): if not os.path.exists(SQLITE3_TARGET):
Utils.pprint('RED','Please re-run ./configure or node-waf configure') Utils.pprint('RED','Please re-run ./configure or node-waf configure')
sys.exit() sys.exit()
...@@ -94,7 +126,7 @@ def clean_internal_sqlite3(): ...@@ -94,7 +126,7 @@ def clean_internal_sqlite3():
def build(bld): def build(bld):
obj = bld.new_task_gen("cxx", "shlib", "node_addon") obj = bld.new_task_gen("cxx", "shlib", "node_addon")
build_internal_sqlite3() build_internal_sqlite3(bld)
obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE",
"-DSQLITE_ENABLE_RTREE=1", "-pthread", "-Wall"] "-DSQLITE_ENABLE_RTREE=1", "-pthread", "-Wall"]
# uncomment the next line to remove '-undefined dynamic_lookup' # uncomment the next line to remove '-undefined dynamic_lookup'
......
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