752 changes: 752 additions & 0 deletions contrib/wscript

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion doc/doxygen.conf
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,8 @@ INPUT = doc/modules \
doc/introspected-doxygen.h \
examples \
utils \
src
src \
contrib

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
21 changes: 21 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#
interesting_config_items = [
"NS3_ENABLED_MODULES",
"NS3_ENABLED_CONTRIBUTED_MODULES",
"NS3_MODULE_PATH",
"NSC_ENABLED",
"ENABLE_REAL_TIME",
Expand Down Expand Up @@ -1153,6 +1154,26 @@ def run_tests():
example_tests,
example_names_original,
python_tests)

for module in NS3_ENABLED_CONTRIBUTED_MODULES:
# Remove the "ns3-" from the module name.
module = module[len("ns3-"):]

# Set the directories and paths for this example.
module_directory = os.path.join("contrib", module)
example_directory = os.path.join(module_directory, "examples")
examples_to_run_path = os.path.join(module_directory, "test", "examples-to-run.py")
cpp_executable_dir = os.path.join(NS3_BUILDDIR, example_directory)
python_script_dir = os.path.join(example_directory)

# Parse this module's file.
parse_examples_to_run_file(
examples_to_run_path,
cpp_executable_dir,
python_script_dir,
example_tests,
example_names_original,
python_tests)

#
# If lots of logging is enabled, we can crash Python when it tries to
Expand Down
81 changes: 60 additions & 21 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def options(opt):
opt.recurse('src')
opt.recurse('bindings/python')
opt.recurse('src/internet')

opt.recurse('contrib')

