From a7e1efc5bd137a950e4b04f90dfaf2391ee2eec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= Date: Sat, 10 Jul 2010 20:38:42 +0200 Subject: [PATCH] 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 --- tools/wafadmin/Tools/node_addon.py | 42 +++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/tools/wafadmin/Tools/node_addon.py b/tools/wafadmin/Tools/node_addon.py index 72748c910b..3671979fd1 100644 --- a/tools/wafadmin/Tools/node_addon.py +++ b/tools/wafadmin/Tools/node_addon.py @@ -8,7 +8,7 @@ from Configure import conf, conftest @feature('node_addon') @before('apply_bundle') def init_node_addon(self): - self.default_install_path = '${PREFIX_NODE}/lib/node/libraries' + self.default_install_path = self.env['NODE_PATH'] self.uselib = self.to_list(getattr(self, 'uselib', '')) if not 'NODE' in self.uselib: self.uselib.append('NODE') self.env['MACBUNDLE'] = True @@ -22,23 +22,28 @@ def node_addon_shlib_ext(self): def detect(conf): join = os.path.join - 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['PREFIX_NODE'] = get_prefix() + prefix = conf.env['PREFIX_NODE'] + lib = join(prefix, 'lib') + conf.env['LIBPATH_NODE'] = lib - conf.env['CPPPATH_NODE'] = join(prefix, 'include/node') + conf.env['CPPPATH_NODE'] = join(prefix, 'include', 'node') conf.env['CPPFLAGS_NODE'] = '-D_GNU_SOURCE' conf.env['CPPFLAGS_NODE'] = '-DEV_MULTIPLICITY=0' # with symbols conf.env.append_value('CCFLAGS', ['-g']) conf.env.append_value('CXXFLAGS', ['-g']) + # install path + conf.env['NODE_PATH'] = get_node_path() + # this changes the install path of cxx task_gen + conf.env['LIBDIR'] = conf.env['NODE_PATH'] + + found = os.path.exists(conf.env['NODE_PATH']) + conf.check_message('node path', '', found, conf.env['NODE_PATH']) - found = os.path.exists(join(prefix, "bin/node")) + found = os.path.exists(join(prefix, 'bin', 'node')) conf.check_message('node prefix', '', found, prefix) ## On Cygwin we need to link to the generated symbol definitions @@ -47,3 +52,22 @@ def detect(conf): ## On Mac OSX we need to use mac bundles if Options.platform == 'darwin': conf.check_tool('osx') +def get_node_path(): + join = os.path.join + nodePath = None + if not os.environ.has_key('NODE_PATH'): + if not os.environ.has_key('HOME'): + nodePath = join(get_prefix(), 'lib', 'nodejs') + else: + nodePath = join(os.environ['HOME'], '.node_libraries') + else: + nodePath = os.environ['NODE_PATH'] + return nodePath + +def get_prefix(): + prefix = None + if not os.environ.has_key('PREFIX_NODE'): + prefix = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..')) + else: + prefix = os.environ['PREFIX_NODE'] + return prefix \ No newline at end of file