src/simulator/wscript
author Mitch Watrous <watrous@u.washington.edu>
Wed, 19 Jan 2011 10:51:11 -0800
changeset 6777 ba6d0ca3e28a
parent 6496 ed210e7279a7
child 6780 e1189bae98e5
permissions -rw-r--r--
Make core module not depend on simulator module

## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
import sys

import Options


def set_options(opt):
    opt.add_option('--high-precision-as-double',
                   help=('Whether to use a double floating point'
                         ' type for high precision time values'
                         ' WARNING: this option only has effect '
                         'with the configure command.'),
                   action="store_true", default=False,
                   dest='high_precision_as_double')


def configure(conf):
    a = conf.check(type_name='uint128_t', define_name='HAVE_UINT128_T')
    b = conf.check(type_name='__uint128_t', define_name='HAVE___UINT128_T')


    if Options.options.high_precision_as_double:
        conf.define('USE_HIGH_PRECISION_DOUBLE', 1)
        conf.env['USE_HIGH_PRECISION_DOUBLE'] = 1
        highprec = 'long double'
    elif a or b:
        conf.define('USE_HIGH_PRECISION_128', 1)
        conf.env['USE_HIGH_PRECISION_128'] = 1
        highprec = '128-bit integer'
    else:
        conf.define('USE_HIGH_PRECISION_CAIRO', 1)
        conf.env['USE_HIGH_PRECISION_CAIRO'] = 1
        highprec = 'cairo 128-bit integer'

    conf.check_message_custom('high precision time', 'implementation', highprec)

    conf.check(header_name='stdint.h', define_name='HAVE_STDINT_H')
    conf.check(header_name='inttypes.h', define_name='HAVE_INTTYPES_H')

    conf.check(header_name='sys/inttypes.h', define_name='HAVE_SYS_INT_TYPES_H')

    conf.write_config_header('ns3/simulator-config.h', top=True)

    if not conf.check(lib='rt', uselib='RT', define_name='HAVE_RT'):
        conf.report_optional_feature("RealTime", "Real Time Simulator",
                                     False, "librt is not available")
    else:
        conf.report_optional_feature("RealTime", "Real Time Simulator",
                                     conf.env['ENABLE_THREADING'],
                                     "threading not enabled")
        conf.env["ENABLE_REAL_TIME"] = conf.env['ENABLE_THREADING']


def build(bld):
    sim = bld.create_ns3_module('simulator', ['core'])
    sim.source = [
        'high-precision.cc',
        'time-base.cc',
        'time.cc',
        'event-id.cc',
        'scheduler.cc',
        'list-scheduler.cc',
        'map-scheduler.cc',
        'heap-scheduler.cc',
        'calendar-scheduler.cc',
        'ns2-calendar-scheduler.cc',
        'event-impl.cc',
        'simulator.cc',
        'simulator-impl.cc',
        'default-simulator-impl.cc',
        'timer.cc',
        'watchdog.cc',
        'synchronizer.cc',
        'make-event.cc',
        ]

    headers = bld.new_task_gen('ns3header')
    headers.module = 'simulator'
    headers.source = [
        'high-precision.h',
        'time-base.h',
        'nstime.h',
        'event-id.h',
        'event-impl.h',
        'simulator.h',
        'simulator-impl.h',
        'default-simulator-impl.h',
        'scheduler.h',
        'list-scheduler.h',
        'map-scheduler.h',
        'heap-scheduler.h',
        'calendar-scheduler.h',
        'ns2-calendar-scheduler.h',
        'simulation-singleton.h',
        'timer.h',
        'timer-impl.h',
        'watchdog.h',
        'synchronizer.h',
        'make-event.h',
        ]

    env = bld.env_of_name('default')
    if env['USE_HIGH_PRECISION_DOUBLE']:
        headers.source.extend(['high-precision-double.h'])
    elif env['USE_HIGH_PRECISION_128']:
        headers.source.extend(['high-precision-128.h'])
        sim.source.extend(['high-precision-128.cc'])
    elif env['USE_HIGH_PRECISION_CAIRO']:
        sim.source.extend([
            'high-precision-cairo.cc',
#            'cairo-wideint.c',
            ])
        headers.source.extend([
            'high-precision-cairo.h',
            'cairo-wideint-private.h',
            ])

    if env['ENABLE_REAL_TIME']:
        headers.source.extend([
                'realtime-simulator-impl.h',
                'wall-clock-synchronizer.h',
                ])
        sim.source.extend([
                'realtime-simulator-impl.cc',
                'wall-clock-synchronizer.cc',
                ])
        sim.uselib = 'RT'

    if env['ENABLE_THREADING']:
        sim.source.extend([
            'unix-fd-reader.cc',
            ])
        sim.uselib = sim.uselib + ' PTHREAD'
        headers.source.extend([
                'unix-fd-reader.h',
                ])