Files
unison/src/core/wscript
Jared Dulmage 643378b816 Removed extended-attribute-helper.h
This file should be part of another merge request.
2020-09-20 14:52:02 -07:00

455 lines
16 KiB
Python

## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
import sys
import re
from waflib import Context, Configure, Options, Utils
import wutils
int64x64 = {
# implementation name: [define, env, highprec]
'default': ['INT64X64_USE_128', 'INT64X64_USE_128', '128-bit integer'],
'int128': ['INT64X64_USE_128', 'INT64X64_USE_128', '128-bit integer'],
'cairo': ['INT64X64_USE_CAIRO', 'INT64X64_USE_CAIRO', 'cairo 128-bit integer'],
'double': ['INT64X64_USE_DOUBLE', 'INT64X64_USE_DOUBLE', 'long double'],
}
default_int64x64 = 'default'
def options(opt):
assert default_int64x64 in int64x64
opt.add_option('--int64x64',
action='store',
default=default_int64x64,
help=("Force the choice of int64x64_t implementation "
"(normally only for debugging). "
"The supported implementations use int128_t, "
"cairo_int128, or long double. "
"The int128_t implementation (the preferred option) "
"requires compiler support. "
"The cairo implementation fallback provides exactly "
"the same numerical results, but possibly at lower "
"execution speed. The long double implementation "
"may not provide the same numerical results because "
"the implementation-defined numerical precision may "
"be less than the other implementations. "
"[Allowed Values: %s]"
% ", ".join([repr(p) for p in list(int64x64.keys())])),
choices=list(int64x64.keys()),
dest='int64x64_impl')
opt.add_option('--disable-pthread',
help=('Whether to enable the use of POSIX threads'),
action="store_true", default=False,
dest='disable_pthread')
opt.add_option('--check-version',
help=("Print the current build version"),
action="store_true", default=False,
dest='check_version')
def configure(conf):
conf.load('versioning', ['waf-tools'])
int64x64_impl = Options.options.int64x64_impl
if int64x64_impl == 'default' or int64x64_impl == 'int128':
code_snip_type='''
#include <stdint.h>
int main(int argc, char **argv) {
(void)argc; (void)argv;
if ((uint128_t *) 0) return 0;
if (sizeof (uint128_t)) return 0;
return 1;
}
'''
have_uint128 = conf.check_nonfatal(msg='checking for uint128_t',
define_name='HAVE_UINT128_T',
code=code_snip_type)
code_snip_type='''
#include <stdint.h>
int main(int argc, char **argv) {
(void)argc; (void)argv;
if ((__uint128_t *) 0) return 0;
if (sizeof (__uint128_t)) return 0;
return 1;
}
'''
have__uint128 = conf.check_nonfatal(msg='checking for __uint128_t',
define_name='HAVE___UINT128_T',
code=code_snip_type)
if have_uint128 or have__uint128:
int64x64_impl = 'int128'
else:
int64x64_impl = 'cairo'
def_flag, env_flag, highprec = int64x64[int64x64_impl]
# Add a tag confirming default choice
if Options.options.int64x64_impl == 'default':
highprec += ' (default)'
conf.define(def_flag, 1)
conf.env[env_flag] = 1
conf.msg('Checking high precision implementation', highprec)
conf.check_nonfatal(header_name='stdint.h', define_name='HAVE_STDINT_H')
conf.check_nonfatal(header_name='inttypes.h', define_name='HAVE_INTTYPES_H')
conf.check_nonfatal(header_name='sys/inttypes.h', define_name='HAVE_SYS_INT_TYPES_H')
conf.check_nonfatal(header_name='sys/types.h', define_name='HAVE_SYS_TYPES_H')
conf.check_nonfatal(header_name='sys/stat.h', define_name='HAVE_SYS_STAT_H')
conf.check_nonfatal(header_name='dirent.h', define_name='HAVE_DIRENT_H')
if conf.check_nonfatal(header_name='stdlib.h'):
conf.define('HAVE_STDLIB_H', 1)
conf.define('HAVE_GETENV', 1)
conf.check_nonfatal(header_name='signal.h', define_name='HAVE_SIGNAL_H')
# Check for POSIX threads
test_env = conf.env.derive()
if Utils.unversioned_sys_platform() != 'darwin' and Utils.unversioned_sys_platform() != 'cygwin':
test_env.append_value('LINKFLAGS', '-pthread')
test_env.append_value('CXXFLAGS', '-pthread')
test_env.append_value('CCFLAGS', '-pthread')
fragment = r"""
#include <pthread.h>
int main ()
{
pthread_mutex_t m;
pthread_mutex_init (&m, NULL);
return 0;
}
"""
if Options.options.disable_pthread:
conf.report_optional_feature("Threading", "Threading Primitives",
False,
"Disabled by user request (--disable-pthread)")
have_pthread = False
else:
have_pthread = conf.check_nonfatal(header_name='pthread.h', define_name='HAVE_PTHREAD_H',
env=test_env, fragment=fragment,
errmsg='Could not find pthread support (build/config.log for details)')
if have_pthread:
# darwin accepts -pthread but prints a warning saying it is ignored
if Utils.unversioned_sys_platform() != 'darwin' and Utils.unversioned_sys_platform() != 'cygwin':
conf.env['CXXFLAGS_PTHREAD'] = '-pthread'
conf.env['CCFLAGS_PTHREAD'] = '-pthread'
conf.env['LINKFLAGS_PTHREAD'] = '-pthread'
conf.env['ENABLE_THREADING'] = have_pthread
conf.report_optional_feature("Threading", "Threading Primitives",
conf.env['ENABLE_THREADING'],
"<pthread.h> include not detected")
conf.check_nonfatal(header_name='stdint.h', define_name='HAVE_STDINT_H')
conf.check_nonfatal(header_name='inttypes.h', define_name='HAVE_INTTYPES_H')
conf.check_nonfatal(header_name='sys/inttypes.h', define_name='HAVE_SYS_INT_TYPES_H')
if not conf.check_nonfatal(lib='rt', uselib='RT, PTHREAD', 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']
conf.write_config_header('ns3/core-config.h', top=True)
def build(bld):
bld.install_files('${INCLUDEDIR}/%s%s/ns3' % (wutils.APPNAME, wutils.VERSION), '../../ns3/core-config.h')
version_template = bld.path.find_node('model/version-defines.h.in')
version_header = bld.bldnode.make_node('version-defines.h')
vers_tg = bld(features='version-defines',
source=version_template,
target=version_header)
#silence errors about no mapping for version-defines.h.in
vers_tg.mappings['.h'] = lambda *a, **k: None
vers_tg.mappings['.h.in'] = lambda *a, **k: None
if Options.options.check_version:
print_version(bld, vers_tg)
raise SystemExit(0)
return
core = bld.create_ns3_module('core')
core.source = [
'model/time.cc',
'model/event-id.cc',
'model/scheduler.cc',
'model/list-scheduler.cc',
'model/map-scheduler.cc',
'model/heap-scheduler.cc',
'model/calendar-scheduler.cc',
'model/priority-queue-scheduler.cc',
'model/event-impl.cc',
'model/simulator.cc',
'model/simulator-impl.cc',
'model/default-simulator-impl.cc',
'model/timer.cc',
'model/watchdog.cc',
'model/synchronizer.cc',
'model/make-event.cc',
'model/log.cc',
'model/breakpoint.cc',
'model/type-id.cc',
'model/attribute-construction-list.cc',
'model/object-base.cc',
'model/ref-count-base.cc',
'model/object.cc',
'model/test.cc',
'model/random-variable-stream.cc',
'model/rng-seed-manager.cc',
'model/rng-stream.cc',
'model/command-line.cc',
'model/type-name.cc',
'model/attribute.cc',
'model/boolean.cc',
'model/integer.cc',
'model/uinteger.cc',
'model/enum.cc',
'model/double.cc',
'model/int64x64.cc',
'model/string.cc',
'model/pointer.cc',
'model/object-ptr-container.cc',
'model/object-factory.cc',
'model/global-value.cc',
'model/trace-source-accessor.cc',
'model/config.cc',
'model/callback.cc',
'model/names.cc',
'model/vector.cc',
'model/fatal-impl.cc',
'model/system-path.cc',
'helper/random-variable-stream-helper.cc',
'helper/event-garbage-collector.cc',
'model/hash-function.cc',
'model/hash-murmur3.cc',
'model/hash-fnv.cc',
'model/hash.cc',
'model/des-metrics.cc',
'model/ascii-file.cc',
'model/attribute-container.cc',
'model/pair.cc',
'model/node-printer.cc',
'model/time-printer.cc',
'model/show-progress.cc',
'model/system-wall-clock-timestamp.cc',
'model/version.cc',
'model/attribute-container.cc',
'model/pair.cc',
]
if (bld.env['ENABLE_EXAMPLES']):
core.source.append('model/example-as-test.cc')
core_test = bld.create_ns3_module_test_library('core')
core_test.source = [
'test/attribute-test-suite.cc',
'test/build-profile-test-suite.cc',
'test/callback-test-suite.cc',
'test/command-line-test-suite.cc',
'test/config-test-suite.cc',
'test/global-value-test-suite.cc',
'test/int64x64-test-suite.cc',
'test/names-test-suite.cc',
'test/object-test-suite.cc',
'test/ptr-test-suite.cc',
'test/event-garbage-collector-test-suite.cc',
'test/many-uniform-random-variables-one-get-value-call-test-suite.cc',
'test/one-uniform-random-variable-many-get-value-calls-test-suite.cc',
'test/sample-test-suite.cc',
'test/simulator-test-suite.cc',
'test/time-test-suite.cc',
'test/timer-test-suite.cc',
'test/traced-callback-test-suite.cc',
'test/type-traits-test-suite.cc',
'test/watchdog-test-suite.cc',
'test/hash-test-suite.cc',
'test/type-id-test-suite.cc',
'test/pair-value-test-suite.cc',
'test/attribute-container-test-suite.cc',
]
headers = bld(features='ns3header')
headers.module = 'core'
headers.source = [
'model/nstime.h',
'model/event-id.h',
'model/event-impl.h',
'model/simulator.h',
'model/simulator-impl.h',
'model/default-simulator-impl.h',
'model/scheduler.h',
'model/list-scheduler.h',
'model/map-scheduler.h',
'model/heap-scheduler.h',
'model/calendar-scheduler.h',
'model/simulation-singleton.h',
'model/singleton.h',
'model/timer.h',
'model/timer-impl.h',
'model/watchdog.h',
'model/synchronizer.h',
'model/make-event.h',
'model/system-wall-clock-ms.h',
'model/empty.h',
'model/callback.h',
'model/object-base.h',
'model/ref-count-base.h',
'model/simple-ref-count.h',
'model/type-id.h',
'model/attribute-construction-list.h',
'model/ptr.h',
'model/object.h',
'model/log.h',
'model/log-macros-enabled.h',
'model/log-macros-disabled.h',
'model/assert.h',
'model/breakpoint.h',
'model/fatal-error.h',
'model/test.h',
'model/random-variable-stream.h',
'model/rng-seed-manager.h',
'model/rng-stream.h',
'model/command-line.h',
'model/type-name.h',
'model/type-traits.h',
'model/int-to-type.h',
'model/attribute.h',
'model/attribute-accessor-helper.h',
'model/boolean.h',
'model/int64x64.h',
'model/int64x64-double.h',
'model/integer.h',
'model/uinteger.h',
'model/double.h',
'model/enum.h',
'model/string.h',
'model/pointer.h',
'model/object-factory.h',
'model/attribute-helper.h',
'model/global-value.h',
'model/traced-callback.h',
'model/traced-value.h',
'model/trace-source-accessor.h',
'model/config.h',
'model/object-ptr-container.h',
'model/object-vector.h',
'model/object-map.h',
'model/deprecated.h',
'model/abort.h',
'model/names.h',
'model/vector.h',
'model/default-deleter.h',
'model/fatal-impl.h',
'model/system-path.h',
'model/unused.h',
'model/math.h',
'helper/event-garbage-collector.h',
'helper/random-variable-stream-helper.h',
'model/hash-function.h',
'model/hash-murmur3.h',
'model/hash-fnv.h',
'model/hash.h',
'model/valgrind.h',
'model/non-copyable.h',
'model/build-profile.h',
'model/des-metrics.h',
'model/ascii-file.h',
'model/ascii-test.h',
'model/node-printer.h',
'model/time-printer.h',
'model/show-progress.h',
'model/version.h',
'model/pair.h',
'model/attribute-container-accessor-helper.h',
'model/attribute-container.h',
'model/extended-attribute-helper.h',
'model/node-printer.h',
'model/time-printer.h',
'model/show-progress.h',
]
if (bld.env['ENABLE_EXAMPLES']):
headers.source.append('model/example-as-test.h')
if sys.platform == 'win32':
core.source.extend([
'model/win32-system-wall-clock-ms.cc',
])
else:
core.source.extend([
'model/unix-system-wall-clock-ms.cc',
])
env = bld.env
if env['INT64X64_USE_DOUBLE']:
headers.source.extend(['model/int64x64-double.h'])
elif env['INT64X64_USE_128']:
headers.source.extend(['model/int64x64-128.h'])
core.source.extend(['model/int64x64-128.cc'])
elif env['INT64X64_USE_CAIRO']:
core.source.extend([
'model/int64x64-cairo.cc',
])
headers.source.extend([
'model/int64x64-cairo.h',
'model/cairo-wideint-private.h',
])
if env['ENABLE_REAL_TIME']:
headers.source.extend([
'model/realtime-simulator-impl.h',
'model/wall-clock-synchronizer.h',
])
core.source.extend([
'model/realtime-simulator-impl.cc',
'model/wall-clock-synchronizer.cc',
])
core.use.append('RT')
core_test.use.append('RT')
if env['ENABLE_THREADING']:
core.source.extend([
'model/system-thread.cc',
'model/unix-fd-reader.cc',
'model/unix-system-mutex.cc',
'model/unix-system-condition.cc',
])
core.use.append('PTHREAD')
core_test.use.append('PTHREAD')
core_test.source.extend(['test/threaded-test-suite.cc'])
headers.source.extend([
'model/unix-fd-reader.h',
'model/system-mutex.h',
'model/system-thread.h',
'model/system-condition.h',
])
if env['ENABLE_GSL']:
core.use.extend(['GSL', 'GSLCBLAS', 'M'])
core_test.use.extend(['GSL', 'GSLCBLAS', 'M'])
core_test.source.extend([
'test/rng-test-suite.cc',
'test/random-variable-stream-test-suite.cc'
])
if (bld.env['ENABLE_EXAMPLES']):
bld.recurse('examples')
pymod = bld.ns3_python_bindings()
if pymod is not None:
pymod.source += ['bindings/module_helpers.cc']