def _check_compilation_flag(conf, flag, mode='cxx', linkflags=None):
"""
Expand Down Expand Up @@ -457,21 +457,46 @@ def configure(conf):
conf.recurse('bindings/python')

conf.recurse('src')
conf.recurse('contrib')

# Set the list of enabled modules.
if Options.options.enable_modules:
# Use the modules explicitly enabled.
conf.env['NS3_ENABLED_MODULES'] = ['ns3-'+mod for mod in
Options.options.enable_modules.split(',')]
_enabled_mods = []
_enabled_contrib_mods = []
for mod in Options.options.enable_modules.split(','):
if mod in conf.env['NS3_MODULES'] and mod.startswith('ns3-'):
_enabled_mods.append(mod)
elif 'ns3-' + mod in conf.env['NS3_MODULES']:
_enabled_mods.append('ns3-' + mod)
elif mod in conf.env['NS3_CONTRIBUTED_MODULES'] and mod.startswith('ns3-'):
_enabled_contrib_mods.append(mod)
elif 'ns3-' + mod in conf.env['NS3_CONTRIBUTED_MODULES']:
_enabled_contrib_mods.append('ns3-' + mod)
conf.env['NS3_ENABLED_MODULES'] = _enabled_mods
conf.env['NS3_ENABLED_CONTRIBUTED_MODULES'] = _enabled_contrib_mods

else:
# Use the enabled modules list from the ns3 configuration file.
if modules_enabled[0] == 'all_modules':
# Enable all modules if requested.
conf.env['NS3_ENABLED_MODULES'] = conf.env['NS3_MODULES']
conf.env['NS3_ENABLED_CONTRIBUTED_MODULES'] = conf.env['NS3_CONTRIBUTED_MODULES']
else:
# Enable the modules from the list.
conf.env['NS3_ENABLED_MODULES'] = ['ns3-'+mod for mod in
modules_enabled]
_enabled_mods = []
_enabled_contrib_mods = []
for mod in modules_enabled:
if mod in conf.env['NS3_MODULES'] and mod.startswith('ns3-'):
_enabled_mods.append(mod)
elif 'ns3-' + mod in conf.env['NS3_MODULES']:
_enabled_mods.append('ns3-' + mod)
elif mod in conf.env['NS3_CONTRIBUTED_MODULES'] and mod.startswith('ns3-'):
_enabled_contrib_mods.append(mod)
elif 'ns3-' + mod in conf.env['NS3_CONTRIBUTED_MODULES']:
_enabled_contrib_mods.append('ns3-' + mod)
conf.env['NS3_ENABLED_MODULES'] = _enabled_mods
conf.env['NS3_ENABLED_CONTRIBUTED_MODULES'] = _enabled_contrib_mods

# Add the template module to the list of enabled modules that
# should not be built if this is a static build on Darwin. They
Expand All @@ -487,6 +512,8 @@ def configure(conf):
conf.env['NS3_ENABLED_MODULES'].remove(not_built_name)
if not conf.env['NS3_ENABLED_MODULES']:
raise WafError('Exiting because the ' + not_built + ' module can not be built and it was the only one enabled.')
elif not_built_name in conf.env['NS3_ENABLED_CONTRIBUTED_MODULES']:
conf.env['NS3_ENABLED_CONTRIBUTED_MODULES'].remove(not_built_name)

conf.recurse('src/mpi')

Expand Down Expand Up @@ -719,7 +746,8 @@ def add_examples_programs(bld):
return

def add_scratch_programs(bld):
all_modules = [mod[len("ns3-"):] for mod in bld.env['NS3_ENABLED_MODULES']]
all_modules = [mod[len("ns3-"):] for mod in bld.env['NS3_ENABLED_MODULES'] + bld.env['NS3_ENABLED_CONTRIBUTED_MODULES']]

try:
for filename in os.listdir("scratch"):
if filename.startswith('.') or filename == 'CVS':
Expand Down Expand Up @@ -835,58 +863,65 @@ def build(bld):

# process subfolders from here
bld.recurse('src')
bld.recurse('contrib')

# If modules have been enabled, then set lists of enabled modules
# and enabled module test libraries.
if env['NS3_ENABLED_MODULES']:
if env['NS3_ENABLED_MODULES'] or env['NS3_ENABLED_CONTRIBUTED_MODULES']:

modules = env['NS3_ENABLED_MODULES']
contribModules = env['NS3_ENABLED_CONTRIBUTED_MODULES']

# Find out about additional modules that need to be enabled
# due to dependency constraints.
changed = True
while changed:
changed = False
for module in modules:
for module in modules + contribModules:
module_obj = bld.get_tgen_by_name(module)
if module_obj is None:
raise ValueError("module %s not found" % module)
# Each enabled module has its own library.
for dep in module_obj.use:
if not dep.startswith('ns3-'):
continue
if dep not in modules:
modules.append(dep)
if dep not in modules and dep not in contribModules:
if dep in env['NS3_MODULES']: modules.append(dep)
elif dep in env['NS3_CONTRIBUTED_MODULES']: contribModules.append(dep)
changed = True

env['NS3_ENABLED_MODULES'] = modules

env['NS3_ENABLED_CONTRIBUTED_MODULES'] = contribModules

# If tests are being built, then set the list of the enabled
# module test libraries.
if env['ENABLE_TESTS']:
for (mod, testlib) in bld.env['NS3_MODULES_WITH_TEST_LIBRARIES']:
if mod in bld.env['NS3_ENABLED_MODULES']:
if mod in bld.env['NS3_ENABLED_MODULES'] or mod in bld.env['NS3_ENABLED_CONTRIBUTED_MODULES']:
bld.env.append_value('NS3_ENABLED_MODULE_TEST_LIBRARIES', testlib)

add_examples_programs(bld)
add_scratch_programs(bld)

if env['NS3_ENABLED_MODULES']:
if env['NS3_ENABLED_MODULES'] or env['NS3_ENABLED_CONTRIBUTED_MODULES']:
modules = env['NS3_ENABLED_MODULES']
contribModules = env['NS3_ENABLED_CONTRIBUTED_MODULES']

# Exclude the programs other misc task gens that depend on disabled modules
for obj in list(bld.all_task_gen):

# check for ns3moduleheader_taskgen
if 'ns3moduleheader' in getattr(obj, "features", []):
if ("ns3-%s" % obj.module) not in modules:
if ("ns3-%s" % obj.module) not in modules and ("ns3-%s" % obj.module) not in contribModules:
obj.mode = 'remove' # tell it to remove headers instead of installing

# check for programs
if hasattr(obj, 'ns3_module_dependencies'):
# this is an NS-3 program (bld.create_ns3_program)
program_built = True
for dep in obj.ns3_module_dependencies:
if dep not in modules: # prog. depends on a module that isn't enabled?
if dep not in modules and dep not in contribModules: # prog. depends on a module that isn't enabled?
bld.exclude_taskgen(obj)
program_built = False
break
Expand All @@ -907,38 +942,42 @@ def build(bld):
bld.env.append_value('NS3_RUNNABLE_PROGRAMS', object_relative_path)

# disable the modules themselves
if hasattr(obj, "is_ns3_module") and obj.name not in modules:
if hasattr(obj, "is_ns3_module") and obj.name not in modules and obj.name not in contribModules:
bld.exclude_taskgen(obj) # kill the module

# disable the module test libraries
if hasattr(obj, "is_ns3_module_test_library"):
if not env['ENABLE_TESTS'] or (obj.module_name not in modules):
if not env['ENABLE_TESTS'] or ((obj.module_name not in modules) and (obj.module_name not in contribModules)) :
bld.exclude_taskgen(obj) # kill the module test library

# disable the ns3header_taskgen
if 'ns3header' in getattr(obj, "features", []):
if ("ns3-%s" % obj.module) not in modules:
if ("ns3-%s" % obj.module) not in modules and ("ns3-%s" % obj.module) not in contribModules:
obj.mode = 'remove' # tell it to remove headers instead of installing

# disable the ns3privateheader_taskgen
if 'ns3privateheader' in getattr(obj, "features", []):
if ("ns3-%s" % obj.module) not in modules:
if ("ns3-%s" % obj.module) not in modules and ("ns3-%s" % obj.module) not in contribModules:

obj.mode = 'remove' # tell it to remove headers instead of installing

# disable pcfile taskgens for disabled modules
if 'ns3pcfile' in getattr(obj, "features", []):
if obj.module not in bld.env.NS3_ENABLED_MODULES:
if obj.module not in bld.env.NS3_ENABLED_MODULES and obj.module not in bld.env.NS3_ENABLED_CONTRIBUTED_MODULES:
bld.exclude_taskgen(obj)


if env['NS3_ENABLED_MODULES']:
env['NS3_ENABLED_MODULES'] = list(modules)

if env['NS3_ENABLED_CONTRIBUTED_MODULES']:
env['NS3_ENABLED_CONTRIBUTED_MODULES'] = list(contribModules)

# Determine which scripts will be runnable.
for (script, dependencies) in bld.env['NS3_SCRIPT_DEPENDENCIES']:
script_runnable = True
for dep in dependencies:
if dep not in modules:
if dep not in modules and dep not in contribModules:
script_runnable = False
break

Expand Down Expand Up @@ -1018,7 +1057,7 @@ def shutdown(ctx):
print()
print('Modules built:')
names_without_prefix = []
for name in env['NS3_ENABLED_MODULES']:
for name in env['NS3_ENABLED_MODULES'] + env['NS3_ENABLED_CONTRIBUTED_MODULES']:
name1 = name[len('ns3-'):]
if name not in env.MODULAR_BINDINGS_MODULES:
name1 += " (no Python)"
Expand Down