From 6e375eee8e193963927348f6f4e57bbd47fa38e0 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Fri, 5 Sep 2008 16:47:15 +0100 Subject: [PATCH 1/5] New pybindgen, should fix bug #308. --- bindings/python/wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/wscript b/bindings/python/wscript index 1b1751b7c..dcd38d7e5 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -22,7 +22,7 @@ else: os.environ['PYTHONPATH'] = LOCAL_PYBINDGEN_PATH ## https://launchpad.net/pybindgen/ -REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 576) +REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 577) REQUIRED_PYGCCXML_VERSION = (0, 9, 5) From 453dd8a2945014e0704c0a97bda462583158ffca Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Fri, 5 Sep 2008 18:16:29 +0100 Subject: [PATCH 2/5] Add a summary of optional features at the end of the configuration stage. --- bindings/python/wscript | 21 ++++++++++++++++++++- src/contrib/stats/wscript | 4 ++++ src/contrib/wscript | 4 ++++ src/internet-stack/wscript | 4 ++++ wscript | 17 +++++++++++++++++ 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/bindings/python/wscript b/bindings/python/wscript index dcd38d7e5..102c966a1 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -87,11 +87,15 @@ __version__ = %r def configure(conf): conf.env['ENABLE_PYTHON_BINDINGS'] = False if Params.g_options.python_disable: + conf.report_optional_feature("python", "Python Bindings", False, + "disabled by user request") return conf.check_tool('misc') if sys.platform == 'cygwin': + conf.report_optional_feature("python", "Python Bindings", False, + "unsupported platform 'cygwin'") warning("Python is not supported in CygWin environment. Try MingW instead.") return @@ -100,7 +104,8 @@ def configure(conf): conf.check_tool('python') conf.check_python_version((2,3)) conf.check_python_headers() - except Configure.ConfigurationError: + except Configure.ConfigurationError, ex: + conf.report_optional_feature("python", "Python Bindings", False, str(ex)) return ## Check for pybindgen @@ -112,6 +117,8 @@ def configure(conf): except Configure.ConfigurationError: warning("pybindgen missing") if not fetch_pybindgen(conf): + conf.report_optional_feature("python", "Python Bindings", False, + "PyBindGen missing and could not be retrieved") return else: out = subprocess.Popen([conf.env['PYTHON'], "-c", @@ -128,15 +135,20 @@ def configure(conf): (pybindgen_version_str, '.'.join([str(x) for x in REQUIRED_PYBINDGEN_VERSION]))) if not fetch_pybindgen(conf): + conf.report_optional_feature("python", "Python Bindings", False, + "PyBindGen too old and newer version could not be retrieved") return ## If all has gone well, we finally enable the Python bindings conf.env['ENABLE_PYTHON_BINDINGS'] = True + conf.report_optional_feature("python", "Python Bindings", True, None) ## Check for pygccxml try: conf.check_python_module('pygccxml') except Configure.ConfigurationError: + conf.report_optional_feature("pygccxml", "Python API Scanning Support", False, + "Missing 'pygccxml' Python module") return out = subprocess.Popen([conf.env['PYTHON'], "-c", @@ -152,6 +164,8 @@ def configure(conf): "automatic scanning of API definitions will not be possible" % (pygccxml_version_str, '.'.join([str(x) for x in REQUIRED_PYGCCXML_VERSION]))) + conf.report_optional_feature("pygccxml", "Python API Scanning Support", False, + "pygccxml too old") return @@ -159,6 +173,8 @@ def configure(conf): gccxml = conf.find_program('gccxml', var='GCCXML') if not gccxml: warning("gccxml missing; automatic scanning of API definitions will not be possible") + conf.report_optional_feature("pygccxml", "Python API Scanning Support", False, + "gccxml missing") return gccxml_version_line = os.popen(gccxml + " --version").readline().strip() @@ -168,10 +184,13 @@ def configure(conf): conf.check_message('gccxml', 'version', True, gccxml_version) if not gccxml_version_ok: warning("gccxml too old, need version >= 0.9; automatic scanning of API definitions will not be possible") + conf.report_optional_feature("pygccxml", "Python API Scanning Support", False, + "gccxml too old") return ## If we reached conf.env['ENABLE_PYTHON_SCANNING'] = True + conf.report_optional_feature("pygccxml", "Python API Scanning Support", True, None) prio_headers = { diff --git a/src/contrib/stats/wscript b/src/contrib/stats/wscript index 286837c47..3be5543e9 100644 --- a/src/contrib/stats/wscript +++ b/src/contrib/stats/wscript @@ -7,6 +7,10 @@ def configure(conf): e.define = 'SQLITE3' e.uselib = 'SQLITE3' conf.env['SQLITE_STATS'] = e.run() + conf.report_optional_feature("SqliteDataOutput", "SQlite stats data output", + conf.env['SQLITE_STATS'], + "library 'sqlite3' not found") + def build(bld): obj = bld.create_ns3_module('stats', ['node']) diff --git a/src/contrib/wscript b/src/contrib/wscript index 1c79b5437..e49b5c064 100644 --- a/src/contrib/wscript +++ b/src/contrib/wscript @@ -6,6 +6,10 @@ def configure(conf): check.uselib = 'GTK_CONFIG_STORE' check.mandatory = False conf.env['ENABLE_GTK_CONFIG_STORE'] = check.run() + conf.report_optional_feature("GtkConfigStore", "GtkConfigStore", + conf.env['ENABLE_GTK_CONFIG_STORE'], + "library 'gtk+-2.0 >= 2.12' not found") + conf.sub_config('stats') def build(bld): diff --git a/src/internet-stack/wscript b/src/internet-stack/wscript index f932574c7..aa8a098a8 100644 --- a/src/internet-stack/wscript +++ b/src/internet-stack/wscript @@ -37,6 +37,8 @@ def configure(conf): e.run() if not Params.g_options.nsc: + conf.report_optional_feature("nsc", "Network Simulation Cradle", False, + "--nsc configure option not given") return check_nsc_buildutils() @@ -55,6 +57,8 @@ def configure(conf): e.run() 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() diff --git a/wscript b/wscript index 4e3201db1..970d0a736 100644 --- a/wscript +++ b/wscript @@ -197,8 +197,16 @@ def check_compilation_flag(conf, flag): if not ok: # if it doesn't accept, remove it again conf.env['CXXFLAGS'] = save_CXXFLAGS +def report_optional_feature(conf, name, caption, was_enabled, reason_not_enabled): + conf.env.append_value('NS3_OPTIONAL_FEATURES', (name, caption, was_enabled, reason_not_enabled)) def configure(conf): + + # attach some extra methods + conf.check_compilation_flag = types.MethodType(check_compilation_flag, conf) + conf.report_optional_feature = types.MethodType(report_optional_feature, conf) + conf.env['NS3_OPTIONAL_FEATURES'] = [] + conf.env['NS3_BUILDDIR'] = conf.m_blddir conf.check_tool('compiler_cxx') @@ -271,6 +279,15 @@ def configure(conf): ## we cannot run regression tests without diff conf.find_program('diff', var='DIFF') + # Write a summary of optional features status + print "---- Summary of optional NS-3 features:" + for (name, caption, was_enabled, reason_not_enabled) in conf.env['NS3_OPTIONAL_FEATURES']: + if was_enabled: + status = 'enabled' + else: + status = 'not enabled (%s)' % reason_not_enabled + print "%-30s: %s" % (caption, status) + def create_ns3_program(bld, name, dependencies=('simulator',)): program = bld.create_obj('cpp', 'program') From e4bd4773e84db4ad0f85baf51d2740703cfd2841 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Fri, 5 Sep 2008 18:37:00 +0100 Subject: [PATCH 3/5] We don't want mercurial -q option when fetching nsc, user feedback is important. --- src/internet-stack/wscript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internet-stack/wscript b/src/internet-stack/wscript index aa8a098a8..06137c3d2 100644 --- a/src/internet-stack/wscript +++ b/src/internet-stack/wscript @@ -9,7 +9,7 @@ def nsc_fetch(): print "Retrieving nsc from " + NETWORK_SIMULATION_CRADLE_REPO if os.system("hg version > /dev/null 2>&1") != 0: Params.fatal("Mercurial not installed, http fallback not yet implemented") - if os.system("hg -q clone " + NETWORK_SIMULATION_CRADLE_REPO) != 0: + if os.system("hg clone " + NETWORK_SIMULATION_CRADLE_REPO) != 0: Params.fatal("hg -q clone %s failed" % NETWORK_SIMULATION_CRADLE_REPO) def nsc_update(): @@ -17,7 +17,7 @@ def nsc_fetch(): Params.warning("Mercurial not installed, not updating nsc source") print "Pulling nsc updates from " + NETWORK_SIMULATION_CRADLE_REPO - if os.system("cd nsc && hg -q pull %s && hg -q update" % NETWORK_SIMULATION_CRADLE_REPO) != 0: + if os.system("cd nsc && hg pull %s && hg update" % NETWORK_SIMULATION_CRADLE_REPO) != 0: Params.warning("Updating nsc using mercurial failed") if not os.path.exists("nsc"): From f77da8c7554d628c4dfc5ebc6afc63cf6a49ccbf Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Fri, 5 Sep 2008 18:42:59 +0100 Subject: [PATCH 4/5] Exclude any possible 'nsc' folder from the dist tarball (nsc is ~= 100MB). --- wscript | 1 + 1 file changed, 1 insertion(+) diff --git a/wscript b/wscript index 970d0a736..dc466ec84 100644 --- a/wscript +++ b/wscript @@ -62,6 +62,7 @@ def dist_hook(): import tarfile shutil.rmtree("doc/html", True) shutil.rmtree("doc/latex", True) + shutil.rmtree("nsc", True) if not os.path.exists("bindings/python/pybindgen"): Params.fatal("Missing pybindgen checkout; run './waf configure --pybindgen-checkout' first.") 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 5/5] 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: