diff --git a/bindings/python/ns3modulegen.py b/bindings/python/ns3modulegen.py index e2e261b5b..1aa9c8c16 100755 --- a/bindings/python/ns3modulegen.py +++ b/bindings/python/ns3modulegen.py @@ -126,6 +126,15 @@ def main(): except KeyError: pass + if 'Threading' not in enabled_features: + for clsname in ['SystemThread', 'SystemMutex', 'SystemCondition', 'CriticalSection']: + root_module.classes.remove(root_module['ns3::%s' % clsname]) + + if 'RealTime' not in enabled_features: + for clsname in ['WallClockSynchronizer', 'RealtimeSimulatorImpl', 'RealtimeEventLock']: + root_module.classes.remove(root_module['ns3::%s' % clsname]) + root_module.enums.remove(root_module['ns3::RealtimeSimulatorImpl::SynchronizationMode']) + root_module.generate(out, '_ns3') out.close() diff --git a/src/core/wscript b/src/core/wscript index 545a42e10..39b7846e9 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -28,6 +28,15 @@ def configure(conf): e.uselib = 'RT' e.run() + e = conf.create_header_configurator() + e.mandatory = False + e.name = 'pthread.h' + e.define = 'HAVE_PTHREAD_H' + conf.env['ENABLE_THREADING'] = e.run() + conf.report_optional_feature("Threading", "Threading Primitives", + conf.env['ENABLE_THREADING'], + " include not detected") + conf.write_config_header('ns3/core-config.h') def build(bld): @@ -66,24 +75,9 @@ def build(bld): ] core.uselib = 'RT' - if sys.platform == 'win32': - core.source.extend([ - 'win32-system-wall-clock-ms.cc', - ]) - else: - core.source.extend([ - 'unix-system-thread.cc', - 'unix-system-mutex.cc', - 'unix-system-condition.cc', - 'unix-system-wall-clock-ms.cc', - ]) - headers = bld.create_obj('ns3header') headers.module = 'core' headers.source = [ - 'system-mutex.h', - 'system-thread.h', - 'system-condition.h', 'system-wall-clock-ms.h', 'empty.h', 'callback.h', @@ -124,3 +118,24 @@ def build(bld): 'deprecated.h' ] + if sys.platform == 'win32': + core.source.extend([ + 'win32-system-wall-clock-ms.cc', + ]) + else: + core.source.extend([ + 'unix-system-wall-clock-ms.cc', + ]) + + if bld.env()['ENABLE_THREADING']: + core.source.extend([ + 'unix-system-thread.cc', + 'unix-system-mutex.cc', + 'unix-system-condition.cc', + ]) + headers.source.extend([ + 'system-mutex.h', + 'system-thread.h', + 'system-condition.h', + ]) + diff --git a/src/simulator/event-impl.h b/src/simulator/event-impl.h index d0b0c13ae..36092fe9d 100644 --- a/src/simulator/event-impl.h +++ b/src/simulator/event-impl.h @@ -21,7 +21,6 @@ #define EVENT_IMPL_H #include -#include "ns3/system-mutex.h" namespace ns3 { diff --git a/src/simulator/wscript b/src/simulator/wscript index a30e30bb3..90503fd2c 100644 --- a/src/simulator/wscript +++ b/src/simulator/wscript @@ -44,6 +44,9 @@ def configure(conf): conf.write_config_header('ns3/simulator-config.h') + conf.report_optional_feature("RealTime", "Real Time Simulator", + conf.env['ENABLE_THREADING'], + "threading not enabled") def build(bld): @@ -59,11 +62,9 @@ def build(bld): 'event-impl.cc', 'simulator.cc', 'default-simulator-impl.cc', - 'realtime-simulator-impl.cc', 'timer.cc', 'watchdog.cc', 'synchronizer.cc', - 'wall-clock-synchronizer.cc', ] headers = bld.create_obj('ns3header') @@ -76,7 +77,6 @@ def build(bld): 'simulator.h', 'simulator-impl.h', 'default-simulator-impl.h', - 'realtime-simulator-impl.h', 'scheduler.h', 'list-scheduler.h', 'map-scheduler.h', @@ -86,7 +86,6 @@ def build(bld): 'timer-impl.h', 'watchdog.h', 'synchronizer.h', - 'wall-clock-synchronizer.h', ] env = bld.env_of_name('default') @@ -107,3 +106,13 @@ def build(bld): 'cairo-wideint-private.h', ]) + if env['ENABLE_THREADING']: + headers.source.extend([ + 'realtime-simulator-impl.h', + 'wall-clock-synchronizer.h', + ]) + sim.source.extend([ + 'realtime-simulator-impl.cc', + 'wall-clock-synchronizer.cc', + ]) +