Make emu and template modules not be built if not appropriate

This commit is contained in:
Mitch Watrous
2011-05-27 14:48:14 -07:00
parent 3de354eb08
commit 24f7bc6f0c
4 changed files with 108 additions and 58 deletions

View File

@@ -20,26 +20,23 @@ def configure(conf):
conf.env.append_value('NS3_EXECUTABLE_PATH', emucreatordir)
def build(bld):
module = bld.create_ns3_module('emu', ['network'])
module.source = [
]
headers = bld.new_task_gen('ns3header')
headers.module = 'emu'
headers.source = [
]
# Don't do anything for this module if emu's not enabled.
if not bld.env['ENABLE_EMU']:
return
module.source.extend([
module = bld.create_ns3_module('emu', ['network'])
module.source = [
'model/emu-net-device.cc',
'model/emu-encode-decode.cc',
'helper/emu-helper.cc',
])
headers.source.extend([
]
headers = bld.new_task_gen('ns3header')
headers.module = 'emu'
headers.source = [
'model/emu-net-device.h',
'helper/emu-helper.h',
])
]
obj = bld.create_suid_program('emu-sock-creator')
obj.source = [

View File

@@ -108,6 +108,7 @@ def main(argv):
flowmon_helper = ns.flow_monitor.FlowMonitorHelper()
#flowmon_helper.SetMonitorAttribute("StartTime", ns.core.TimeValue(ns.core.Seconds(31)))
monitor = flowmon_helper.InstallAll()
monitor = flowmon_helper.GetMonitor()
monitor.SetAttribute("DelayBinWidth", ns.core.DoubleValue(0.001))
monitor.SetAttribute("JitterBinWidth", ns.core.DoubleValue(0.001))
monitor.SetAttribute("PacketSizeBinWidth", ns.core.DoubleValue(20))

View File

@@ -1,6 +1,7 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
import os, os.path
import sys
import shutil
import types
import warnings
@@ -20,7 +21,7 @@ try:
except NameError:
from sets import Set as set # Python 2.3 fallback
all_modules = (
all_modules = [
'core',
'network',
'config-store',
@@ -60,7 +61,7 @@ all_modules = (
'point-to-point-layout',
'csma-layout',
'template',
)
]
def set_options(opt):
opt.sub_options('core')
@@ -282,6 +283,21 @@ def build(bld):
bld.create_obj = types.MethodType(create_obj, bld)
bld.ns3_python_bindings = types.MethodType(ns3_python_bindings, bld)
# Remove the emu module from the list of all modules if it
# is there and emu is not enabled.
emu_module_name = 'emu'
if emu_module_name in all_modules:
if not bld.env['ENABLE_EMU']:
all_modules.remove(emu_module_name)
# Remove the template module from the list of all modules if this
# is a static build on Darwin because they don't work there for
# the template module. This is probably because it is empty.
template_module_name = 'template'
if template_module_name in all_modules:
if bld.env['ENABLE_STATIC_NS3'] and sys.platform == 'darwin':
all_modules.remove(template_module_name)
bld.add_subdirs(list(all_modules))
for module in all_modules:

124
wscript
View File

@@ -102,6 +102,24 @@ def dist_hook():
shutil.rmtree("doc/latex", True)
shutil.rmtree("nsc", True)
# Print the module names without prefixes, sorted, and in columns.
def print_module_names(names):
# Get the sorted list of module names without the "ns3-" prefix.
names_without_prefix =[name[len('ns3-'):] for name in names]
names_without_prefix.sort()
# Print the list of module names in 3 columns.
i = 1
for name in names_without_prefix:
print name.ljust(25),
if i == 3:
print
i = 0
i = i+1
if i != 1:
print
def set_options(opt):
# options provided by the modules
opt.tool_options('compiler_cc')
@@ -293,6 +311,36 @@ def configure(conf):
if conf.check_compilation_flag('-Wl,--soname=foo'):
env['WL_SONAME_SUPPORTED'] = True
env['ENABLE_STATIC_NS3'] = False
if Options.options.enable_static:
if env['PLATFORM'].startswith('linux') and \
env['CXX_NAME'] in ['gcc', 'icc']:
if re.match('i[3-6]86', os.uname()[4]):
conf.report_optional_feature("static", "Static build", True, '')
env['ENABLE_STATIC_NS3'] = True
elif os.uname()[4] == 'x86_64':
if env['ENABLE_PYTHON_BINDINGS'] and \
not conf.check_compilation_flag('-mcmodel=large'):
conf.report_optional_feature("static", "Static build", False,
"Can't enable static builds because " + \
"no -mcmodel=large compiler " \
"option. Try --disable-python or upgrade your " \
"compiler to at least gcc 4.3.x.")
else:
conf.report_optional_feature("static", "Static build", True, '')
env['ENABLE_STATIC_NS3'] = True
elif env['CXX_NAME'] == 'gcc' and \
(env['PLATFORM'].startswith('darwin') or \
env['PLATFORM'].startswith('cygwin')):
conf.report_optional_feature("static", "Static build", True, '')
env['ENABLE_STATIC_NS3'] = True
else:
conf.report_optional_feature("static", "Static build", False,
"Unsupported platform")
else:
conf.report_optional_feature("static", "Static build", False,
"option --enable-static not selected")
conf.sub_config('src')
# Set the list of enabled modules.
@@ -309,6 +357,29 @@ def configure(conf):
# Enable the modules from the list.
conf.env['NS3_ENABLED_MODULES'] = ['ns3-'+mod for mod in
modules_enabled]
# Remove the emu module from the list of enabled modules if it
# is there and emu is not enabled.
conf.env['NS3_ENABLED_MODULES_NOT_BUILT'] = []
emu_module_name = 'ns3-emu'
if emu_module_name in conf.env['NS3_ENABLED_MODULES']:
if not conf.env['ENABLE_EMU']:
conf.env['NS3_ENABLED_MODULES'].remove(emu_module_name)
conf.env['NS3_ENABLED_MODULES_NOT_BUILT'].append(emu_module_name)
if not conf.env['NS3_ENABLED_MODULES']:
raise Utils.WafError("Exiting because the emu module can not be built and it was the only one enabled.")
# Remove the template module from the list of enabled modules if
# this is a static build on Darwin because they don't work there
# for the template module. This is probably because it is empty.
template_module_name = 'ns3-template'
if template_module_name in conf.env['NS3_ENABLED_MODULES']:
if conf.env['ENABLE_STATIC_NS3'] and sys.platform == 'darwin':
conf.env['NS3_ENABLED_MODULES'].remove(template_module_name)
conf.env['NS3_ENABLED_MODULES_NOT_BUILT'].append(template_module_name)
if not conf.env['NS3_ENABLED_MODULES']:
raise Utils.WafError("Exiting because the template module can not be built and it was the only one enabled.")
conf.sub_config('bindings/python')
conf.sub_config('src/mpi')
@@ -380,36 +451,6 @@ def configure(conf):
conf.find_program('valgrind', var='VALGRIND')
env['ENABLE_STATIC_NS3'] = False
if Options.options.enable_static:
if env['PLATFORM'].startswith('linux') and \
env['CXX_NAME'] in ['gcc', 'icc']:
if re.match('i[3-6]86', os.uname()[4]):
conf.report_optional_feature("static", "Static build", True, '')
env['ENABLE_STATIC_NS3'] = True
elif os.uname()[4] == 'x86_64':
if env['ENABLE_PYTHON_BINDINGS'] and \
not conf.check_compilation_flag('-mcmodel=large'):
conf.report_optional_feature("static", "Static build", False,
"Can't enable static builds because " + \
"no -mcmodel=large compiler " \
"option. Try --disable-python or upgrade your " \
"compiler to at least gcc 4.3.x.")
else:
conf.report_optional_feature("static", "Static build", True, '')
env['ENABLE_STATIC_NS3'] = True
elif env['CXX_NAME'] == 'gcc' and \
(env['PLATFORM'].startswith('darwin') or \
env['PLATFORM'].startswith('cygwin')):
conf.report_optional_feature("static", "Static build", True, '')
env['ENABLE_STATIC_NS3'] = True
else:
conf.report_optional_feature("static", "Static build", False,
"Unsupported platform")
else:
conf.report_optional_feature("static", "Static build", False,
"option --enable-static not selected")
# These flags are used for the implicitly dependent modules.
if env['ENABLE_STATIC_NS3']:
if sys.platform == 'darwin':
@@ -733,26 +774,21 @@ def shutdown(ctx):
return
env = bld.env
# Don't print the list if this a clean or distribution clean.
# Don't print the lists if this a clean or distribution clean.
if ('clean' not in Options.arg_line) and ('distclean' not in Options.arg_line):
# Get the sorted list of built modules without the "ns3-" in their name.
modules_without_prefix =[mod[len('ns3-'):] for mod in env['NS3_ENABLED_MODULES']]
modules_without_prefix.sort()
# Print the list of built modules in 3 columns.
# Print the list of built modules.
print
print 'Modules built:'
i = 1
for mod in modules_without_prefix:
print mod.ljust(25),
if i == 3:
print
i = 0
i = i+1
print
print_module_names(env['NS3_ENABLED_MODULES'])
print
# Print the list of enabled modules that were not built.
if env['NS3_ENABLED_MODULES_NOT_BUILT']:
print 'Modules not built:'
print_module_names(env['NS3_ENABLED_MODULES_NOT_BUILT'])
print
# Write the build status file.
build_status_file = os.path.join (env['NS3_BUILDDIR'], env['NS3_ACTIVE_VARIANT'], 'build-status.py')
out = open(build_status_file, 'w')