bug 1869: append local build directory before recursing into modules
authorTom Henderson <tomh@tomh.org>
Thu, 13 Mar 2014 06:37:04 -0700
changeset 10658 2a407999964e
parent 10657 6531a8817def
child 10659 0ae847ef07a9
bug 1869: append local build directory before recursing into modules
src/wscript
wutils.py
--- a/src/wscript	Thu Mar 13 09:29:47 2014 +0100
+++ b/src/wscript	Thu Mar 13 06:37:04 2014 -0700
@@ -59,11 +59,16 @@
             if not conf.env['LIB_BOOST']:
                 conf.env['LIB_BOOST'] = []
 
+    # Append blddir to the module path before recursing into modules
+    blddir = os.path.abspath(os.path.join(conf.bldnode.abspath(), conf.variant))
+    conf.env.append_value('NS3_MODULE_PATH', blddir)
+
     for module in all_modules:
         conf.recurse(module, mandatory=False)
 
-    blddir = os.path.abspath(os.path.join(conf.bldnode.abspath(), conf.variant))
-    conf.env.append_value('NS3_MODULE_PATH', blddir)
+    # Remove duplicate path items
+    conf.env['NS3_MODULE_PATH'] = wutils.uniquify_list(conf.env['NS3_MODULE_PATH'])
+
     if Options.options.enable_rpath:
         conf.env.append_value('RPATH', '-Wl,-rpath,%s' % (os.path.join(blddir),))
 
--- a/wutils.py	Thu Mar 13 09:29:47 2014 +0100
+++ b/wutils.py	Thu Mar 13 06:37:04 2014 -0700
@@ -228,3 +228,10 @@
     return run_argv([env['PYTHON'][0]] + execvec, env, cwd=cwd)
 
 
+def uniquify_list(seq):
+    """Remove duplicates while preserving order
+       From Dave Kirby http://www.peterbe.com/plog/uniqifiers-benchmark
+    """
+    seen = set()
+    return [ x for x in seq if x not in seen and not seen.add(x)]
+