merge with HEAD

This commit is contained in:
Mathieu Lacage
2011-04-15 20:50:42 +02:00
48 changed files with 358 additions and 179 deletions

View File

@@ -48,17 +48,17 @@ us a note on ns-developers mailing list. </p>
<h2>Changes to build system:</h2>
<ul>
<li><b>Tests are no longer built by default in ns-3</b>
<li><b>Examples and tests are no longer built by default in ns-3</b>
<p>
You can now make tests be built in ns-3 in two ways.
You can now make examples and tests be built in ns-3 in two ways.
<ol>
<li> Using build.py when ns-3 is built for the first time:
<pre>
./build.py --enable-tests
./build.py --enable-examples --enable-tests
</pre>
<li> Using waf once ns-3 has been built:
<pre>
./waf configure --enable-tests
./waf configure --enable-examples --enable-tests
</pre>
</ol>
</p></li>

View File

@@ -36,8 +36,8 @@ The resulting binaries are placed in build/<debuglevel>/srcpath.
Other waf usages include:
1. ./waf configure --enable-tests
Turn on unit tests.
1. ./waf configure --enable-examples --enable-tests
Turn on examples and tests.
2. ./waf --doxygen
Run doxygen to generate documentation

View File

@@ -637,7 +637,7 @@ EXCLUDE_SYMBOLS =
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH = samples
EXAMPLE_PATH =
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp

View File

@@ -278,7 +278,7 @@ Default values and command-line arguments
+++++++++++++++++++++++++++++++++++++++++
Let's look at how a user script might access these values.
This is based on the script found at ``samples/main-attribute-value.cc``,
This is based on the script found at ``src/core/examples/main-attribute-value.cc``,
with some details stripped out.::
//
@@ -768,7 +768,7 @@ Ubuntu installation command is:::
sudo apt-get install libgtk2.0-0 libgtk2.0-dev
To check whether it is configured or not, check the output of the
./waf configure --enable-tests step:::
./waf configure --enable-examples --enable-tests step:::
---- Summary of optional NS-3 features:
Threading Primitives : enabled
@@ -776,7 +776,7 @@ To check whether it is configured or not, check the output of the
GtkConfigStore : not enabled (library 'gtk+-2.0 >= 2.12' not found)
In the above example, it was not enabled, so it cannot be used until a suitable
version is installed and ./waf configure --enable-tests; ./waf is rerun.
version is installed and ./waf configure --enable-examples --enable-tests; ./waf is rerun.
Usage is almost the same as the non-GTK-based version, but there
are no ConfigStore attributes involved:::

View File

@@ -73,7 +73,7 @@ The --enable-wifi flag may be skipped if you don't intend on using Click with Wi
Once Click has been built successfully, change into the ns-3 directory and
configure ns-3 with Click Integration support::
$: ./waf configure --enable-tests --with-nsclick=/path/to/click/source
$: ./waf configure --enable-examples --enable-tests --with-nsclick=/path/to/click/source
If it says 'enabled' beside 'NS-3 Click Integration Support', then you're good to go.

View File

@@ -118,7 +118,7 @@ If you already built |ns3| without MPI enabled, you must re-build:::
Configure |ns3| with the --enable-mpi option:::
./waf -d debug configure --enable-tests --enable-mpi
./waf -d debug configure --enable-examples --enable-tests --enable-mpi
Ensure that MPI is enabled by checking the optional features shown from the
output of configure.

View File

@@ -143,7 +143,7 @@ the library. From the "openflow" directory, run:::
link to an ns-3 build with this OpenFlow switch module, run from the ns-3-dev
(or whatever you have named your distribution):::
$ ./waf configure --enable-tests --with-openflow=path/to/openflow
$ ./waf configure --enable-examples --enable-tests --with-openflow=path/to/openflow
#3 Under ``---- Summary of optional NS-3 features:`` you should see:::

View File

@@ -488,7 +488,7 @@ statements at the beginning of their programs:::
Sample programs
***************
See ``samples/main-packet.cc`` and ``samples/main-packet-tag.cc``.
See ``src/network/examples/main-packet-header.cc`` and ``src/network/examples/main-packet-tag.cc``.
Implementation details
**********************

