This commit is contained in:
Gustavo J. A. M. Carneiro
2008-12-29 14:19:25 +00:00
6 changed files with 54 additions and 37 deletions

View File

@@ -19,9 +19,13 @@ NSC_DIR = "nsc"
def set_options(opt):
opt.add_option('--enable-nsc',
help=('Enable Network Simulation Cradle to allow the use real-world network stacks'),
help=('[deprecated option] Enable Network Simulation Cradle to allow the use real-world network stacks'),
action="store_true", default=False,
dest='enable_nsc')
opt.add_option('--with-nsc',
help=('Use Network Simulation Cradle, given by the indicated path,'
' to allow the use of real-world network stacks'),
default='', dest='with_nsc')
def nsc_fetch():
@@ -66,35 +70,48 @@ def configure(conf):
conf.check_tool('flex bison')
conf.check(lib='fl', mandatory=True)
if not Options.options.enable_nsc:
if not (Options.options.enable_nsc or Options.options.with_nsc):
conf.report_optional_feature("nsc", "Network Simulation Cradle", False,
"--enable-nsc configure option not given")
"--with/enable-nsc configure option not given")
return
check_nsc_buildutils()
if Options.options.enable_nsc:
Logs.warn("--enable-nsc is a deprecated option; use --with-nsc instead")
conf.env['WITH_NSC'] = 'nsc'
if Options.options.with_nsc:
if not os.path.isdir(Options.options.with_nsc):
raise Utils.WafError("--with-nsc nsc path %r does not exist" % Options.options.with_nsc)
conf.env['WITH_NSC'] = Options.options.with_nsc
arch = os.uname()[4]
ok = False
if arch == 'x86_64' or arch == 'i686' or arch == 'i586' or arch == 'i486' or arch == 'i386':
conf.env['NSC_ENABLED'] = 'yes'
conf.env.append_value('CXXDEFINES', 'NETWORK_SIMULATION_CRADLE')
conf.env['ENABLE_NSC'] = conf.check(mandatory=True, lib='dl', define_name='HAVE_DL', uselib='DL')
conf.check(mandatory=True, lib='dl', define_name='HAVE_DL', uselib='DL')
ok = True
conf.check_message('NSC supported architecture', arch, ok)
conf.report_optional_feature("nsc", "Network Simulation Cradle", ok,
"architecture %r not supported" % arch)
nsc_fetch()
if not Options.options.with_nsc:
nsc_fetch()
class NscBuildTask(Task.TaskBase):
"""task that builds nsc
"""
after = 'link' # build after the rest of ns-3
def __init__(self, builddir):
self.builddir = builddir
after = 'cc_link cxx_link' # build after the rest of ns-3
def __init__(self, builddir, nsc_dir, env):
super(NscBuildTask, self).__init__()
self.display = 'build-nsc\n'
self.builddir = builddir
self.env = env
self.nsc_dir = nsc_dir
def display(self):
return 'build-nsc\n'
def run(self):
# XXX: Detect gcc major version(s) available to build supported stacks
@@ -103,13 +120,13 @@ class NscBuildTask(Task.TaskBase):
['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:
if not os.path.exists(os.path.join("..", self.nsc_dir, dir, soname)):
if os.system('cd ../%s && python scons.py %s' % (self.nsc_dir, dir)) != 0:
raise Utils.WafError("Building NSC stack failed")
if not os.path.exists(builddir + '/' + soname):
try:
os.symlink('../../' + NSC_DIR + '/' + dir + '/' + soname, builddir + '/' + soname)
os.symlink('../../' + self.nsc_dir + '/' + dir + '/' + soname, builddir + '/' + soname)
except:
raise Utils.WafError("Error linking " + builddir + '/' + soname)
@@ -163,11 +180,11 @@ def build(bld):
'icmpv4.h',
]
if bld.env['NSC_ENABLED']:
if bld.env['WITH_NSC']:
obj.source.append ('nsc-tcp-socket-impl.cc')
obj.source.append ('nsc-tcp-l4-protocol.cc')
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)
builddir = os.path.abspath(os.path.join(bld.env['NS3_BUILDDIR'], bld.env.variant()))
NscBuildTask(builddir, bld.env['WITH_NSC'], bld.env)