blob: 6f200dcdc781f77322202b4a419210dd57ba8d53 [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 Afanasyevc9f2e252013-07-14 15:35:21 -07002#
3# Copyright (c) 2011-2013, Regents of the University of California
4# Alexander Afanasyev
5#
6# GNU 3.0 license, See the LICENSE file for more information
7#
8# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
9#
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 Afanasyevac46d452012-05-31 15:33:21 -070018 opt.add_option('--enable-ndn-plugins',
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080019 help=("Enable NDN plugins (may require patching). topology plugin enabled by default"),
Alexander Afanasyevac46d452012-05-31 15:33:21 -070020 dest='enable_ndn_plugins')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070021
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080022 opt.add_option('--disable-ndn-plugins',
23 help=("Enable NDN plugins (may require patching). topology plugin enabled by default"),
24 dest='disable_ndn_plugins')
25
Alexander Afanasyevb66a89b2013-05-05 00:20:12 -070026REQUIRED_BOOST_LIBS = ['graph']
Alexander Afanasyev3b936292011-09-20 08:45:36 -070027
Alexander Afanasyev152660b2013-01-08 09:33:05 -080028def required_boost_libs(conf):
29 conf.env.REQUIRED_BOOST_LIBS += REQUIRED_BOOST_LIBS
30
31def configure(conf):
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080032 conf.env['ENABLE_NDNSIM']=False;
33
Alexander Afanasyev3b936292011-09-20 08:45:36 -070034 if not conf.env['LIB_BOOST']:
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080035 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070036 "Required boost libraries not found")
Alexander Afanasyevb66a89b2013-05-05 00:20:12 -070037 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 -070038 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070039 return
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080040 else:
Alexander Afanasyev152660b2013-01-08 09:33:05 -080041 present_boost_libs = []
42 for boost_lib_name in conf.env['LIB_BOOST']:
43 if boost_lib_name.startswith("boost_"):
44 boost_lib_name = boost_lib_name[6:]
45 if boost_lib_name.endswith("-mt"):
46 boost_lib_name = boost_lib_name[:-3]
Alexander Afanasyevcd38c842013-05-05 00:24:41 -070047 present_boost_libs.append(boost_lib_name)
Alexander Afanasyev152660b2013-01-08 09:33:05 -080048
49 missing_boost_libs = [lib for lib in REQUIRED_BOOST_LIBS if lib not in present_boost_libs]
50
51 if missing_boost_libs != []:
52 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
53 "ndnSIM requires boost libraries: %s" % ' '.join(missing_boost_libs))
54 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
55
56 Logs.error ("ndnSIM will not be build as it requires boost libraries: %s" % ' '.join(missing_boost_libs))
57 Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
58 return
59
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080060 boost_version = conf.env.BOOST_VERSION.split('_')
Alexander Afanasyevb66a89b2013-05-05 00:20:12 -070061 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080062 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
Alexander Afanasyevb66a89b2013-05-05 00:20:12 -070063 "ndnSIM requires at least boost version 1.46")
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080064 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
65
Alexander Afanasyevb66a89b2013-05-05 00:20:12 -070066 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 -080067 Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
68 return
Alexander Afanasyevac46d452012-05-31 15:33:21 -070069
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080070 conf.env['NDN_plugins'] = ['topology']
Alexander Afanasyevac46d452012-05-31 15:33:21 -070071 if Options.options.enable_ndn_plugins:
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080072 conf.env['NDN_plugins'] = conf.env['NDN_plugins'] + Options.options.enable_ndn_plugins.split(',')
73
74 if Options.options.disable_ndn_plugins:
75 conf.env['NDN_plugins'] = conf.env['NDN_plugins'] - Options.options.disable_ndn_plugins.split(',')
Alexander Afanasyev957a84a2013-01-23 10:21:06 -080076
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080077 conf.env['ENABLE_NDNSIM']=True;
78 conf.env['MODULES_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070079
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080080 conf.report_optional_feature("ndnSIM", "ndnSIM", True, "")
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070081
Ilya Moiseenko1762af72011-07-18 16:43:10 -070082def build(bld):
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070083 deps = ['core', 'network', 'point-to-point']
84 deps.append ('internet') # Until RttEstimator is moved to network module
Alexander Afanasyev3bea3702011-11-16 10:27:18 -080085 if bld.env['ENABLE_PYTHON_BINDINGS']:
86 deps.append ('visualizer')
87
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070088 if 'topology' in bld.env['NDN_plugins']:
89 deps.append ('topology-read')
Alexander Afanasyev7d8127a2012-11-26 00:33:10 -080090 deps.append ('mobility')
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070091
Alexander Afanasyev4a3b2be2012-06-29 14:29:13 -070092 if 'mobility' in bld.env['NDN_plugins']:
93 deps.append ('mobility')
94
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070095 module = bld.create_ns3_module ('ndnSIM', deps)
Alexander Afanasyev59314802012-11-26 14:56:04 -080096 module.module = 'ndnSIM'
Alexander Afanasyev152660b2013-01-08 09:33:05 -080097 module.features += ' ns3fullmoduleheaders'
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070098 module.uselib = 'BOOST BOOST_IOSTREAMS'
Alexander Afanasyev404c0792011-08-09 17:09:59 -070099
Alexander Afanasyev152660b2013-01-08 09:33:05 -0800100 headers = bld (features='ns3header')
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700101 headers.module = 'ndnSIM'
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700102
Alexander Afanasyev1bfce322012-11-23 21:38:02 -0800103 if not bld.env['ENABLE_NDNSIM']:
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700104 bld.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700105 return
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800106
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -0700107 module.source = bld.path.ant_glob(['model/**/*.cc',
108 'apps/*.cc',
Alexander Afanasyev1a2df6a2012-08-17 13:21:51 -0700109 'utils/**/*.cc',
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -0700110 'helper/**/*.cc',
Alexander Afanasyev79606062013-07-11 00:57:28 -0700111 'ndn.cxx/**/*.cc',
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -0700112 ])
Alexander Afanasyev59314802012-11-26 14:56:04 -0800113 module.full_headers = [p.path_from(bld.path) for p in bld.path.ant_glob([
114 'utils/**/*.h',
115 'model/**/*.h',
116 'apps/**/*.h',
117 'helper/**/*.h',
Alexander Afanasyev79606062013-07-11 00:57:28 -0700118 'ndn.cxx/**/*.h',
Alexander Afanasyev59314802012-11-26 14:56:04 -0800119 ])]
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700120
Alexander Afanasyev07827182011-12-13 01:07:32 -0800121 headers.source = [
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700122 "helper/ndn-stack-helper.h",
123 "helper/ndn-app-helper.h",
124 "helper/ndn-header-helper.h",
125 "helper/ndn-face-container.h",
126 "helper/ndn-global-routing-helper.h",
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700127 "helper/ndn-link-control-helper.h",
Ilya Moiseenko1762af72011-07-18 16:43:10 -0700128
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700129 "apps/ndn-app.h",
Alexander Afanasyev07827182011-12-13 01:07:32 -0800130
Alexander Afanasyev1043c702013-07-15 16:21:09 -0700131 "model/ndn-common.h",
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700132 "model/ndn-l3-protocol.h",
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700133 "model/ndn-face.h",
134 "model/ndn-app-face.h",
135 "model/ndn-net-device-face.h",
Alexander Afanasyevbd9c18e2012-11-19 15:23:41 -0800136 "model/ndn-interest.h",
137 "model/ndn-content-object.h",
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700138 "model/ndn-name-components.h",
Alexander Afanasyev32c07562013-02-01 12:58:43 -0800139 "model/ndn-name.h",
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700140
Alexander Afanasyev92136012013-07-16 20:36:30 -0700141 "ndn.cxx/blob.h",
Alexander Afanasyevf23a7b62013-07-17 13:22:25 -0700142 "ndn.cxx/name-component.h",
143 "ndn.cxx/name.h",
Alexander Afanasyev92136012013-07-16 20:36:30 -0700144 "ndn.cxx/exclude.h",
145 "ndn.cxx/ndn-api-face.h",
146
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700147 "model/cs/ndn-content-store.h",
148
149 "model/fib/ndn-fib.h",
150 "model/fib/ndn-fib-entry.h",
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800151
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700152 "model/pit/ndn-pit.h",
153 "model/pit/ndn-pit-entry.h",
154 "model/pit/ndn-pit-entry-incoming-face.h",
155 "model/pit/ndn-pit-entry-outgoing-face.h",
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800156
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700157 "model/fw/ndn-forwarding-strategy.h",
Alexander Afanasyeved449cc2012-08-21 11:10:33 -0700158 "model/fw/ndn-fw-tag.h",
Alexander Afanasyev4975f732011-12-20 17:52:19 -0800159
Alexander Afanasyev7b923f32013-07-16 13:23:04 -0700160 "model/wire/ndn-wire.h",
Alexander Afanasyev1043c702013-07-15 16:21:09 -0700161
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700162 "utils/ndn-limits.h",
Alexander Afanasyevd9a7f192013-03-07 13:58:14 -0800163 "utils/ndn-rtt-estimator.h",
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700164
Alexander Afanasyeve4795ae2013-07-11 20:01:31 -0700165 "apps/callback-based-app.h",
Alexander Afanasyev07827182011-12-13 01:07:32 -0800166 ]
Alexander Afanasyev3b936292011-09-20 08:45:36 -0700167
Alexander Afanasyevac46d452012-05-31 15:33:21 -0700168 if 'topology' in bld.env['NDN_plugins']:
169 headers.source.extend ([
170 "plugins/topology/rocketfuel-weights-reader.h",
171 "plugins/topology/annotated-topology-reader.h",
172 ])
173 module.source.extend (bld.path.ant_glob(['plugins/topology/*.cc']))
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800174 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 -0700175
176 if 'mobility' in bld.env['NDN_plugins']:
177 headers.source.extend ([
178 "plugins/mobility/spring-mobility-model.h",
179 "plugins/mobility/spring-mobility-helper.h",
180 ])
181 module.source.extend (bld.path.ant_glob(['plugins/mobility/*.cc']))
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800182 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 -0700183
Alexander Afanasyev59314802012-11-26 14:56:04 -0800184 # bld.install_files('${INCLUDEDIR}/%s%s/ns3/ndnSIM' % (wutils.APPNAME, wutils.VERSION), ndnSIM_headers, relative_trick=True)
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700185 # bld.install_files('$PREFIX/include', ndnSIM_headers)
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800186
Alexander Afanasyev5662b362012-07-11 13:34:21 -0700187 tests = bld.create_ns3_module_test_library('ndnSIM')
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700188 tests.source = bld.path.ant_glob('test/*.cc')
Alexander Afanasyev3b936292011-09-20 08:45:36 -0700189
Alexander Afanasyevf04d4512012-02-14 18:42:47 -0800190 if bld.env.ENABLE_EXAMPLES:
Alexander Afanasyev152660b2013-01-08 09:33:05 -0800191 bld.recurse ('examples')
Lucas64b85362012-01-30 16:28:37 -0800192
Alexander Afanasyev152660b2013-01-08 09:33:05 -0800193 bld.recurse ('tools')
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800194
Alexander Afanasyev76b11572013-07-16 21:49:50 -0700195 bld.ns3_python_bindings()
Alexander Afanasyev59314802012-11-26 14:56:04 -0800196
Alexander Afanasyev7992ab62013-07-19 16:50:58 -0700197 bld (features = "pyext",
198 source = bld.path.ant_glob (["PyNDN/**/*.py"]),
199 install_from = "."
200 )
Alexander Afanasyev59314802012-11-26 14:56:04 -0800201
202@TaskGen.feature('ns3fullmoduleheaders')
203@TaskGen.after_method('process_rule')
204def apply_ns3fullmoduleheaders(self):
205 # ## get all of the ns3 headers
Alexander Afanasyev1a62e612013-05-02 16:50:48 -0700206 ns3_dir_node = self.bld.path.find_or_declare("ns3")
Alexander Afanasyev59314802012-11-26 14:56:04 -0800207
208 mode = getattr(self, "mode", "install")
209
210 for filename in set(self.to_list(self.full_headers)):
211 src_node = self.path.find_resource(filename)
212 if src_node is None:
213 raise WafError("source ns3 header file %s not found" % (filename,))
214 dst_node = ns3_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src')))
215 assert dst_node is not None
216
217 relpath = src_node.parent.path_from(self.bld.path.find_dir('src'))
218
219 task = self.create_task('ns3header')
220 task.mode = getattr(self, 'mode', 'install')
221 if task.mode == 'install':
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800222 self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/%s' % (wutils.APPNAME, wutils.VERSION, relpath),
Alexander Afanasyev59314802012-11-26 14:56:04 -0800223 [src_node])
224 task.set_inputs([src_node])
225 task.set_outputs([dst_node])
226 else:
227 task.header_to_remove = dst_node
228