--- a/bindings/python/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/bindings/python/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -2,7 +2,7 @@
import types
import re
import os
-import pproc as subprocess
+import subprocess
import shutil
import sys
@@ -21,17 +21,17 @@
from TaskGen import feature, after
-import Task, ccroot
-from python import _get_python_variables # this comes from wafadmin/Tools/python.py
-
+import Task
+#from python import _get_python_variables # this comes from wafadmin/Tools/python.py
-# Patch a bug in waf-1.5.16's python detection, see
-# https://www.nsnam.org/bugzilla/show_bug.cgi?id=1250
-import python
-python.FRAG_2 = """
-#include <Python.h>
-""" + python.FRAG_2
-del python
+if 0:
+ # Patch a bug in waf-1.5.16's python detection, see
+ # https://www.nsnam.org/bugzilla/show_bug.cgi?id=1250
+ import python
+ python.FRAG_2 = """
+ #include <Python.h>
+ """ + python.FRAG_2
+ del python
@@ -86,7 +86,7 @@
available_modules.sort()
all_modules_enabled = (enabled_modules == available_modules)
- conf.check_tool('misc')
+ conf.check_tool('misc', tooldir=['waf-tools'])
if sys.platform == 'cygwin':
conf.report_optional_feature("python", "Python Bindings", False,
@@ -104,16 +104,17 @@
return
- # alternative code to computing PYTHONDIR, that is more correct than the one in waf 1.5.16
- if 'PYTHONDIR' in conf.environ:
- pydir = conf.environ['PYTHONDIR']
- else:
- (pydir,) = _get_python_variables(conf.env['PYTHON'],
- ["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r)" % conf.env['PREFIX']],
- ['from distutils.sysconfig import get_python_lib'])
- if hasattr(conf, 'define'): # conf.define is added by the C tool, so may not exist
- conf.define('PYTHONDIR', pydir)
- conf.env['PYTHONDIR'] = pydir
+ if 0:
+ # alternative code to computing PYTHONDIR, that is more correct than the one in waf 1.5.16
+ if 'PYTHONDIR' in conf.environ:
+ pydir = conf.environ['PYTHONDIR']
+ else:
+ (pydir,) = _get_python_variables(conf.env['PYTHON'],
+ ["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r)" % conf.env['PREFIX']],
+ ['from distutils.sysconfig import get_python_lib'])
+ if hasattr(conf, 'define'): # conf.define is added by the C tool, so may not exist
+ conf.define('PYTHONDIR', pydir)
+ conf.env['PYTHONDIR'] = pydir
# -fvisibility=hidden optimization
@@ -125,7 +126,7 @@
# Check for the location of pybindgen
if Options.options.with_pybindgen is not None:
if os.path.isdir(Options.options.with_pybindgen):
- conf.check_message("pybindgen location", '', True, ("%s (given)" % Options.options.with_pybindgen))
+ conf.msg("Checking for pybindgen location", ("%s (given)" % Options.options.with_pybindgen))
conf.env['WITH_PYBINDGEN'] = os.path.abspath(Options.options.with_pybindgen)
else:
# ns-3-dev uses ../pybindgen, while ns-3 releases use ../REQUIRED_PYBINDGEN_VERSION
@@ -133,15 +134,15 @@
pybindgen_release_str = "pybindgen-" + '.'.join([str(x) for x in REQUIRED_PYBINDGEN_VERSION])
pybindgen_release_dir = os.path.join('..', pybindgen_release_str)
if os.path.isdir(pybindgen_dir):
- conf.check_message("pybindgen location", '', True, ("%s (guessed)" % pybindgen_dir))
+ conf.msg("Checking for pybindgen location", ("%s (guessed)" % pybindgen_dir))
conf.env['WITH_PYBINDGEN'] = os.path.abspath(pybindgen_dir)
elif os.path.isdir(pybindgen_release_dir):
- conf.check_message("pybindgen location", '', True, ("%s (guessed)" % pybindgen_release_dir))
+ conf.msg("Checking for pybindgen location", ("%s (guessed)" % pybindgen_release_dir))
conf.env['WITH_PYBINDGEN'] = os.path.abspath(pybindgen_release_dir)
del pybindgen_dir
del pybindgen_release_dir
if not conf.env['WITH_PYBINDGEN']:
- conf.check_message("pybindgen location", '', False)
+ conf.msg("pybindgen location", False)
# Check for pybindgen
@@ -155,15 +156,13 @@
"PyBindGen missing")
return
else:
- out = subprocess.Popen([conf.env['PYTHON'], "-c",
+ out = subprocess.Popen([conf.env['PYTHON'][0], "-c",
"import pybindgen.version; "
"print '.'.join([str(x) for x in pybindgen.version.__version__])"],
stdout=subprocess.PIPE).communicate()[0]
pybindgen_version_str = out.strip()
pybindgen_version = tuple([int(x) for x in pybindgen_version_str.split('.')])
- conf.check_message('pybindgen', 'version',
- (pybindgen_version == REQUIRED_PYBINDGEN_VERSION),
- pybindgen_version_str)
+ conf.msg('Checking for pybindgen version', pybindgen_version_str)
if not (pybindgen_version == REQUIRED_PYBINDGEN_VERSION):
Logs.warn("pybindgen (found %s), (need %s)" %
(pybindgen_version_str,
@@ -188,10 +187,10 @@
try:
ret = conf.run_c_code(code=test_program,
env=conf.env.copy(), compile_filename='test.cc',
- compile_mode='cxx',type='cprogram', execute=False)
+ features='cxx cprogram', execute=False)
except Configure.ConfigurationError:
ret = 1
- conf.check_message_custom('types %s and %s' % (t1, t2), 'equivalency', (ret and 'no' or 'yes'))
+ conf.msg('Checking for types %s and %s equivalence' % (t1, t2), (ret and 'no' or 'yes'))
return not ret
uint64_is_long = test("uint64_t", "unsigned long")
@@ -208,7 +207,7 @@
else:
msg = conf.env['PYTHON_BINDINGS_APIDEFS']
- conf.check_message_custom('the apidefs that can be used for Python bindings', '', msg)
+ conf.msg('Checking for the apidefs that can be used for Python bindings', msg)
if conf.env['PYTHON_BINDINGS_APIDEFS'] is None:
conf.report_optional_feature("python", "Python Bindings", False,
@@ -230,9 +229,9 @@
return 0;
}
"""
- gcc_rtti_abi = conf.check(fragment=fragment, msg="Checking for internal GCC cxxabi",
- okmsg="complete", errmsg='incomplete',
- mandatory=False)
+ gcc_rtti_abi = conf.check_nonfatal(fragment=fragment, msg="Checking for internal GCC cxxabi",
+ okmsg="complete", errmsg='incomplete',
+ mandatory=False)
conf.env["GCC_RTTI_ABI_COMPLETE"] = str(bool(gcc_rtti_abi))
@@ -245,14 +244,12 @@
"Missing 'pygccxml' Python module")
return
- out = subprocess.Popen([conf.env['PYTHON'], "-c",
+ out = subprocess.Popen([conf.env['PYTHON'][0], "-c",
"import pygccxml; print pygccxml.__version__"],
stdout=subprocess.PIPE).communicate()[0]
pygccxml_version_str = out.strip()
pygccxml_version = tuple([int(x) for x in pygccxml_version_str.split('.')])
- conf.check_message('pygccxml', 'version',
- (pygccxml_version >= REQUIRED_PYGCCXML_VERSION),
- pygccxml_version_str)
+ conf.msg('Checking for pygccxml version', pygccxml_version_str)
if not (pygccxml_version >= REQUIRED_PYGCCXML_VERSION):
Logs.warn("pygccxml (found %s) is too old (need %s) => "
"automatic scanning of API definitions will not be possible" %
@@ -275,7 +272,7 @@
m = re.match( "^GCC-XML version (\d\.\d(\.\d)?)$", gccxml_version_line)
gccxml_version = m.group(1)
gccxml_version_ok = ([int(s) for s in gccxml_version.split('.')] >= [0, 9])
- conf.check_message('gccxml', 'version', True, gccxml_version)
+ conf.msg('Checking for gccxml version', gccxml_version)
if not gccxml_version_ok:
Logs.warn("gccxml too old, need version >= 0.9; automatic scanning of API definitions will not be possible")
conf.report_optional_feature("pygccxml", "Python API Scanning Support", False,
@@ -311,7 +308,7 @@
class apiscan_task(Task.TaskBase):
"""Uses gccxml to scan the file 'everything.h' and extract API definitions.
"""
- after = 'gen_ns3_module_header_task ns3header_task'
+ after = 'gen_ns3_module_header ns3header'
before = 'cc cxx gchx'
color = "BLUE"
def __init__(self, curdirnode, env, bld, target, cflags, module):
@@ -378,47 +375,11 @@
-class python_scan_task(Task.TaskBase):
- """Uses gccxml to scan the file 'everything.h' and extract API definitions.
- """
- after = 'gen_everything_h_task'
- before = 'cc cxx gchx'
- color = "BLUE"
- def __init__(self, curdirnode, env, bld, target, cflags):
- self.bld = bld
- super(python_scan_task, self).__init__(generator=self)
- self.curdirnode = curdirnode
- self.env = env
- self.target = target
- self.cflags = cflags
-
- def display(self):
- return 'python-scan-%s\n' % (self.target,)
-
- def run(self):
- defsdir = os.path.join(self.curdirnode.abspath(), 'apidefs', self.target)
- try:
- os.mkdir(defsdir)
- except OSError:
- pass
- argv = [
- self.env['PYTHON'],
- os.path.join(self.curdirnode.abspath(), 'ns3modulescan.py'), # scanning script
- self.curdirnode.find_dir('../..').abspath(self.env), # include path (where the ns3 include dir is)
- self.curdirnode.find_or_declare('everything.h').abspath(self.env),
- os.path.join(defsdir, 'ns3modulegen_generated.py'), # output file
- self.cflags,
- ]
- scan = subprocess.Popen(argv, stdin=subprocess.PIPE)
- print >> scan.stdin, repr(get_modules_and_headers(self.bld))
- scan.stdin.close()
- retval = scan.wait()
- return retval
class python_scan_task_collector(Task.TaskBase):
"""Tasks that waits for the python-scan-* tasks to complete and then signals WAF to exit
"""
- after = 'python_scan_task apiscan_task'
+ after = 'apiscan'
before = 'cc cxx'
color = "BLUE"
def __init__(self, curdirnode, env, bld):
@@ -512,7 +473,7 @@
if env['ENABLE_PYTHON_BINDINGS']:
- task = gen_ns3_compat_pymod_task(env)
+ task = gen_ns3_compat_pymod_task(env=env)
task.set_outputs(bld.path.find_or_declare("ns3.py"))
task.dep_vars = ['PYTHON_MODULES_BUILT']
--- a/src/aodv/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/aodv/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -23,7 +23,7 @@
'test/loopback.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'aodv'
headers.source = [
'model/aodv-id-cache.h',
--- a/src/applications/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/applications/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -32,7 +32,7 @@
'test/udp-client-server-test.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'applications'
headers.source = [
'model/bulk-send-application.h',
--- a/src/bridge/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/bridge/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -7,7 +7,7 @@
'model/bridge-channel.cc',
'helper/bridge-helper.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'bridge'
headers.source = [
'model/bridge-net-device.h',
--- a/src/click/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/click/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -12,16 +12,16 @@
def configure(conf):
if Options.options.with_nsclick:
if os.path.isdir(Options.options.with_nsclick):
- conf.check_message("libnsclick.so location", '', True, ("%s (given)" % Options.options.with_nsclick))
+ conf.msg("libnsclick.so location", ("%s (given)" % Options.options.with_nsclick))
conf.env['WITH_NSCLICK'] = os.path.abspath(Options.options.with_nsclick)
else:
nsclick_dir = os.path.join('..','click')
if os.path.isdir(nsclick_dir):
- conf.check_message("click location", '', True, ("%s (guessed)" % nsclick_dir))
+ conf.msg("click location", ("%s (guessed)" % nsclick_dir))
conf.env['WITH_NSCLICK'] = os.path.abspath(nsclick_dir)
del nsclick_dir
if not conf.env['WITH_NSCLICK']:
- conf.check_message("click location", '', False)
+ conf.msg("click location", False)
conf.report_optional_feature("nsclick", "NS-3 Click Integration", False,
"nsclick not enabled (see option --with-nsclick)")
@@ -68,7 +68,7 @@
conf.env['CPPPATH_NSCLICK'] = [os.path.abspath(os.path.join(conf.env['WITH_NSCLICK'],'include'))]
- conf.env['NSCLICK'] = conf.check(fragment=test_code, lib='nsclick', uselib='NSCLICK DL')
+ conf.env['NSCLICK'] = conf.check_nonfatal(fragment=test_code, lib='nsclick', uselib='NSCLICK DL')
conf.report_optional_feature("nsclick", "NS-3 Click Integration",
conf.env['NSCLICK'], "nsclick library not found")
if conf.env['NSCLICK']:
@@ -101,7 +101,7 @@
module.uselib = 'NSCLICK DL'
module_test.uselib = 'NSCLICK DL'
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'click'
headers.source = [
'model/ipv4-click-routing.h',
--- a/src/config-store/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/config-store/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -29,7 +29,7 @@
'model/raw-text-config.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'config-store'
headers.source = [
'model/file-config.h',
--- a/src/core/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/core/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -15,9 +15,8 @@
def configure(conf):
- a = conf.check(type_name='uint128_t', define_name='HAVE_UINT128_T')
- b = conf.check(type_name='__uint128_t', define_name='HAVE___UINT128_T')
-
+ a = conf.check_nonfatal(type_name='uint128_t', define_name='HAVE_UINT128_T')
+ b = conf.check_nonfatal(type_name='__uint128_t', define_name='HAVE___UINT128_T')
if Options.options.int64x64_as_double:
conf.define('INT64X64_USE_DOUBLE', 1)
@@ -32,20 +31,20 @@
conf.env['INT64X64_USE_CAIRO'] = 1
highprec = 'cairo 128-bit integer'
- conf.check_message_custom('high precision time', 'implementation', highprec)
+ conf.msg('Checking high precision time implementation', highprec)
- conf.check(header_name='stdint.h', define_name='HAVE_STDINT_H')
- conf.check(header_name='inttypes.h', define_name='HAVE_INTTYPES_H')
- conf.check(header_name='sys/inttypes.h', define_name='HAVE_SYS_INT_TYPES_H')
- conf.check(header_name='sys/types.h', define_name='HAVE_SYS_TYPES_H')
- conf.check(header_name='sys/stat.h', define_name='HAVE_SYS_STAT_H')
- conf.check(header_name='dirent.h', define_name='HAVE_DIRENT_H')
+ conf.check_nonfatal(header_name='stdint.h', define_name='HAVE_STDINT_H')
+ conf.check_nonfatal(header_name='inttypes.h', define_name='HAVE_INTTYPES_H')
+ conf.check_nonfatal(header_name='sys/inttypes.h', define_name='HAVE_SYS_INT_TYPES_H')
+ conf.check_nonfatal(header_name='sys/types.h', define_name='HAVE_SYS_TYPES_H')
+ conf.check_nonfatal(header_name='sys/stat.h', define_name='HAVE_SYS_STAT_H')
+ conf.check_nonfatal(header_name='dirent.h', define_name='HAVE_DIRENT_H')
- if conf.check(header_name='stdlib.h'):
+ if conf.check_nonfatal(header_name='stdlib.h'):
conf.define('HAVE_STDLIB_H', 1)
conf.define('HAVE_GETENV', 1)
- conf.check(header_name='signal.h', define_name='HAVE_SIGNAL_H')
+ conf.check_nonfatal(header_name='signal.h', define_name='HAVE_SIGNAL_H')
# Check for POSIX threads
test_env = conf.env.copy()
@@ -62,10 +61,9 @@
return 0;
}
"""
- have_pthread = conf.check(header_name='pthread.h', define_name='HAVE_PTHREAD_H',
- env=test_env, fragment=fragment,
- errmsg='Could not find pthread support (build/config.log for details)',
- mandatory=False)
+ have_pthread = conf.check_nonfatal(header_name='pthread.h', define_name='HAVE_PTHREAD_H',
+ env=test_env, fragment=fragment,
+ errmsg='Could not find pthread support (build/config.log for details)')
if have_pthread:
# darwin accepts -pthread but prints a warning saying it is ignored
if Options.platform != 'darwin' and Options.platform != 'cygwin':
@@ -79,12 +77,12 @@
conf.env['ENABLE_THREADING'],
"<pthread.h> include not detected")
- conf.check(header_name='stdint.h', define_name='HAVE_STDINT_H')
- conf.check(header_name='inttypes.h', define_name='HAVE_INTTYPES_H')
+ conf.check_nonfatal(header_name='stdint.h', define_name='HAVE_STDINT_H')
+ conf.check_nonfatal(header_name='inttypes.h', define_name='HAVE_INTTYPES_H')
- conf.check(header_name='sys/inttypes.h', define_name='HAVE_SYS_INT_TYPES_H')
+ conf.check_nonfatal(header_name='sys/inttypes.h', define_name='HAVE_SYS_INT_TYPES_H')
- if not conf.check(lib='rt', uselib='RT', define_name='HAVE_RT'):
+ if not conf.check_nonfatal(lib='rt', uselib='RT', define_name='HAVE_RT'):
conf.report_optional_feature("RealTime", "Real Time Simulator",
False, "librt is not available")
else:
@@ -170,7 +168,7 @@
'test/watchdog-test-suite.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'core'
headers.source = [
'model/nstime.h',
@@ -252,7 +250,7 @@
])
- env = bld.env_of_name('default')
+ env = bld.env
if env['INT64X64_USE_DOUBLE']:
headers.source.extend(['model/int64x64-double.h'])
elif env['INT64X64_USE_128']:
--- a/src/csma-layout/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/csma-layout/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -5,7 +5,7 @@
obj.source = [
'model/csma-star-helper.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'csma-layout'
headers.source = [
'model/csma-star-helper.h',
--- a/src/csma/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/csma/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -8,7 +8,7 @@
'model/csma-channel.cc',
'helper/csma-helper.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'csma'
headers.source = [
'model/backoff.h',
--- a/src/dsdv/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/dsdv/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -16,7 +16,7 @@
'test/dsdv-testcase.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'dsdv'
headers.source = [
'model/dsdv-rtable.h',
--- a/src/emu/examples/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/emu/examples/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -1,7 +1,7 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
- env = bld.env_of_name('default')
+ env = bld.env
if env['ENABLE_EMU']:
obj = bld.create_ns3_program('emu-udp-echo', ['emu', 'internet', 'applications'])
obj.source = 'emu-udp-echo.cc'
--- a/src/emu/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/emu/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -15,7 +15,8 @@
"needs threading support which is not available")
if conf.env['ENABLE_EMU']:
- blddir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant()))
+ #blddir = conf.bldnode.abspath()
+ blddir = os.path.abspath(os.path.join(conf.bldnode.abspath(), conf.variant))
emucreatordir = os.path.abspath(os.path.join(blddir, "src/emu"))
conf.env.append_value('NS3_EXECUTABLE_PATH', emucreatordir)
else:
@@ -35,7 +36,7 @@
'helper/emu-helper.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'emu'
headers.source = [
'model/emu-net-device.h',
--- a/src/energy/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/energy/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -25,7 +25,7 @@
'test/li-ion-energy-source-test.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'energy'
headers.source = [
'model/wifi-radio-energy-model.h',
--- a/src/flow-monitor/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/flow-monitor/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -17,7 +17,7 @@
'test/histogram-test-suite.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'flow-monitor'
headers.source = ["model/%s" % s for s in [
'flow-monitor.h',
--- a/src/internet/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/internet/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -32,23 +32,23 @@
# Check for the location of NSC
if Options.options.with_nsc:
if os.path.isdir(Options.options.with_nsc):
- conf.check_message("NSC location", '', True, ("%s (given)" % Options.options.with_nsc))
+ conf.msg("NSC location", ("%s (given)" % Options.options.with_nsc))
conf.env['WITH_NSC'] = os.path.abspath(Options.options.with_nsc)
else:
# ns-3-dev uses ../nsc, while ns-3 releases use ../NSC_RELEASE_NAME
nsc_dir = os.path.join('..', "nsc")
nsc_release_dir = os.path.join('..', NSC_RELEASE_NAME)
if os.path.isdir(nsc_dir):
- conf.check_message("NSC location", '', True, ("%s (guessed)" % nsc_dir))
+ conf.msg("NSC location",("%s (guessed)" % nsc_dir))
conf.env['WITH_NSC'] = os.path.abspath(nsc_dir)
elif os.path.isdir(nsc_release_dir):
- conf.check_message("NSC location", '', True, ("%s (guessed)" % nsc_release_dir))
+ conf.msg("NSC location", ("%s (guessed)" % nsc_release_dir))
conf.env['WITH_NSC'] = os.path.abspath(nsc_release_dir)
del nsc_dir
del nsc_release_dir
if not conf.env['WITH_NSC']:
- conf.check_message("NSC location", '', False)
+ conf.msg("NSC location", False)
conf.report_optional_feature("nsc", "Network Simulation Cradle", False,
"NSC not found (see option --with-nsc)")
return
@@ -61,9 +61,9 @@
if arch in ('x86_64', 'i686', 'i586', 'i486', 'i386'):
conf.env['NSC_ENABLED'] = True
conf.env.append_value('CXXDEFINES', 'NETWORK_SIMULATION_CRADLE')
- conf.check(mandatory=True, lib='dl', define_name='HAVE_DL', uselib='DL')
+ conf.check_nonfatal(mandatory=True, lib='dl', define_name='HAVE_DL', uselib='DL')
ok = True
- conf.check_message('NSC supported architecture', arch, ok)
+ conf.msg('NSC supported architecture ' + arch, ok)
if not ok:
conf.env['NSC_ENABLED'] = False
@@ -205,7 +205,7 @@
'test/udp-test.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'internet'
headers.source = [
'model/udp-header.h',
--- a/src/lte/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/lte/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -47,7 +47,7 @@
'test/lte-propagation-loss-model-test.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'lte'
headers.source = [
'model/lte-spectrum-phy.h',
--- a/src/mesh/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/mesh/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -53,7 +53,7 @@
'test/flame/regression.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'mesh'
headers.source = [
'model/mesh-information-element.h',
--- a/src/mobility/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/mobility/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -30,7 +30,7 @@
'test/waypoint-mobility-model-test.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'mobility'
headers.source = [
'model/box.h',
--- a/src/mpi/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/mpi/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -29,7 +29,7 @@
def build(bld):
- env = bld.env_of_name('default')
+ env = bld.env
sim = bld.create_ns3_module('mpi', ['core', 'network'])
sim.source = [
'model/distributed-simulator-impl.cc',
@@ -37,7 +37,7 @@
'model/mpi-receiver.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'mpi'
headers.source = [
'model/distributed-simulator-impl.h',
--- a/src/netanim/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/netanim/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -8,7 +8,7 @@
'helper/animation-interface-helper.cc',
]
- headers = bld.new_task_gen ('ns3header')
+ headers = bld.new_task_gen (features=['ns3header'])
headers.module = 'netanim'
headers.source = [
'model/animation-interface.h',
--- a/src/network/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/network/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -67,7 +67,7 @@
'test/sequence-number-test-suite.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'network'
headers.source = [
'model/address.h',
--- a/src/nix-vector-routing/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/nix-vector-routing/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -8,7 +8,7 @@
'helper/ipv4-nix-vector-helper.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'nix-vector-routing'
headers.source = [
'model/ipv4-nix-vector-routing.h',
--- a/src/olsr/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/olsr/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -20,7 +20,7 @@
'test/tc-regression-test.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'olsr'
headers.source = [
'model/olsr-routing-protocol.h',
--- a/src/openflow/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/openflow/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -7,7 +7,7 @@
opt.add_option('--with-openflow',
help=('Path to OFSID source for NS-3 OpenFlow Integration support'),
default='', dest='with_openflow')
- opt.tool_options('boost')
+ opt.tool_options('boost', tooldir=["waf-tools"])
def configure(conf):
conf.check_tool('boost')
@@ -146,7 +146,7 @@
obj.uselib = 'OPENFLOW DL XML2'
obj_test.uselib = 'OPENFLOW DL XML2'
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'openflow'
headers.source = [
]
--- a/src/point-to-point-layout/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/point-to-point-layout/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -9,7 +9,7 @@
'model/point-to-point-star.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'point-to-point-layout'
headers.source = [
'model/point-to-point-dumbbell.h',
--- a/src/point-to-point/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/point-to-point/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -16,7 +16,7 @@
'test/point-to-point-test.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'point-to-point'
headers.source = [
'model/point-to-point-net-device.h',
--- a/src/propagation/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/propagation/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -15,7 +15,7 @@
'test/propagation-loss-model-test-suite.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'propagation'
headers.source = [
'model/propagation-delay-model.h',
--- a/src/spectrum/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/spectrum/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -39,7 +39,7 @@
'test/spectrum-ideal-phy-test.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'spectrum'
headers.source = [
'model/spectrum-model.h',
--- a/src/stats/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/stats/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -1,7 +1,7 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def configure(conf):
- conf.env['SQLITE_STATS'] = conf.check(lib='sqlite3', define_name='SQLITE3', uselib='SQLITE3')
+ conf.env['SQLITE_STATS'] = conf.check_nonfatal(lib='sqlite3', define_name='SQLITE3', uselib='SQLITE3')
conf.report_optional_feature("SqliteDataOutput", "SQlite stats data output",
conf.env['SQLITE_STATS'],
"library 'sqlite3' not found")
@@ -23,7 +23,7 @@
'test/basic-data-calculators-test-suite.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'stats'
headers.source = [
'model/data-calculator.h',
--- a/src/tap-bridge/examples/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/tap-bridge/examples/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -1,7 +1,7 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
- env = bld.env_of_name('default')
+ env = bld.env
if env['ENABLE_TAP']:
obj = bld.create_ns3_program('tap-csma', ['csma', 'tap-bridge', 'internet', 'wifi'])
obj.source = 'tap-csma.cc'
--- a/src/tap-bridge/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/tap-bridge/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -15,7 +15,7 @@
"needs threading support which is not available")
if conf.env['ENABLE_TAP']:
- blddir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant()))
+ blddir = os.path.abspath(os.path.join(conf.bldnode.abspath(), conf.variant))
tapcreatordir = os.path.abspath(os.path.join(blddir, "src/tap-bridge"))
conf.env.append_value('NS3_EXECUTABLE_PATH', tapcreatordir)
else:
@@ -34,7 +34,7 @@
'model/tap-encode-decode.cc',
'helper/tap-bridge-helper.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'tap-bridge'
headers.source = [
'model/tap-bridge.h',
--- a/src/template/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/template/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -27,7 +27,7 @@
]
# Make headers be installed for this module.
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'template'
# Set the C++ header files for this module.
--- a/src/test/ns3tcp/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/test/ns3tcp/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -16,7 +16,7 @@
return
ns3tcp = bld.create_ns3_module('ns3tcp', ['internet', 'point-to-point', 'csma', 'applications'])
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'ns3tcp'
headers.source = [
'ns3tcp.h',
--- a/src/test/ns3wifi/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/test/ns3wifi/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -16,7 +16,7 @@
return
ns3wifi = bld.create_ns3_module('ns3wifi', ['internet', 'mobility', 'propagation', 'wifi', 'applications'])
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'ns3wifi'
headers.source = [
'ns3wifi.h',
--- a/src/test/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/test/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -20,7 +20,7 @@
return
test = bld.create_ns3_module('test', ['internet', 'mobility', 'applications', 'csma', 'bridge', 'config-store', 'tools', 'point-to-point', 'csma-layout', 'flow-monitor'])
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'test'
test_test = bld.create_ns3_module_test_library('test')
--- a/src/tools/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/tools/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -14,7 +14,7 @@
'test/event-garbage-collector-test-suite.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'tools'
headers.source = [
'model/average.h',
--- a/src/topology-read/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/topology-read/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -15,7 +15,7 @@
'test/rocketfuel-topology-reader-test-suite.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'topology-read'
headers.source = [
'model/topology-reader.h',
--- a/src/uan/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/uan/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -32,7 +32,7 @@
'test/uan-test.cc',
'test/uan-energy-model-test.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'uan'
headers.source = [
'model/uan-channel.h',
--- a/src/virtual-net-device/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/virtual-net-device/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -6,7 +6,7 @@
module.source = [
'model/virtual-net-device.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'virtual-net-device'
headers.source = [
'model/virtual-net-device.h',
--- a/src/visualizer/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/visualizer/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -13,7 +13,7 @@
if 'visualizer' in bld.env['MODULES_NOT_BUILT']:
return
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'visualizer'
headers.source = [
]
--- a/src/wifi/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/wifi/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -75,7 +75,7 @@
'test/wifi-test.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'wifi'
headers.source = [
'model/wifi-information-element.h',
--- a/src/wimax/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/wimax/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -63,7 +63,7 @@
'test/wimax-fragmentation-test.cc',
]
- headers = bld.new_task_gen('ns3header')
+ headers = bld.new_task_gen(features=['ns3header'])
headers.module = 'wimax'
headers.source = [
'model/wimax-channel.h',
--- a/src/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/src/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -11,10 +11,10 @@
import Options
import Build
import Utils
-import Constants
+#import Constants
-import ccroot
-ccroot.USE_TOP_LEVEL = True
+#import ccroot
+#ccroot.USE_TOP_LEVEL = True
import wutils
@@ -94,7 +94,7 @@
conf.sub_config('stats')
conf.sub_config('visualizer')
- blddir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant()))
+ blddir = os.path.abspath(os.path.join(conf.bldnode.abspath(), conf.variant))
conf.env.append_value('NS3_MODULE_PATH', blddir)
if Options.options.enable_rpath:
conf.env.append_value('RPATH', '-Wl,-rpath=%s' % (os.path.join(blddir),))
@@ -103,169 +103,146 @@
conf.env['NS3_MODULES'] = ['ns3-' + module.split('/')[-1] for module in all_modules]
-class ns3module_taskgen(TaskGen.task_gen):
- def __init__(self, *args, **kwargs):
- super(ns3module_taskgen, self).__init__(*args, **kwargs)
- self.libs = []
-
- def apply(self):
- static_enabled = False
- shared_enabled = True
- bld = self.bld
- if bld.env['ENABLE_STATIC_NS3']:
- static_enabled = True
- shared_enabled = False
- if bld.env['ENABLE_SHARED_AND_STATIC_NS3']:
- static_enabled = True
- shared_enabled = True
-
- assert self.name.startswith("ns3-")
- name = self.name.split("ns3-")[1]
-
- if static_enabled:
- static = self._create_ns3_module(self.bld, name, self.dependencies, True)
- self.libs.append(static)
- else:
- static = None
+# class ns3module_taskgen(TaskGen.task_gen):
+# def __init__(self, *args, **kwargs):
+# super(ns3module_taskgen, self).__init__(*args, **kwargs)
+# self.libs = []
- if shared_enabled:
- shared = self._create_ns3_module(self.bld, name, self.dependencies, False)
- self.libs.append(shared)
- else:
- shared = None
-
- if static is not None and shared is None:
- static.name = self.name + "--lib"
- static.uselib_local = ['ns3-%s--lib' % (dep,) for dep in self.dependencies]
+# def apply(self):
+# print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
+# static_enabled = False
+# shared_enabled = True
+# bld = self.bld
+# if bld.env['ENABLE_STATIC_NS3']:
+# static_enabled = True
+# shared_enabled = False
+# if bld.env['ENABLE_SHARED_AND_STATIC_NS3']:
+# static_enabled = True
+# shared_enabled = True
- elif shared is not None and static is None:
- shared.name = self.name + "--lib"
- shared.uselib_local = ['ns3-%s--lib' % (dep,) for dep in self.dependencies]
- else:
- shared.name = self.name + "--lib"
- shared.uselib_local = ['ns3-%s--lib' % (dep,) for dep in self.dependencies]
- static.name = self.name + "--static"
- static.uselib_local = ['ns3-%s--static' % (dep,) for dep in self.dependencies]
+# assert self.name.startswith("ns3-")
+# name = self.name.split("ns3-")[1]
- if not self.test:
- pcfile = bld.new_task_gen('ns3pcfile')
- pcfile.module = self
-
- def _create_ns3_module(self, bld, name, dependencies, static):
-
- # FIXME: env modifications are overwritten by parent caller
-
- # Create a separate library for this module.
- if static:
- module = bld.new_task_gen('cxx', 'cstaticlib')
- else:
- module = bld.new_task_gen('cxx', 'cshlib')
+# if static_enabled:
+# static = self._create_ns3_module(self.bld, name, self.dependencies, True)
+# self.libs.append(static)
+# else:
+# static = None
- module.source = self.source
- module.env = self.env.copy()
- features = list(self.features)
- features.remove("ns3module")
- module.features.extend(features)
- module.path = self.path
- module.uselib = self.uselib
- module.target = 'ns3-' + name
- if hasattr(self, 'includes'):
- module.includes = self.includes
- if hasattr(self, 'defines'):
- module.defines = self.defines
- else:
- module.defines = []
- if hasattr(self, 'add_objects'):
- module.add_objects = self.add_objects
- else:
- module.add_objects = []
- if hasattr(self, "is_ns3_module"):
- module.is_ns3_module = self.is_ns3_module
- if hasattr(self, 'add_objects'):
- module.add_objects = self.add_objects
+# if shared_enabled:
+# shared = self._create_ns3_module(self.bld, name, self.dependencies, False)
+# self.libs.append(shared)
+# else:
+# shared = None
+
+# if static is not None and shared is None:
+# static.name = self.name + "--lib"
+# static.uselib_local = ['ns3-%s--lib' % (dep,) for dep in self.dependencies]
- linkflags = []
- cxxflags = []
- ccflags = []
- if not static:
- cxxflags = module.env['shlib_CXXFLAGS']
- ccflags = module.env['shlib_CXXFLAGS']
- # Turn on the link flags for shared libraries if we have the
- # proper compiler and platform.
- if module.env['CXX_NAME'] in ['gcc', 'icc'] and module.env['WL_SONAME_SUPPORTED']:
- # Get the module library name without any relative paths
- # at its beginning because all of the libraries will end
- # up in the same directory.
- module_library_name = os.path.basename(ccroot.get_target_name(module))
- linkflags = '-Wl,--soname=%s' % module_library_name
- elif module.env['CXX_NAME'] in ['gcc', 'icc'] and \
- os.uname()[4] == 'x86_64' and \
- sys.platform != 'darwin' and \
- module.env['ENABLE_PYTHON_BINDINGS']:
- # enable that flag for static builds only on x86-64 platforms
- # when gcc is present and only when we want python bindings
- # (it's more efficient to not use this option if we can avoid it)
- cxxflags = ['-mcmodel=large']
- ccflags = ['-mcmodel=large']
- cxxdefines = ["NS3_MODULE_COMPILATION"]
- ccdefines = ["NS3_MODULE_COMPILATION"]
-
- module.env.append_value('CXXFLAGS', cxxflags)
- module.env.append_value('CCFLAGS', ccflags)
- module.env.append_value('LINKFLAGS', linkflags)
- module.env.append_value('CXXDEFINES', cxxdefines)
- module.env.append_value('CCDEFINES', ccdefines)
+# elif shared is not None and static is None:
+# shared.name = self.name + "--lib"
+# shared.uselib_local = ['ns3-%s--lib' % (dep,) for dep in self.dependencies]
+# else:
+# shared.name = self.name + "--lib"
+# shared.uselib_local = ['ns3-%s--lib' % (dep,) for dep in self.dependencies]
+# static.name = self.name + "--static"
+# static.uselib_local = ['ns3-%s--static' % (dep,) for dep in self.dependencies]
- if len(module.source) > 0 and hasattr(self, 'ns3_dir_location'):
- uselib_cpppath = []
- for lib in module.uselib.split():
- if 'CPPPATH_%s' % lib in module.env:
- uselib_cpppath.extend(module.env['CPPPATH_%s' % lib])
- objects = []
- for src in module.source[0:-1]:
- full_src = os.path.join(self.ns3_dir_location, src)
- path = os.path.dirname(full_src)
- target = '%s_object' % src
- # XXX: calculate the features correctly here.
- obj = bld (source=[full_src], target=target, features='cxx cc',
- defines=['NS_TEST_SOURCEDIR="%s"' % path],
- includes=' '.join(uselib_cpppath),
- env = module.env)
- objects.append(target)
- last = module.source[-1]
- full_src = os.path.join(self.ns3_dir_location, last)
- path = os.path.dirname(full_src)
- module.defines.append('NS_TEST_SOURCEDIR="%s"' % path)
- module.source = [last]
- module.add_objects.extend(objects)
+# if not self.test:
+# pcfile = bld.new_task_gen('ns3pcfile')
+# pcfile.module = self
+# def _create_ns3_module(self, bld, name, dependencies, static):
- module.is_static = static
- module.vnum = wutils.VNUM
- # Add the proper path to the module's name.
- module.target = '%s/ns3-%s' % (bld.srcnode.relpath_gen(self.path), name)
- # Set the libraries this module depends on.
- module.module_deps = list(dependencies)
+# # FIXME: env modifications are overwritten by parent caller
- module.install_path = "${LIBDIR}"
-
- return module
def create_ns3_module(bld, name, dependencies=(), test=False):
- module = bld.new_task_gen('ns3module')
+ static = bool(bld.env.ENABLE_STATIC_NS3)
+ # Create a separate library for this module.
+ if static:
+ module = bld.new_task_gen(features=['cxx', 'cxxstlib'])
+ else:
+ module = bld.new_task_gen(features=['cxx', 'cxxshlib'])
+ linkflags = []
+ cxxflags = []
+ ccflags = []
+ if not static:
+ cxxflags = module.env['shlib_CXXFLAGS']
+ ccflags = module.env['shlib_CXXFLAGS']
+ # Turn on the link flags for shared libraries if we have the
+ # proper compiler and platform.
+ if module.env['CXX_NAME'] in ['gcc', 'icc'] and module.env['WL_SONAME_SUPPORTED']:
+ # Get the module library name without any relative paths
+ # at its beginning because all of the libraries will end
+ # up in the same directory.
+ if 0: # TODO FIXME
+ module_library_name = os.path.basename(ccroot.get_target_name(module))
+ linkflags = '-Wl,--soname=%s' % module_library_name
+ elif module.env['CXX_NAME'] in ['gcc', 'icc'] and \
+ os.uname()[4] == 'x86_64' and \
+ sys.platform != 'darwin' and \
+ module.env['ENABLE_PYTHON_BINDINGS']:
+ # enable that flag for static builds only on x86-64 platforms
+ # when gcc is present and only when we want python bindings
+ # (it's more efficient to not use this option if we can avoid it)
+ cxxflags = ['-mcmodel=large']
+ ccflags = ['-mcmodel=large']
+ cxxdefines = ["NS3_MODULE_COMPILATION"]
+ ccdefines = ["NS3_MODULE_COMPILATION"]
+
+ module.env.append_value('CXXFLAGS', cxxflags)
+ module.env.append_value('CCFLAGS', ccflags)
+ module.env.append_value('LINKFLAGS', linkflags)
+ module.env.append_value('CXXDEFINES', cxxdefines)
+ module.env.append_value('CCDEFINES', ccdefines)
+
+ module.is_static = static
+ module.vnum = wutils.VNUM
+ # Add the proper path to the module's name.
+ module.target = '%s/ns3-%s' % (bld.srcnode.relpath_gen(module.path), name)
+ # Set the libraries this module depends on.
+ module.module_deps = list(dependencies)
+
+ module.install_path = "${LIBDIR}"
+
module.bld = bld
module.name = "ns3-" + name
module.dependencies = dependencies
# Initially create an empty value for this because the pcfile
# writing task assumes every module has a uselib attribute.
module.uselib = ''
- module.uselib_local = ['ns3-' + dep for dep in dependencies]
- module.module_deps = list(dependencies)
+ module.use = ['ns3-' + dep for dep in dependencies]
module.test = test
module.is_ns3_module = True
module.ns3_dir_location = bld.path.relpath_gen(bld.srcnode)
+ module.env.append_value("INCLUDES", '#')
+
+ if len(module.source) > 0 and hasattr(self, 'ns3_dir_location'):
+ uselib_cpppath = []
+ for lib in module.uselib.split():
+ if 'CPPPATH_%s' % lib in module.env:
+ uselib_cpppath.extend(module.env['CPPPATH_%s' % lib])
+ objects = []
+ for src in module.source[0:-1]:
+ full_src = os.path.join(self.ns3_dir_location, src)
+ path = os.path.dirname(full_src)
+ target = '%s_object' % src
+ # XXX: calculate the features correctly here.
+ obj = bld (source=[full_src], target=target, features='cxx cc',
+ defines=['NS_TEST_SOURCEDIR="%s"' % path],
+ includes=' '.join(uselib_cpppath),
+ env = module.env)
+ objects.append(target)
+ last = module.source[-1]
+ full_src = os.path.join(self.ns3_dir_location, last)
+ path = os.path.dirname(full_src)
+ module.defines.append('NS_TEST_SOURCEDIR="%s"' % path)
+ module.source = [last]
+ module.add_objects.extend(objects)
+
return module
@@ -367,29 +344,29 @@
if was_enabled:
features.append(name)
- bindgen = bld.new_task_gen('command', source=source, target=target, command=argv)
+ bindgen = bld.new_task_gen(features=['command'], source=source, target=target, command=argv)
bindgen.env['FEATURES'] = ','.join(features)
bindgen.dep_vars = ['FEATURES', "GCC_RTTI_ABI_COMPLETE"]
bindgen.before = 'cxx'
- bindgen.after = 'gen_ns3_module_header_task'
+ bindgen.after = 'gen_ns3_module_header'
bindgen.name = "pybindgen(ns3 module %s)" % module
# generate the extension module
- pymod = bld.new_task_gen(features='cxx cshlib pyext')
+ pymod = bld.new_task_gen(features='cxx cxxshlib pyext')
pymod.source = ['bindings/ns3module.cc']
pymod.target = '%s/%s' % (module_target_dir, extension_name)
pymod.name = 'ns3module_%s' % module
- pymod.uselib_local = ["%s--lib" % mod for mod in pymod.env['NS3_ENABLED_MODULES']] # Should be '"ns3-"+module', but see bug 1117
+ pymod.use = ["%s" % mod for mod in pymod.env['NS3_ENABLED_MODULES']] # Should be '"ns3-"+module', but see bug 1117
if pymod.env['ENABLE_STATIC_NS3']:
if sys.platform == 'darwin':
pymod.env.append_value('LINKFLAGS', '-Wl,-all_load')
- for mod in pymod.uselib_local:
- mod = mod.split("--lib")[0]
+ for mod in pymod.usel:
+ #mod = mod.split("--lib")[0]
pymod.env.append_value('LINKFLAGS', '-l' + mod)
else:
pymod.env.append_value('LINKFLAGS', '-Wl,--whole-archive,-Bstatic')
- for mod in pymod.uselib_local:
- mod = mod.split("--lib")[0]
+ for mod in pymod.use:
+ #mod = mod.split("--lib")[0]
pymod.env.append_value('LINKFLAGS', '-l' + mod)
pymod.env.append_value('LINKFLAGS', '-Wl,-Bdynamic,--no-whole-archive')
defines = list(pymod.env['CXXDEFINES'])
@@ -400,7 +377,7 @@
except ValueError:
pass
pymod.env['CXXDEFINES'] = defines
- pymod.includes = 'bindings'
+ pymod.includes = '# bindings'
pymod.install_path = '${PYTHONDIR}/ns'
return pymod
@@ -427,7 +404,7 @@
bld.add_subdirs(list(all_modules))
for module in all_modules:
- modheader = bld.new_task_gen('ns3moduleheader')
+ modheader = bld.new_task_gen(features=['ns3moduleheader'])
modheader.module = module.split('/')[-1]
class ns3pcfile_task(Task.Task):
@@ -480,7 +457,7 @@
includes = self.env['CPPPATH_%s' % dep]
return [self.env['CPPPATH_ST'] % include for include in includes]
- def _generate_pcfile(self, name, use, uselib_local, env, outfilename):
+ def _generate_pcfile(self, name, uselib, use, env, outfilename):
outfile = open(outfilename, 'w')
prefix = env.PREFIX
includedir = env.INCLUDEDIR
@@ -488,7 +465,7 @@
libs = self._self_libs(self.env, name, '${libdir}')
for dep in use:
libs = libs + self._lib(self.env, dep)
- for dep in uselib_local:
+ for dep in uselib:
libs = libs + [self.env['LIB_ST'] % dep]
cflags = [self.env['CPPPATH_ST'] % '${includedir}']
for dep in use:
@@ -511,7 +488,7 @@
def run(self):
output_filename = self.outputs[0].bldpath(self.env)
self._generate_pcfile(self.module.name, self.module.uselib,
- self.module.uselib_local,
+ self.module.use,
self.env, output_filename)
class ns3pcfile_taskgen(TaskGen.task_gen):
@@ -527,41 +504,49 @@
task.module = self.module
-class ns3header_taskgen(TaskGen.task_gen):
- """A set of NS-3 header files"""
- COLOR = 'BLUE'
- def __init__(self, *args, **kwargs):
- super(ns3header_taskgen, self).__init__(*args, **kwargs)
- self.install_path = None
- self.sub_dir = None # if not None, header files will be published as ns3/sub_dir/file.h
- self.module = None # module name
- self.mode = 'install'
+# @TaskGen.extension('.h')
+# class ns3header_taskgen(TaskGen.task_gen):
+# """A set of NS-3 header files"""
+# COLOR = 'BLUE'
+# def __init__(self, *args, **kwargs):
+# super(ns3header_taskgen, self).__init__(*args, **kwargs)
+# self.install_path = None
+# self.sub_dir = None # if not None, header files will be published as ns3/sub_dir/file.h
+# self.module = None # module name
+# self.mode = 'install'
+# self.features.append(features=['ns3header'])
+# print "YYYYYYYYYYYYYYYYYYYYYYYYYYY", self
+
- def apply(self):
- for filename in set(self.to_list(self.source)):
- src_node = self.path.find_resource(filename)
- if self.module is None:
- raise Utils.WafError("'module' missing on ns3headers object %s" % self)
- ns3_dir_node = self.bld.path.find_dir("ns3")
- if self.sub_dir is not None:
- ns3_dir_node = ns3_dir_node.find_dir(self.sub_dir)
- for filename in set(self.to_list(self.source)):
- src_node = self.path.find_resource(filename)
- if src_node is None:
- raise Utils.WafError("source ns3 header file %s not found" % (filename,))
- dst_node = ns3_dir_node.find_or_declare(os.path.basename(filename))
- assert dst_node is not None
- task = self.create_task('ns3header', env=self.env)
- task.mode = self.mode
- if self.mode == 'install':
- self.bld.install_files('${PREFIX}/include/ns3', [src_node])
- task.set_inputs([src_node])
- task.set_outputs([dst_node])
- else:
- task.header_to_remove = dst_node
+@TaskGen.feature('ns3header')
+@TaskGen.after_method('process_rule')
+def apply_ns3header(self):
+ #for filename in set(self.to_list(self.source)):
+ # src_node = self.path.find_resource(filename)
+ if self.module is None:
+ raise Utils.WafError("'module' missing on ns3headers object %s" % self)
+ ns3_dir_node = self.bld.path.find_dir("ns3")
+ #if self.sub_dir is not None:
+ # ns3_dir_node = ns3_dir_node.find_dir(self.sub_dir)
+ for filename in set(self.to_list(self.source)):
+ src_node = self.path.find_resource(filename)
+ if src_node is None:
+ raise Utils.WafError("source ns3 header file %s not found" % (filename,))
+ dst_node = ns3_dir_node.find_or_declare(src_node.name)
+ assert dst_node is not None
+ task = self.create_task('ns3header')
+ task.mode = getattr(self, 'mode', 'install')
+ if task.mode == 'install':
+ self.bld.install_files('${PREFIX}/include/ns3', [src_node])
+ task.set_inputs([src_node])
+ task.set_outputs([dst_node])
+ else:
+ task.header_to_remove = dst_node
+ self.headers = set(self.to_list(self.source))
+ self.source = '' # tell WAF not to process these files further
class ns3header_task(Task.Task):
- before = 'cc cxx gen_ns3_module_header_task'
+ before = 'cc cxx gen_ns3_module_header'
color = 'BLUE'
def __str__(self):
@@ -578,17 +563,17 @@
def runnable_status(self):
if self.mode == 'remove':
if os.path.exists(self.header_to_remove.bldpath(self.env)):
- return Constants.RUN_ME
+ return Task.RUN_ME
else:
- return Constants.SKIP_ME
+ return Task.SKIP_ME
else:
return super(ns3header_task, self).runnable_status()
def run(self):
if self.mode == 'install':
assert len(self.inputs) == len(self.outputs)
- inputs = [node.srcpath(self.env) for node in self.inputs]
- outputs = [node.bldpath(self.env) for node in self.outputs]
+ inputs = [node.abspath() for node in self.inputs]
+ outputs = [node.abspath() for node in self.outputs]
for src, dst in zip(inputs, outputs):
try:
os.chmod(dst, 0600)
@@ -613,15 +598,15 @@
class gen_ns3_module_header_task(Task.Task):
before = 'cc cxx'
- after = 'ns3header_task'
+ after = 'ns3header'
color = 'BLUE'
def runnable_status(self):
if self.mode == 'remove':
if os.path.exists(self.header_to_remove.bldpath(self.env)):
- return Constants.RUN_ME
+ return Task.RUN_ME
else:
- return Constants.SKIP_ME
+ return Task.SKIP_ME
else:
return super(gen_ns3_module_header_task, self).runnable_status()
@@ -647,10 +632,9 @@
if ex.errno != 2:
raise
return 0
-
assert len(self.outputs) == 1
- out_file_name = self.outputs[0].bldpath(self.env)
- header_files = [os.path.basename(node.abspath(self.env)) for node in self.inputs]
+ out_file_name = self.outputs[0].get_bld().abspath()#self.env)
+ header_files = [os.path.basename(node.abspath()) for node in self.inputs]
outfile = file(out_file_name, "w")
header_files.sort()
@@ -678,7 +662,7 @@
return 0
def sig_explicit_deps(self):
- self.m.update('\n'.join([node.abspath(self.env) for node in self.inputs]))
+ self.m.update('\n'.join([node.abspath() for node in self.inputs]))
return self.m.digest()
def unique_id(self):
@@ -692,50 +676,46 @@
return self.uid
-class ns3moduleheader_taskgen(TaskGen.task_gen):
- """
- Generates a 'ns3/foo-module.h' header file that includes all
- public ns3 headers of a certain module.
- """
- COLOR = 'BLUE'
- def __init__(self, *args, **kwargs):
- super(ns3moduleheader_taskgen, self).__init__(*args, **kwargs)
- self.mode = 'install'
+# Generates a 'ns3/foo-module.h' header file that includes all public
+# ns3 headers of a certain module.
+@TaskGen.feature('ns3moduleheader')
+@TaskGen.after_method('process_rule')
+def apply_ns3moduleheader(self):
+ ## get all of the ns3 headers
+ ns3_dir_node = self.bld.path.find_dir("ns3")
+ all_headers_inputs = []
+ found_the_module = False
+ for ns3headers in self.bld.all_task_gen:
+ if 'ns3header' in getattr(ns3headers, "features", []):
+ if ns3headers.module != self.module:
+ continue
+ found_the_module = True
+ for source in ns3headers.headers:
+ source = os.path.basename(source)
+ node = ns3_dir_node.find_or_declare(os.path.basename(source))
+ if node is None:
+ fatal("missing header file %s" % (source,))
+ all_headers_inputs.append(node)
+ if not found_the_module:
+ raise Utils.WscriptError("error finding headers for module %s" % self.module)
+ if not all_headers_inputs:
+ return
- def apply(self):
- ## get all of the ns3 headers
- ns3_dir_node = self.bld.path.find_dir("ns3")
- all_headers_inputs = []
- found_the_module = False
- for ns3headers in self.bld.all_task_gen:
- if isinstance(ns3headers, ns3header_taskgen):
- if ns3headers.module != self.module:
- continue
- found_the_module = True
- for source in set(ns3headers.to_list(ns3headers.source)):
- source = os.path.basename(source)
- node = ns3_dir_node.find_or_declare(os.path.basename(source))
- if node is None:
- fatal("missing header file %s" % (source,))
- all_headers_inputs.append(node)
- if not found_the_module:
- raise Utils.WscriptError("error finding headers for module %s" % self.module)
- if not all_headers_inputs:
- return
- all_headers_outputs = [ns3_dir_node.find_or_declare("%s-module.h" % self.module)]
- task = self.create_task('gen_ns3_module_header', env=self.env)
- task.module = self.module
- task.mode = self.mode
- if self.mode == 'install':
- self.bld.install_files('${PREFIX}/include/ns3',
- ns3_dir_node.find_or_declare("%s-module.h" % self.module))
- task.set_inputs(all_headers_inputs)
- task.set_outputs(all_headers_outputs)
- module_obj = self.bld.name_to_obj("ns3-" + self.module, self.env)
- assert module_obj is not None, self.module
- task.module_deps = module_obj.module_deps
- else:
- task.header_to_remove = all_headers_outputs[0]
+ try:
+ module_obj = self.bld.get_taskgen("ns3-" + self.module)
+ except KeyError: # maybe the module was disabled, and therefore removed
+ return
- def install(self):
- pass
+ all_headers_outputs = [ns3_dir_node.find_or_declare("%s-module.h" % self.module)]
+ task = self.create_task('gen_ns3_module_header')
+ task.module = self.module
+ task.mode = getattr(self, "mode", "install")
+ if task.mode == 'install':
+ assert module_obj is not None, self.module
+ self.bld.install_files('${PREFIX}/include/ns3',
+ ns3_dir_node.find_or_declare("%s-module.h" % self.module))
+ task.set_inputs(all_headers_inputs)
+ task.set_outputs(all_headers_outputs)
+ task.module_deps = module_obj.module_deps
+ else:
+ task.header_to_remove = all_headers_outputs[0]
--- a/utils/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/utils/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -10,7 +10,7 @@
# Set the libraries the testrunner depends on equal to the list of
# enabled modules plus the list of enabled module test libraries.
- test_runner.uselib_local = [mod+"--lib" for mod in (env['NS3_ENABLED_MODULES'] + env['NS3_ENABLED_MODULE_TEST_LIBRARIES'])]
+ test_runner.use = [mod for mod in (env['NS3_ENABLED_MODULES'] + env['NS3_ENABLED_MODULE_TEST_LIBRARIES'])]
obj = bld.create_ns3_program('bench-simulator', ['core'])
obj.source = 'bench-simulator.cc'
@@ -28,5 +28,5 @@
obj = bld.create_ns3_program('print-introspected-doxygen', ['network'])
obj.source = 'print-introspected-doxygen.cc'
- obj.uselib_local = [mod+"--lib" for mod in env['NS3_ENABLED_MODULES']]
+ obj.use = [mod for mod in env['NS3_ENABLED_MODULES']]
Binary file waf has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/waf-tools/boost.py Thu Sep 08 16:13:40 2011 +0100
@@ -0,0 +1,269 @@
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# partially based on boost.py written by Gernot Vormayr
+# written by Ruediger Sonderfeld <ruediger@c-plusplus.de>, 2008
+# modified by Bjoern Michaelsen, 2008
+# modified by Luca Fossati, 2008
+# rewritten for waf 1.5.1, Thomas Nagy, 2008
+# rewritten for waf 1.6.2, Sylvain Rouquette, 2011
+
+'''
+To add the boost tool to the waf file:
+$ ./waf-light --tools=compat15,boost
+ or, if you have waf >= 1.6.2
+$ ./waf update --files=boost
+
+The wscript will look like:
+
+def options(opt):
+ opt.load('compiler_cxx boost')
+
+def configure(conf):
+ conf.load('compiler_cxx boost')
+ conf.check_boost(lib='system filesystem', mt=True, static=True)
+
+def build(bld):
+ bld(source='main.cpp', target='app', use='BOOST')
+'''
+
+import sys
+import re
+from waflib import Utils, Logs
+from waflib.Configure import conf
+
+BOOST_LIBS = ('/usr/lib', '/usr/local/lib',
+ '/opt/local/lib', '/sw/lib', '/lib')
+BOOST_INCLUDES = ('/usr/include', '/usr/local/include',
+ '/opt/local/include', '/sw/include')
+BOOST_VERSION_FILE = 'boost/version.hpp'
+BOOST_VERSION_CODE = '''
+#include <iostream>
+#include <boost/version.hpp>
+int main() { std::cout << BOOST_LIB_VERSION << std::endl; }
+'''
+
+# toolsets from {boost_dir}/tools/build/v2/tools/common.jam
+PLATFORM = Utils.unversioned_sys_platform()
+detect_intel = lambda env: (PLATFORM == 'win32') and 'iw' or 'il'
+detect_clang = lambda env: (PLATFORM == 'darwin') and 'clang-darwin' or 'clang'
+detect_mingw = lambda env: (re.search('MinGW', env.CXX[0])) and 'mgw' or 'gcc'
+BOOST_TOOLSETS = {
+ 'borland': 'bcb',
+ 'clang': detect_clang,
+ 'como': 'como',
+ 'cw': 'cw',
+ 'darwin': 'xgcc',
+ 'edg': 'edg',
+ 'g++': detect_mingw,
+ 'gcc': detect_mingw,
+ 'icpc': detect_intel,
+ 'intel': detect_intel,
+ 'kcc': 'kcc',
+ 'kylix': 'bck',
+ 'mipspro': 'mp',
+ 'mingw': 'mgw',
+ 'msvc': 'vc',
+ 'qcc': 'qcc',
+ 'sun': 'sw',
+ 'sunc++': 'sw',
+ 'tru64cxx': 'tru',
+ 'vacpp': 'xlc'
+}
+
+
+def options(opt):
+ opt.add_option('--boost-includes', type='string',
+ default='', dest='boost_includes',
+ help='''path to the boost directory where the includes are
+ e.g. /boost_1_45_0/include''')
+ opt.add_option('--boost-libs', type='string',
+ default='', dest='boost_libs',
+ help='''path to the directory where the boost libs are
+ e.g. /boost_1_45_0/stage/lib''')
+ opt.add_option('--boost-static', action='store_true',
+ default=False, dest='boost_static',
+ help='link static libraries')
+ opt.add_option('--boost-mt', action='store_true',
+ default=False, dest='boost_mt',
+ help='select multi-threaded libraries')
+ opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
+ help='''select libraries with tags (dgsyp, d for debug),
+ see doc Boost, Getting Started, chapter 6.1''')
+ opt.add_option('--boost-toolset', type='string',
+ default='', dest='boost_toolset',
+ help='force a toolset e.g. msvc, vc90, \
+ gcc, mingw, mgw45 (default: auto)')
+ py_version = '%d%d' % (sys.version_info[0], sys.version_info[1])
+ opt.add_option('--boost-python', type='string',
+ default=py_version, dest='boost_python',
+ help='select the lib python with this version \
+ (default: %s)' % py_version)
+
+
+@conf
+def __boost_get_version_file(self, dir):
+ try:
+ return self.root.find_dir(dir).find_node(BOOST_VERSION_FILE)
+ except:
+ return None
+
+
+@conf
+def boost_get_version(self, dir):
+ """silently retrieve the boost version number"""
+ re_but = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.*)"$', re.M)
+ try:
+ val = re_but.search(self.__boost_get_version_file(dir).read()).group(1)
+ except:
+ val = self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[dir],
+ execute=True, define_ret=True)
+ return val
+
+
+@conf
+def boost_get_includes(self, *k, **kw):
+ includes = k and k[0] or kw.get('includes', None)
+ if includes and self.__boost_get_version_file(includes):
+ return includes
+ for dir in BOOST_INCLUDES:
+ if self.__boost_get_version_file(dir):
+ return dir
+ if includes:
+ self.fatal('headers not found in %s' % includes)
+ else:
+ self.fatal('headers not found, use --boost-includes=/path/to/boost')
+
+
+@conf
+def boost_get_toolset(self, cc):
+ toolset = cc
+ if not cc:
+ build_platform = Utils.unversioned_sys_platform()
+ if build_platform in BOOST_TOOLSETS:
+ cc = build_platform
+ else:
+ cc = self.env.CXX_NAME
+ if cc in BOOST_TOOLSETS:
+ toolset = BOOST_TOOLSETS[cc]
+ return isinstance(toolset, str) and toolset or toolset(self.env)
+
+
+@conf
+def __boost_get_libs_path(self, *k, **kw):
+ ''' return the lib path and all the files in it '''
+ if 'files' in kw:
+ return self.root.find_dir('.'), Utils.to_list(kw['files'])
+ libs = k and k[0] or kw.get('libs', None)
+ if libs:
+ path = self.root.find_dir(libs)
+ files = path.ant_glob('*boost_*')
+ if not libs or not files:
+ for dir in BOOST_LIBS:
+ try:
+ path = self.root.find_dir(dir)
+ files = path.ant_glob('*boost_*')
+ if files:
+ break
+ path = self.root.find_dir(dir + '64')
+ files = path.ant_glob('*boost_*')
+ if files:
+ break
+ except:
+ path = None
+ if not path:
+ if libs:
+ self.fatal('libs not found in %s' % libs)
+ else:
+ self.fatal('libs not found, \
+ use --boost-includes=/path/to/boost/lib')
+ return path, files
+
+
+@conf
+def boost_get_libs(self, *k, **kw):
+ '''
+ return the lib path and the required libs
+ according to the parameters
+ '''
+ path, files = self.__boost_get_libs_path(**kw)
+ t = []
+ if kw.get('mt', False):
+ t.append('mt')
+ if kw.get('abi', None):
+ t.append(kw['abi'])
+ tags = t and '(-%s)+' % '-'.join(t) or ''
+ toolset = '(-%s[0-9]{0,3})+' % self.boost_get_toolset(kw.get('toolset', ''))
+ version = '(-%s)+' % self.env.BOOST_VERSION
+
+ def find_lib(re_lib, files):
+ for file in files:
+ if re_lib.search(file.name):
+ return file
+ return None
+
+ def format_lib_name(name):
+ if name.startswith('lib'):
+ name = name[3:]
+ return name.split('.')[0]
+
+ libs = []
+ for lib in Utils.to_list(k and k[0] or kw.get('lib', None)):
+ py = (lib == 'python') and '(-py%s)+' % kw['python'] or ''
+ # Trying libraries, from most strict match to least one
+ for pattern in ['boost_%s%s%s%s%s' % (lib, toolset, tags, py, version),
+ 'boost_%s%s%s%s' % (lib, tags, py, version),
+ 'boost_%s%s%s' % (lib, tags, version),
+ # Give up trying to find the right version
+ 'boost_%s%s%s%s' % (lib, toolset, tags, py),
+ 'boost_%s%s%s' % (lib, tags, py),
+ 'boost_%s%s' % (lib, tags)]:
+ file = find_lib(re.compile(pattern), files)
+ if file:
+ libs.append(format_lib_name(file.name))
+ break
+ else:
+ self.fatal('lib %s not found in %s' % (lib, path))
+
+ return path.abspath(), libs
+
+
+@conf
+def check_boost(self, *k, **kw):
+ """
+ initialize boost
+
+ You can pass the same parameters as the command line (without "--boost-"),
+ but the command line has the priority.
+ """
+ if not self.env['CXX']:
+ self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
+
+ params = {'lib': k and k[0] or kw.get('lib', None)}
+ for key, value in self.options.__dict__.items():
+ if not key.startswith('boost_'):
+ continue
+ key = key[len('boost_'):]
+ params[key] = value and value or kw.get(key, '')
+
+ var = kw.get('uselib_store', 'BOOST')
+
+ self.start_msg('Checking boost includes')
+ self.env['INCLUDES_%s' % var] = self.boost_get_includes(**params)
+ self.env.BOOST_VERSION = self.boost_get_version(self.env['INCLUDES_%s' % var])
+ self.end_msg(self.env.BOOST_VERSION)
+ if Logs.verbose:
+ Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
+
+ if not params['lib']:
+ return
+ self.start_msg('Checking boost libs')
+ suffix = params.get('static', 'ST') or ''
+ path, libs = self.boost_get_libs(**params)
+ self.env['%sLIBPATH_%s' % (suffix, var)] = [path]
+ self.env['%sLIB_%s' % (suffix, var)] = libs
+ self.end_msg('ok')
+ if Logs.verbose:
+ Logs.pprint('CYAN', ' path : %s' % path)
+ Logs.pprint('CYAN', ' libs : %s' % libs)
+
--- a/waf-tools/command.py Wed Sep 07 12:18:37 2011 -0700
+++ b/waf-tools/command.py Thu Sep 08 16:13:40 2011 +0100
@@ -1,9 +1,10 @@
-from TaskGen import feature, taskgen, before, task_gen
-import Node, Task, Utils, Build, pproc, Constants
+import TaskGen# import feature, taskgen_method, before_method, task_gen
+import Node, Task, Utils, Build
+import subprocess
import Options
import shellcmd
-shellcmd.subprocess = pproc # the WAF version of the subprocess module is supposedly less buggy
+#shellcmd.subprocess = pproc # the WAF version of the subprocess module is supposedly less buggy
from Logs import debug, error
shellcmd.debug = debug
@@ -18,7 +19,7 @@
class command_task(Task.Task):
color = "BLUE"
def __init__(self, env, generator):
- Task.Task.__init__(self, env, normal=1, generator=generator)
+ Task.Task.__init__(self, env=env, normal=1, generator=generator)
def __str__(self):
"string to display to the user"
@@ -33,7 +34,6 @@
pipeline = shellcmd.Pipeline()
pipeline.parse(self.generator.command)
cmd = pipeline.get_abbreviated_command()
-
return 'command (%s): %s%s%s\n' % (cmd, src_str, sep, tgt_str)
def _subst_arg(self, arg, direction, namespace):
@@ -50,21 +50,24 @@
result = eval(var+code, namespace)
if isinstance(result, Node.Node):
if var == 'TGT':
- return result.bldpath(self.env)
+ return result.get_bld().abspath()
elif var == 'SRC':
- return result.srcpath(self.env)
+ return result.srcpath()
else:
raise ValueError("Bad subst variable %r" % var)
elif result is self.inputs:
if len(self.inputs) == 1:
- return result[0].srcpath(self.env)
+ return result[0].srcpath()
else:
raise ValueError("${SRC} requested but have multiple sources; which one?")
elif result is self.outputs:
if len(self.outputs) == 1:
- return result[0].bldpath(self.env)
+ return result[0].get_bld().abspath()
else:
raise ValueError("${TGT} requested but have multiple targets; which one?")
+ elif isinstance(result, list):
+ assert len(result) == 1
+ return result[0]
else:
return result
return None
@@ -95,11 +98,10 @@
cmd.env_vars = env_vars
elif isinstance(cmd, shellcmd.Chdir):
cmd.dir = self._subst_arg(cmd.dir, None, namespace)
-
return pipeline.run(verbose=(Options.options.verbose > 0))
-@taskgen
-@feature('command')
+@TaskGen.taskgen_method
+@TaskGen.feature('command')
def init_command(self):
Utils.def_attrs(self,
# other variables that can be used in the command: ${VARIABLE}
@@ -107,28 +109,25 @@
-@taskgen
-@feature('command')
-@before('apply_core')
+@TaskGen.feature('command')
+@TaskGen.after_method('process_rule')
def apply_command(self):
- self.meths.remove('apply_core')
+ #self.meths.remove('apply_core')
# create the task
task = self.create_task('command')
setattr(task, "dep_vars", getattr(self, "dep_vars", None))
# process the sources
inputs = []
- for src in self.to_list(self.source):
- node = self.path.find_resource(src)
- if node is None:
- raise Utils.WafError("source %s not found" % src)
- inputs.append(node)
+ for node in self.source:
+ inputs.append(node)
task.set_inputs(inputs)
task.set_outputs([self.path.find_or_declare(tgt) for tgt in self.to_list(self.target)])
+ self.source = ''
#Task.file_deps = Task.extract_deps
-class command_taskgen(task_gen):
- def __init__(self, *k, **kw):
- task_gen.__init__(self, *k, **kw)
- self.features.append('command')
+# class command_taskgen(task_gen):
+# def __init__(self, *k, **kw):
+# task_gen.__init__(self, *k, **kw)
+# self.features.append('command')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/waf-tools/misc.py Thu Sep 08 16:13:40 2011 +0100
@@ -0,0 +1,416 @@
+#!/usr/bin/env python
+# encoding: utf-8
+# Thomas Nagy, 2006-2010 (ita)
+
+"""
+This tool is totally deprecated
+
+Try using:
+ .pc.in files for .pc files
+ the feature intltool_in - see demos/intltool
+ make-like rules
+"""
+
+import shutil, re, os
+from waflib import TaskGen, Node, Task, Utils, Build, Errors
+from waflib.TaskGen import feature, after_method, before_method
+from waflib.Logs import debug
+
+def copy_attrs(orig, dest, names, only_if_set=False):
+ """
+ copy class attributes from an object to another
+ """
+ for a in Utils.to_list(names):
+ u = getattr(orig, a, ())
+ if u or not only_if_set:
+ setattr(dest, a, u)
+
+def copy_func(tsk):
+ "Make a file copy. This might be used to make other kinds of file processing (even calling a compiler is possible)"
+ env = tsk.env
+ infile = tsk.inputs[0].abspath()
+ outfile = tsk.outputs[0].abspath()
+ try:
+ shutil.copy2(infile, outfile)
+ except (OSError, IOError):
+ return 1
+ else:
+ if tsk.chmod: os.chmod(outfile, tsk.chmod)
+ return 0
+
+def action_process_file_func(tsk):
+ "Ask the function attached to the task to process it"
+ if not tsk.fun: raise Errors.WafError('task must have a function attached to it for copy_func to work!')
+ return tsk.fun(tsk)
+
+@feature('cmd')
+def apply_cmd(self):
+ "call a command everytime"
+ if not self.fun: raise Errors.WafError('cmdobj needs a function!')
+ tsk = Task.TaskBase()
+ tsk.fun = self.fun
+ tsk.env = self.env
+ self.tasks.append(tsk)
+ tsk.install_path = self.install_path
+
+@feature('copy')
+@before_method('process_source')
+def apply_copy(self):
+ Utils.def_attrs(self, fun=copy_func)
+ self.default_install_path = 0
+
+ lst = self.to_list(self.source)
+ self.meths.remove('process_source')
+
+ for filename in lst:
+ node = self.path.find_resource(filename)
+ if not node: raise Errors.WafError('cannot find input file %s for processing' % filename)
+
+ target = self.target
+ if not target or len(lst)>1: target = node.name
+
+ # TODO the file path may be incorrect
+ newnode = self.path.find_or_declare(target)
+
+ tsk = self.create_task('copy', node, newnode)
+ tsk.fun = self.fun
+ tsk.chmod = getattr(self, 'chmod', Utils.O644)
+
+ if not tsk.env:
+ tsk.debug()
+ raise Errors.WafError('task without an environment')
+
+def subst_func(tsk):
+ "Substitutes variables in a .in file"
+
+ m4_re = re.compile('@(\w+)@', re.M)
+
+ code = tsk.inputs[0].read() #Utils.readf(infile)
+
+ # replace all % by %% to prevent errors by % signs in the input file while string formatting
+ code = code.replace('%', '%%')
+
+ s = m4_re.sub(r'%(\1)s', code)
+
+ env = tsk.env
+ di = getattr(tsk, 'dict', {}) or getattr(tsk.generator, 'dict', {})
+ if not di:
+ names = m4_re.findall(code)
+ for i in names:
+ di[i] = env.get_flat(i) or env.get_flat(i.upper())
+
+ tsk.outputs[0].write(s % di)
+
+@feature('subst')
+@before_method('process_source')
+def apply_subst(self):
+ Utils.def_attrs(self, fun=subst_func)
+ lst = self.to_list(self.source)
+ self.meths.remove('process_source')
+
+ self.dict = getattr(self, 'dict', {})
+
+ for filename in lst:
+ node = self.path.find_resource(filename)
+ if not node: raise Errors.WafError('cannot find input file %s for processing' % filename)
+
+ if self.target:
+ newnode = self.path.find_or_declare(self.target)
+ else:
+ newnode = node.change_ext('')
+
+ try:
+ self.dict = self.dict.get_merged_dict()
+ except AttributeError:
+ pass
+
+ if self.dict and not self.env['DICT_HASH']:
+ self.env = self.env.derive()
+ keys = list(self.dict.keys())
+ keys.sort()
+ lst = [self.dict[x] for x in keys]
+ self.env['DICT_HASH'] = str(Utils.h_list(lst))
+
+ tsk = self.create_task('copy', node, newnode)
+ tsk.fun = self.fun
+ tsk.dict = self.dict
+ tsk.dep_vars = ['DICT_HASH']
+ tsk.chmod = getattr(self, 'chmod', Utils.O644)
+
+ if not tsk.env:
+ tsk.debug()
+ raise Errors.WafError('task without an environment')
+
+####################
+## command-output ####
+####################
+
+class cmd_arg(object):
+ """command-output arguments for representing files or folders"""
+ def __init__(self, name, template='%s'):
+ self.name = name
+ self.template = template
+ self.node = None
+
+class input_file(cmd_arg):
+ def find_node(self, base_path):
+ assert isinstance(base_path, Node.Node)
+ self.node = base_path.find_resource(self.name)
+ if self.node is None:
+ raise Errors.WafError("Input file %s not found in " % (self.name, base_path))
+
+ def get_path(self, env, absolute):
+ if absolute:
+ return self.template % self.node.abspath()
+ else:
+ return self.template % self.node.srcpath()
+
+class output_file(cmd_arg):
+ def find_node(self, base_path):
+ assert isinstance(base_path, Node.Node)
+ self.node = base_path.find_or_declare(self.name)
+ if self.node is None:
+ raise Errors.WafError("Output file %s not found in " % (self.name, base_path))
+
+ def get_path(self, env, absolute):
+ if absolute:
+ return self.template % self.node.abspath()
+ else:
+ return self.template % self.node.bldpath()
+
+class cmd_dir_arg(cmd_arg):
+ def find_node(self, base_path):
+ assert isinstance(base_path, Node.Node)
+ self.node = base_path.find_dir(self.name)
+ if self.node is None:
+ raise Errors.WafError("Directory %s not found in " % (self.name, base_path))
+
+class input_dir(cmd_dir_arg):
+ def get_path(self, dummy_env, dummy_absolute):
+ return self.template % self.node.abspath()
+
+class output_dir(cmd_dir_arg):
+ def get_path(self, env, dummy_absolute):
+ return self.template % self.node.abspath()
+
+
+class command_output(Task.Task):
+ color = "BLUE"
+ def __init__(self, env, command, command_node, command_args, stdin, stdout, cwd, os_env, stderr):
+ Task.Task.__init__(self, env=env)
+ assert isinstance(command, (str, Node.Node))
+ self.command = command
+ self.command_args = command_args
+ self.stdin = stdin
+ self.stdout = stdout
+ self.cwd = cwd
+ self.os_env = os_env
+ self.stderr = stderr
+
+ if command_node is not None: self.dep_nodes = [command_node]
+ self.dep_vars = [] # additional environment variables to look
+
+ def run(self):
+ task = self
+ #assert len(task.inputs) > 0
+
+ def input_path(node, template):
+ if task.cwd is None:
+ return template % node.bldpath()
+ else:
+ return template % node.abspath()
+ def output_path(node, template):
+ fun = node.abspath
+ if task.cwd is None: fun = node.bldpath
+ return template % fun()
+
+ if isinstance(task.command, Node.Node):
+ argv = [input_path(task.command, '%s')]
+ else:
+ argv = [task.command]
+
+ for arg in task.command_args:
+ if isinstance(arg, str):
+ argv.append(arg)
+ else:
+ assert isinstance(arg, cmd_arg)
+ argv.append(arg.get_path(task.env, (task.cwd is not None)))
+
+ if task.stdin:
+ stdin = open(input_path(task.stdin, '%s'))
+ else:
+ stdin = None
+
+ if task.stdout:
+ stdout = open(output_path(task.stdout, '%s'), "w")
+ else:
+ stdout = None
+
+ if task.stderr:
+ stderr = open(output_path(task.stderr, '%s'), "w")
+ else:
+ stderr = None
+
+ if task.cwd is None:
+ cwd = ('None (actually %r)' % os.getcwd())
+ else:
+ cwd = repr(task.cwd)
+ debug("command-output: cwd=%s, stdin=%r, stdout=%r, argv=%r" %
+ (cwd, stdin, stdout, argv))
+
+ if task.os_env is None:
+ os_env = os.environ
+ else:
+ os_env = task.os_env
+ command = Utils.subprocess.Popen(argv, stdin=stdin, stdout=stdout, stderr=stderr, cwd=task.cwd, env=os_env)
+ return command.wait()
+
+@feature('command-output')
+def init_cmd_output(self):
+ Utils.def_attrs(self,
+ stdin = None,
+ stdout = None,
+ stderr = None,
+ # the command to execute
+ command = None,
+
+ # whether it is an external command; otherwise it is assumed
+ # to be an executable binary or script that lives in the
+ # source or build tree.
+ command_is_external = False,
+
+ # extra parameters (argv) to pass to the command (excluding
+ # the command itself)
+ argv = [],
+
+ # dependencies to other objects -> this is probably not what you want (ita)
+ # values must be 'task_gen' instances (not names!)
+ dependencies = [],
+
+ # dependencies on env variable contents
+ dep_vars = [],
+
+ # input files that are implicit, i.e. they are not
+ # stdin, nor are they mentioned explicitly in argv
+ hidden_inputs = [],
+
+ # output files that are implicit, i.e. they are not
+ # stdout, nor are they mentioned explicitly in argv
+ hidden_outputs = [],
+
+ # change the subprocess to this cwd (must use obj.input_dir() or output_dir() here)
+ cwd = None,
+
+ # OS environment variables to pass to the subprocess
+ # if None, use the default environment variables unchanged
+ os_env = None)
+
+@feature('command-output')
+@after_method('init_cmd_output')
+def apply_cmd_output(self):
+ if self.command is None:
+ raise Errors.WafError("command-output missing command")
+ if self.command_is_external:
+ cmd = self.command
+ cmd_node = None
+ else:
+ cmd_node = self.path.find_resource(self.command)
+ assert cmd_node is not None, ('''Could not find command '%s' in source tree.
+Hint: if this is an external command,
+use command_is_external=True''') % (self.command,)
+ cmd = cmd_node
+
+ if self.cwd is None:
+ cwd = None
+ else:
+ assert isinstance(cwd, CmdDirArg)
+ self.cwd.find_node(self.path)
+
+ args = []
+ inputs = []
+ outputs = []
+
+ for arg in self.argv:
+ if isinstance(arg, cmd_arg):
+ arg.find_node(self.path)
+ if isinstance(arg, input_file):
+ inputs.append(arg.node)
+ if isinstance(arg, output_file):
+ outputs.append(arg.node)
+
+ if self.stdout is None:
+ stdout = None
+ else:
+ assert isinstance(self.stdout, str)
+ stdout = self.path.find_or_declare(self.stdout)
+ if stdout is None:
+ raise Errors.WafError("File %s not found" % (self.stdout,))
+ outputs.append(stdout)
+
+ if self.stderr is None:
+ stderr = None
+ else:
+ assert isinstance(self.stderr, str)
+ stderr = self.path.find_or_declare(self.stderr)
+ if stderr is None:
+ raise Errors.WafError("File %s not found" % (self.stderr,))
+ outputs.append(stderr)
+
+ if self.stdin is None:
+ stdin = None
+ else:
+ assert isinstance(self.stdin, str)
+ stdin = self.path.find_resource(self.stdin)
+ if stdin is None:
+ raise Errors.WafError("File %s not found" % (self.stdin,))
+ inputs.append(stdin)
+
+ for hidden_input in self.to_list(self.hidden_inputs):
+ node = self.path.find_resource(hidden_input)
+ if node is None:
+ raise Errors.WafError("File %s not found in dir %s" % (hidden_input, self.path))
+ inputs.append(node)
+
+ for hidden_output in self.to_list(self.hidden_outputs):
+ node = self.path.find_or_declare(hidden_output)
+ if node is None:
+ raise Errors.WafError("File %s not found in dir %s" % (hidden_output, self.path))
+ outputs.append(node)
+
+ if not (inputs or getattr(self, 'no_inputs', None)):
+ raise Errors.WafError('command-output objects must have at least one input file or give self.no_inputs')
+ if not (outputs or getattr(self, 'no_outputs', None)):
+ raise Errors.WafError('command-output objects must have at least one output file or give self.no_outputs')
+
+ cwd = self.bld.variant_dir
+ task = command_output(self.env, cmd, cmd_node, self.argv, stdin, stdout, cwd, self.os_env, stderr)
+ task.generator = self
+ copy_attrs(self, task, 'before after ext_in ext_out', only_if_set=True)
+ self.tasks.append(task)
+
+ task.inputs = inputs
+ task.outputs = outputs
+ task.dep_vars = self.to_list(self.dep_vars)
+
+ for dep in self.dependencies:
+ assert dep is not self
+ dep.post()
+ for dep_task in dep.tasks:
+ task.set_run_after(dep_task)
+
+ if not task.inputs:
+ # the case for svnversion, always run, and update the output nodes
+ task.runnable_status = type(Task.TaskBase.run)(runnable_status, task, task.__class__) # always run
+ task.post_run = type(Task.TaskBase.run)(post_run, task, task.__class__)
+
+ # TODO the case with no outputs?
+
+def post_run(self):
+ for x in self.outputs:
+ x.sig = Utils.h_file(x.abspath())
+
+def runnable_status(self):
+ return self.RUN_ME
+
+Task.task_factory('copy', vars=[], func=action_process_file_func)
+
--- a/waf-tools/pkgconfig.py Wed Sep 07 12:18:37 2011 -0700
+++ b/waf-tools/pkgconfig.py Thu Sep 08 16:13:40 2011 +0100
@@ -3,10 +3,11 @@
import Options
import Configure
-import pproc as subprocess
+import subprocess
import config_c
+import sys
-def detect(conf):
+def configure(conf):
pkg_config = conf.find_program('pkg-config', var='PKG_CONFIG')
if not pkg_config: return
@@ -19,25 +20,31 @@
else:
return False
+ if Options.options.verbose:
+ extra_msg = ' (%s)' % expression
+ else:
+ extra_msg = ''
+
+ conf.start_msg('pkg-config flags for %s%s' % (uselib_name, extra_msg))
+
argv = [pkg_config, '--cflags', '--libs', expression]
- cmd = subprocess.Popen(argv, stdout=subprocess.PIPE)
- out, dummy = cmd.communicate()
+ cmd = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = cmd.communicate()
retval = cmd.wait()
- msg_checking = ("pkg-config flags for %s" % (uselib_name,))
- if Options.options.verbose:
- if retval == 0:
- conf.check_message_custom(msg_checking,
- ('(%s)' % expression), out)
+ conf.to_log('%r: %r (exit code %i)\n%s' % (argv, out, retval, err))
+
+ if retval != 0:
+ conf.end_msg(False)
+ sys.stderr.write(err)
+ else:
+ if Options.options.verbose:
+ conf.end_msg(out)
else:
- conf.check_message(msg_checking, ('(%s)' % expression), False)
- else:
- conf.check_message(msg_checking, '', (retval == 0), '')
- conf.log.write('%r: %r (exit code %i)\n' % (argv, out, retval))
+ conf.end_msg(True)
if retval == 0:
-
- config_c.parse_flags(out, uselib_name, conf.env)
+ conf.parse_flags(out, uselib_name, conf.env)
conf.env[uselib_name] = True
return True
--- a/wscript Wed Sep 07 12:18:37 2011 -0700
+++ b/wscript Thu Sep 08 16:13:40 2011 +0100
@@ -11,18 +11,18 @@
import textwrap
# WAF modules
-import pproc as subprocess
+import subprocess
import Options
import Logs
import TaskGen
-import Constants
+#import Constants
-import ccroot
-ccroot.USE_TOP_LEVEL = True
+#import ccroot
+#ccroot.USE_TOP_LEVEL = True
import Task
-Task.algotype = Constants.JOBCONTROL # so that Task.maxjobs=1 takes effect
+#Task.algotype = Constants.JOBCONTROL # so that Task.maxjobs=1 takes effect
import Utils
import Build
@@ -58,7 +58,7 @@
# local modules
import wutils
-Configure.autoconfig = 1
+Configure.autoconfig = 0
# the following two variables are used by the target "waf dist"
VERSION = file("VERSION", "rt").read().strip()
@@ -124,12 +124,12 @@
if i != 1:
print
-def set_options(opt):
+def options(opt):
# options provided by the modules
- opt.tool_options('compiler_cc')
- opt.tool_options('compiler_cxx')
- opt.tool_options('cflags')
- opt.tool_options('gnu_dirs')
+ opt.load('compiler_c')
+ opt.load('compiler_cxx')
+ opt.load('cflags')
+ opt.load('gnu_dirs')
opt.add_option('--cwd',
help=('Set the working directory for a program.'),
@@ -234,6 +234,7 @@
flag: can be a string or a list of strings
"""
+ conf.start_msg('Checking for compilation flag %r support' % (flag,))
env = conf.env.copy()
if mode == 'cxx':
fname = 'test.cc'
@@ -244,26 +245,36 @@
try:
retval = conf.run_c_code(code='#include <stdio.h>\nint main() { return 0; }\n',
env=env, compile_filename=fname,
- compile_mode=mode, type='cprogram', execute=False)
+ compile_mode=mode, features='c cprogram', execute=False)
except Configure.ConfigurationError:
ok = False
else:
ok = (retval == 0)
- conf.check_message_custom(flag, 'support', (ok and 'yes' or 'no'))
+ conf.end_msg(ok)
return ok
def report_optional_feature(conf, name, caption, was_enabled, reason_not_enabled):
- conf.env.append_value('NS3_OPTIONAL_FEATURES', (name, caption, was_enabled, reason_not_enabled))
+ conf.env.append_value('NS3_OPTIONAL_FEATURES', [(name, caption, was_enabled, reason_not_enabled)])
+
+
+# starting with waf 1.6, conf.check() becomes fatal by default if the
+# test fails, this alternative method makes the test non-fatal, as it
+# was in waf <= 1.5
+def _check_nonfatal(conf, *args, **kwargs):
+ try:
+ return conf.check(*args, **kwargs)
+ except conf.errors.ConfigurationError:
+ return None
def configure(conf):
# attach some extra methods
+ conf.check_nonfatal = types.MethodType(_check_nonfatal, conf)
conf.check_compilation_flag = types.MethodType(_check_compilation_flag, conf)
conf.report_optional_feature = types.MethodType(report_optional_feature, conf)
conf.env['NS3_OPTIONAL_FEATURES'] = []
- conf.env['NS3_BUILDDIR'] = conf.blddir
- conf.check_tool('compiler_cc')
+ conf.check_tool('compiler_c')
conf.check_tool('compiler_cxx')
conf.check_tool('cflags', ['waf-tools'])
try:
@@ -276,24 +287,20 @@
#if os.path.exists('/usr/lib64'):
# conf.env.LIBDIR = os.path.join(conf.env.PREFIX, "lib64")
- # create the second environment, set the variant and set its name
- variant_env = conf.env.copy()
- variant_name = Options.options.build_profile
+
+ # variant_name = Options.options.build_profile
+ # if Options.options.enable_gcov:
+ # variant_name += '-gcov'
+ # conf.env['NS3_ACTIVE_VARIANT'] = variant_name
+ # conf.setenv(variant_name, env=conf.env.derive()) # start with a copy instead of a new env
+ env = conf.env
if Options.options.enable_gcov:
- variant_name += '-gcov'
- variant_env.append_value('CCFLAGS', '-fprofile-arcs')
- variant_env.append_value('CCFLAGS', '-ftest-coverage')
- variant_env.append_value('CXXFLAGS', '-fprofile-arcs')
- variant_env.append_value('CXXFLAGS', '-ftest-coverage')
- variant_env.append_value('LINKFLAGS', '-fprofile-arcs')
-
- conf.env['NS3_ACTIVE_VARIANT'] = variant_name
- variant_env['NS3_ACTIVE_VARIANT'] = variant_name
- variant_env.set_variant(variant_name)
- conf.set_env_name(variant_name, variant_env)
- conf.setenv(variant_name)
- env = variant_env
+ env.append_value('CCFLAGS', '-fprofile-arcs')
+ env.append_value('CCFLAGS', '-ftest-coverage')
+ env.append_value('CXXFLAGS', '-fprofile-arcs')
+ env.append_value('CXXFLAGS', '-ftest-coverage')
+ env.append_value('LINKFLAGS', '-fprofile-arcs')
if Options.options.build_profile == 'debug':
env.append_value('CXXDEFINES', 'NS3_ASSERT_ENABLE')
@@ -332,8 +339,6 @@
conf.report_optional_feature("static", "Static build", True, '')
if Options.options.enable_static:
env['ENABLE_STATIC_NS3'] = True
- if Options.options.enable_shared_and_static:
- env['ENABLE_SHARED_AND_STATIC_NS3'] = True
elif os.uname()[4] == 'x86_64':
if env['ENABLE_PYTHON_BINDINGS'] and \
not conf.check_compilation_flag('-mcmodel=large'):
@@ -346,8 +351,6 @@
conf.report_optional_feature("static", "Static build", True, '')
if Options.options.enable_static:
env['ENABLE_STATIC_NS3'] = True
- if Options.options.enable_shared_and_static:
- env['ENABLE_SHARED_AND_STATIC_NS3'] = True
elif env['CXX_NAME'] == 'gcc' and \
(env['PLATFORM'].startswith('darwin') or \
env['PLATFORM'].startswith('cygwin')):
@@ -553,13 +556,12 @@
"RUN_ME SKIP_ME or ASK_LATER"
st = os.stat(self.filename)
if st.st_uid == 0:
- return Constants.SKIP_ME
+ return Task.SKIP_ME
else:
- return Constants.RUN_ME
-
+ return Task.RUN_ME
def create_suid_program(bld, name):
- program = bld.new_task_gen('cxx', 'program')
+ program = bld.new_task_gen(features=['cxx', 'cxxprogram'])
program.is_ns3_program = True
program.module_deps = list()
program.name = name
@@ -571,20 +573,21 @@
return program
def create_ns3_program(bld, name, dependencies=('core',)):
- program = bld.new_task_gen('cxx', 'program')
+ program = bld.new_task_gen(features=['cxx', 'cxxprogram'])
program.is_ns3_program = True
program.name = name
program.target = program.name
# Each of the modules this program depends on has its own library.
program.ns3_module_dependencies = ['ns3-'+dep for dep in dependencies]
+ program.includes = "# #/.."
return program
def register_ns3_script(bld, name, dependencies=('core',)):
ns3_module_dependencies = ['ns3-'+dep for dep in dependencies]
- bld.env.append_value('NS3_SCRIPT_DEPENDENCIES', (name, ns3_module_dependencies))
+ bld.env.append_value('NS3_SCRIPT_DEPENDENCIES', [(name, ns3_module_dependencies)])
def add_examples_programs(bld):
- env = bld.env_of_name('default')
+ env = bld.env
if env['ENABLE_EXAMPLES']:
for dir in os.listdir('examples'):
if dir.startswith('.') or dir == 'CVS':
@@ -615,8 +618,9 @@
def _add_ns3_program_missing_deps(bld, program):
deps_found = program.ns3_module_dependencies
- program.uselib_local = getattr(program, "uselib_local", []) + [dep + "--lib" for dep in deps_found]
- if program.env['ENABLE_STATIC_NS3'] and not program.env['ENABLE_SHARED_AND_STATIC_NS3']:
+ program.use = getattr(program, "use", []) + [dep #+ "--lib"
+ for dep in deps_found]
+ if program.env['ENABLE_STATIC_NS3']:
if sys.platform == 'darwin':
program.env.append_value('LINKFLAGS', '-Wl,-all_load')
for dep in deps_found:
@@ -628,8 +632,62 @@
program.env.append_value('LINKFLAGS', '-Wl,-Bdynamic,--no-whole-archive')
+from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext
+class Ns3BuildContext(BuildContext):
+ cmd = 'build'
+ #variant = 'debug' # FIXME
+
+ # @property
+ # def variant(self):
+ # if not self.all_envs:
+ # self.load_envs()
+ # return self.all_envs[''].NS3_ACTIVE_VARIANT
+
+ def get_all_task_gen(self):
+ for group in self.groups:
+ for taskgen in group:
+ yield taskgen
+ all_task_gen = property(get_all_task_gen)
+
+ def get_taskgen(self, name):
+ for group in self.groups:
+ for taskgen in group:
+ if taskgen.name == name:
+ return taskgen
+ raise KeyError(name)
+
+ def exclude_taskgen(self, taskgen):
+ # ok, so WAF does not provide an API to prevent an
+ # arbitrary taskgen from running; we have to muck around with
+ # WAF internal state, something that might stop working if
+ # WAF is upgraded...
+ for group in self.groups:
+ for tg1 in group:
+ if tg1 is taskgen:
+ group.remove(tg1)
+ break
+ else:
+ continue
+ break
+
def build(bld):
+
+
+ # switch to the variant matching our debug level
+ #variant_name = bld.env['NS3_ACTIVE_VARIANT']
+ #print variant_name
+ #bld.variant = variant_name
+ #variant_env = bld.env_of_name(variant_name)
+ #bld.all_envs['default'] = variant_env
+
+ env = bld.env
+ #bld.variant = bld.env.NS3_ACTIVE_VARIANT
+ #bld.init_dirs()
+ #env = bld.env
+ #print "-----------------------------------------------------------------------"
+ #print env
+
# If --enabled-modules option was given, then print a warning
# message and exit this function.
if Options.options.enable_modules:
@@ -654,15 +712,10 @@
bld.register_ns3_script = types.MethodType(register_ns3_script, bld)
bld.create_suid_program = types.MethodType(create_suid_program, bld)
- # switch default variant to the one matching our debug level
- variant_name = bld.env_of_name('default')['NS3_ACTIVE_VARIANT']
- variant_env = bld.env_of_name(variant_name)
- bld.all_envs['default'] = variant_env
-
# process subfolders from here
bld.add_subdirs('src')
- env = bld.env
+ #env = bld.env
# If modules have been enabled, then set lists of enabled modules
# and enabled module test libraries.
@@ -679,7 +732,7 @@
if module_obj is None:
raise ValueError("module %s not found" % module)
# Each enabled module has its own library.
- for dep in module_obj.uselib_local:
+ for dep in module_obj.use:
if not dep.startswith('ns3-'):
continue
if dep not in modules:
@@ -701,20 +754,6 @@
if env['NS3_ENABLED_MODULES']:
modules = env['NS3_ENABLED_MODULES']
- def exclude_taskgen(bld, taskgen):
- # ok, so WAF does not provide an API to prevent an
- # arbitrary taskgen from running; we have to muck around with
- # WAF internal state, something that might stop working if
- # WAF is upgraded...
- bld.all_task_gen.remove(taskgen)
- for group in bld.task_manager.groups:
- try:
- group.tasks_gen.remove(taskgen)
- except ValueError:
- pass
- else:
- break
-
# Exclude the programs other misc task gens that depend on disabled modules
for obj in list(bld.all_task_gen):
@@ -729,7 +768,7 @@
program_built = True
for dep in obj.ns3_module_dependencies:
if dep not in modules: # prog. depends on a module that isn't enabled?
- exclude_taskgen(bld, obj)
+ bld.exclude_taskgen(obj)
program_built = False
break
@@ -740,12 +779,12 @@
# disable the modules themselves
if hasattr(obj, "is_ns3_module") and obj.name not in modules:
- exclude_taskgen(bld, obj) # kill the module
+ bld.exclude_taskgen(obj) # kill the module
# disable the module test libraries
if hasattr(obj, "is_ns3_module_test_library"):
if not env['ENABLE_TESTS'] or (obj.module_name not in modules):
- exclude_taskgen(bld, obj) # kill the module test library
+ bld.exclude_taskgen(obj) # kill the module test library
# disable the ns3header_taskgen
if type(obj).__name__ == 'ns3header_taskgen':
@@ -806,7 +845,7 @@
# When --run'ing a program, tell WAF to only build that program,
# nothing more; this greatly speeds up compilation when all you
# want to do is run a test program.
- Options.options.compile_targets += ',' + os.path.basename(program_name)
+ Options.options.targets += ',' + os.path.basename(program_name)
for gen in bld.all_task_gen:
if type(gen).__name__ in ['ns3header_taskgen', 'ns3moduleheader_taskgen']:
gen.post()
@@ -826,9 +865,9 @@
# clean.
if ((not Options.options.run)
and (not Options.options.pyrun)
- and ('clean' not in Options.arg_line)
- and ('distclean' not in Options.arg_line)
- and ('shell' not in Options.arg_line)):
+ and ('clean' not in Options.commands)
+ and ('distclean' not in Options.commands)
+ and ('shell' not in Options.commands)):
# Print the list of built modules.
print
@@ -844,7 +883,8 @@
print
# Write the build status file.
- build_status_file = os.path.join (env['NS3_BUILDDIR'], env['NS3_ACTIVE_VARIANT'], 'build-status.py')
+ build_status_file = os.path.join(bld.out_dir, #env['NS3_ACTIVE_VARIANT'],
+ 'build-status.py')
out = open(build_status_file, 'w')
out.write('#! /usr/bin/env python\n')
out.write('\n')
@@ -955,21 +995,31 @@
raise Utils.WafError(msg)
-shell_context = Build.BuildContext
-def shell(ctx):
+from waflib import Context, Build
+class Ns3ShellContext(Context.Context):
"""run a shell with an environment suitably modified to run locally built programs"""
+ cmd = 'shell'
- #make sure we build first"
- Scripting.build(ctx)
+ def execute(self):
+
+ # first we execute the build
+ bld = Context.create_context("build")
+ bld.options = Options.options # provided for convenience
+ bld.cmd = "build"
+ bld.execute()
- if sys.platform == 'win32':
- shell = os.environ.get("COMSPEC", "cmd.exe")
- else:
- shell = os.environ.get("SHELL", "/bin/sh")
+ if sys.platform == 'win32':
+ shell = os.environ.get("COMSPEC", "cmd.exe")
+ else:
+ shell = os.environ.get("SHELL", "/bin/sh")
- env = wutils.bld.env
- os_env = {'NS3_MODULE_PATH': os.pathsep.join(env['NS3_MODULE_PATH']), 'NS3_EXECUTABLE_PATH': os.pathsep.join(env['NS3_EXECUTABLE_PATH'])}
- wutils.run_argv([shell], env, os_env)
+ env = bld.env
+ os_env = {
+ 'NS3_MODULE_PATH': os.pathsep.join(env['NS3_MODULE_PATH']),
+ 'NS3_EXECUTABLE_PATH': os.pathsep.join(env['NS3_EXECUTABLE_PATH']),
+ }
+ wutils.run_argv([shell], env, os_env)
+
def _doxygen(bld):
env = wutils.bld.env
@@ -1049,109 +1099,109 @@
## and the .hg repository tree. Here we provide a replacement DistDir
## implementation that is more efficient.
##
-import Scripting
-from Scripting import dist_exts, excludes, BLDDIR
-import Utils
-import os
+# import Scripting
+# from Scripting import dist_exts, excludes, BLDDIR
+# import Utils
+# import os
-def _copytree(src, dst, symlinks=False, excludes=(), build_dir=None):
- """Recursively copy a directory tree using copy2().
+# def _copytree(src, dst, symlinks=False, excludes=(), build_dir=None):
+# """Recursively copy a directory tree using copy2().
- The destination directory must not already exist.
- If exception(s) occur, an Error is raised with a list of reasons.
+# The destination directory must not already exist.
+# If exception(s) occur, an Error is raised with a list of reasons.
- If the optional symlinks flag is true, symbolic links in the
- source tree result in symbolic links in the destination tree; if
- it is false, the contents of the files pointed to by symbolic
- links are copied.
+# If the optional symlinks flag is true, symbolic links in the
+# source tree result in symbolic links in the destination tree; if
+# it is false, the contents of the files pointed to by symbolic
+# links are copied.
- XXX Consider this example code rather than the ultimate tool.
+# XXX Consider this example code rather than the ultimate tool.
- Note: this is a modified version of shutil.copytree from python
- 2.5.2 library; modified for WAF purposes to exclude dot dirs and
- another list of files.
- """
- names = os.listdir(src)
- os.makedirs(dst)
- errors = []
- for name in names:
- srcname = os.path.join(src, name)
- dstname = os.path.join(dst, name)
- try:
- if symlinks and os.path.islink(srcname):
- linkto = os.readlink(srcname)
- os.symlink(linkto, dstname)
- elif os.path.isdir(srcname):
- if name in excludes:
- continue
- elif name.startswith('.') or name.startswith(',,') or name.startswith('++') or name.startswith('CVS'):
- continue
- elif name == build_dir:
- continue
- else:
- ## build_dir is not passed into the recursive
- ## copytree, but that is intentional; it is a
- ## directory name valid only at the top level.
- copytree(srcname, dstname, symlinks, excludes)
- else:
- ends = name.endswith
- to_remove = False
- if name.startswith('.') or name.startswith('++'):
- to_remove = True
- else:
- for x in dist_exts:
- if ends(x):
- to_remove = True
- break
- if not to_remove:
- shutil.copy2(srcname, dstname)
- # XXX What about devices, sockets etc.?
- except (IOError, os.error), why:
- errors.append((srcname, dstname, str(why)))
- # catch the Error from the recursive copytree so that we can
- # continue with other files
- except shutil.Error, err:
- errors.extend(err.args[0])
- try:
- shutil.copystat(src, dst)
- except WindowsError:
- # can't copy file access times on Windows
- pass
- except OSError, why:
- errors.extend((src, dst, str(why)))
- if errors:
- raise shutil.Error, errors
+# Note: this is a modified version of shutil.copytree from python
+# 2.5.2 library; modified for WAF purposes to exclude dot dirs and
+# another list of files.
+# """
+# names = os.listdir(src)
+# os.makedirs(dst)
+# errors = []
+# for name in names:
+# srcname = os.path.join(src, name)
+# dstname = os.path.join(dst, name)
+# try:
+# if symlinks and os.path.islink(srcname):
+# linkto = os.readlink(srcname)
+# os.symlink(linkto, dstname)
+# elif os.path.isdir(srcname):
+# if name in excludes:
+# continue
+# elif name.startswith('.') or name.startswith(',,') or name.startswith('++') or name.startswith('CVS'):
+# continue
+# elif name == build_dir:
+# continue
+# else:
+# ## build_dir is not passed into the recursive
+# ## copytree, but that is intentional; it is a
+# ## directory name valid only at the top level.
+# copytree(srcname, dstname, symlinks, excludes)
+# else:
+# ends = name.endswith
+# to_remove = False
+# if name.startswith('.') or name.startswith('++'):
+# to_remove = True
+# else:
+# for x in dist_exts:
+# if ends(x):
+# to_remove = True
+# break
+# if not to_remove:
+# shutil.copy2(srcname, dstname)
+# # XXX What about devices, sockets etc.?
+# except (IOError, os.error), why:
+# errors.append((srcname, dstname, str(why)))
+# # catch the Error from the recursive copytree so that we can
+# # continue with other files
+# except shutil.Error, err:
+# errors.extend(err.args[0])
+# try:
+# shutil.copystat(src, dst)
+# except WindowsError:
+# # can't copy file access times on Windows
+# pass
+# except OSError, why:
+# errors.extend((src, dst, str(why)))
+# if errors:
+# raise shutil.Error, errors
-def DistDir(appname, version):
- #"make a distribution directory with all the sources in it"
- import shutil
+# def DistDir(appname, version):
+# #"make a distribution directory with all the sources in it"
+# import shutil
- # Our temporary folder where to put our files
- TMPFOLDER=appname+'-'+version
+# # Our temporary folder where to put our files
+# TMPFOLDER=appname+'-'+version
- # Remove an old package directory
- if os.path.exists(TMPFOLDER): shutil.rmtree(TMPFOLDER)
+# # Remove an old package directory
+# if os.path.exists(TMPFOLDER): shutil.rmtree(TMPFOLDER)
- global g_dist_exts, g_excludes
+# global g_dist_exts, g_excludes
- # Remove the Build dir
- build_dir = getattr(Utils.g_module, BLDDIR, None)
+# # Remove the Build dir
+# build_dir = getattr(Utils.g_module, BLDDIR, None)
- # Copy everything into the new folder
- _copytree('.', TMPFOLDER, excludes=excludes, build_dir=build_dir)
+# # Copy everything into the new folder
+# _copytree('.', TMPFOLDER, excludes=excludes, build_dir=build_dir)
- # TODO undocumented hook
- dist_hook = getattr(Utils.g_module, 'dist_hook', None)
- if dist_hook:
- os.chdir(TMPFOLDER)
- try:
- dist_hook()
- finally:
- # go back to the root directory
- os.chdir('..')
- return TMPFOLDER
+# # TODO undocumented hook
+# dist_hook = getattr(Utils.g_module, 'dist_hook', None)
+# if dist_hook:
+# os.chdir(TMPFOLDER)
+# try:
+# dist_hook()
+# finally:
+# # go back to the root directory
+# os.chdir('..')
+# return TMPFOLDER
-Scripting.DistDir = DistDir
+# Scripting.DistDir = DistDir
--- a/wutils.py Wed Sep 07 12:18:37 2011 -0700
+++ b/wutils.py Thu Sep 08 16:13:40 2011 +0100
@@ -1,18 +1,17 @@
import os
import os.path
import sys
-import pproc as subprocess
+import subprocess
import shlex
# WAF modules
-import ccroot
import Options
import Utils
import Logs
import TaskGen
import Build
import re
-
+from waflib.Errors import WafError
# these are set from the main wscript file
APPNAME=None
@@ -48,10 +47,10 @@
return os.path.curdir
return os.path.join(*rel_list)
-
+from waflib import Context
def find_program(program_name, env):
- launch_dir = os.path.abspath(Options.cwd_launch)
- top_dir = os.path.abspath(Options.launch_dir)
+ launch_dir = os.path.abspath(Context.launch_dir)
+ #top_dir = os.path.abspath(Options.cwd_launch)
found_programs = []
for obj in bld.all_task_gen:
if not getattr(obj, 'is_ns3_program', False):
@@ -63,7 +62,7 @@
continue
name1 = obj.target
- name2 = os.path.join(relpath(obj.path.abspath(), top_dir), obj.target)
+ name2 = os.path.join(relpath(obj.path.abspath(), launch_dir), obj.target)
names = [name1, name2]
found_programs.extend(names)
if program_name in names:
@@ -99,7 +98,7 @@
else:
proc_env[pathvar] = os.pathsep.join(list(env['NS3_MODULE_PATH']))
- pymoddir = bld.path.find_dir('bindings/python').abspath(env)
+ pymoddir = bld.path.find_dir('bindings/python').get_bld().abspath()
pyvizdir = bld.path.find_dir('src/visualizer').abspath()
if 'PYTHONPATH' in proc_env:
proc_env['PYTHONPATH'] = os.pathsep.join([pymoddir, pyvizdir] + [proc_env['PYTHONPATH']])
@@ -117,9 +116,9 @@
proc_env = get_proc_env(os_env)
if Options.options.valgrind and not force_no_valgrind:
if Options.options.command_template:
- raise Utils.WafError("Options --command-template and --valgrind are conflicting")
+ raise WafError("Options --command-template and --valgrind are conflicting")
if not env['VALGRIND']:
- raise Utils.WafError("valgrind is not installed")
+ raise WafError("valgrind is not installed")
argv = [env['VALGRIND'], "--leak-check=full", "--show-reachable=yes", "--error-exitcode=1"] + argv
proc = subprocess.Popen(argv, env=proc_env, cwd=cwd, stderr=subprocess.PIPE)
error = False
@@ -139,7 +138,7 @@
try:
retval = subprocess.Popen(argv, env=proc_env, cwd=cwd).wait()
except WindowsError, ex:
- raise Utils.WafError("Command %s raised exception %s" % (argv, ex))
+ raise WafError("Command %s raised exception %s" % (argv, ex))
if retval:
signame = None
if retval < 0: # signal?
@@ -150,11 +149,11 @@
signame = name
break
if signame:
- raise Utils.WafError("Command %s terminated with signal %s."
+ raise WafError("Command %s terminated with signal %s."
" Run it under a debugger to get more information "
"(./waf --run <program> --command-template=\"gdb --args %%s <args>\")." % (argv, signame))
else:
- raise Utils.WafError("Command %s exited with code %i" % (argv, retval))
+ raise WafError("Command %s exited with code %i" % (argv, retval))
return retval
def get_run_program(program_string, command_template=None):
@@ -173,15 +172,15 @@
try:
program_obj = find_program(program_name, env)
except ValueError, ex:
- raise Utils.WafError(str(ex))
+ raise WafError(str(ex))
- program_node = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj))
+ program_node = program_obj.path.find_or_declare(program_obj.target)
#try:
# program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
#except AttributeError:
# raise Utils.WafError("%s does not appear to be a program" % (program_name,))
- execvec = [program_node.abspath(env)] + argv[1:]
+ execvec = [program_node.abspath()] + argv[1:]
else:
@@ -189,9 +188,9 @@
try:
program_obj = find_program(program_name, env)
except ValueError, ex:
- raise Utils.WafError(str(ex))
+ raise WafError(str(ex))
- program_node = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj))
+ program_node = program_obj.path.find_or_declare(program_obj.target)
#try:
# program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
#except AttributeError: