forked from direct-code-execution/ns-3-dce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
executable file
·1091 lines (937 loc) · 45.8 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
import os
import os.path
import ns3waf
import sys
import types
# local modules
import wutils
import subprocess
from waflib import Utils, Scripting, Configure, Build, Options, TaskGen, Context, Task, Logs, Errors
from waflib.Errors import WafError
def options(opt):
opt.load('compiler_c')
opt.load('compiler_cxx')
ns3waf.options(opt)
opt.add_option('--enable-kernel-stack',
help=('Path to the prefix where the kernel wrapper headers are installed'),
default=None,
dest='kernel_stack', type="string")
opt.add_option('--enable-mpi',
help=('Enable MPI and distributed simulation support'),
dest='enable_mpi', action='store_true',
default=False)
opt.add_option('--enable-opt',
help=('Enable use of DCE and NS-3 optimized compilation'),
dest='enable_opt', action='store_true',
default=False)
opt.add_option('--with-ns3',
help=('Specify the installed directory of ns-3-dev'),
dest='with_ns3', type='string',
default=None)
opt.add_option('--with-elf-loader',
help=('Specify the installed directory of elf-loader'),
dest='with_elf_loader', type='string',
default=None)
opt.add_option('--with-libaspect',
help=('Specify the installed directory of libaspect.so'),
dest='with_libaspect', type='string',
default=None)
opt.add_option('--cwd',
help=('Set the working directory for a program.'),
action="store", type="string", default=None,
dest='cwd_launch')
opt.add_option('--command-template',
help=('Template of the command used to run the program given by --run;'
' It should be a shell command string containing %s inside,'
' which will be replaced by the actual program.'),
type="string", default=None, dest='command_template')
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('--pyrun',
help=('Run a python program using locally built dce and ns3 python modules;'
' argument is the path to the python program, optionally followed'
' by command-line options that are passed to the program.'),
type="string", default='', dest='pyrun')
opt.add_option('--dlmloader',
help=('Run with DlmLoaderFactory,'),
action="store_true", default=False, dest='dlm')
opt.add_option('--visualize',
help=('Modify --run arguments to enable the visualizer'),
action="store_true", default=False, dest='visualize')
opt.add_option('--valgrind',
help=('Change the default command template to run programs and unit tests with valgrind'),
action="store_true", default=False,
dest='valgrind')
opt.recurse('bindings/python')
def search_file(files):
for f in files:
if os.path.isfile (f):
return f
return None
# starting with waf 1.6, conf.check() becomes fatal by default if the
# test fails, this alternative method makes the test non-fatal, as it
# was in waf <= 1.5
def _check_nonfatal(conf, *args, **kwargs):
try:
return conf.check(*args, **kwargs)
except conf.errors.ConfigurationError:
return None
def configure(conf):
conf.load('relocation', tooldir=['waf-tools'])
conf.load('compiler_c')
cc_string = '.'.join(conf.env['CC_VERSION'])
conf.msg('Checking for cc version',cc_string,'GREEN')
conf.load('compiler_cxx')
conf.check_nonfatal = types.MethodType(_check_nonfatal, conf)
conf.check_compilation_flag = types.MethodType(_check_compilation_flag, conf)
conf.report_optional_feature = types.MethodType(report_optional_feature, conf)
conf.load('clang_compilation_database', tooldir=['waf-tools'])
conf.load('command', tooldir=['waf-tools'])
if Options.options.with_ns3 is not None and os.path.isdir(Options.options.with_ns3):
conf.env['NS3_DIR']= os.path.abspath(Options.options.with_ns3)
if not 'PKG_CONFIG_PATH' in os.environ:
os.environ['PKG_CONFIG_PATH']= os.path.join(Options.options.with_ns3, 'lib', 'pkgconfig')
os.environ['PKG_CONFIG_PATH']+= ":" + os.path.join(Options.options.with_ns3, 'lib64', 'pkgconfig')
else:
os.environ['PKG_CONFIG_PATH']+= ":" + os.path.join(Options.options.with_ns3, 'lib', 'pkgconfig')
os.environ['PKG_CONFIG_PATH']+= ":" + os.path.join(Options.options.with_ns3, 'lib64', 'pkgconfig')
conf.env.append_value('NS3_EXECUTABLE_PATH', os.path.join(conf.env['NS3_DIR'], 'bin'))
ns3waf.check_modules(conf, ['core', 'network', 'internet'], mandatory = True)
ns3waf.check_modules(conf, ['point-to-point', 'tap-bridge', 'netanim'], mandatory = False)
ns3waf.check_modules(conf, ['wifi', 'point-to-point', 'csma', 'mobility'], mandatory = False)
ns3waf.check_modules(conf, ['point-to-point-layout'], mandatory = False)
ns3waf.check_modules(conf, ['mpi', 'lte'], mandatory = False)
ns3waf.check_modules(conf, ['visualizer'], mandatory = False)
ns3waf.check_modules(conf, ['applications'], mandatory = False)
ns3waf.check_modules(conf, ['fd-net-device'], mandatory = False)
conf.check(header_name='stdint.h', define_name='HAVE_STDINT_H', mandatory=False)
conf.check(header_name='inttypes.h', define_name='HAVE_INTTYPES_H', mandatory=False)
conf.check(header_name='sys/inttypes.h', define_name='HAVE_SYS_INT_TYPES_H', mandatory=False)
conf.check(header_name='sys/types.h', define_name='HAVE_SYS_TYPES_H', mandatory=False)
conf.check(header_name='sys/stat.h', define_name='HAVE_SYS_STAT_H', mandatory=False)
conf.check(header_name='dirent.h', define_name='HAVE_DIRENT_H', mandatory=False)
if Options.options.enable_mpi:
conf.env.append_value ('DEFINES', 'DCE_MPI=1')
conf.env['MPI'] = '1'
conf.env.prepend_value('LINKFLAGS', '-Wl,--no-as-needed')
conf.env.append_value('LINKFLAGS', '-pthread')
conf.check (lib='dl', mandatory = True)
conf.check_cc(fragment='int main() {__get_cpu_features();}\n', msg='Checking for glibc get_cpu_features', define_name='HAVE_GETCPUFEATURES', mandatory=False)
conf.check_cc(fragment='int main() {secure_getenv("test");}\n', msg='Checking for glibc secure_getenv', define_name='HAVE_SECURE_GETENV', mandatory=False)
conf.check_cc(fragment='int main() {explicit_bzero("test", 1, 1);}\n', msg='Checking for glibc explicit_bzero', define_name='HAVE___EXPLICIT_BZERO', mandatory=False)
vg_h = conf.check(header_name='valgrind/valgrind.h', mandatory=False)
vg_memcheck_h = conf.check(header_name='valgrind/memcheck.h', mandatory=False)
if vg_h and vg_memcheck_h:
conf.env.append_value('CXXDEFINES', 'HAVE_VALGRIND_H')
# Enable C++-11 support
conf.env.append_value('CXXFLAGS', '-std=c++11')
if Options.options.kernel_stack:
if not os.path.isdir(Options.options.kernel_stack):
Logs.error( "\"%s\" is not a directory: please fix your --enable-kernel-stack parameter." % (Options.options.kernel_stack))
raise SystemExit(1)
# look for kernel dir from 1) {KERNEL_DIR}/sim, then 2) {KERNEL_DIR}/lib.
architectures = ["sim", "lib"]
kernel_stack_dir = None
for subdir in architectures:
subdir = os.path.join(Options.options.kernel_stack, subdir)
if os.path.isdir(subdir):
kernel_stack_dir = subdir
break
if not kernel_stack_dir:
Logs.error("Could not find any of the [%s] architecture. Make sure you use the net-next-sim kernel or fix your --enabled-kernel-stack parameter" % ','.join(architectures))
raise SystemExit(1)
conf.check(header_name='sim.h',
includes=os.path.join(kernel_stack_dir, 'include'))
conf.env['KERNEL_STACK'] = kernel_stack_dir
conf.env.append_value ('DEFINES', 'KERNEL_STACK=Y')
conf.env['ENABLE_PYTHON_BINDINGS'] = False
conf.env['EXAMPLE_DIRECTORIES'] = '.'
conf.env['NS3_ENABLED_MODULES'] = []
conf_myscripts(conf)
if Options.options.with_elf_loader is not None and os.path.isdir(Options.options.with_elf_loader):
if os.path.exists(Options.options.with_elf_loader + '/ldso'):
conf.env['ELF_LOADER_PATH'] = Options.options.with_elf_loader
else:
Logs.warn("elf-loader does not exist")
ns3waf._report_optional_feature(conf, "elf-loader", "ELF magic loader",
conf.env['ELF_LOADER_PATH'],
"elf-loader not found")
conf.env['LIB_ASPECT_PATH'] = conf.env['PREFIX']
if Options.options.with_libaspect is not None and os.path.isdir(Options.options.with_libaspect):
if os.path.exists(Options.options.with_libaspect):
conf.env['LIB_ASPECT_PATH'] = os.path.abspath(Options.options.with_libaspect)
else:
Logs.warn("libaspect does not exist")
have_aspect = conf.check(header_name='hook-manager.h', lib=['aspect', 'dl'],
includes=os.path.join(conf.env['LIB_ASPECT_PATH'], 'include'),
libpath=os.path.join(conf.env['LIB_ASPECT_PATH'], 'lib'),
uselib_store='ASPECT', mandatory=False)
if have_aspect is None:
conf.env['LIB_ASPECT_PATH'] = None
ns3waf._report_optional_feature(conf, "libaspect", "Aspect-based tracing",
have_aspect,
"libaspect not found")
conf.env['VALGRIND_FOUND'] = False
try:
conf.find_program('valgrind', var='VALGRIND')
conf.env['VALGRIND_FOUND'] = True
except WafError:
pass
try:
conf.find_program('doxygen', var='DOXYGEN')
except WafError:
pass
# sctp-tools check
have_sctp_tools = conf.check(header_name='netinet/sctp.h',
define_name='HAVE_SCTP_H', mandatory=False)
conf.env['SCTP_TOOLS_FOUND'] = True
if have_sctp_tools is None:
conf.env['SCTP_TOOLS_FOUND'] = False
ns3waf._report_optional_feature(conf, "sctp", "sctp-tools-dev",
have_sctp_tools,
"sctp-tools (netinet/sctp.h) not found")
conf.recurse(os.path.join('utils'))
conf.recurse('bindings/python')
ns3waf.print_feature_summary(conf)
def build_netlink(bld):
module_source = [
'netlink/netlink-socket.cc',
'netlink/netlink-socket-address.cc',
'netlink/netlink-socket-factory.cc',
'netlink/netlink-attribute.cc',
'netlink/netlink-message.cc',
'netlink/netlink-message-route.cc',
]
module_headers = [
'netlink/netlink-socket-factory.h',
'netlink/netlink-socket-address.h',
]
module = ns3waf.create_module(bld,
name='netlink',
needed = ['internet', 'core'],
source=module_source,
headers=module_headers)
module_tests = [
'test/netlink-socket-test.cc',
]
def dce_kw(**kw):
d = dict(**kw)
if os.uname()[4] == 'x86_64':
mcmodel = ['-mcmodel=large']
else:
mcmodel = []
nofortify = ['-U_FORTIFY_SOURCE']
#debug_dl = ['-Wl,--dynamic-linker=/usr/lib/debug/ld-linux-x86-64.so.2']
debug_dl = []
d['cxxflags'] = d.get('cxxflags', []) + ['-fpie'] + mcmodel + nofortify + ['-Wno-deprecated-declarations']
d['cflags'] = d.get('cflags', []) + ['-fpie'] + mcmodel + nofortify
d['linkflags'] = d.get('linkflags', []) + ['-pie'] + ['-lrt'] + ['-rdynamic'] + debug_dl
return d
def build_dce_tests(module, bld):
tests_source = [
'test/dce-manager-test.cc',
]
if bld.env['KERNEL_STACK']:
tests_source += [
'test/dce-cradle-test.cc',
'test/dce-mptcp-test.cc',
]
for subdir in os.listdir('test/addons'):
if subdir.startswith('.') or subdir == 'CVS':
continue
elif subdir.endswith(".cc"):
tests_source += ["test/addons/" + subdir]
module.add_runner_test(needed=['core', 'dce', 'internet', 'applications'],
source=tests_source)
module.add_test(features='cxx cxxshlib', source=['test/test-macros.cc'],
target='lib/test', linkflags=['-Wl,-soname=libtest.so'])
bld.install_files('${PREFIX}/lib', 'lib/libtest.so', chmod=Utils.O755 )
tests = [['test-empty', []],
['test-sleep', []],
['test-nanosleep', []],
['test-pthread', ['PTHREAD']],
['test-mutex', ['PTHREAD']],
['test-once', ['PTHREAD']],
['test-pthread-key', ['PTHREAD']],
['test-sem', ['PTHREAD']],
['test-malloc', []],
['test-malloc-2', []],
['test-fd-simple', []],
['test-strerror', []],
['test-stdio', []],
['test-string', []],
['test-netdb', []],
['test-env', []],
['test-cond', ['PTHREAD']],
['test-timer-fd', []],
['test-stdlib', []],
['test-select', ['PTHREAD']],
['test-random', []],
['test-ioctl', []],
['test-fork', []],
['test-local-socket', ['PTHREAD']],
['test-poll', ['PTHREAD']],
['test-tcp-socket', ['PTHREAD']],
['test-exec', []],
['test-exec-target-1', []],
['test-raw-socket', []],
['test-fork-fd', []],
['test-iperf', []],
['test-name', []],
['test-pipe', []],
['test-dirent', []],
['test-socket', []],
['test-bug-multi-select', []],
['test-tsearch', []],
['test-signal', []],
['test-clock-gettime', []],
['test-gcc-builtin-apply', []],
]
for name,uselib in tests:
module.add_test(**dce_kw(target='bin_dce/' + name, source = ['test/' + name + '.cc'],
use = uselib + ['lib/test']))
bld.install_files('${PREFIX}/bin_dce', 'build/bin_dce/' + name , chmod=Utils.O755 )
def build_dce_examples(module, bld):
dce_examples = [['udp-server', []],
['udp-client', []],
['udp-perf', ['m']],
['tcp-server', []],
['tcp-client', []],
['tcp-loopback', []],
['unix-server', []],
['unix-client', []],
['udp-echo-server', []],
['udp-echo-client', []],
['dccp-server', []],
['dccp-client', []],
['freebsd-iproute', []],
# ['little-cout', []],
]
if bld.env['SCTP_TOOLS_FOUND']:
dce_examples += [
['sctp-server', ['sctp']],
['sctp-client', ['sctp']],
]
for name,lib in dce_examples:
module.add_example(**dce_kw(target = 'bin_dce/' + name,
source = ['example/' + name + '.cc'],
lib = lib))
bld.install_files('${PREFIX}/bin_dce', 'bin_dce/' + name , chmod=Utils.O755 )
module.add_example(needed = ['core', 'internet', 'dce'],
target='bin/dce-tcp-simple',
source=['example/dce-tcp-simple.cc'])
module.add_example(needed = ['core', 'internet', 'dce'],
target='bin/dce-udp-simple',
source=['example/dce-udp-simple.cc'])
module.add_example(needed = ['core', 'internet', 'dce'],
target='bin/dce-ccnd-simple',
source=['example/ccnx/dce-ccnd-simple.cc'])
module.add_example(needed = ['core', 'internet', 'dce'],
target='bin/dce-ccnd-short-stuff',
source=['example/ccnx/dce-ccnd-short-stuff.cc'])
module.add_example(needed = ['core', 'internet', 'dce', 'tap-bridge', 'point-to-point', 'csma'],
target='bin/dce-tap-udp-echo',
source=['example/ccnx/dce-tap-udp-echo.cc'])
module.add_example(needed = ['core', 'internet', 'dce', 'tap-bridge', 'csma' ],
target='bin/dce-tap-ccnd',
source=['example/ccnx/dce-tap-ccnd.cc'])
module.add_example(needed = ['core', 'internet', 'dce', 'tap-bridge', 'csma' ],
target='bin/dce-tap-vlc',
source=['example/ccnx/dce-tap-vlc.cc'])
# module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'netanim'],
# target='bin/dce-ping',
# source=['example/dce-ping.cc', 'example/ccnx/misc-tools.cc'])
module.add_example(needed = ['core', 'internet', 'dce' ],
target='bin/dce-bash-simple',
source=['example/bash/dce-bash-simple.cc'])
module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'netanim'],
target='bin/dce-ccn-cache',
source=['example/ccnx/dce-ccn-cache.cc', 'example/ccnx/misc-tools.cc'])
module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'netanim', 'csma'],
target='bin/dce-iperf',
source=['example/dce-iperf.cc', 'example/ccnx/misc-tools.cc'])
module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'netanim', 'csma', 'fd-net-device'],
target='bin/dce-iperf-emulation',
source=['example/dce-iperf-emulation.cc', 'example/ccnx/misc-tools.cc'])
module.add_example(needed = ['core', 'network', 'internet', 'dce', 'point-to-point', 'csma', 'applications'],
target='bin/linear-udp-perf',
source=['example/linear-udp-perf.cc'])
if bld.env['LIB_ASPECT_PATH']:
module.add_example(needed = ['core', 'network', 'internet', 'dce', 'point-to-point', 'csma', 'applications'],
target='bin/dce-debug-aspect',
use=['ASPECT'],
source=['example/dce-debug-aspect.cc'])
# module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'netanim'],
# target='bin/dce-xorp-simple',
# source=['example/xorp/dce-xorp-simple.cc', 'example/ccnx/misc-tools.cc'])
# module.add_example(needed = ['core', 'internet', 'dce', 'csma' ],
# target='bin/dce-udp-multicast',
# source=['example/dce-udp-multicast.cc'])
# module.add_example(needed = ['core', 'dce', ],
# target='bin/dce-cout-bug',
# source=['example/dce-cout-bug.cc'])
def build_dce_kernel_examples(module, bld):
module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point'],
target='bin/dce-udp-perf',
source=['example/dce-udp-perf.cc'])
module.add_example(needed = ['core', 'network', 'dce'],
target='bin/dce-linux-simple',
source=['example/dce-linux-simple.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'wifi', 'point-to-point', 'csma', 'mobility' ],
target='bin/dce-linux',
source=['example/dce-linux.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'csma'],
target='bin/dce-dccp',
source=['example/dce-dccp.cc'])
module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'netanim'],
target='bin/dce-ccnd-udp-2-nodes',
source=['example/ccnx/dce-ccnd-udp-2-nodes.cc', 'example/ccnx/misc-tools.cc'])
module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'netanim'],
target='bin/dce-ccnd-linear-multiple',
source=['example/ccnx/dce-ccnd-linear-multiple.cc', 'example/ccnx/misc-tools.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'point-to-point'],
target='bin/dce-xfrm',
source=['example/dce-xfrm.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'wifi', 'point-to-point', 'csma', 'mobility' ],
target='bin/dce-ltp',
source=['example/dce-ltp.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'point-to-point', 'mobility'],
target='bin/dce-iperf-mptcp',
source=['example/dce-iperf-mptcp.cc'])
module.add_example(needed = ['core', 'internet', 'network', 'dce', 'point-to-point', 'mobility'],
target='bin/dce-iperf-heterogeneous-multihop',
source=['example/dce-iperf-heterogeneous-multihop.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'point-to-point', 'mobility', 'applications'],
target='bin/dce-cradle-mptcp',
source=['example/dce-cradle-mptcp.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'point-to-point', 'mobility', 'wifi', 'dce-quagga'],
target='bin/dce-mptcp-handoff-v6',
source=['example/dce-mptcp-handoff-v6.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'point-to-point', 'mobility', 'wifi', 'dce-quagga'],
target='bin/dce-mptcp-handoff-v4v6',
source=['example/dce-mptcp-handoff-v4v6.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'point-to-point', 'mobility', 'wifi', 'lte'],
target='bin/dce-mptcp-lte-wifi',
source=['example/dce-mptcp-lte-wifi.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'point-to-point', 'mobility', 'wifi', 'lte', 'dce-quagga'],
target='bin/dce-mptcp-lte-wifi-v6',
source=['example/dce-mptcp-lte-wifi-v6.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'point-to-point', 'applications'],
target='bin/dce-cradle-simple',
source=['example/dce-cradle-simple.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'point-to-point', 'applications', 'internet'],
target='bin/dce-tcp-ns3-nsc-comparison',
source=['example/dce-tcp-ns3-nsc-comparison.cc'])
module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point'],
target='bin/dce-httpd',
source=['example/dce-httpd.cc'])
module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'netanim', 'mobility', 'wifi', 'network'],
target='bin/dce-wifi-ccnx',
source=['example/ccnx/dce-wifi-ccnx.cc'])
if bld.env['SCTP_TOOLS_FOUND']:
module.add_example(needed = ['core', 'network', 'dce', 'point-to-point' ],
target='bin/dce-sctp-simple',
source=['example/dce-sctp-simple.cc'])
module.add_example(needed = ['core', 'network', 'dce', 'wifi', 'point-to-point', 'csma', 'mobility' ],
target='bin/dce-freebsd',
source=['example/dce-freebsd.cc'])
# Add a script to build system
def build_a_script(bld, name, needed = [], **kw):
external = [i for i in needed if not i == name]
if not ns3waf.modules_found(bld, external):
return
kw['use'] = kw.get('use', []) + ns3waf.modules_uselib(bld, needed)
if 'features' not in kw:
kw['features'] = 'cxx cxxprogram'
if bld.env['NS3_ENABLE_STATIC']:
for module in kw['use']:
kw['linkflags'] = kw.get('linkflags', [])
# XXX pkg-config doesn't give the proper order of whole-archive option..
if 'dce' in module.lower():
continue
if 'netlink' in module.lower():
continue
if 'header' in module.lower():
continue
if 'library' in module.lower():
continue
kw['linkflags'] += ['-ldl']
kw['linkflags'] += ['-Wl,--whole-archive,-Bstatic']
kw['linkflags'] += bld.env['STLIB_ST_%s' % module.upper()]
program = bld(**kw)
program.is_ns3_program = True
bld.env.append_value('NS3_RUNNABLE_PROGRAMS', name)
# Add directories under myscripts dir
def add_myscripts(bld):
# submodule parse should be the first
submodules = []
scratches = []
for dir in os.listdir('myscripts'):
if dir.startswith('.') or dir == 'CVS':
continue
if os.path.isdir(os.path.join('myscripts', dir)):
if dir.startswith('ns-3-dce-'):
submodules.append(dir)
else:
scratches.append(dir)
else:
scratches.append(dir)
for dir in submodules:
bld.recurse(os.path.join('myscripts', dir))
for dir in scratches:
if os.path.isdir(os.path.join('myscripts', dir)):
bld.recurse(os.path.join('myscripts', dir))
elif dir.endswith(".cc"):
bld.build_a_script('dce',
needed = bld.env['NS3_MODULES_FOUND'] + ['dce'],
target='bin/' + os.path.splitext(dir)[0],
source=[os.path.join('myscripts', dir)])
# Configure directories under myscripts dir
def conf_myscripts(conf):
for folder in os.listdir('myscripts'):
if folder.startswith('.') or folder == 'CVS':
continue
if os.path.isdir(os.path.join('myscripts', folder)):
conf.recurse(os.path.join('myscripts', folder))
def _get_all_task_gen(self):
for group in self.groups:
for taskgen in group:
yield taskgen
def build(bld):
bld.env['NS3_MODULES_WITH_TEST_LIBRARIES'] = []
bld.env['NS3_ENABLED_MODULE_TEST_LIBRARIES'] = []
bld.env['NS3_SCRIPT_DEPENDENCIES'] = []
bld.env['NS3_RUNNABLE_PROGRAMS'] = []
bld.env['NS3_RUNNABLE_SCRIPTS'] = []
bld.add_group('ns3moduleheader')
bld.add_group('ns3modulebuild')
build_netlink(bld)
if bld.env['KERNEL_STACK']:
kernel_source = [
'model/kernel-socket-fd-factory.cc',
'model/kernel-socket-fd.cc',
'model/linux-socket-fd-factory.cc',
'model/freebsd-socket-fd-factory.cc',
'model/linux/linux-socket-impl.cc',
]
kernel_headers = [
'model/kernel-socket-fd-factory.h',
'model/linux-socket-fd-factory.h',
'model/freebsd-socket-fd-factory.h',
'model/linux/linux-socket-impl.h',
]
kernel_includes = [bld.env['KERNEL_STACK']]
else:
kernel_source = []
kernel_headers = []
kernel_includes = []
module_source = [
'model/dce-manager.cc',
'model/dce-application.cc',
'model/dce.cc',
'model/dce-signal.cc',
'model/libc-dce.cc',
'model/utils.cc',
'model/unix-fd.cc',
'model/unix-file-fd.cc',
'model/unix-socket-fd.cc',
'model/unix-datagram-socket-fd.cc',
'model/unix-stream-socket-fd.cc',
'model/unix-timer-fd.cc',
'model/dce-fd.cc',
'model/dce-stdio.cc',
'model/dce-pthread.cc',
'model/dce-stdlib.cc',
'model/dce-debug.cc',
'model/dce-semaphore.cc',
'model/dce-pthread-mutex.cc',
'model/dce-cxa.cc',
'model/dce-netdb.cc',
'model/dce-string.cc',
'model/dce-env.cc',
'model/dce-pthread-cond.cc',
'model/dce-timerfd.cc',
'model/dce-time.cc',
'model/dce-stat.cc',
'model/dce-syslog.cc',
'model/dce-dl.cc',
'model/dce-global-variables.cc',
'model/cmsg.cc',
'model/waiter.cc',
'model/kingsley-alloc.cc',
'model/dce-alloc.cc',
'model/fiber-manager.cc',
'model/ucontext-fiber-manager.cc',
'model/pthread-fiber-manager.cc',
'model/task-manager.cc',
'model/task-scheduler.cc',
'model/rr-task-scheduler.cc',
'model/loader-factory.cc',
'model/elf-dependencies.cc',
'model/elf-cache.cc',
'model/cooja-loader-factory.cc',
'model/dlm-loader-factory.cc',
'model/socket-fd-factory.cc',
'model/ns3-socket-fd-factory.cc',
'model/local-socket-fd.cc',
'model/local-stream-socket-fd.cc',
'model/local-datagram-socket-fd.cc',
'model/local-socket-fd-factory.cc',
'model/dce-umask.cc',
'model/dce-misc.cc',
'model/dce-node-context.cc',
'model/dce-wait.cc',
'model/wait-queue.cc',
'model/file-usage.cc',
'model/dce-poll.cc',
'model/ipv4-dce-routing.cc',
'model/dce-credentials.cc',
'model/dce-pwd.cc',
'model/pipe-fd.cc',
'model/fifo-buffer.cc',
'model/dce-dirent.cc',
'model/dce-at.cc',
'model/exec-utils.cc',
'model/linux/ipv4-linux.cc',
'model/linux/ipv6-linux.cc',
'model/freebsd/ipv4-freebsd.cc',
'model/dce-vfs.cc',
'model/elf-ldd.cc',
'model/dce-termio.cc',
'model/process-delay-model.cc',
'model/linux/linux-ipv4-raw-socket-factory.cc',
'model/linux/linux-ipv4-raw-socket-factory-impl.cc',
'model/linux/linux-ipv6-raw-socket-factory.cc',
'model/linux/linux-ipv6-raw-socket-factory-impl.cc',
'model/linux/linux-udp-socket-factory.cc',
'model/linux/linux-udp-socket-factory-impl.cc',
'model/linux/linux-udp6-socket-factory.cc',
'model/linux/linux-udp6-socket-factory-impl.cc',
'model/linux/linux-tcp-socket-factory.cc',
'model/linux/linux-tcp-socket-factory-impl.cc',
'model/linux/linux-tcp6-socket-factory.cc',
'model/linux/linux-tcp6-socket-factory-impl.cc',
'model/linux/linux-dccp-socket-factory.cc',
'model/linux/linux-dccp-socket-factory-impl.cc',
'model/linux/linux-dccp6-socket-factory.cc',
'model/linux/linux-dccp6-socket-factory-impl.cc',
'model/linux/linux-sctp-socket-factory.cc',
'model/linux/linux-sctp-socket-factory-impl.cc',
'model/linux/linux-sctp6-socket-factory.cc',
'model/linux/linux-sctp6-socket-factory-impl.cc',
# helper.
'helper/ipv4-dce-routing-helper.cc',
'helper/dce-manager-helper.cc',
'helper/dce-application-helper.cc',
'helper/ccn-client-helper.cc',
'helper/linux-stack-helper.cc',
'helper/freebsd-stack-helper.cc',
]
module_headers = [
'model/dce-manager.h',
'model/task-scheduler.h',
'model/task-manager.h',
'model/socket-fd-factory.h',
'model/loader-factory.h',
'model/dce-application.h',
'model/ipv4-dce-routing.h',
'model/linux/ipv4-linux.h',
'model/linux/ipv6-linux.h',
'model/freebsd/ipv4-freebsd.h',
'model/process-delay-model.h',
'model/exec-utils.h',
'model/utils.h',
'model/unix-fd.h',
'model/wait-queue.h',
'model/process.h',
'model/linux/linux-ipv4-raw-socket-factory.h',
'model/linux/linux-ipv6-raw-socket-factory.h',
'model/linux/linux-udp-socket-factory.h',
'model/linux/linux-udp6-socket-factory.h',
'model/linux/linux-tcp-socket-factory.h',
'model/linux/linux-tcp6-socket-factory.h',
'model/linux/linux-dccp-socket-factory.h',
'model/linux/linux-dccp6-socket-factory.h',
'model/linux/linux-sctp-socket-factory.h',
'model/linux/linux-sctp6-socket-factory.h',
'helper/dce-manager-helper.h',
'helper/dce-application-helper.h',
'helper/ccn-client-helper.h',
'helper/ipv4-dce-routing-helper.h',
'helper/linux-stack-helper.h',
'helper/freebsd-stack-helper.h',
]
module_source = module_source + kernel_source
module_headers = module_headers + kernel_headers
uselib = ns3waf.modules_uselib(bld, ['core', 'network', 'internet', 'netlink'])
module = ns3waf.create_module(bld, name='dce',
source=module_source,
headers=module_headers,
use=uselib,
includes=kernel_includes,
cxxflags= ['-Wno-deprecated-declarations'],
lib=['dl'])
# lib=['dl','efence'])
# make sure submodules built before building examples (that depend submodules)
bld.build_a_script = types.MethodType(build_a_script, bld)
add_myscripts(bld)
build_dce_tests(module, bld)
build_dce_examples(module, bld)
# no idea to solve this two-way dependency (dce <-> netlink)
module.add_runner_test(needed = ['internet', 'point-to-point', 'core', 'dce'],
use=uselib,
includes=['netlink'],
source=['test/netlink-socket-test.cc'],
name='netlink')
if bld.env['KERNEL_STACK']:
build_dce_kernel_examples(module, bld)
# build test-runner
module.add_example(target='bin/test-runner',
source = ['utils/test-runner.cc'],
use = bld.env['NS3_ENABLED_MODULE_TEST_LIBRARIES'],
linkflags = [],
needed = bld.env['NS3_MODULES_FOUND'] + ['dce'])
bld.env.append_value('NS3_RUNNABLE_PROGRAMS', 'bin/test-runner')
if bld.env['ELF_LOADER_PATH']:
module.add_example(target='bin/test-runner-vdl',
source = ['utils/test-runner.cc'],
use = bld.env['NS3_ENABLED_MODULE_TEST_LIBRARIES'],
linkflags = ['-Wl,--dynamic-linker=' + os.path.abspath (bld.env['ELF_LOADER_PATH'] + '/ldso')],
needed = bld.env['NS3_MODULES_FOUND'] + ['dce'])
bld.add_group('dce_version_files')
bld.program(source='utils/dcemakeversion.c',
name='dcemakeversion',
target='dcemakeversion', cflags = [ '-g'], linkflags = ['-lpthread', '-lrt', '-lm', '-ldl'])
bld(source=['dcemakeversion','model/libc-ns3.version' , 'model/libpthread-ns3.version' ,
'model/librt-ns3.version', 'model/libm-ns3.version', 'model/libdl-ns3.version'],
target=['model/libc.version','model/libpthread.version','model/librt.version','model/libm.version','model/libdl.version'],
rule='${SRC[0].abspath()} ${SRC[1].abspath()} ${SRC[2].abspath()} ${SRC[3].abspath()} ${SRC[4].abspath()} ${SRC[5].abspath()}')
bld.add_group('dce_use_version_files')
# The very small libc used to replace the glibc
# and forward to the dce_* code
bld.shlib(source = ['model/libc.cc', 'model/libc-setup.cc', 'model/libc-global-variables.cc'],
target='lib/c-ns3',
cxxflags=['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch'],
defines=['LIBSETUP=libc_setup'],
linkflags=['-nostdlib', '-fno-profile-arcs',
'-Wl,--version-script=' + os.path.join('model', 'libc.version'),
'-Wl,-soname=libc.so.6'])
# The very small libpthread used to replace the glibc
# and forward to the dce_* code
bld.shlib(source = ['model/libc.cc', 'model/libc-setup.cc'],
target='lib/pthread-ns3',
cxxflags=['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch'],
defines=['LIBSETUP=libpthread_setup'],
linkflags=['-nostdlib', '-fno-profile-arcs',
'-Wl,--version-script=' + os.path.join('model', 'libpthread.version'),
'-Wl,-soname=libpthread.so.0'])
# The very small librt used to replace the glibc
# and forward to the dce_* code
bld.shlib(source = ['model/libc.cc', 'model/libc-setup.cc'],
target='lib/rt-ns3',
cxxflags=['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch'],
defines=['LIBSETUP=librt_setup'],
linkflags=['-nostdlib', '-fno-profile-arcs',
'-Wl,--version-script=' + os.path.join('model', 'librt.version'),
'-Wl,-soname=librt.so.1'])
# The very small libm used to replace the glibc
# and forward to the dce_* code
bld.shlib(source = ['model/libc.cc', 'model/libc-setup.cc'],
target='lib/m-ns3',
cxxflags=['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch'],
defines=['LIBSETUP=libm_setup'],
linkflags=['-nostdlib', '-fno-profile-arcs',
'-Wl,--version-script=' + os.path.join('model', 'libm.version'),
'-Wl,-soname=libm.so.6'])
# The very small libdl used to replace the glibc
# and forward to the dce_* code
bld.shlib(source = ['model/libc.cc', 'model/libc-setup.cc'],
target='lib/dl-ns3',
cxxflags=['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch'],
defines=['LIBSETUP=libdl_setup'],
linkflags=['-nostdlib', '-fno-profile-arcs',
'-Wl,--version-script=' + os.path.join('model', 'libdl.version'),
'-Wl,-soname=libdl.so.2'])
bld.recurse(['utils'])
bld.recurse('bindings/python')
# Write the build status file.
build_status_file = os.path.join(bld.out_dir, 'build-status.py')
out = open(build_status_file, 'w')
out.write('#! /usr/bin/env python\n')
out.write('\n')
out.write('# Programs that are runnable.\n')
out.write('ns3_runnable_programs = ' + str(bld.env['NS3_RUNNABLE_PROGRAMS']) + '\n')
out.write('\n')
out.write('# Scripts that are runnable.\n')
out.write('ns3_runnable_scripts = ' + str(bld.env['NS3_RUNNABLE_SCRIPTS']) + '\n')
out.write('\n')
out.close()
wutils.bld = bld
bld.__class__.all_task_gen = property(_get_all_task_gen)
Options.cwd_launch = bld.path.abspath()
if Options.options.run:
# Check that the requested program name is valid
program_name, dummy_program_argv = wutils.get_run_program(Options.options.run, wutils.get_command_template(bld.env))
# When --run'ing a program, tell WAF to only build that program,
# nothing more; this greatly speeds up compilation when all you
# want to do is run a test program.
Options.options.targets += ',' + os.path.basename(program_name)
if getattr(Options.options, "visualize", False):
program_obj = wutils.find_program(program_name, bld.env)
program_obj.use.append('NS3_VISUALIZER')
for gen in bld.all_task_gen:
if type(gen).__name__ in ['task_gen', 'ns3header_taskgen', 'ns3moduleheader_taskgen']:
gen.post()
bld.env['PRINT_BUILT_MODULES_AT_END'] = False
def _doxygen(bld):
env = wutils.bld.env
proc_env = wutils.get_proc_env()
if not env['DOXYGEN']:
Logs.error("waf configure did not detect doxygen in the system -> cannot build api docs.")
raise SystemExit(1)
return
# try:
# program_obj = wutils.find_program('print-introspected-doxygen', env)
# except ValueError:
# Logs.warn("print-introspected-doxygen does not exist")
# raise SystemExit(1)
# return
# prog = program_obj.path.find_or_declare(program_obj.target).abspath()
# if not os.path.exists(prog):
# Logs.error("print-introspected-doxygen has not been built yet."
# " You need to build ns-3 at least once before "
# "generating doxygen docs...")
# raise SystemExit(1)
# # Create a header file with the introspected information.
# doxygen_out = open(os.path.join('doc', 'introspected-doxygen.h'), 'w')
# if subprocess.Popen([prog], stdout=doxygen_out, env=proc_env).wait():
# raise SystemExit(1)
# doxygen_out.close()
# # Create a text file with the introspected information.
# text_out = open(os.path.join('doc', 'ns3-object.txt'), 'w')
# if subprocess.Popen([prog, '--output-text'], stdout=text_out, env=proc_env).wait():
# raise SystemExit(1)
# text_out.close()
#_getVersion()
doxygen_config = os.path.join('doc', 'doxygen.conf')
if subprocess.Popen([env['DOXYGEN'], doxygen_config]).wait():
Logs.error("Doxygen build returned an error.")
raise SystemExit(1)
from waflib import Context, Build
class Ns3ShellContext(Context.Context):
"""run a shell with an environment suitably modified to run locally built programs"""
cmd = 'shell'
def execute(self):
# first we execute the build
bld = Context.create_context("build")
bld.options = Options.options # provided for convenience
bld.cmd = "build"
bld.execute()
# Set this so that the lists won't be printed when the user
# exits the shell.
bld.env['PRINT_BUILT_MODULES_AT_END'] = False
if sys.platform == 'win32':
shell = os.environ.get("COMSPEC", "cmd.exe")
else:
shell = os.environ.get("SHELL", "/bin/sh")
env = bld.env
os_env = {
'NS3_MODULE_PATH': os.pathsep.join(env['NS3_MODULE_PATH']),
'NS3_EXECUTABLE_PATH': os.pathsep.join(env['NS3_EXECUTABLE_PATH']),
}
wutils.run_argv([shell], env, os_env)
def _check_compilation_flag(conf, flag, mode='cxx', linkflags=None):
"""
Checks if the C++ compiler accepts a certain compilation flag or flags
flag: can be a string or a list of strings
"""
l = []
if flag:
l.append(flag)
if isinstance(linkflags, list):
l.extend(linkflags)
else:
if linkflags:
l.append(linkflags)
if len(l) > 1:
flag_str = 'flags ' + ' '.join(l)
else:
flag_str = 'flag ' + ' '.join(l)
if len(flag_str) > 28:
flag_str = flag_str[:28] + "..."
conf.start_msg('Checking for compilation %s support' % (flag_str,))
env = conf.env.derive()