--- a/bindings/python/wscript Thu Apr 09 15:17:28 2009 +0100
+++ b/bindings/python/wscript Mon Apr 13 23:10:37 2009 +0100
@@ -273,7 +273,7 @@
def apply(self):
## get all of the ns3 headers
- ns3_dir_node = Build.bld.path.find_dir("ns3")
+ ns3_dir_node = self.bld.path.find_dir("ns3")
all_headers_inputs = []
for filename in self.to_list(self.source):
@@ -284,7 +284,7 @@
## if self.source was empty, include all ns3 headers in enabled modules
if not all_headers_inputs:
- for ns3headers in Build.bld.all_task_gen:
+ for ns3headers in self.bld.all_task_gen:
if type(ns3headers).__name__ == 'ns3header_taskgen': # XXX: find less hackish way to compare
## skip headers not part of enabled modules
if self.env['NS3_ENABLED_MODULES']:
@@ -307,7 +307,7 @@
pass
-def get_modules_and_headers():
+def get_modules_and_headers(bld):
"""
Gets a dict of
module_name => ([module_dep1, module_dep2, ...], [module_header1, module_header2, ...])
@@ -315,13 +315,13 @@
"""
retval = {}
- for module in Build.bld.all_task_gen:
+ for module in bld.all_task_gen:
if not module.name.startswith('ns3-'):
continue
module_name = module.name[4:] # strip the ns3- prefix
## find the headers object for this module
headers = []
- for ns3headers in Build.bld.all_task_gen:
+ for ns3headers in bld.all_task_gen:
if type(ns3headers).__name__ != 'ns3header_taskgen': # XXX: find less hackish way to compare
continue
if ns3headers.module != module_name:
@@ -338,8 +338,9 @@
"""
after = 'gen_everything_h_task'
before = 'cc cxx'
- def __init__(self, curdirnode, env):
- super(python_scan_task, self).__init__()
+ def __init__(self, curdirnode, env, bld):
+ self.bld = bld
+ super(python_scan_task, self).__init__(generator=self)
self.curdirnode = curdirnode
self.env = env
@@ -356,7 +357,7 @@
os.path.join(self.curdirnode.abspath(), 'ns3modulegen_generated.py'), # output file
]
scan = subprocess.Popen(argv, stdin=subprocess.PIPE)
- scan.stdin.write(repr(get_modules_and_headers()))
+ scan.stdin.write(repr(get_modules_and_headers(self.bld)))
scan.stdin.close()
retval = scan.wait()
print "Scan finished with exit code", retval
@@ -365,7 +366,7 @@
# signal stop (we generated files into the source dir and WAF
# can't cope with it, so we have to force the user to restart
# WAF)
- Build.bld.generator.stop = 1
+ self.bld.generator.stop = 1
return 0
@@ -384,7 +385,7 @@
if Options.options.python_scan:
if not env['ENABLE_PYTHON_SCANNING']:
raise Utils.WafError("Cannot re-scan python bindings: (py)gccxml not available")
- python_scan_task(bld.path, env)
+ python_scan_task(bld.path, env, bld)
return
## Get a list of scanned modules; the set of scanned modules
@@ -412,7 +413,7 @@
'ns3modulegen.log',
]
argv = ['NS3_ENABLED_FEATURES=${FEATURES}', '${PYTHON}', '${SRC[0]}', '${TGT[0]}']
- argv.extend(get_modules_and_headers().iterkeys())
+ argv.extend(get_modules_and_headers(bld).iterkeys())
for module in scanned_modules:
source.append("ns3_module_%s.py" % module)
local = "ns3_module_%s__local.py" % module
@@ -434,12 +435,8 @@
bindgen.dep_vars = ['FEATURES']
bindgen.before = 'cxx'
bindgen.after = 'gen_everything_h_task'
+ bindgen.name = "pybindgen-command"
- ## we build python bindings if either we have the tools to
- ## generate them or if the pregenerated source file is already
- ## present in the source dir.
- if env['ENABLE_PYTHON_BINDINGS'] \
- or os.path.exists(os.path.join(bld.path.abspath(), 'ns3module.cc')):
pymod = bld.new_task_gen('cxx', 'shlib', 'pyext')
pymod.source = ['ns3module.cc', 'ns3module_helpers.cc']
pymod.includes = '.'
--- a/regression.py Thu Apr 09 15:17:28 2009 +0100
+++ b/regression.py Mon Apr 13 23:10:37 2009 +0100
@@ -6,7 +6,6 @@
import errno
# WAF modules
-import Build
import Options
import Utils
import Task
@@ -66,9 +65,11 @@
after = 'cc cxx cc_link cxx_link'
color = 'BLUE'
- def __init__(self, env, test_name, test_scripts_dir, build_traces_dir, reference_traces):
- super(regression_test_task, self).__init__()
+ def __init__(self, bld, env, test_name, test_scripts_dir, build_traces_dir, reference_traces):
+ self.bld = bld
+ self.generator = self
self.env = env
+ super(regression_test_task, self).__init__(generator=self, env=env)
self.test_name = test_name
self.test_scripts_dir = test_scripts_dir
self.build_traces_dir = build_traces_dir
@@ -77,6 +78,9 @@
def __str__(self):
return 'regression-test (%s)\n' % self.test_name
+ def runnable_status(self):
+ return Task.RUN_ME
+
def run(self):
"""Run a single test"""
sys.path.insert(0, self.test_scripts_dir)
@@ -119,7 +123,7 @@
if Options.options.regression_generate:
# clean the target dir
try:
- shutil.rmtree(trace_output_path)
+ shutil.rmtree(reference_traces_path)
except OSError, ex:
if ex.errno not in [errno.ENOENT]:
raise
@@ -206,13 +210,17 @@
after = 'regression_test_task'
color = 'BLUE'
- def __init__(self, test_tasks):
- super(regression_test_collector_task, self).__init__()
+ def __init__(self, bld, test_tasks):
+ self.bld = bld
+ super(regression_test_collector_task, self).__init__(generator=self)
self.test_tasks = test_tasks
def __str__(self):
return 'regression-test-collector\n'
+ def runnable_status(self):
+ return Task.RUN_ME
+
def run(self):
failed_tests = [test for test in self.test_tasks if test.result is not None and test.result != 0]
skipped_tests = [test for test in self.test_tasks if test.result is None]
@@ -256,5 +264,7 @@
build_traces_dir = bld.path.find_or_declare('regression/traces').abspath(bld.env)
tasks = []
for test in tests:
- tasks.append(regression_test_task(bld.env, test, test_scripts_dir, build_traces_dir, reference_traces))
- regression_test_collector_task(tasks)
+ task = regression_test_task(bld, bld.env, test, test_scripts_dir, build_traces_dir, reference_traces)
+ #bld.task_manager.add_task(task)
+ tasks.append(task)
+ regression_test_collector_task(bld, tasks)
--- a/src/wscript Thu Apr 09 15:17:28 2009 +0100
+++ b/src/wscript Mon Apr 13 23:10:37 2009 +0100
@@ -9,8 +9,7 @@
import Task
import Options
import Build
-from Utils import md5
-
+import Utils
all_modules = (
'core',
@@ -109,7 +108,7 @@
def apply(self):
if self.module is None:
raise Utils.WafError("'module' missing on ns3headers object %s" % self)
- ns3_dir_node = Build.bld.path.find_dir("ns3")
+ 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 self.to_list(self.source):
@@ -176,7 +175,7 @@
return 0
def sig_explicit_deps(self):
- m = md5()
+ m = Utils.md5()
m.update('\n'.join([node.abspath(self.env) for node in self.inputs]))
return m.digest()
@@ -185,7 +184,7 @@
return self.uid
except AttributeError:
"this is not a real hot zone, but we want to avoid surprizes here"
- m = md5()
+ m = Utils.md5()
m.update("ns-3-module-header-%s" % self.module)
self.uid = m.digest()
return self.uid
@@ -199,13 +198,12 @@
COLOR = 'BLUE'
def __init__(self, *args, **kwargs):
super(ns3moduleheader_taskgen, self).__init__(*args, **kwargs)
- self.module_name = None
def apply(self):
## get all of the ns3 headers
- ns3_dir_node = Build.bld.path.find_dir("ns3")
+ ns3_dir_node = self.bld.path.find_dir("ns3")
all_headers_inputs = []
- for ns3headers in Build.bld.all_task_gen:
+ for ns3headers in self.bld.all_task_gen:
if isinstance(ns3headers, ns3header_taskgen):
if ns3headers.module != self.module:
continue
@@ -215,8 +213,10 @@
if node is None:
fatal("missing header file %s" % (source,))
all_headers_inputs.append(node)
+ if not all_headers_inputs:
+ raise Utils.WscriptError("error finding headers for module %s" % self.module)
assert all_headers_inputs
- module_obj = Build.bld.name_to_obj("ns3-" + self.module, self.env)
+ module_obj = self.bld.name_to_obj("ns3-" + self.module, self.env)
assert module_obj is not None
all_headers_outputs = [ns3_dir_node.find_or_declare("%s-module.h" % self.module)]
task = self.create_task('gen_ns3_module_header', self.env)
Binary file waf has changed
--- a/wscript Thu Apr 09 15:17:28 2009 +0100
+++ b/wscript Mon Apr 13 23:10:37 2009 +0100
@@ -10,6 +10,7 @@
# WAF modules
import pproc as subprocess
import Options
+
import Logs
import TaskGen
import Constants
@@ -23,6 +24,7 @@
import Utils
import Build
import Configure
+import Scripting
import cflags # override the build profiles from waf
cflags.profiles = {
@@ -133,7 +135,7 @@
action="store_true", default=False,
dest='valgrind')
opt.add_option('--shell',
- help=('Run a shell with an environment suitably modified to run locally built programs'),
+ help=('DEPRECATED (run ./waf shell)'),
action="store_true", default=False,
dest='shell')
opt.add_option('--enable-sudo',
@@ -161,7 +163,7 @@
opt.sub_options('src/internet-stack')
-def check_compilation_flag(conf, flag):
+def _check_compilation_flag(conf, flag):
"""
Checks if the C++ compiler accepts a certain compilation flag or flags
flag: can be a string or a list of strings
@@ -186,7 +188,7 @@
def configure(conf):
# attach some extra methods
- conf.check_compilation_flag = types.MethodType(check_compilation_flag, 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'] = []
@@ -235,7 +237,7 @@
env.append_value('CXXDEFINES', 'RUN_SELF_TESTS')
if env['COMPILER_CXX'] == 'g++' and 'CXXFLAGS' not in os.environ:
- if check_compilation_flag(conf, '-Wno-error=deprecated-declarations'):
+ if conf.check_compilation_flag('-Wno-error=deprecated-declarations'):
env.append_value('CXXFLAGS', '-Wno-error=deprecated-declarations')
if Options.options.build_profile == 'debug':
@@ -363,6 +365,7 @@
def build(bld):
+ wutils.bld = bld
if Options.options.no_task_lines:
import Runner
def null_printout(s):
@@ -378,21 +381,6 @@
variant_env = bld.env_of_name(variant_name)
bld.all_envs['default'] = variant_env
- if Options.options.shell:
- run_shell()
- raise SystemExit(0)
-
- if Options.options.doxygen:
- doxygen()
- raise SystemExit(0)
-
- check_shell()
-
- if Options.options.doxygen:
- doxygen()
- raise SystemExit(0)
-
- print "Entering directory `%s'" % os.path.join(bld.path.abspath(), 'build')
# process subfolders from here
bld.add_subdirs('src')
bld.add_subdirs('samples utils examples')
@@ -427,14 +415,14 @@
changed = True
## remove objects that depend on modules not listed
- for obj in list(Build.bld.all_task_gen):
+ for obj in list(bld.all_task_gen):
if hasattr(obj, 'ns3_module_dependencies'):
for dep in obj.ns3_module_dependencies:
if dep not in modules:
- Build.bld.all_task_gen.remove(obj)
+ bld.all_task_gen.remove(obj)
break
if obj.name in env['NS3_MODULES'] and obj.name not in modules:
- Build.bld.all_task_gen.remove(obj)
+ bld.all_task_gen.remove(obj)
## Create a single ns3 library containing all enabled modules
lib = bld.new_task_gen('cxx', 'shlib')
@@ -468,11 +456,13 @@
regression.run_regression(bld, regression_traces)
-def shutdown():
- env = Build.bld.env
- if Options.commands['check']:
- _run_waf_check()
+def shutdown(ctx):
+ bld = wutils.bld
+ env = bld.env
+
+ #if Options.commands['check']:
+ # _run_waf_check()
if Options.options.lcov_report:
lcov_report()
@@ -485,9 +475,26 @@
wutils.run_python_program(Options.options.pyrun)
raise SystemExit(0)
-def _run_waf_check():
+ if Options.options.shell:
+ raise Utils.WafError("Run `./waf shell' now, instead of `./waf shell'")
+
+ if Options.options.doxygen:
+ doxygen()
+ raise SystemExit(0)
+
+ check_shell(bld)
+
+ if Options.options.doxygen:
+ doxygen()
+ raise SystemExit(0)
+
+
+check_context = Build.BuildContext
+def check(bld):
+ "run the NS-3 unit tests"
+ Scripting.build(bld)
## generate the trace sources list docs
- env = Build.bld.env
+ env = bld.env
proc_env = wutils.get_proc_env()
try:
program_obj = wutils.find_program('print-introspected-doxygen', env)
@@ -514,14 +521,14 @@
-def check_shell():
+def check_shell(bld):
if 'NS3_MODULE_PATH' not in os.environ:
return
- env = Build.bld.env
+ env = bld.env
correct_modpath = os.pathsep.join(env['NS3_MODULE_PATH'])
found_modpath = os.environ['NS3_MODULE_PATH']
if found_modpath != correct_modpath:
- msg = ("Detected shell (waf --shell) with incorrect configuration\n"
+ msg = ("Detected shell (./waf shell) with incorrect configuration\n"
"=========================================================\n"
"Possible reasons for this problem:\n"
" 1. You switched to another ns-3 tree from inside this shell\n"
@@ -533,13 +540,19 @@
raise Utils.WafError(msg)
-def run_shell():
+shell_context = Build.BuildContext
+def shell(ctx):
+ """run a shell with an environment suitably modified to run locally built programs"""
+
+ #make sure we build first"
+ Scripting.build(ctx)
+
if sys.platform == 'win32':
shell = os.environ.get("COMSPEC", "cmd.exe")
else:
shell = os.environ.get("SHELL", "/bin/sh")
- env = Build.bld.env
+ env = wutils.bld.env
wutils.run_argv([shell], {'NS3_MODULE_PATH': os.pathsep.join(env['NS3_MODULE_PATH'])})
def doxygen():
@@ -598,7 +611,7 @@
import Utils
import os
-def copytree(src, dst, symlinks=False, excludes=(), build_dir=None):
+def _copytree(src, dst, symlinks=False, excludes=(), build_dir=None):
"""Recursively copy a directory tree using copy2().
The destination directory must not already exist.
@@ -668,7 +681,7 @@
def DistDir(appname, version):
- "make a distribution directory with all the sources in it"
+ #"make a distribution directory with all the sources in it"
import shutil
# Our temporary folder where to put our files
@@ -683,7 +696,7 @@
build_dir = getattr(Utils.g_module, BLDDIR, None)
# Copy everything into the new folder
- copytree('.', TMPFOLDER, excludes=excludes, build_dir=build_dir)
+ _copytree('.', TMPFOLDER, excludes=excludes, build_dir=build_dir)
# TODO undocumented hook
dist_hook = getattr(Utils.g_module, 'dist_hook', None)
--- a/wutils.py Thu Apr 09 15:17:28 2009 +0100
+++ b/wutils.py Mon Apr 13 23:10:37 2009 +0100
@@ -16,6 +16,7 @@
# these are set from the main wscript file
APPNAME=None
VERSION=None
+bld=None
#
# The last part of the path name to use to find the regression traces tarball.
@@ -65,7 +66,7 @@
launch_dir = os.path.abspath(Options.cwd_launch)
top_dir = os.path.abspath(Options.launch_dir)
found_programs = []
- for obj in Build.bld.all_task_gen:
+ for obj in bld.all_task_gen:
if not getattr(obj, 'is_ns3_program', False):
continue
@@ -84,7 +85,7 @@
% (program_name, found_programs))
def get_proc_env(os_env=None):
- env = Build.bld.env
+ env = bld.env
if sys.platform == 'linux2':
pathvar = 'LD_LIBRARY_PATH'
elif sys.platform == 'darwin':
@@ -111,7 +112,7 @@
else:
proc_env[pathvar] = os.pathsep.join(list(env['NS3_MODULE_PATH']))
- pymoddir = Build.bld.path.find_dir('bindings/python').abspath(env)
+ pymoddir = bld.path.find_dir('bindings/python').abspath(env)
if 'PYTHONPATH' in proc_env:
proc_env['PYTHONPATH'] = os.pathsep.join([pymoddir] + [proc_env['PYTHONPATH']])
else:
@@ -121,7 +122,6 @@
def run_argv(argv, os_env=None, cwd=None):
proc_env = get_proc_env(os_env)
- #env = Build.bld.env
retval = subprocess.Popen(argv, env=proc_env, cwd=cwd).wait()
if retval:
raise Utils.WafError("Command %s exited with code %i" % (argv, retval))
@@ -133,7 +133,7 @@
run_program(program_string, command_template).
"""
#print "get_run_program_argv(program_string=%r, command_template=%r)" % (program_string, command_template)
- env = Build.bld.env
+ env = bld.env
if command_template in (None, '%s'):
argv = shlex.split(program_string)
@@ -187,7 +187,7 @@
def run_python_program(program_string):
- env = Build.bld.env
+ env = bld.env
execvec = shlex.split(program_string)
if (Options.options.cwd_launch):
cwd = Options.options.cwd_launch