From b9a4eaca8ef5fc2e3d0535d37f23a0a3b285c54b Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Fri, 5 Sep 2008 19:55:21 +0100 Subject: [PATCH] Move all NSC related build code into src/internet-stack, to unclutter a bit the main wscript --- src/internet-stack/wscript | 49 ++++++++++++++++++++++++++++++++++++++ wscript | 31 +----------------------- 2 files changed, 50 insertions(+), 30 deletions(-) diff --git a/src/internet-stack/wscript b/src/internet-stack/wscript index 06137c3d2..8a46b7bab 100644 --- a/src/internet-stack/wscript +++ b/src/internet-stack/wscript @@ -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,38 @@ def configure(conf): nsc_fetch() + +class NscBuildTask(Task.TaskBase): + """task that builds nsc + """ + def __init__(self, builddir): + self.m_display = 'build-nsc' + self.prio = 1000 # build after the rest of ns-3 + self.builddir = builddir + 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") + builddir = self.builddir + 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): obj = bld.create_ns3_module('internet-stack', ['node']) obj.source = [ @@ -110,3 +156,6 @@ def build(bld): obj.source.append ('nsc-tcp-socket-factory-impl.cc') obj.source.append ('nsc-sysctl.cc') obj.uselib = 'DL' + + builddir = os.path.abspath(os.path.join(bld.env()['NS3_BUILDDIR'], bld.env ().variant())) + NscBuildTask(builddir) diff --git a/wscript b/wscript index dc466ec84..561b32fde 100644 --- a/wscript +++ b/wscript @@ -55,8 +55,6 @@ REGRESSION_SUFFIX = "-ref-traces" # TRACEBALL_SUFFIX = ".tar.bz2" -# directory that contains network simulation cradle source -NSC_DIR = "nsc" def dist_hook(): import tarfile @@ -168,14 +166,11 @@ def set_options(opt): 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 @@ def _exec_command_interact_win32(s): 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 @@ def build(bld): bld.add_subdirs('bindings/python') - if env['NSC_ENABLED'] == 'yes': - nsc_build(bld) def get_command_template(*arguments): if Params.g_options.valgrind: