forked from spirosmastorakis/scenario-ChronoSync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
133 lines (109 loc) · 5.12 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
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
VERSION='0.1'
APPNAME='template'
from waflib import Build, Logs, Options, TaskGen
import subprocess
import os
def options(opt):
opt.load(['compiler_c', 'compiler_cxx'])
opt.load(['default-compiler-flags',
'boost', 'ns3'],
tooldir=['.waf-tools'])
opt.add_option('--logging',action='store_true',default=True,dest='logging',help='''enable logging in simulation scripts''')
opt.add_option('--run',
help=('Run a locally built program; argument can be a program name,'
' or a command starting with the program name.'),
type="string", default='', dest='run')
opt.add_option('--visualize',
help=('Modify --run arguments to enable the visualizer'),
action="store_true", default=False, dest='visualize')
opt.add_option('--mpi',
help=('Run in MPI mode'),
type="string", default="", dest="mpi")
opt.add_option('--time',
help=('Enable time for the executed command'),
action="store_true", default=False, dest='time')
MANDATORY_NS3_MODULES = ['core', 'network', 'point-to-point', 'applications', 'mobility', 'ndnSIM']
OTHER_NS3_MODULES = ['antenna', 'aodv', 'bridge', 'brite', 'buildings', 'click', 'config-store', 'csma', 'csma-layout', 'dsdv', 'dsr', 'emu', 'energy', 'fd-net-device', 'flow-monitor', 'internet', 'lte', 'mesh', 'mpi', 'netanim', 'nix-vector-routing', 'olsr', 'openflow', 'point-to-point-layout', 'propagation', 'spectrum', 'stats', 'tap-bridge', 'topology-read', 'uan', 'virtual-net-device', 'visualizer', 'wifi', 'wimax']
def configure(conf):
conf.load(['compiler_c', 'compiler_cxx',
'default-compiler-flags',
'boost', 'ns3'])
if not os.environ.has_key('PKG_CONFIG_PATH'):
os.environ['PKG_CONFIG_PATH'] = ':'.join([
'/usr/local/lib/pkgconfig',
'/opt/local/lib/pkgconfig'])
try:
conf.check_ns3_modules(MANDATORY_NS3_MODULES)
for module in OTHER_NS3_MODULES:
conf.check_ns3_modules(module, mandatory = False)
except:
Logs.error ("NS-3 or one of the required NS-3 modules not found")
Logs.error ("NS-3 needs to be compiled and installed somewhere. You may need also to set PKG_CONFIG_PATH variable in order for configure find installed NS-3.")
Logs.error ("For example:")
Logs.error (" PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH ./waf configure")
conf.fatal ("")
if conf.options.debug:
conf.define ('NS3_LOG_ENABLE', 1)
conf.define ('NS3_ASSERT_ENABLE', 1)
if conf.env.DEST_BINFMT == 'elf':
# All ELF platforms are impacted but only the gcc compiler has a flag to fix it.
if 'gcc' in (conf.env.CXX_NAME, conf.env.CC_NAME):
conf.env.append_value('SHLIB_MARKER', '-Wl,--no-as-needed')
if conf.options.logging:
conf.define('NS3_LOG_ENABLE', 1)
conf.define('NS3_ASSERT_ENABLE', 1)
conf.write_config_header('ChronoSync/config.hpp', remove=False)
def build (bld):
deps = ' '.join (['ns3_'+dep for dep in MANDATORY_NS3_MODULES + OTHER_NS3_MODULES]).upper ()
chronoSync = bld.objects (
target = "ChronoSync",
features = ["cxx"],
source = bld.path.ant_glob("ChronoSync/src/**/*.cpp"),
includes = "ChronoSync",
export_includes = "ChronoSync",
use = deps
)
common = bld.objects (
target = "extensions",
features = ["cxx"],
source = bld.path.ant_glob(['extensions/**/*.cc', 'extensions/**/*.cpp']),
use = deps + " ChronoSync",
)
for scenario in bld.path.ant_glob (['scenarios/*.cc']):
name = str(scenario)[:-len(".cc")]
app = bld.program (
target = name,
features = ['cxx'],
source = [scenario],
use = deps + " extensions",
includes = "extensions",
export_includes = "extensions"
)
for scenario in bld.path.ant_glob (['scenarios/*.cpp']):
name = str(scenario)[:-len(".cpp")]
app = bld.program (
target = name,
features = ['cxx'],
source = [scenario],
use = deps + " extensions ChronoSync"
)
def shutdown (ctx):
if Options.options.run:
visualize=Options.options.visualize
mpi = Options.options.mpi
if mpi and visualize:
Logs.error ("You cannot specify --mpi and --visualize options at the same time!!!")
return
argv = Options.options.run.split (' ');
argv[0] = "build/%s" % argv[0]
if visualize:
argv.append ("--SimulatorImplementationType=ns3::VisualSimulatorImpl")
if mpi:
argv.append ("--SimulatorImplementationType=ns3::DistributedSimulatorImpl")
argv.append ("--mpi=1")
argv = ["openmpirun", "-np", mpi] + argv
Logs.error (argv)
if Options.options.time:
argv = ["time"] + argv
return subprocess.call (argv)