View File

@@ -164,7 +164,7 @@ Using the ``build.py`` script in ns-3-allinone directory, NSC will be enabled by
default unless the platform does not support it. To disable it when building
|ns3|, type:::
./waf configure --enable-tests --disable-nsc
./waf configure --enable-examples --enable-tests --disable-nsc
Building and validating
+++++++++++++++++++++++

View File

@@ -48,7 +48,7 @@ Steps in doing an ns-3 release
- cd ns-3.x
- ./test.py
- ./test.py -g
- ./waf -d optimized --enable-tests configure
- ./waf -d optimized --enable-examples --enable-tests configure
- ./waf
- ./test.py
- ./test.py -g

View File

@@ -64,11 +64,12 @@ as well.
``test.py`` is very flexible in allowing the user to specify the number
and kind of tests to run; and also the amount and kind of output to generate.
Before running ``test.py``, make sure that ns3's tests have been built by doing the following
Before running ``test.py``, make sure that ns3's examples and tests
have been built by doing the following
::
./waf configure --enable-tests
./waf configure --enable-examples --enable-tests
./waf
By default, ``test.py`` will run all available tests and report status

View File

@@ -155,10 +155,10 @@ directory structure something like the following:
::
AUTHORS doc/ README src/ waf.bat*
bindings/ examples/ RELEASE_NOTES utils/ wscript
build/ LICENSE samples/ VERSION wutils.py
CHANGES.html ns3/ scratch/ waf* wutils.pyc
AUTHORS doc/ README utils/ wscript
bindings/ examples/ RELEASE_NOTES VERSION wutils.py
build/ LICENSE scratch/ waf* wutils.pyc
CHANGES.html ns3/ src waf.bat*
Change into the ``examples/tutorial`` directory. You should see a file named
``first.cc`` located there. This is a script that will create a simple
@@ -249,10 +249,10 @@ already have done a
::
./waf -d debug --enable-tests configure
./waf -d debug --enable-examples --enable-tests configure
in order to configure the project to perform debug builds that include
tests. You will also have done a
examples and tests. You will also have done a
::
@@ -805,7 +805,6 @@ most of our *repositories* will look:
drwxr-xr-x doc files
drwxr-xr-x examples files
drwxr-xr-x ns3 files
drwxr-xr-x samples files
drwxr-xr-x scratch files
drwxr-xr-x src files
drwxr-xr-x utils files

View File

