diff -r 672f2a6de8b4 src/internet-stack/wscript --- a/src/internet-stack/wscript Fri Sep 05 18:42:59 2008 +0100 +++ b/src/internet-stack/wscript Fri Sep 05 19:42:16 2008 +0100 @@ -1,9 +1,23 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- import Params +import Task import os # Mercurial repository of the network simulation cradle NETWORK_SIMULATION_CRADLE_REPO = "https://secure.wand.net.nz/mercurial/nsc" + +# directory that contains network simulation cradle source +# note, this path is relative to the project root +NSC_DIR = "nsc" + + +def set_options(opt): + opt.add_option('--nsc', + help=('Enable Network Simulation Cradle to allow the use real-world network stacks'), + action="store_true", default=False, + dest='nsc') + + def nsc_fetch(): def nsc_clone(): print "Retrieving nsc from " + NETWORK_SIMULATION_CRADLE_REPO @@ -62,6 +76,26 @@ nsc_fetch() + +class NscBuildTask(Task.TaskBase): + """task that builds nsc + """ + def __init__(self): + self.m_display = 'build-nsc' + self.prio = 1000 # build after the rest of ns-3 + super(NscBuildTask, self).__init__() + + def run(self): + # XXX: Detect gcc major version(s) available to build supported stacks + kernels = [['linux-2.6.18', 'linux2.6.18'], + ['linux-2.6.26', 'linux2.6.26']] + for dir, name in kernels: + soname = 'lib' + name + '.so' + if not os.path.exists(os.path.join("..", NSC_DIR, dir, soname)): + if os.system('cd ../%s && python scons.py %s' % (NSC_DIR, dir)) != 0: + Params.fatal("Building NSC stack failed") + + def build(bld): obj = bld.create_ns3_module('internet-stack', ['node']) obj.source = [ @@ -110,3 +144,5 @@ obj.source.append ('nsc-tcp-socket-factory-impl.cc') obj.source.append ('nsc-sysctl.cc') obj.uselib = 'DL' + + NscBuildTask() diff -r 672f2a6de8b4 wscript --- a/wscript Fri Sep 05 18:42:59 2008 +0100 +++ b/wscript Fri Sep 05 19:42:16 2008 +0100 @@ -55,8 +55,6 @@ # TRACEBALL_SUFFIX = ".tar.bz2" -# directory that contains network simulation cradle source -NSC_DIR = "nsc" def dist_hook(): import tarfile @@ -168,14 +166,11 @@ help=('For regression testing, only run/generate the indicated regression tests, ' 'specified as a comma separated list of test names'), dest='regression_tests', type="string") - opt.add_option('--nsc', - help=('Enable Network Simulation Cradle to allow the use real-world network stacks'), - action="store_true", default=False, - dest='nsc') # options provided in a script in a subdirectory named "src" opt.sub_options('src') opt.sub_options('bindings/python') + opt.sub_options('src/internet-stack') def check_compilation_flag(conf, flag): @@ -329,28 +324,6 @@ return stat >> 8 -def nsc_build(bld): - # XXX: Detect gcc major version(s) available to build supported stacks - kernels = [['linux-2.6.18', 'linux2.6.18'], - ['linux-2.6.26', 'linux2.6.26']] - for dir,name in kernels: - soname = 'lib' + name + '.so' - tmp = NSC_DIR + '/' + dir +'/' + soname - if not os.path.exists(tmp): - if os.system('cd ' + NSC_DIR + ' && python scons.py ' + dir) != 0: - Params.fatal("Building NSC stack failed") - builddir = os.path.abspath(os.path.join(bld.env()['NS3_BUILDDIR'], bld.env ().variant())) - if not os.path.exists(builddir + '/nsc'): - try: - os.symlink('../../' + NSC_DIR, builddir + '/nsc') - except: - Params.fatal("Error linkink " + builddir + '/nsc') - if not os.path.exists(builddir + '/' + soname): - try: - os.symlink('../../' + NSC_DIR + '/' + dir + '/' + soname, builddir + '/' + soname) - except: - Params.fatal("Error linking " + builddir + '/' + soname) - def build(bld): if Params.g_options.no_task_lines: import Runner @@ -440,8 +413,6 @@ bld.add_subdirs('bindings/python') - if env['NSC_ENABLED'] == 'yes': - nsc_build(bld) def get_command_template(*arguments): if Params.g_options.valgrind: