--- a/wscript Mon Apr 01 21:56:36 2013 +0200
+++ b/wscript Mon Apr 01 22:33:46 2013 +0200
@@ -8,25 +8,20 @@
import os.path
import re
import shlex
+import subprocess
import textwrap
+from utils import read_config_file
+
+
# WAF modules
-import subprocess
-import Options
-
-import Logs
-import TaskGen
-
-import Task
-
-import Utils
-import Build
-import Configure
-import Scripting
-
+from waflib import Utils, Scripting, Configure, Build, Options, TaskGen, Context, Task, Logs, Errors
from waflib.Errors import WafError
-from utils import read_config_file
+
+# local modules
+import wutils
+
# By default, all modules will be enabled, examples will be disabled,
# and tests will be disabled.
@@ -52,9 +47,6 @@
}
cflags.default_profile = 'debug'
-# local modules
-import wutils
-
Configure.autoconfig = 0
# the following two variables are used by the target "waf dist"
@@ -214,9 +206,9 @@
dest='doxygen_no_build')
# options provided in subdirectories
- opt.sub_options('src')
- opt.sub_options('bindings/python')
- opt.sub_options('src/internet')
+ opt.recurse('src')
+ opt.recurse('bindings/python')
+ opt.recurse('src/internet')
def _check_compilation_flag(conf, flag, mode='cxx', linkflags=None):
@@ -240,7 +232,7 @@
flag_str = flag_str[:28] + "..."
conf.start_msg('Checking for compilation %s support' % (flag_str,))
- env = conf.env.copy()
+ env = conf.env.derive()
if mode == 'cc':
mode = 'c'
@@ -259,7 +251,7 @@
retval = conf.run_c_code(code='#include <stdio.h>\nint main() { return 0; }\n',
env=env, compile_filename=fname,
features=[mode, mode+'program'], execute=False)
- except Configure.ConfigurationError:
+ except Errors.ConfigurationError:
ok = False
else:
ok = (retval == 0)
@@ -286,7 +278,7 @@
return None
def configure(conf):
- conf.check_tool("relocation", ["waf-tools"])
+ conf.load('relocation', tooldir=['waf-tools'])
# attach some extra methods
conf.check_nonfatal = types.MethodType(_check_nonfatal, conf)
@@ -295,15 +287,11 @@
conf.check_optional_feature = types.MethodType(check_optional_feature, conf)
conf.env['NS3_OPTIONAL_FEATURES'] = []
- conf.check_tool('compiler_c')
- conf.check_tool('compiler_cxx')
- conf.check_tool('cflags', ['waf-tools'])
- try:
- conf.check_tool('pkgconfig', ['waf-tools'])
- except Configure.ConfigurationError:
- pass
- conf.check_tool('command', ['waf-tools'])
- conf.check_tool('gnu_dirs')
+ conf.load('compiler_c')
+ conf.load('compiler_cxx')
+ conf.load('cflags', tooldir=['waf-tools'])
+ conf.load('command', tooldir=['waf-tools'])
+ conf.load('gnu_dirs')
env = conf.env
@@ -376,9 +364,9 @@
conf.env['MODULES_NOT_BUILT'] = []
- conf.sub_config('bindings/python')
+ conf.recurse('bindings/python')
- conf.sub_config('src')
+ conf.recurse('src')
# Set the list of enabled modules.
if Options.options.enable_modules:
@@ -410,7 +398,7 @@
if not conf.env['NS3_ENABLED_MODULES']:
raise WafError('Exiting because the ' + not_built + ' module can not be built and it was the only one enabled.')
- conf.sub_config('src/mpi')
+ conf.recurse('src/mpi')
# for suid bits
try:
@@ -488,19 +476,18 @@
# These flags are used for the implicitly dependent modules.
if env['ENABLE_STATIC_NS3']:
if sys.platform == 'darwin':
- env.STATICLIB_MARKER = '-Wl,-all_load'
+ env.STLIB_MARKER = '-Wl,-all_load'
else:
- env.STATICLIB_MARKER = '-Wl,--whole-archive,-Bstatic'
+ env.STLIB_MARKER = '-Wl,--whole-archive,-Bstatic'
env.SHLIB_MARKER = '-Wl,-Bdynamic,--no-whole-archive'
- have_gsl = conf.pkg_check_modules('GSL', 'gsl', mandatory=False)
+
+ have_gsl = conf.check_cfg(package='gsl', args=['--cflags', '--libs'],
+ uselib_store='GSL', mandatory=False)
conf.env['ENABLE_GSL'] = have_gsl
-
conf.report_optional_feature("GSL", "GNU Scientific Library (GSL)",
conf.env['ENABLE_GSL'],
"GSL not found")
- if have_gsl:
- conf.env.append_value('DEFINES', "ENABLE_GSL")
# for compiling C code, copy over the CXX* flags
conf.env.append_value('CCFLAGS', conf.env['CXXFLAGS'])
@@ -543,7 +530,7 @@
print "%-30s: %s%s%s" % (caption, Logs.colors_lst[color], status, Logs.colors_lst['NORMAL'])
-class SuidBuild_task(Task.TaskBase):
+class SuidBuild_task(Task.Task):
"""task that makes a binary Suid
"""
after = 'link'
@@ -555,7 +542,7 @@
except ValueError, ex:
raise WafError(str(ex))
program_node = program_obj.path.find_or_declare(program_obj.target)
- self.filename = program_node.abspath()
+ self.filename = program_node.get_bld().abspath()
def run(self):
@@ -580,7 +567,7 @@
def create_suid_program(bld, name):
grp = bld.current_group
bld.add_group() # this to make sure no two sudo tasks run at the same time
- program = bld.new_task_gen(features=['cxx', 'cxxprogram'])
+ program = bld(features='cxx cxxprogram')
program.is_ns3_program = True
program.module_deps = list()
program.name = name
@@ -594,7 +581,7 @@
return program
def create_ns3_program(bld, name, dependencies=('core',)):
- program = bld.new_task_gen(features=['cxx', 'cxxprogram'])
+ program = bld(features='cxx cxxprogram')
program.is_ns3_program = True
program.name = name
@@ -607,7 +594,7 @@
if sys.platform == 'darwin':
program.env.STLIB_MARKER = '-Wl,-all_load'
else:
- program.env.STLIB_MARKER = '-Wl,--whole-archive,-Bstatic'
+ program.env.STLIB_MARKER = '-Wl,-Bstatic,--whole-archive'
program.env.SHLIB_MARKER = '-Wl,-Bdynamic,--no-whole-archive'
else:
if program.env.DEST_BINFMT == 'elf':
@@ -628,8 +615,7 @@
if dir.startswith('.') or dir == 'CVS':
continue
if os.path.isdir(os.path.join('examples', dir)):
- bld.add_subdirs(os.path.join('examples', dir))
-
+ bld.recurse(os.path.join('examples', dir))
def add_scratch_programs(bld):
all_modules = [mod[len("ns3-"):] for mod in bld.env['NS3_ENABLED_MODULES']]
@@ -652,7 +638,6 @@
obj.name = obj.target
obj.install_path = None
-
def _get_all_task_gen(self):
for group in self.groups:
for taskgen in group:
@@ -699,7 +684,7 @@
wutils.bld = bld
if Options.options.no_task_lines:
- import Runner
+ from waflib import Runner
def null_printout(s):
pass
Runner.printout = null_printout
@@ -717,7 +702,7 @@
_cleandocs()
# process subfolders from here
- bld.add_subdirs('src')
+ bld.recurse('src')
# If modules have been enabled, then set lists of enabled modules
# and enabled module test libraries.
@@ -784,7 +769,7 @@
# launch directory.
launch_dir = os.path.abspath(Context.launch_dir)
object_relative_path = os.path.join(
- wutils.relpath(obj.path.abspath(), launch_dir),
+ wutils.relpath(obj.path.get_bld().abspath(), launch_dir),
object_name)
bld.env.append_value('NS3_RUNNABLE_PROGRAMS', object_relative_path)
@@ -825,11 +810,11 @@
if script_runnable:
bld.env.append_value('NS3_RUNNABLE_SCRIPTS', script)
- bld.add_subdirs('bindings/python')
+ bld.recurse('bindings/python')
# Process this subfolder here after the lists of enabled modules
# and module test libraries have been set.
- bld.add_subdirs('utils')
+ bld.recurse('utils')
# Set this so that the lists will be printed at the end of this
# build command.
@@ -943,7 +928,6 @@
-from waflib import Context, Build
class CheckContext(Context.Context):
"""run the equivalent of the old ns-3 unit tests using test.py"""
cmd = 'check'
@@ -961,7 +945,7 @@
class print_introspected_doxygen_task(Task.TaskBase):
- after = 'cc cxx link'
+ after = 'cxx link'
color = 'BLUE'
def __init__(self, bld):
@@ -985,7 +969,7 @@
# --enable-modules=xxx
pass
else:
- prog = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj)).abspath(env)
+ prog = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj)).get_bld().abspath(env)
# Create a header file with the introspected information.
doxygen_out = open(os.path.join('doc', 'introspected-doxygen.h'), 'w')
@@ -1000,7 +984,7 @@
text_out.close()
class run_python_unit_tests_task(Task.TaskBase):
- after = 'cc cxx link'
+ after = 'cxx link'
color = 'BLUE'
def __init__(self, bld):
@@ -1039,7 +1023,6 @@
raise WafError(msg)
-from waflib import Context, Build
class Ns3ShellContext(Context.Context):
"""run a shell with an environment suitably modified to run locally built programs"""
cmd = 'shell'
@@ -1085,7 +1068,7 @@
raise SystemExit(1)
return
- prog = program_obj.path.find_or_declare(program_obj.target).abspath()
+ prog = program_obj.path.find_or_declare(program_obj.target).get_bld().abspath()
if not os.path.exists(prog):
Logs.error("print-introspected-doxygen has not been built yet."
@@ -1112,8 +1095,6 @@
raise SystemExit(1)
-from waflib import Context, Build
-
def _getVersion():
"""update the ns3_version.js file, when building documentation"""
@@ -1133,7 +1114,6 @@
bld.execute()
_doxygen(bld)
-from waflib import Context, Build
class Ns3SphinxContext(Context.Context):
"""build the Sphinx documentation: manual, tutorial, models"""
@@ -1154,7 +1134,6 @@
self.sphinx_build(os.path.join("doc", sphinxdir))
-from waflib import Context, Build
class Ns3DocContext(Context.Context):
"""build all the documentation: doxygen, manual, tutorial, models"""