@@ -207,10 +207,10 @@ directory. You should see something like the following there:
::
AUTHORS examples/ RELEASE_NOTES utils/ wscript
bindings/ LICENSE samples/ VERSION wutils.py
CHANGES.html ns3/ scratch/ waf*
doc/ README src/ waf.bat*
AUTHORS examples/ RELEASE_NOTES VERSION wutils.py
bindings/ LICENSE scratch/ waf*
CHANGES.html ns3/ src/ waf.bat*
doc/ README utils/ wscript
You are now ready to build the |ns3| distribution.
@@ -264,12 +264,12 @@ breath and type the following:
::
./build.py --enable-tests
./build.py --enable-examples --enable-tests
Because we are working with tests in this tutorial, and because they
are not built by default in |ns3|, the argument for build.py tells it
to build them for us. In the future you can build |ns3| without tests
if you wish.
Because we are working with examples and tests in this tutorial, and
because they are not built by default in |ns3|, the arguments for
build.py tells it to build them for us. In the future you can build
|ns3| without examples and tests if you wish.
You will see lots of typical compiler output messages displayed as the build
script builds the various pieces you downloaded. Eventually you should see the
@@ -300,12 +300,12 @@ Probably the most useful configuration change you can make will be to
build the optimized version of the code. By default you have configured
your project to build the debug version. Let's tell the project to
make an optimized build. To explain to Waf that it should do optimized
builds that include the tests, you will need to execute the
builds that include the examples and tests, you will need to execute the
following command,
::
./waf -d optimized --enable-tests configure
./waf -d optimized --enable-examples --enable-tests configure
This runs Waf out of the local directory (which is provided as a convenience
for you). As the build system checks for various dependencies you should see
@@ -367,7 +367,7 @@ output that looks similar to the following,
Python Bindings : enabled
Python API Scanning Support : enabled
Use sudo to set suid bit : not enabled (option --enable-sudo not selected)
Build examples and samples : enabled
Build examples : enabled
Static build : not enabled (option --enable-static not selected)
'configure' finished successfully (2.870s)
@@ -379,11 +379,11 @@ would not be enabled and a message would be displayed. Note further that there
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."
Now go ahead and switch back to the debug build that includes the tests.
Now go ahead and switch back to the debug build that includes the examples and tests.
::
./waf -d debug --enable-tests configure
./waf -d debug --enable-examples --enable-tests configure
The build system is now configured and you can build the debug versions of
the |ns3| programs by simply typing,
@@ -396,11 +396,11 @@ Some waf commands are meaningful during the build phase and some commands are va
in the configuration phase. For example, if you wanted to use the emulation
features of |ns3|, you might want to enable setting the suid bit using
sudo as described above. This turns out to be a configuration-time command, and so
you could reconfigure using the following command that also includes the tests
you could reconfigure using the following command that also includes the examples and tests
::
./waf -d debug --enable-sudo --enable-tests configure
./waf -d debug --enable-sudo --enable-examples --enable-tests configure
If you do this, waf will have run sudo to change the socket creator programs of the
emulation code to run as root. There are many other configure- and build-time options
@@ -499,10 +499,10 @@ type the following,
::
./waf -d debug --enable-tests configure
./waf -d debug --enable-examples --enable-tests configure
to tell ``waf`` to build the debug versions of the |ns3|
programs that includes the tests. You must still build
programs that includes the examples and tests. You must still build
the actual debug version of the code by typing,
::

1
samples/waf vendored
View File

@@ -1 +0,0 @@
exec "`dirname "$0"`"/../waf "$@"

View File

@@ -1,56 +0,0 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
env = bld.env_of_name('default')
if not env['ENABLE_EXAMPLES']:
return;
obj = bld.create_ns3_program('main-attribute-value', ['core', 'node', 'devices/point-to-point'])
obj.source = 'main-attribute-value.cc'
obj = bld.create_ns3_program('main-callback', ['core'])
obj.source = 'main-callback.cc'
obj = bld.create_ns3_program('sample-simulator', ['core'])
obj.source = 'sample-simulator.cc'
obj = bld.create_ns3_program('main-ptr', ['core'] )
obj.source = 'main-ptr.cc'
obj = bld.create_ns3_program('main-random-variable', ['core', 'config-store', 'tools'])
obj.source = 'main-random-variable.cc'
obj = bld.create_ns3_program('main-packet-header', ['common', 'core'])
obj.source = 'main-packet-header.cc'
obj = bld.create_ns3_program('main-packet-tag', ['common', 'core'])
obj.source = 'main-packet-tag.cc'
if bld.env['ENABLE_THREADING'] and bld.env["ENABLE_REAL_TIME"]:
obj = bld.create_ns3_program('main-test-sync')
obj.source = 'main-test-sync.cc'
obj = bld.create_ns3_program('main-simple',
['node', 'internet', 'applications'])
obj.source = 'main-simple.cc'
obj = bld.create_ns3_program('main-grid-topology',
['core', 'mobility', 'network'])
obj.source = 'main-grid-topology.cc'
obj = bld.create_ns3_program('main-random-topology',
['core', 'mobility'])
obj.source = 'main-random-topology.cc'
obj = bld.create_ns3_program('main-random-walk',
['core', 'mobility'])
obj.source = 'main-random-walk.cc'
obj = bld.create_ns3_program('main-propagation-loss',
['core', 'mobility', 'config-store', 'tools', 'propagation'])
obj.source = 'main-propagation-loss.cc'
obj = bld.create_ns3_program('sample-random-variable',
['core'])
obj.source = 'sample-random-variable.cc'

25
src/core/examples/wscript Normal file
View File

