src/simulator/wscript
author Craig Dowell <craigdo@ee.washington.edu>
Tue, 14 Oct 2008 22:52:41 -0700
changeset 3801 dc1f5e534e56
parent 3798 898d8a14b88f
child 3809 5e007004402e
permissions -rw-r--r--
slight reorganization and naming change for added realtime methods

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

import Params


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):
    if Params.g_options.high_precision_as_double:
        conf.define('USE_HIGH_PRECISION_DOUBLE', 1)
        conf.env['USE_HIGH_PRECISION_DOUBLE'] = 1
        highprec = 'long double'
    else:
        conf.env['USE_HIGH_PRECISION_DOUBLE'] = 0
        highprec = '128-bit integer'
    conf.check_message_custom('high precision time','implementation',highprec)

    e = conf.create_header_configurator()
    e.mandatory = False
    e.name = 'stdint.h'
    e.define = 'HAVE_STDINT_H'
    e.run()

    e = conf.create_header_configurator()
    e.mandatory = False
    e.name = 'inttypes.h'
    e.define = 'HAVE_INTTYPES_H'
    e.run()

    e = conf.create_header_configurator()
    e.mandatory = False
    e.name = 'sys/inttypes.h'
    e.define = 'HAVE_SYS_INT_TYPES_H'
    e.run()

    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):
    sim = bld.create_ns3_module('simulator', ['core'])
    sim.source = [
        'high-precision.cc',
        'time.cc',
        'event-id.cc',
        'scheduler.cc',
        'list-scheduler.cc',
        'map-scheduler.cc',
        'heap-scheduler.cc',
        'event-impl.cc',
        'simulator.cc',
        'default-simulator-impl.cc',
        'timer.cc',
        'watchdog.cc',
        'synchronizer.cc',
        ]

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

    env = bld.env_of_name('default')
    if env['USE_HIGH_PRECISION_DOUBLE']:
        sim.source.extend([
            'high-precision-double.cc',
            ])
        headers.source.extend([
            'high-precision-double.h',
            ])
    else:
        sim.source.extend([
            'high-precision-128.cc',
            'cairo-wideint.c',
            ])
        headers.source.extend([
            'high-precision-128.h',
            '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',
                ])