Skip to content

Commit a7e1efc

Browse files
kapouerry
authored andcommitted
Environment variables NODE_PREFIX, NODE_PATH in node-waf
Those variables have following defaults : - NODE_PREFIX is relative to the current path of the node_addon.py file It is used as the base path of node include files. - NODE_PATH is ~/.node_libraries It's where modules are installed when calling `node-waf install` Note .js files must be explicitely installed by the module's wscript. Usage : NODE_PREFIX=/usr/local NODE_PATH=~/.node_libraries node-waf configure
1 parent b1901cd commit a7e1efc

1 file changed

Lines changed: 33 additions & 9 deletions

File tree

tools/wafadmin/Tools/node_addon.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@feature('node_addon')
99
@before('apply_bundle')
1010
def init_node_addon(self):
11-
self.default_install_path = '${PREFIX_NODE}/lib/node/libraries'
11+
self.default_install_path = self.env['NODE_PATH']
1212
self.uselib = self.to_list(getattr(self, 'uselib', ''))
1313
if not 'NODE' in self.uselib: self.uselib.append('NODE')
1414
self.env['MACBUNDLE'] = True
@@ -22,23 +22,28 @@ def node_addon_shlib_ext(self):
2222

2323
def detect(conf):
2424
join = os.path.join
25-
abspath = os.path.abspath
26-
wafadmin = abspath(join(os.path.dirname(__file__), '..'))
27-
libnode = abspath(join(wafadmin, '..'))
28-
lib = abspath(join(libnode, '..'))
29-
prefix = abspath(join(lib, '..'))
3025

31-
conf.env['PREFIX_NODE'] = prefix
26+
conf.env['PREFIX_NODE'] = get_prefix()
27+
prefix = conf.env['PREFIX_NODE']
28+
lib = join(prefix, 'lib')
29+
3230
conf.env['LIBPATH_NODE'] = lib
33-
conf.env['CPPPATH_NODE'] = join(prefix, 'include/node')
31+
conf.env['CPPPATH_NODE'] = join(prefix, 'include', 'node')
3432
conf.env['CPPFLAGS_NODE'] = '-D_GNU_SOURCE'
3533
conf.env['CPPFLAGS_NODE'] = '-DEV_MULTIPLICITY=0'
3634

3735
# with symbols
3836
conf.env.append_value('CCFLAGS', ['-g'])
3937
conf.env.append_value('CXXFLAGS', ['-g'])
38+
# install path
39+
conf.env['NODE_PATH'] = get_node_path()
40+
# this changes the install path of cxx task_gen
41+
conf.env['LIBDIR'] = conf.env['NODE_PATH']
42+
43+
found = os.path.exists(conf.env['NODE_PATH'])
44+
conf.check_message('node path', '', found, conf.env['NODE_PATH'])
4045

41-
found = os.path.exists(join(prefix, "bin/node"))
46+
found = os.path.exists(join(prefix, 'bin', 'node'))
4247
conf.check_message('node prefix', '', found, prefix)
4348

4449
## On Cygwin we need to link to the generated symbol definitions
@@ -47,3 +52,22 @@ def detect(conf):
4752
## On Mac OSX we need to use mac bundles
4853
if Options.platform == 'darwin': conf.check_tool('osx')
4954

55+
def get_node_path():
56+
join = os.path.join
57+
nodePath = None
58+
if not os.environ.has_key('NODE_PATH'):
59+
if not os.environ.has_key('HOME'):
60+
nodePath = join(get_prefix(), 'lib', 'nodejs')
61+
else:
62+
nodePath = join(os.environ['HOME'], '.node_libraries')
63+
else:
64+
nodePath = os.environ['NODE_PATH']
65+
return nodePath
66+
67+
def get_prefix():
68+
prefix = None
69+
if not os.environ.has_key('PREFIX_NODE'):
70+
prefix = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
71+
else:
72+
prefix = os.environ['PREFIX_NODE']
73+
return prefix

0 commit comments

Comments
 (0)