blob: 0197ae8089c9b5d5c85c04b2804a5adc982dc1d9 [file] [log] [blame]
Ilya Moiseenko1762af72011-07-18 16:43:10 -07001## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -07002#
Alexander Afanasyevc9f2e252013-07-14 15:35:21 -07003# Copyright (c) 2011-2013, Regents of the University of California
4# Alexander Afanasyev
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -07005#
Alexander Afanasyevc9f2e252013-07-14 15:35:21 -07006# GNU 3.0 license, See the LICENSE file for more information
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -07007#
Alexander Afanasyevc9f2e252013-07-14 15:35:21 -07008# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -07009#
Ilya Moiseenko1762af72011-07-18 16:43:10 -070010
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070011import os
Alexander Afanasyev152660b2013-01-08 09:33:05 -080012from waflib import Logs, Utils, Options, TaskGen, Task
Alexander Afanasyev9de011f2011-11-11 00:55:05 -080013from waflib.Errors import WafError
14
Alexander Afanasyeva65ab322012-10-23 21:43:39 -070015import wutils
16
Alexander Afanasyev3b936292011-09-20 08:45:36 -070017def options(opt):
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070018 opt = opt.add_option_group ('ndnSIM Options')
Alexander Afanasyevac46d452012-05-31 15:33:21 -070019 opt.add_option('--enable-ndn-plugins',
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070020 help="""Enable NDN plugins (may require patching). topology plugin enabled by default""",
Alexander Afanasyevac46d452012-05-31 15:33:21 -070021 dest='enable_ndn_plugins')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070022
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080023 opt.add_option('--disable-ndn-plugins',
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070024 help="""Enable NDN plugins (may require patching). topology plugin enabled by default""",
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080025 dest='disable_ndn_plugins')
26
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070027 opt.add_option('--pyndn-install-path', dest='pyndn_install_path',
28 help="""Installation path for PyNDN (by default: into standard location under PyNDN folder""")
29
Alexander Afanasyevb66a89b2013-05-05 00:20:12 -070030REQUIRED_BOOST_LIBS = ['graph']
Alexander Afanasyev3b936292011-09-20 08:45:36 -070031
Alexander Afanasyev152660b2013-01-08 09:33:05 -080032def required_boost_libs(conf):
33 conf.env.REQUIRED_BOOST_LIBS += REQUIRED_BOOST_LIBS
34
35def configure(conf):
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080036 conf.env['ENABLE_NDNSIM']=False;
37
Alexander Afanasyev3b936292011-09-20 08:45:36 -070038 if not conf.env['LIB_BOOST']:
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080039 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070040 "Required boost libraries not found")
Alexander Afanasyevb66a89b2013-05-05 00:20:12 -070041 Logs.error ("ndnSIM will not be build as it requires boost libraries of version at least 1.46")
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070042 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070043 return
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080044 else:
Alexander Afanasyev152660b2013-01-08 09:33:05 -080045 present_boost_libs = []
46 for boost_lib_name in conf.env['LIB_BOOST']:
47 if boost_lib_name.startswith("boost_"):
48 boost_lib_name = boost_lib_name[6:]
49 if boost_lib_name.endswith("-mt"):
50 boost_lib_name = boost_lib_name[:-3]
Alexander Afanasyevcd38c842013-05-05 00:24:41 -070051 present_boost_libs.append(boost_lib_name)
Alexander Afanasyev152660b2013-01-08 09:33:05 -080052
53 missing_boost_libs = [lib for lib in REQUIRED_BOOST_LIBS if lib not in present_boost_libs]
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070054
Alexander Afanasyev152660b2013-01-08 09:33:05 -080055 if missing_boost_libs != []:
56 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
57 "ndnSIM requires boost libraries: %s" % ' '.join(missing_boost_libs))
58 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
59
60 Logs.error ("ndnSIM will not be build as it requires boost libraries: %s" % ' '.join(missing_boost_libs))
61 Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
62 return
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070063
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080064 boost_version = conf.env.BOOST_VERSION.split('_')
Alexander Afanasyevb66a89b2013-05-05 00:20:12 -070065 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080066 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
Alexander Afanasyevb66a89b2013-05-05 00:20:12 -070067 "ndnSIM requires at least boost version 1.46")
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080068 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
69
Alexander Afanasyevb66a89b2013-05-05 00:20:12 -070070 Logs.error ("ndnSIM will not be build as it requires boost libraries of version at least 1.46")
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080071 Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
72 return
Alexander Afanasyevac46d452012-05-31 15:33:21 -070073
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070074 conf.env['NDN_plugins'] = ['topology', 'ip-faces']
Alexander Afanasyevac46d452012-05-31 15:33:21 -070075 if Options.options.enable_ndn_plugins:
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080076 conf.env['NDN_plugins'] = conf.env['NDN_plugins'] + Options.options.enable_ndn_plugins.split(',')
77
78 if Options.options.disable_ndn_plugins:
79 conf.env['NDN_plugins'] = conf.env['NDN_plugins'] - Options.options.disable_ndn_plugins.split(',')
Alexander Afanasyev957a84a2013-01-23 10:21:06 -080080
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070081 if Options.options.pyndn_install_path:
82 conf.env['PyNDN_install_path'] = Options.options.pyndn_install_path
83
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080084 conf.env['ENABLE_NDNSIM']=True;
85 conf.env['MODULES_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070086
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080087 conf.report_optional_feature("ndnSIM", "ndnSIM", True, "")
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070088
Ilya Moiseenko1762af72011-07-18 16:43:10 -070089def build(bld):
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070090 deps = ['core', 'network', 'point-to-point']
91 deps.append ('internet') # Until RttEstimator is moved to network module
Alexander Afanasyevc141ec02013-07-27 11:44:04 -070092 if 'visualizer' in bld.env['NS3_ENABLED_MODULES']:
Alexander Afanasyev3bea3702011-11-16 10:27:18 -080093 deps.append ('visualizer')
94
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070095 if 'topology' in bld.env['NDN_plugins']:
96 deps.append ('topology-read')
Alexander Afanasyev7d8127a2012-11-26 00:33:10 -080097 deps.append ('mobility')
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070098
Alexander Afanasyev4a3b2be2012-06-29 14:29:13 -070099 if 'mobility' in bld.env['NDN_plugins']:
100 deps.append ('mobility')
101
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700102 module = bld.create_ns3_module ('ndnSIM', deps)
Alexander Afanasyev59314802012-11-26 14:56:04 -0800103 module.module = 'ndnSIM'
Alexander Afanasyev152660b2013-01-08 09:33:05 -0800104 module.features += ' ns3fullmoduleheaders'
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700105 module.uselib = 'BOOST BOOST_IOSTREAMS'
Alexander Afanasyev404c0792011-08-09 17:09:59 -0700106
Alexander Afanasyev152660b2013-01-08 09:33:05 -0800107 headers = bld (features='ns3header')
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700108 headers.module = 'ndnSIM'
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700109
Alexander Afanasyev1bfce322012-11-23 21:38:02 -0800110 if not bld.env['ENABLE_NDNSIM']:
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700111 bld.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700112 return
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800113
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -0700114 module.source = bld.path.ant_glob(['model/**/*.cc',
115 'apps/*.cc',
Alexander Afanasyev1a2df6a2012-08-17 13:21:51 -0700116 'utils/**/*.cc',
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -0700117 'helper/**/*.cc',
Alexander Afanasyev79606062013-07-11 00:57:28 -0700118 'ndn.cxx/**/*.cc',
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -0700119 ])
Alexander Afanasyev59314802012-11-26 14:56:04 -0800120 module.full_headers = [p.path_from(bld.path) for p in bld.path.ant_glob([
121 'utils/**/*.h',
122 'model/**/*.h',
123 'apps/**/*.h',
124 'helper/**/*.h',
Alexander Afanasyev79606062013-07-11 00:57:28 -0700125 'ndn.cxx/**/*.h',
Alexander Afanasyev59314802012-11-26 14:56:04 -0800126 ])]
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700127
Alexander Afanasyev07827182011-12-13 01:07:32 -0800128 headers.source = [
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700129 "helper/ndn-stack-helper.h",
130 "helper/ndn-app-helper.h",
131 "helper/ndn-header-helper.h",
132 "helper/ndn-face-container.h",
133 "helper/ndn-global-routing-helper.h",
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700134 "helper/ndn-link-control-helper.h",
Ilya Moiseenko1762af72011-07-18 16:43:10 -0700135
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700136 "apps/ndn-app.h",
Alexander Afanasyev07827182011-12-13 01:07:32 -0800137
Alexander Afanasyev1043c702013-07-15 16:21:09 -0700138 "model/ndn-common.h",
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700139 "model/ndn-l3-protocol.h",
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700140 "model/ndn-face.h",
141 "model/ndn-app-face.h",
142 "model/ndn-net-device-face.h",
Alexander Afanasyevbd9c18e2012-11-19 15:23:41 -0800143 "model/ndn-interest.h",
Alexander Afanasyev6eba36f2013-08-07 17:42:54 -0700144 "model/ndn-data.h",
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700145 "model/ndn-name-components.h",
Alexander Afanasyev32c07562013-02-01 12:58:43 -0800146 "model/ndn-name.h",
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700147
Alexander Afanasyev92136012013-07-16 20:36:30 -0700148 "ndn.cxx/blob.h",
Alexander Afanasyevf23a7b62013-07-17 13:22:25 -0700149 "ndn.cxx/name-component.h",
150 "ndn.cxx/name.h",
Alexander Afanasyev92136012013-07-16 20:36:30 -0700151 "ndn.cxx/exclude.h",
152 "ndn.cxx/ndn-api-face.h",
153
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700154 "model/cs/ndn-content-store.h",
155
156 "model/fib/ndn-fib.h",
157 "model/fib/ndn-fib-entry.h",
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800158
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700159 "model/pit/ndn-pit.h",
160 "model/pit/ndn-pit-entry.h",
161 "model/pit/ndn-pit-entry-incoming-face.h",
162 "model/pit/ndn-pit-entry-outgoing-face.h",
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800163
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700164 "model/fw/ndn-forwarding-strategy.h",
Alexander Afanasyeved449cc2012-08-21 11:10:33 -0700165 "model/fw/ndn-fw-tag.h",
Alexander Afanasyev4975f732011-12-20 17:52:19 -0800166
Alexander Afanasyev7b923f32013-07-16 13:23:04 -0700167 "model/wire/ndn-wire.h",
Alexander Afanasyev1043c702013-07-15 16:21:09 -0700168
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700169 "utils/ndn-limits.h",
Alexander Afanasyevd9a7f192013-03-07 13:58:14 -0800170 "utils/ndn-rtt-estimator.h",
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700171
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700172 # "utils/tracers/ipv4-app-tracer.h",
173 # "utils/tracers/ipv4-l3-tracer.h",
174 # "utils/tracers/ipv4-rate-l3-tracer.h",
175 # "utils/tracers/ipv4-seqs-app-tracer.h",
176
177 "utils/tracers/l2-rate-tracer.h",
178 "utils/tracers/l2-tracer.h",
179 "utils/tracers/ndn-app-delay-tracer.h",
180 "utils/tracers/ndn-cs-tracer.h",
181 "utils/tracers/ndn-l3-aggregate-tracer.h",
182 "utils/tracers/ndn-l3-tracer.h",
183 "utils/tracers/ndn-l3-rate-tracer.h",
184
Alexander Afanasyeve4795ae2013-07-11 20:01:31 -0700185 "apps/callback-based-app.h",
Alexander Afanasyev07827182011-12-13 01:07:32 -0800186 ]
Alexander Afanasyev3b936292011-09-20 08:45:36 -0700187
Alexander Afanasyevac46d452012-05-31 15:33:21 -0700188 if 'topology' in bld.env['NDN_plugins']:
189 headers.source.extend ([
190 "plugins/topology/rocketfuel-weights-reader.h",
191 "plugins/topology/annotated-topology-reader.h",
192 ])
193 module.source.extend (bld.path.ant_glob(['plugins/topology/*.cc']))
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800194 module.full_headers.extend ([p.path_from(bld.path) for p in bld.path.ant_glob(['plugins/topology/**/*.h'])])
Alexander Afanasyevac46d452012-05-31 15:33:21 -0700195
196 if 'mobility' in bld.env['NDN_plugins']:
197 headers.source.extend ([
198 "plugins/mobility/spring-mobility-model.h",
199 "plugins/mobility/spring-mobility-helper.h",
200 ])
201 module.source.extend (bld.path.ant_glob(['plugins/mobility/*.cc']))
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800202 module.full_headers.extend ([p.path_from(bld.path) for p in bld.path.ant_glob(['plugins/mobility/**/*.h'])])
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700203
Alexander Afanasyevf4e24522013-06-24 14:11:57 -0700204 if 'ip-faces' in bld.env['NDN_plugins']:
205 headers.source.extend ([
206 "plugins/ip-faces/ndn-ip-faces-helper.h",
207 ])
208 module.source.extend (bld.path.ant_glob(['plugins/ip-faces/*.cc']))
209 module.full_headers.extend ([p.path_from(bld.path) for p in bld.path.ant_glob(['plugins/ip-faces/**/*.h'])])
210
Alexander Afanasyev59314802012-11-26 14:56:04 -0800211 # bld.install_files('${INCLUDEDIR}/%s%s/ns3/ndnSIM' % (wutils.APPNAME, wutils.VERSION), ndnSIM_headers, relative_trick=True)
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700212 # bld.install_files('$PREFIX/include', ndnSIM_headers)
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800213
Alexander Afanasyev5662b362012-07-11 13:34:21 -0700214 tests = bld.create_ns3_module_test_library('ndnSIM')
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700215 tests.source = bld.path.ant_glob('test/*.cc')
Alexander Afanasyev3b936292011-09-20 08:45:36 -0700216
Alexander Afanasyevf04d4512012-02-14 18:42:47 -0800217 if bld.env.ENABLE_EXAMPLES:
Alexander Afanasyev152660b2013-01-08 09:33:05 -0800218 bld.recurse ('examples')
Lucas64b85362012-01-30 16:28:37 -0800219
Alexander Afanasyev152660b2013-01-08 09:33:05 -0800220 bld.recurse ('tools')
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800221
Alexander Afanasyev76b11572013-07-16 21:49:50 -0700222 bld.ns3_python_bindings()
Alexander Afanasyev59314802012-11-26 14:56:04 -0800223
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -0700224 if bld.env['PyNDN_install_path']:
225 bld (features = "py",
226 source = bld.path.ant_glob (["PyNDN/**/*.py"]),
227 install_from = "PyNDN",
228 install_path = bld.env['PyNDN_install_path'])
229 else:
230 bld (features = "py",
231 source = bld.path.ant_glob (["PyNDN/**/*.py"]),
232 install_from = ".")
Alexander Afanasyev59314802012-11-26 14:56:04 -0800233
234@TaskGen.feature('ns3fullmoduleheaders')
235@TaskGen.after_method('process_rule')
236def apply_ns3fullmoduleheaders(self):
237 # ## get all of the ns3 headers
Alexander Afanasyev1a62e612013-05-02 16:50:48 -0700238 ns3_dir_node = self.bld.path.find_or_declare("ns3")
Alexander Afanasyev59314802012-11-26 14:56:04 -0800239
240 mode = getattr(self, "mode", "install")
241
242 for filename in set(self.to_list(self.full_headers)):
243 src_node = self.path.find_resource(filename)
244 if src_node is None:
245 raise WafError("source ns3 header file %s not found" % (filename,))
246 dst_node = ns3_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src')))
247 assert dst_node is not None
248
249 relpath = src_node.parent.path_from(self.bld.path.find_dir('src'))
250
251 task = self.create_task('ns3header')
252 task.mode = getattr(self, 'mode', 'install')
253 if task.mode == 'install':
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800254 self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/%s' % (wutils.APPNAME, wutils.VERSION, relpath),
Alexander Afanasyev59314802012-11-26 14:56:04 -0800255 [src_node])
256 task.set_inputs([src_node])
257 task.set_outputs([dst_node])
258 else:
259 task.header_to_remove = dst_node
260