@@ -0,0 +1,25 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
if not bld.env['ENABLE_EXAMPLES']:
return;
obj = bld.create_ns3_program('main-attribute-value', ['core', 'node', 'devices/point-to-point'])
obj.source = 'main-attribute-value.cc'
obj = bld.create_ns3_program('main-callback', ['core'])
obj.source = 'main-callback.cc'
obj = bld.create_ns3_program('sample-simulator', ['core'])
obj.source = 'sample-simulator.cc'
obj = bld.create_ns3_program('main-ptr', ['core'] )
obj.source = 'main-ptr.cc'
obj = bld.create_ns3_program('main-random-variable', ['core', 'config-store', 'tools'])
obj.source = 'main-random-variable.cc'
obj = bld.create_ns3_program('sample-random-variable',
['core'])
obj.source = 'sample-random-variable.cc'

View File

@@ -0,0 +1,19 @@
#! /usr/bin/env python
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
# A list of C++ examples to run in order to ensure that they remain
# buildable and runnable over time. Each tuple in the list contains
#
# (example_name, do_run, do_valgrind_run).
#
# See test.py for more information.
cpp_examples = [
]
# A list of Python examples to run in order to ensure that they remain
# runnable over time. Each tuple in the list contains
#
# (example_name, do_run).
#
# See test.py for more information.
python_examples = []

View File

@@ -1,5 +1,8 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
if not bld.env['ENABLE_EXAMPLES']:
return;
obj = bld.create_ns3_program('li-ion-energy-source', ['core', 'energy'])
obj.source = 'li-ion-energy-source.cc'

View File

@@ -0,0 +1,9 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
if not bld.env['ENABLE_EXAMPLES']:
return;
obj = bld.create_ns3_program('main-simple',
['node', 'internet', 'applications'])
obj.source = 'main-simple.cc'

View File

@@ -0,0 +1,19 @@
#! /usr/bin/env python
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
# A list of C++ examples to run in order to ensure that they remain
# buildable and runnable over time. Each tuple in the list contains
#
# (example_name, do_run, do_valgrind_run).
#
# See test.py for more information.
cpp_examples = [
]
# A list of Python examples to run in order to ensure that they remain
# runnable over time. Each tuple in the list contains
#
# (example_name, do_run).
#
# See test.py for more information.
python_examples = []

View File

@@ -0,0 +1,18 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
if not bld.env['ENABLE_EXAMPLES']:
return;
obj = bld.create_ns3_program('main-grid-topology',
['core', 'mobility', 'network'])
obj.source = 'main-grid-topology.cc'
obj = bld.create_ns3_program('main-random-topology',
['core', 'mobility'])
obj.source = 'main-random-topology.cc'
obj = bld.create_ns3_program('main-random-walk',
['core', 'mobility'])
obj.source = 'main-random-walk.cc'

View File

@@ -0,0 +1,19 @@
#! /usr/bin/env python
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
# A list of C++ examples to run in order to ensure that they remain
# buildable and runnable over time. Each tuple in the list contains
#
# (example_name, do_run, do_valgrind_run).
#
# See test.py for more information.
cpp_examples = [
]
# A list of Python examples to run in order to ensure that they remain
# runnable over time. Each tuple in the list contains
#
# (example_name, do_run).
#
# See test.py for more information.
python_examples = []

View File

@@ -0,0 +1,16 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
if not bld.env['ENABLE_EXAMPLES']:
return;
obj = bld.create_ns3_program('main-packet-header', ['common', 'core'])
obj.source = 'main-packet-header.cc'
obj = bld.create_ns3_program('main-packet-tag', ['common', 'core'])
obj.source = 'main-packet-tag.cc'
if bld.env['ENABLE_THREADING'] and bld.env["ENABLE_REAL_TIME"]:
obj = bld.create_ns3_program('main-test-sync')
obj.source = 'main-test-sync.cc'

View File

@@ -0,0 +1,19 @@
#! /usr/bin/env python
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
# A list of C++ examples to run in order to ensure that they remain
# buildable and runnable over time. Each tuple in the list contains
#
# (example_name, do_run, do_valgrind_run).
#
# See test.py for more information.
cpp_examples = [
]
# A list of Python examples to run in order to ensure that they remain
# runnable over time. Each tuple in the list contains
#
# (example_name, do_run).
#
# See test.py for more information.
python_examples = []

