-
Notifications
You must be signed in to change notification settings - Fork 8
/
wscript
169 lines (143 loc) · 6.75 KB
/
wscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
# Copyright (c) 2017-2019, Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable Energy, LLC. See the top-level NOTICE for additional details. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
import os
from waflib import Options
def options(opt):
opt.add_option('--with-zmq',
help=('Installation prefix for ZMQ'),
dest='with_zmq', default='/usr/local')
opt.add_option('--with-helics',
help=('Path to HELICS for federated simulator integration'),
default='', dest='with_helics')
def configure(conf):
if Options.options.with_zmq:
if os.path.isdir(Options.options.with_zmq):
conf.msg("Checking for libzmq.so location", ("%s (given)" % Options.options.with_zmq))
conf.env['WITH_ZMQ'] = os.path.abspath(Options.options.with_zmq)
if (not conf.env['WITH_ZMQ']):
conf.env['MODULES_NOT_BUILT'].append('helics')
return
if Options.options.with_helics:
if os.path.isdir(Options.options.with_helics):
conf.msg("Checking for HELICS location", ("%s (given)" % Options.options.with_helics))
conf.env['WITH_HELICS'] = os.path.abspath(Options.options.with_helics)
# else:
# bake.py uses ../../build, while ns-3-dev uses ../helics
if not conf.env['WITH_HELICS']:
conf.msg("Checking for HELICS location", False)
conf.report_optional_feature("helics", "HELICS Integration", False,
"HELICS not enabled (see option --with-helics)")
# Add this module to the list of modules that won't be built
# if they are enabled.
conf.env['MODULES_NOT_BUILT'].append('helics')
return
zmq_test_code = '''
#include <zmq.h>
int main()
{
void *context = zmq_ctx_new();
(void) zmq_term(context);
return 0;
}
'''
helics_test_code = '''
int main()
{
return 0;
}
'''
conf.env.append_value('NS3_MODULE_PATH', os.path.abspath(os.path.join(conf.env['WITH_ZMQ'], 'build', 'default')))
conf.env.append_value('NS3_MODULE_PATH', os.path.abspath(os.path.join(conf.env['WITH_ZMQ'], 'lib')))
conf.env.append_value('NS3_MODULE_PATH', os.path.abspath(os.path.join(conf.env['WITH_ZMQ'], 'lib64')))
conf.env['INCLUDES_ZMQ'] = [os.path.abspath(os.path.join(conf.env['WITH_ZMQ'], 'include'))]
conf.env['LIBPATH_ZMQ'] = [
os.path.abspath(os.path.join(conf.env['WITH_ZMQ'], 'build', 'default')),
os.path.abspath(os.path.join(conf.env['WITH_ZMQ'], 'lib')),
os.path.abspath(os.path.join(conf.env['WITH_ZMQ'], 'lib64'))
]
conf.env['DEFINES_ZMQ'] = ['HAVE_ZMQ']
conf.env['ZMQ'] = conf.check(fragment=zmq_test_code, lib='zmq', libpath=conf.env['LIBPATH_ZMQ'], use='ZMQ')
conf.env.append_value('LIB_ZMQ', 'zmq')
conf.report_optional_feature("zmq", "ZMQ Integration", conf.env['ZMQ'], "zmq library not found")
conf.env.append_value('NS3_MODULE_PATH', os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'build', 'default')))
conf.env.append_value('NS3_MODULE_PATH', os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'lib', 'helics')))
conf.env.append_value('NS3_MODULE_PATH', os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'lib')))
conf.env['INCLUDES_HELICS'] = [
os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'include')),
os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'include/helics'))
]
conf.env['LIBPATH_HELICS'] = [
os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'build', 'default')),
os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'lib')),
os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'lib', 'helics')),
os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'lib64')),
os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'lib64', 'helics'))
]
conf.env['RPATH_HELICS'] = [
os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'lib')),
os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'lib', 'helics')),
os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'lib64')),
os.path.abspath(os.path.join(conf.env['WITH_HELICS'], 'lib64', 'helics'))
]
conf.env['DEFINES_HELICS'] = ['NS3_HELICS']
# Look for HELICS library
# HELICS 3: helicscpp, helicscppd
possible_helics_lib_names = ['helicscpp', 'helicscppd']
for try_helics_lib in possible_helics_lib_names:
retval = conf.check_nonfatal(fragment=helics_test_code, lib=try_helics_lib, libpath=conf.env['LIBPATH_HELICS'], use='HELICS')
if retval:
conf.env['HELICS'] = retval
conf.env.append_value('LIB_HELICS', [try_helics_lib])
break
conf.env.append_value('INCLUDES', conf.env['INCLUDES_HELICS'])
conf.report_optional_feature("helics", "HELICS Integration", conf.env['HELICS'], "HELICS library not found")
if conf.env['HELICS']:
conf.env['ENABLE_HELICS'] = True
else:
# Add this module to the list of modules that won't be built
# if they are enabled.
conf.env['MODULES_NOT_BUILT'].append('helics')
# if HELICS is enabled, we must use c++17 instead of c++11
if conf.env['HELICS']:
for index,flag in enumerate(conf.env['CXXFLAGS']):
if 'c++11' in flag:
conf.env['CXXFLAGS'][index] = '-std=c++17'
break
print(conf.env['CXXFLAGS'])
def build(bld):
if 'helics' in bld.env['MODULES_NOT_BUILT']:
return
module = bld.create_ns3_module('helics', ['core', 'internet'])
module.source = [
'model/helics.cc',
'model/helics-application.cc',
'model/helics-filter-application.cc',
'model/helics-static-sink-application.cc',
'model/helics-static-source-application.cc',
'model/helics-simulator-impl.cc',
'model/helics-id-tag.cc',
'helper/helics-helper.cc',
]
module_test = bld.create_ns3_module_test_library('helics')
module_test.source = [
'test/helics-test-suite.cc',
]
if bld.env['ENABLE_HELICS']:
module.use.extend(['HELICS', 'ZMQ'])
headers = bld(features='ns3header')
headers.module = 'helics'
headers.source = [
'model/helics.h',
'model/helics-application.h',
'model/helics-filter-application.h',
'model/helics-static-sink-application.h',
'model/helics-static-source-application.h',
'model/helics-simulator-impl.h',
'model/helics-id-tag.h',
'helper/helics-helper.h',
]
if bld.env.ENABLE_EXAMPLES:
bld.recurse('examples')
# bld.ns3_python_bindings()