blob: 835cdaf0814b66a73cf46099e3f676bea1b0e351 [file] [log] [blame]
Ilya Moiseenko1762af72011-07-18 16:43:10 -07001## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyev45b92d42011-08-14 23:11:38 -07003import os
4import Logs
5import Utils
Alexander Afanasyev2a5df202011-08-15 22:39:05 -07006import Options
7
Alexander Afanasyev9de011f2011-11-11 00:55:05 -08008from waflib.Errors import WafError
9
Alexander Afanasyeva65ab322012-10-23 21:43:39 -070010import wutils
Alexander Afanasyev59314802012-11-26 14:56:04 -080011import TaskGen
12import Task
Alexander Afanasyeva65ab322012-10-23 21:43:39 -070013
Alexander Afanasyev3b936292011-09-20 08:45:36 -070014def options(opt):
15 opt.tool_options('boost', tooldir=["waf-tools"])
Alexander Afanasyevac46d452012-05-31 15:33:21 -070016 opt.add_option('--enable-ndn-plugins',
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080017 help=("Enable NDN plugins (may require patching). topology plugin enabled by default"),
Alexander Afanasyevac46d452012-05-31 15:33:21 -070018 dest='enable_ndn_plugins')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070019
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080020 opt.add_option('--disable-ndn-plugins',
21 help=("Enable NDN plugins (may require patching). topology plugin enabled by default"),
22 dest='disable_ndn_plugins')
23
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070024def configure(conf):
Alexander Afanasyev3b936292011-09-20 08:45:36 -070025 try:
26 conf.check_tool('boost')
27 conf.check_boost(lib = 'iostreams')
28 except WafError:
29 conf.env['LIB_BOOST'] = []
30
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080031 conf.env['ENABLE_NDNSIM']=False;
32
Alexander Afanasyev3b936292011-09-20 08:45:36 -070033 if not conf.env['LIB_BOOST']:
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080034 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070035 "Required boost libraries not found")
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070036 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070037 return
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080038 else:
39 boost_version = conf.env.BOOST_VERSION.split('_')
40 if int(boost_version[0]) < 1 or int(boost_version[1]) < 48:
41 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
42 "ndnSIM requires at least boost version 1.48")
43 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
44
45 Logs.error ("ndnSIM requires at least boost version 1.48")
46 Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
47 return
Alexander Afanasyevac46d452012-05-31 15:33:21 -070048
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080049 conf.env['NDN_plugins'] = ['topology']
Alexander Afanasyevac46d452012-05-31 15:33:21 -070050 if Options.options.enable_ndn_plugins:
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080051 conf.env['NDN_plugins'] = conf.env['NDN_plugins'] + Options.options.enable_ndn_plugins.split(',')
52
53 if Options.options.disable_ndn_plugins:
54 conf.env['NDN_plugins'] = conf.env['NDN_plugins'] - Options.options.disable_ndn_plugins.split(',')
Alexander Afanasyev957a84a2013-01-23 10:21:06 -080055
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080056 conf.env['ENABLE_NDNSIM']=True;
57 conf.env['MODULES_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070058
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080059 conf.report_optional_feature("ndnSIM", "ndnSIM", True, "")
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070060
Ilya Moiseenko1762af72011-07-18 16:43:10 -070061def build(bld):
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070062 deps = ['core', 'network', 'point-to-point']
63 deps.append ('internet') # Until RttEstimator is moved to network module
Alexander Afanasyev3bea3702011-11-16 10:27:18 -080064 if bld.env['ENABLE_PYTHON_BINDINGS']:
65 deps.append ('visualizer')
66
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070067 if 'topology' in bld.env['NDN_plugins']:
68 deps.append ('topology-read')
Alexander Afanasyev7d8127a2012-11-26 00:33:10 -080069 deps.append ('mobility')
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070070
Alexander Afanasyev4a3b2be2012-06-29 14:29:13 -070071 if 'mobility' in bld.env['NDN_plugins']:
72 deps.append ('mobility')
73
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070074 module = bld.create_ns3_module ('ndnSIM', deps)
Alexander Afanasyev59314802012-11-26 14:56:04 -080075 module.module = 'ndnSIM'
76 module.features += ['ns3fullmoduleheaders']
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070077 module.uselib = 'BOOST BOOST_IOSTREAMS'
Alexander Afanasyev404c0792011-08-09 17:09:59 -070078
Alexander Afanasyev3b936292011-09-20 08:45:36 -070079 headers = bld.new_task_gen(features=['ns3header'])
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070080 headers.module = 'ndnSIM'
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070081
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080082 if not bld.env['ENABLE_NDNSIM']:
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070083 bld.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070084 return
Alexander Afanasyev957a84a2013-01-23 10:21:06 -080085
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -070086 module.source = bld.path.ant_glob(['model/**/*.cc',
87 'apps/*.cc',
Alexander Afanasyev1a2df6a2012-08-17 13:21:51 -070088 'utils/**/*.cc',
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -070089 'helper/**/*.cc',
90 ])
Alexander Afanasyev59314802012-11-26 14:56:04 -080091 module.full_headers = [p.path_from(bld.path) for p in bld.path.ant_glob([
92 'utils/**/*.h',
93 'model/**/*.h',
94 'apps/**/*.h',
95 'helper/**/*.h',
96 ])]
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070097
Alexander Afanasyev07827182011-12-13 01:07:32 -080098 headers.source = [
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070099 "helper/ndn-stack-helper.h",
100 "helper/ndn-app-helper.h",
101 "helper/ndn-header-helper.h",
102 "helper/ndn-face-container.h",
103 "helper/ndn-global-routing-helper.h",
Ilya Moiseenko1762af72011-07-18 16:43:10 -0700104
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700105 "apps/ndn-app.h",
Alexander Afanasyev07827182011-12-13 01:07:32 -0800106
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700107 "model/ndn-l3-protocol.h",
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700108 "model/ndn-face.h",
109 "model/ndn-app-face.h",
110 "model/ndn-net-device-face.h",
Alexander Afanasyevbd9c18e2012-11-19 15:23:41 -0800111 "model/ndn-interest.h",
112 "model/ndn-content-object.h",
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700113 "model/ndn-name-components.h",
Alexander Afanasyev32c07562013-02-01 12:58:43 -0800114 "model/ndn-name.h",
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700115
116 "model/cs/ndn-content-store.h",
117
118 "model/fib/ndn-fib.h",
119 "model/fib/ndn-fib-entry.h",
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800120
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700121 "model/pit/ndn-pit.h",
122 "model/pit/ndn-pit-entry.h",
123 "model/pit/ndn-pit-entry-incoming-face.h",
124 "model/pit/ndn-pit-entry-outgoing-face.h",
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800125
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700126 "model/fw/ndn-forwarding-strategy.h",
Alexander Afanasyeved449cc2012-08-21 11:10:33 -0700127 "model/fw/ndn-fw-tag.h",
Alexander Afanasyev4975f732011-12-20 17:52:19 -0800128
Alexander Afanasyevf5c07742012-10-31 13:13:05 -0700129 # "utils/batches.h",
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700130 "utils/ndn-limits.h",
Alexander Afanasyevd9a7f192013-03-07 13:58:14 -0800131 "utils/ndn-rtt-estimator.h",
Alexander Afanasyevc1e33eb2012-05-31 12:13:17 -0700132 # "utils/weights-path-stretch-tag.h",
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700133
Alexander Afanasyev07827182011-12-13 01:07:32 -0800134 ]
Alexander Afanasyev3b936292011-09-20 08:45:36 -0700135
Alexander Afanasyevac46d452012-05-31 15:33:21 -0700136 if 'topology' in bld.env['NDN_plugins']:
137 headers.source.extend ([
138 "plugins/topology/rocketfuel-weights-reader.h",
139 "plugins/topology/annotated-topology-reader.h",
140 ])
141 module.source.extend (bld.path.ant_glob(['plugins/topology/*.cc']))
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800142 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 -0700143
144 if 'mobility' in bld.env['NDN_plugins']:
145 headers.source.extend ([
146 "plugins/mobility/spring-mobility-model.h",
147 "plugins/mobility/spring-mobility-helper.h",
148 ])
149 module.source.extend (bld.path.ant_glob(['plugins/mobility/*.cc']))
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800150 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 -0700151
Alexander Afanasyev59314802012-11-26 14:56:04 -0800152 # bld.install_files('${INCLUDEDIR}/%s%s/ns3/ndnSIM' % (wutils.APPNAME, wutils.VERSION), ndnSIM_headers, relative_trick=True)
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700153 # bld.install_files('$PREFIX/include', ndnSIM_headers)
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800154
Alexander Afanasyev5662b362012-07-11 13:34:21 -0700155 tests = bld.create_ns3_module_test_library('ndnSIM')
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700156 tests.source = bld.path.ant_glob('test/*.cc')
Alexander Afanasyev3b936292011-09-20 08:45:36 -0700157
Alexander Afanasyevf04d4512012-02-14 18:42:47 -0800158 if bld.env.ENABLE_EXAMPLES:
159 bld.add_subdirs('examples')
Lucas64b85362012-01-30 16:28:37 -0800160
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800161 bld.add_subdirs('tools')
162
Alexander Afanasyev07827182011-12-13 01:07:32 -0800163 bld.ns3_python_bindings()
Alexander Afanasyev59314802012-11-26 14:56:04 -0800164
165
166@TaskGen.feature('ns3fullmoduleheaders')
167@TaskGen.after_method('process_rule')
168def apply_ns3fullmoduleheaders(self):
169 # ## get all of the ns3 headers
170 ns3_dir_node = self.bld.path.find_dir("ns3")
171
172 mode = getattr(self, "mode", "install")
173
174 for filename in set(self.to_list(self.full_headers)):
175 src_node = self.path.find_resource(filename)
176 if src_node is None:
177 raise WafError("source ns3 header file %s not found" % (filename,))
178 dst_node = ns3_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src')))
179 assert dst_node is not None
180
181 relpath = src_node.parent.path_from(self.bld.path.find_dir('src'))
182
183 task = self.create_task('ns3header')
184 task.mode = getattr(self, 'mode', 'install')
185 if task.mode == 'install':
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800186 self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/%s' % (wutils.APPNAME, wutils.VERSION, relpath),
Alexander Afanasyev59314802012-11-26 14:56:04 -0800187 [src_node])
188 task.set_inputs([src_node])
189 task.set_outputs([dst_node])
190 else:
191 task.header_to_remove = dst_node
192