View File

@@ -324,37 +324,29 @@ RadiotapHeader::GetChannelFlags (void) const
}
void
RadiotapHeader::SetAntennaSignalPower (int8_t signal)
RadiotapHeader::SetAntennaSignalPower (double signal)
{
NS_LOG_FUNCTION (this << signal);
m_antennaSignal = signal;
if (!(m_present & RADIOTAP_DBM_ANTSIGNAL))
{
m_present |= RADIOTAP_DBM_ANTSIGNAL;
m_length += 1;
}
NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
}
void
RadiotapHeader::SetAntennaSignalPower (double signal)
{
NS_LOG_FUNCTION (this << signal);
if (signal < -128)
{
return SetAntennaSignalPower (static_cast<int8_t> (-128));
}
if (signal > 127)
{
return SetAntennaSignalPower (static_cast<int8_t> (127));
m_antennaSignal = 127;
}
SetAntennaSignalPower (static_cast<int8_t> (floor(signal + 0.5)));
}
else if (signal < -128)
{
m_antennaSignal = -128;
}
else
{
m_antennaSignal = static_cast<int8_t> (floor(signal + 0.5));
}
NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);}
uint8_t
RadiotapHeader::GetAntennaSignalPower (void) const
@@ -364,38 +356,31 @@ RadiotapHeader::GetAntennaSignalPower (void) const
}
void
RadiotapHeader::SetAntennaNoisePower (int8_t noise)
RadiotapHeader::SetAntennaNoisePower (double noise)
{
NS_LOG_FUNCTION (this << noise);
m_antennaNoise = noise;
if (!(m_present & RADIOTAP_DBM_ANTNOISE))
{
m_present |= RADIOTAP_DBM_ANTNOISE;
m_length += 1;
}
if (noise > 127.0)
{
m_antennaNoise = 127;
}
else if (noise < -128.0)
{
m_antennaNoise = -128;
}
else
{
m_antennaNoise = static_cast<int8_t> (floor (noise + 0.5));
}
NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
}
void
RadiotapHeader::SetAntennaNoisePower (double noise)
{
NS_LOG_FUNCTION (this << noise);
if (noise < -128)
{
return SetAntennaNoisePower (static_cast<int8_t> (-128));
}
if (noise > 127)
{
return SetAntennaNoisePower (static_cast<int8_t> (127));
}
SetAntennaNoisePower (static_cast<int8_t> (floor(noise + 0.5)));
}
uint8_t
RadiotapHeader::GetAntennaNoisePower (void) const
{

View File

@@ -187,15 +187,6 @@ public:
*/
uint16_t GetChannelFlags (void) const;
/**
* @brief Set the RF signal power at the antenna as a decibel difference
* from an arbitrary, fixed reference.
*
* @param signal The RF signal power at the antenna as a decibel difference
* from an arbitrary, fixed reference.
*/
void SetAntennaSignalPower (int8_t signal);
/**
* @brief Set the RF signal power at the antenna as a decibel difference
* from an arbitrary, fixed reference.
@@ -214,15 +205,6 @@ public:
*/
uint8_t GetAntennaSignalPower (void) const;
/**
* @brief Set the RF noise power at the antenna as a decibel difference
* from an arbitrary, fixed reference.
*
* @param noise The RF noise power at the antenna as a decibel difference
* from an arbitrary, fixed reference.
*/
void SetAntennaNoisePower (int8_t noise);
/**
* @brief Set the RF noise power at the antenna as a decibel difference
* from an arbitrary, fixed reference.

View File

@@ -0,0 +1,11 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
if not bld.env['ENABLE_EXAMPLES']:
return;
obj = bld.create_ns3_program('main-propagation-loss',
['core', 'mobility', 'config-store', 'tools', 'propagation'])
obj.source = 'main-propagation-loss.cc'

View File

@@ -0,0 +1,19 @@
#! /usr/bin/env python
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
# A list of C++ examples to run in order to ensure that they remain
# buildable and runnable over time. Each tuple in the list contains
#
# (example_name, do_run, do_valgrind_run).
#
# See test.py for more information.
cpp_examples = [
]
# A list of Python examples to run in order to ensure that they remain
# runnable over time. Each tuple in the list contains
#
# (example_name, do_run).
#
# See test.py for more information.
python_examples = []

View File

@@ -105,6 +105,10 @@ def create_ns3_module(bld, name, dependencies=(), test=False):
pcfile = bld.new_task_gen('ns3pcfile')
pcfile.module = module
# Initially create an empty value for this because the pcfile
# writing task assumes every module has a uselib attribute.
module.uselib = ''
module.is_ns3_module = True
module.name = 'ns3-' + name
# Add the proper path to the module's name.

View File

@@ -44,6 +44,38 @@ def get_list_from_file(file_path, list_name):
return list
def get_bool_from_file(file_path, bool_name, value_if_missing):
'''Looks for a Python boolean variable called bool_name in the
file specified by file_path and returns its value.
If the file or boolean variable aren't found, this function will
return value_if_missing.
'''
# Read in the file if it exists.
if os.path.exists(file_path):
file_in = open(file_path, "r")
# Look for the boolean variable.
bool_found = False
for line in file_in:
if bool_name in line:
# Evaluate the variable's line once it is found. Make
# the split function only split it once.
bool = eval(line.split('=', 1)[1].strip())
bool_found = True
break
# Close the file
file_in.close()
if bool_found:
return bool
else:
return value_if_missing
def read_config_file():
'''Reads the NS-3 configuration file and returns a list of enabled modules.
@@ -53,20 +85,38 @@ def read_config_file():
'''
# By default, all modules will be enabled, examples will be disabled,
# and tests will be disabled.
modules_enabled = ['all_modules']
examples_enabled = False
tests_enabled = False
# See if the ns3 configuration file exists in the current working
# directory and then look for it in the ~ directory.
config_file_exists = False
dot_ns3rc_name = '.ns3rc'
dot_ns3rc_path = dot_ns3rc_name
if not os.path.exists(dot_ns3rc_path):
dot_ns3rc_path = os.path.expanduser('~/') + dot_ns3rc_name
if not os.path.exists(dot_ns3rc_path):
# Enable all modules if the .ns3rc file can't be found.
return ['all_modules']
# Return all of the default values if the .ns3rc file can't be found.
return (config_file_exists, modules_enabled, examples_enabled, tests_enabled)
# Read in the ns3 configuration file.
config_file_exists = True
# Read in the enabled modules.
modules_enabled = get_list_from_file(dot_ns3rc_path, 'modules_enabled')
if not modules_enabled:
# Enable all modules if the modules_enabled line can't be found.
return ['all_modules']
modules_enabled = ['all_modules']
# Read in whether examples should be enabled or not.
value_if_missing = False
examples_enabled = get_bool_from_file(dot_ns3rc_path, 'examples_enabled', value_if_missing)
# Read in whether tests should be enabled or not.
value_if_missing = False
tests_enabled = get_bool_from_file(dot_ns3rc_path, 'tests_enabled', value_if_missing)
return (config_file_exists, modules_enabled, examples_enabled, tests_enabled)
return modules_enabled

View File

@@ -5,3 +5,9 @@
#
# All modules can be enabled by choosing 'all_modules'.
modules_enabled = ['all_modules']
# Set this equal to true if you want examples to be run.
examples_enabled = False
# Set this equal to true if you want tests to be run.
tests_enabled = False

64
wscript
View File

@@ -30,11 +30,15 @@ import Scripting
from utils import read_config_file
# By default, all modules will be enabled.
modules_enabled = ['all_modules']
# By default, all modules will be enabled, examples will be disabled,
# and tests will be disabled.
modules_enabled = ['all_modules']
examples_enabled = False
tests_enabled = False
# Get the list of enabled modules out of the NS-3 configuration file.
modules_enabled = read_config_file()
# Get the information out of the NS-3 configuration file.
config_file_exists = False
(config_file_exists, modules_enabled, examples_enabled, tests_enabled) = read_config_file()
sys.path.insert(0, os.path.abspath('waf-tools'))
try:
@@ -163,14 +167,16 @@ def set_options(opt):
default=False)
opt.add_option('--disable-tests',
help=('Do not build the ns-3 tests.'),
dest='enable_tests', action='store_false')
dest='disable_tests', action='store_true',
default=False)
opt.add_option('--enable-examples',
help=('Build the ns-3 examples and samples.'),
help=('Build the ns-3 examples.'),
dest='enable_examples', action='store_true',
default=True)
default=False)
opt.add_option('--disable-examples',
help=('Do not build the ns-3 examples and samples.'),
dest='enable_examples', action='store_false')
help=('Do not build the ns-3 examples.'),
dest='disable_examples', action='store_true',
default=False)
opt.add_option('--check',
help=('DEPRECATED (run ./test.py)'),
default=False, dest='check', action="store_true")
@@ -321,21 +327,45 @@ def configure(conf):
conf.report_optional_feature("ENABLE_SUDO", "Use sudo to set suid bit", env['ENABLE_SUDO'], why_not_sudo)
# Decide if tests will be built or not.
if Options.options.enable_tests:
# Tests were explicitly enabled.
env['ENABLE_TESTS'] = True
why_not_tests = "option --enable-tests selected"
else:
elif Options.options.disable_tests:
# Tests were explicitly disabled.
env['ENABLE_TESTS'] = False
why_not_tests = "defaults to disabled"
why_not_tests = "option --disable-tests selected"
else:
# Enable tests based on the ns3 configuration file.
env['ENABLE_TESTS'] = tests_enabled
if config_file_exists:
why_not_tests = "based on configuration file"
elif tests_enabled:
why_not_tests = "defaults to enabled"
else:
why_not_tests = "defaults to disabled"
conf.report_optional_feature("ENABLE_TESTS", "Build tests", env['ENABLE_TESTS'], why_not_tests)
# Decide if examples will be built or not.
if Options.options.enable_examples:
# Examples were explicitly enabled.
env['ENABLE_EXAMPLES'] = True
why_not_examples = "defaults to enabled"
else:
why_not_examples = "option --enable-examples selected"
elif Options.options.disable_examples:
# Examples were explicitly disabled.
env['ENABLE_EXAMPLES'] = False
why_not_examples = "option --disable-examples selected"
else:
# Enable examples based on the ns3 configuration file.
env['ENABLE_EXAMPLES'] = examples_enabled
if config_file_exists:
why_not_examples = "based on configuration file"
elif examples_enabled:
why_not_examples = "defaults to enabled"
else:
why_not_examples = "defaults to disabled"
env['EXAMPLE_DIRECTORIES'] = []
for dir in os.listdir('examples'):
@@ -344,7 +374,7 @@ def configure(conf):
if os.path.isdir(os.path.join('examples', dir)):
env['EXAMPLE_DIRECTORIES'].append(dir)
conf.report_optional_feature("ENABLE_EXAMPLES", "Build examples and samples", env['ENABLE_EXAMPLES'],
conf.report_optional_feature("ENABLE_EXAMPLES", "Build examples", env['ENABLE_EXAMPLES'],
why_not_examples)
conf.find_program('valgrind', var='VALGRIND')
@@ -433,6 +463,10 @@ def configure(conf):
status = 'not enabled (%s)' % reason_not_enabled
print "%-30s: %s" % (caption, status)
# Print all of the enabled modules without the "ns3-" in their name.
print
print 'Enabled modules =', str([mod[len('ns3-'):] for mod in conf.env['NS3_ENABLED_MODULES']])
print
class SuidBuildTask(Task.TaskBase):
"""task that makes a binary Suid
@@ -554,7 +588,6 @@ def build(bld):
# process subfolders from here
bld.add_subdirs('src')
bld.add_subdirs('samples')
env = bld.env
@@ -581,7 +614,6 @@ def build(bld):
changed = True
env['NS3_ENABLED_MODULES'] = modules
#print "Modules to build:", modules
# If tests are being built, then set the list of the enabled
# module test libraries.