--- a/src/internet-stack/wscript Fri Sep 05 18:42:59 2008 +0100
+++ b/src/internet-stack/wscript Fri Sep 05 19:55:21 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,38 @@
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 @@
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)