From 46932fa7b29eb04dbd8be7f1fb2a5e50ae200952 Mon Sep 17 00:00:00 2001
From: "Peter D. Barnes, Jr."
Date: Mon, 19 Sep 2016 23:06:16 -0700
Subject: [PATCH] build: (fixes #2459) Add ./waf --check-config option to
reprint the summary
Add ./waf --check-config option to reprint the summary of optional features
from the configuration
---
CHANGES.html | 2 +
RELEASE_NOTES | 1 +
doc/tutorial/source/getting-started.rst | 36 +++++++------
wscript | 71 ++++++++++++++++---------
4 files changed, 69 insertions(+), 41 deletions(-)
diff --git a/CHANGES.html b/CHANGES.html
index 032ac25dd..d14517c6f 100644
--- a/CHANGES.html
+++ b/CHANGES.html
@@ -136,6 +136,8 @@ us a note on ns-developers mailing list.
Changes to build system:
+ - A new waf build option, --check-config, was added to allow users to print the current configuration summary, as appears at the end of ./waf configure. See bug 2459 for discussion.
+ - The configure summary is now sorted, to make it easier to check the status of optional features.
Changed behavior:
This section is for behavioral changes to the models that were not due to a bug fix.
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index b40232766..5b6519a83 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -44,6 +44,7 @@ New user-visible features
models.
- (core) DES Metrics support, see the API docs for class DesMetrics.
- (aodv) The node search radius is increased progressively (as per standard).
++- (build system) New --check-config option to waf to reprint the summary of optional features which are configured.
Bugs fixed
----------
diff --git a/doc/tutorial/source/getting-started.rst b/doc/tutorial/source/getting-started.rst
index 23011b859..3ed3b146a 100644
--- a/doc/tutorial/source/getting-started.rst
+++ b/doc/tutorial/source/getting-started.rst
@@ -392,7 +392,7 @@ builds that include the examples and tests, you will need to execute the
following commands::
$ ./waf clean
- $ ./waf --build-profile=optimized --enable-examples --enable-tests configure
+ $ ./waf configure --build-profile=optimized --enable-examples --enable-tests
This runs Waf out of the local directory (which is provided as a convenience
for you). The first command to clean out the previous build is not
@@ -453,29 +453,29 @@ output that looks similar to the following::
Checking for program doxygen : /usr/local/bin/doxygen
---- Summary of optional NS-3 features:
Build profile : debug
- Build directory : build
- Python Bindings : enabled
BRITE Integration : not enabled (BRITE not enabled (see option --with-brite))
- NS-3 Click Integration : not enabled (nsclick not enabled (see option --with-nsclick))
- GtkConfigStore : enabled
- XmlIo : enabled
- Threading Primitives : enabled
- Real Time Simulator : enabled (librt is not available)
+ Build directory : build
+ Build examples : enabled
+ Build tests : enabled
Emulated Net Device : enabled ( include not detected)
- File descriptor NetDevice : enabled
- Tap FdNetDevice : not enabled (needs linux/if_tun.h)
Emulation FdNetDevice : not enabled (needs netpacket/packet.h)
- PlanetLab FdNetDevice : not enabled (PlanetLab operating system not detected (see option --force-planetlab))
- Network Simulation Cradle : not enabled (NSC not found (see option --with-nsc))
+ File descriptor NetDevice : enabled
+ GNU Scientific Library (GSL) : enabled
+ GtkConfigStore : enabled
MPI Support : enabled
+ NS-3 Click Integration : not enabled (nsclick not enabled (see option --with-nsclick))
NS-3 OpenFlow Integration : not enabled (Required boost libraries not found, missing: system, signals, filesystem)
+ Network Simulation Cradle : not enabled (NSC not found (see option --with-nsc))
+ PlanetLab FdNetDevice : not enabled (PlanetLab operating system not detected (see option --force-planetlab))
+ PyViz visualizer : enabled
+ Python Bindings : enabled
+ Real Time Simulator : enabled (librt is not available)
SQlite stats data output : enabled
Tap Bridge : not enabled ( include not detected)
- PyViz visualizer : enabled
+ Tap FdNetDevice : not enabled (needs linux/if_tun.h)
+ Threading Primitives : enabled
Use sudo to set suid bit : not enabled (option --enable-sudo not selected)
- Build tests : enabled
- Build examples : enabled
- GNU Scientific Library (GSL) : enabled
+ XmlIo : enabled
'configure' finished successfully (1.944s)
Note the last part of the above output. Some |ns3| options are not enabled by
@@ -485,13 +485,15 @@ system. If this library were not found, the corresponding |ns3| feature
would not be enabled and a message would be displayed. Note further that there is
a feature to use the program ``sudo`` to set the suid bit of certain programs.
This is not enabled by default and so this feature is reported as "not enabled."
+Finally, to reprint this summary of which optional features are enabled, use
+the ``--check-config`` option to waf.
Now go ahead and switch back to the debug build that includes the examples and tests.
::
$ ./waf clean
- $ ./waf --build-profile=debug --enable-examples --enable-tests configure
+ $ ./waf configure --build-profile=debug --enable-examples --enable-tests
The build system is now configured and you can build the debug versions of
the |ns3| programs by simply typing
diff --git a/wscript b/wscript
index 375ee6bd9..8598296c0 100644
--- a/wscript
+++ b/wscript
@@ -146,6 +146,11 @@ def options(opt):
opt.load('cflags')
opt.load('gnu_dirs')
+ opt.add_option('--check-config',
+ help=('Print the current configuration.'),
+ action="store_true", default=False,
+ dest="check_config")
+
opt.add_option('--cwd',
help=('Set the working directory for a program.'),
action="store", type="string", default=None,
@@ -308,6 +313,29 @@ def _check_nonfatal(conf, *args, **kwargs):
except conf.errors.ConfigurationError:
return None
+# Write a summary of optional features status
+def print_config(env, phase='configure'):
+ if phase == 'configure':
+ profile = get_build_profile(env)
+ else:
+ profile = get_build_profile()
+
+ print("---- Summary of optional NS-3 features:")
+ print("%-30s: %s%s%s" % ("Build profile", Logs.colors('GREEN'),
+ profile, Logs.colors('NORMAL')))
+ bld = wutils.bld
+ print("%-30s: %s%s%s" % ("Build directory", Logs.colors('GREEN'),
+ Options.options.out, Logs.colors('NORMAL')))
+
+
+ for (name, caption, was_enabled, reason_not_enabled) in sorted(env['NS3_OPTIONAL_FEATURES'], key=lambda s : s[1]):
+ if was_enabled:
+ status = 'enabled'
+ color = 'GREEN'
+ else:
+ status = 'not enabled (%s)' % reason_not_enabled
+ color = 'RED'
+ print("%-30s: %s%s%s" % (caption, Logs.colors(color), status, Logs.colors('NORMAL')))
def configure(conf):
conf.load('relocation', tooldir=['waf-tools'])
@@ -597,24 +625,8 @@ def configure(conf):
value = shlex.split(os.environ[envvar])
conf.env.append_value(confvar, value)
- # Write a summary of optional features status
- print("---- Summary of optional NS-3 features:")
- print("%-30s: %s%s%s" % ("Build profile", Logs.colors('GREEN'),
- Options.options.build_profile, Logs.colors('NORMAL')))
- bld = wutils.bld
- print("%-30s: %s%s%s" % ("Build directory", Logs.colors('GREEN'),
- Options.options.out, Logs.colors('NORMAL')))
+ print_config(env)
-
- for (name, caption, was_enabled, reason_not_enabled) in sorted(conf.env['NS3_OPTIONAL_FEATURES'], key=lambda s : s[1]):
- if was_enabled:
- status = 'enabled'
- color = 'GREEN'
- else:
- status = 'not enabled (%s)' % reason_not_enabled
- color = 'RED'
- print("%-30s: %s%s%s" % (caption, Logs.colors(color), status, Logs.colors('NORMAL')))
-
class SuidBuild_task(Task.Task):
"""task that makes a binary Suid
@@ -758,12 +770,9 @@ def _find_ns3_module(self, name):
return obj
raise KeyError(name)
-
-def build(bld):
- env = bld.env
-
- if Options.options.check_profile:
- # Parse the waf lockfile generated by latest 'configure' operation
+# Parse the waf lockfile generated by latest 'configure' operation
+def get_build_profile(env=None):
+ if env == None:
lockfile = os.environ.get('WAFLOCK', '.lock-waf_%s_build' % sys.platform)
profile = "not found"
with open(lockfile, "r") as f:
@@ -775,7 +784,21 @@ def build(bld):
optkey,optval = x.split(':')
if (optkey.lstrip() == '\'build_profile\''):
profile = str(optval.lstrip()).replace("'","")
- print("Build profile: %s" % profile)
+ else:
+ profile = Options.options.build_profile
+ return profile
+
+def build(bld):
+ env = bld.env
+
+ if Options.options.check_config:
+ print_config(env, 'build')
+ else:
+ if Options.options.check_profile:
+ profile = get_build_profile()
+ print("Build profile: %s" % profile)
+
+ if Options.options.check_profile or Options.options.check_config:
raise SystemExit(0)
return