node/tools/wafadmin/Tools/node_addon.py

47 lines
1.5 KiB
Python
Raw Normal View History

import os
import TaskGen, Utils, Utils, Runner, Options, Build
from TaskGen import extension, taskgen, before, after, feature
2009-10-04 17:50:53 +08:00
from Configure import conf, conftest
@taskgen
@before('apply_incpaths', 'apply_lib_vars', 'apply_type_vars')
@feature('node_addon')
@before('apply_bundle')
def init_node_addon(self):
2009-10-04 17:50:53 +08:00
self.default_install_path = '${PREFIX_NODE}/lib/node/libraries'
self.uselib = self.to_list(getattr(self, 'uselib', ''))
if not 'NODE' in self.uselib: self.uselib.append('NODE')
self.env['MACBUNDLE'] = True
@taskgen
@before('apply_link', 'apply_lib_vars', 'apply_type_vars')
@after('apply_bundle')
@feature('node_addon')
def node_addon_shlib_ext(self):
self.env['shlib_PATTERN'] = "%s.node"
2009-10-04 17:50:53 +08:00
def detect(conf):
join = os.path.join
2009-10-04 17:50:53 +08:00
abspath = os.path.abspath
wafadmin = abspath(join(os.path.dirname(__file__), '..'))
libnode = abspath(join(wafadmin, '..'))
lib = abspath(join(libnode, '..'))
prefix = abspath(join(lib, '..'))
conf.env['PREFIX_NODE'] = prefix
conf.env['LIBPATH_NODE'] = lib
conf.env['CPPPATH_NODE'] = join(prefix, 'include/node')
conf.env['CPPFLAGS_NODE'] = '-D_GNU_SOURCE'
conf.env['CPPFLAGS_NODE'] = '-DEV_MULTIPLICITY=0'
2010-05-30 03:25:28 +08:00
# with symbols
conf.env.append_value('CCFLAGS', ['-g'])
conf.env.append_value('CXXFLAGS', ['-g'])
2009-10-04 17:50:53 +08:00
found = os.path.exists(join(prefix, "bin/node"))
conf.check_message('node prefix', '', found, prefix)
2009-10-12 22:01:22 +08:00
## On Mac OSX we need to use mac bundles
if Options.platform == 'darwin': conf.check_tool('osx')