Ilya Moiseenko | 1762af7 | 2011-07-18 16:43:10 -0700 | [diff] [blame] | 1 | ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 3 | import os |
| 4 | import Logs |
| 5 | import Utils |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 6 | import Options |
| 7 | |
Alexander Afanasyev | 9de011f | 2011-11-11 00:55:05 -0800 | [diff] [blame] | 8 | from waflib.Errors import WafError |
| 9 | |
Alexander Afanasyev | a65ab32 | 2012-10-23 21:43:39 -0700 | [diff] [blame] | 10 | import wutils |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 11 | import TaskGen |
| 12 | import Task |
Alexander Afanasyev | a65ab32 | 2012-10-23 21:43:39 -0700 | [diff] [blame] | 13 | |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 14 | def options(opt): |
| 15 | opt.tool_options('boost', tooldir=["waf-tools"]) |
Alexander Afanasyev | ac46d45 | 2012-05-31 15:33:21 -0700 | [diff] [blame] | 16 | opt.add_option('--enable-ndn-plugins', |
Alexander Afanasyev | e8dab50 | 2012-11-21 16:17:51 -0800 | [diff] [blame] | 17 | help=("Enable NDN plugins (may require patching). topology plugin enabled by default"), |
Alexander Afanasyev | ac46d45 | 2012-05-31 15:33:21 -0700 | [diff] [blame] | 18 | dest='enable_ndn_plugins') |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 19 | |
Alexander Afanasyev | e8dab50 | 2012-11-21 16:17:51 -0800 | [diff] [blame] | 20 | 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 Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 24 | def configure(conf): |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 25 | try: |
| 26 | conf.check_tool('boost') |
| 27 | conf.check_boost(lib = 'iostreams') |
| 28 | except WafError: |
| 29 | conf.env['LIB_BOOST'] = [] |
| 30 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 31 | conf.env['ENABLE_NDNSIM']=False; |
| 32 | |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 33 | if not conf.env['LIB_BOOST']: |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 34 | conf.report_optional_feature("ndnSIM", "ndnSIM", False, |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 35 | "Required boost libraries not found") |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 36 | conf.env['MODULES_NOT_BUILT'].append('ndnSIM') |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 37 | return |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 38 | 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 Afanasyev | ac46d45 | 2012-05-31 15:33:21 -0700 | [diff] [blame] | 48 | |
Alexander Afanasyev | e8dab50 | 2012-11-21 16:17:51 -0800 | [diff] [blame] | 49 | conf.env['NDN_plugins'] = ['topology'] |
Alexander Afanasyev | ac46d45 | 2012-05-31 15:33:21 -0700 | [diff] [blame] | 50 | if Options.options.enable_ndn_plugins: |
Alexander Afanasyev | e8dab50 | 2012-11-21 16:17:51 -0800 | [diff] [blame] | 51 | 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 Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 55 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 56 | conf.env['ENABLE_NDNSIM']=True; |
| 57 | conf.env['MODULES_BUILT'].append('ndnSIM') |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 58 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 59 | conf.report_optional_feature("ndnSIM", "ndnSIM", True, "") |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 60 | |
Ilya Moiseenko | 1762af7 | 2011-07-18 16:43:10 -0700 | [diff] [blame] | 61 | def build(bld): |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 62 | deps = ['core', 'network', 'point-to-point'] |
| 63 | deps.append ('internet') # Until RttEstimator is moved to network module |
Alexander Afanasyev | 3bea370 | 2011-11-16 10:27:18 -0800 | [diff] [blame] | 64 | if bld.env['ENABLE_PYTHON_BINDINGS']: |
| 65 | deps.append ('visualizer') |
| 66 | |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 67 | if 'topology' in bld.env['NDN_plugins']: |
| 68 | deps.append ('topology-read') |
Alexander Afanasyev | 7d8127a | 2012-11-26 00:33:10 -0800 | [diff] [blame] | 69 | deps.append ('mobility') |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 70 | |
Alexander Afanasyev | 4a3b2be | 2012-06-29 14:29:13 -0700 | [diff] [blame] | 71 | if 'mobility' in bld.env['NDN_plugins']: |
| 72 | deps.append ('mobility') |
| 73 | |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 74 | module = bld.create_ns3_module ('ndnSIM', deps) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 75 | module.module = 'ndnSIM' |
| 76 | module.features += ['ns3fullmoduleheaders'] |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 77 | module.uselib = 'BOOST BOOST_IOSTREAMS' |
Alexander Afanasyev | 404c079 | 2011-08-09 17:09:59 -0700 | [diff] [blame] | 78 | |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 79 | headers = bld.new_task_gen(features=['ns3header']) |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 80 | headers.module = 'ndnSIM' |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 81 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 82 | if not bld.env['ENABLE_NDNSIM']: |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 83 | bld.env['MODULES_NOT_BUILT'].append('ndnSIM') |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 84 | return |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 85 | |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 86 | module.source = bld.path.ant_glob(['model/**/*.cc', |
| 87 | 'apps/*.cc', |
Alexander Afanasyev | 1a2df6a | 2012-08-17 13:21:51 -0700 | [diff] [blame] | 88 | 'utils/**/*.cc', |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 89 | 'helper/**/*.cc', |
| 90 | ]) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 91 | 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 Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 97 | |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 98 | headers.source = [ |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 99 | "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 Moiseenko | 1762af7 | 2011-07-18 16:43:10 -0700 | [diff] [blame] | 104 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 105 | "apps/ndn-app.h", |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 106 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 107 | "model/ndn-l3-protocol.h", |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 108 | "model/ndn-face.h", |
| 109 | "model/ndn-app-face.h", |
| 110 | "model/ndn-net-device-face.h", |
Alexander Afanasyev | bd9c18e | 2012-11-19 15:23:41 -0800 | [diff] [blame] | 111 | "model/ndn-interest.h", |
| 112 | "model/ndn-content-object.h", |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 113 | "model/ndn-name-components.h", |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 114 | |
| 115 | "model/cs/ndn-content-store.h", |
| 116 | |
| 117 | "model/fib/ndn-fib.h", |
| 118 | "model/fib/ndn-fib-entry.h", |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 119 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 120 | "model/pit/ndn-pit.h", |
| 121 | "model/pit/ndn-pit-entry.h", |
| 122 | "model/pit/ndn-pit-entry-incoming-face.h", |
| 123 | "model/pit/ndn-pit-entry-outgoing-face.h", |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 124 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 125 | "model/fw/ndn-forwarding-strategy.h", |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame] | 126 | "model/fw/ndn-fw-tag.h", |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 127 | |
Alexander Afanasyev | f5c0774 | 2012-10-31 13:13:05 -0700 | [diff] [blame] | 128 | # "utils/batches.h", |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 129 | "utils/ndn-limits.h", |
Alexander Afanasyev | c1e33eb | 2012-05-31 12:13:17 -0700 | [diff] [blame] | 130 | # "utils/weights-path-stretch-tag.h", |
Alexander Afanasyev | a65ab32 | 2012-10-23 21:43:39 -0700 | [diff] [blame] | 131 | |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 132 | ] |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 133 | |
Alexander Afanasyev | ac46d45 | 2012-05-31 15:33:21 -0700 | [diff] [blame] | 134 | if 'topology' in bld.env['NDN_plugins']: |
| 135 | headers.source.extend ([ |
| 136 | "plugins/topology/rocketfuel-weights-reader.h", |
| 137 | "plugins/topology/annotated-topology-reader.h", |
| 138 | ]) |
| 139 | module.source.extend (bld.path.ant_glob(['plugins/topology/*.cc'])) |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 140 | module.full_headers.extend ([p.path_from(bld.path) for p in bld.path.ant_glob(['plugins/topology/**/*.h'])]) |
Alexander Afanasyev | ac46d45 | 2012-05-31 15:33:21 -0700 | [diff] [blame] | 141 | |
| 142 | if 'mobility' in bld.env['NDN_plugins']: |
| 143 | headers.source.extend ([ |
| 144 | "plugins/mobility/spring-mobility-model.h", |
| 145 | "plugins/mobility/spring-mobility-helper.h", |
| 146 | ]) |
| 147 | module.source.extend (bld.path.ant_glob(['plugins/mobility/*.cc'])) |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 148 | module.full_headers.extend ([p.path_from(bld.path) for p in bld.path.ant_glob(['plugins/mobility/**/*.h'])]) |
Alexander Afanasyev | a65ab32 | 2012-10-23 21:43:39 -0700 | [diff] [blame] | 149 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 150 | # bld.install_files('${INCLUDEDIR}/%s%s/ns3/ndnSIM' % (wutils.APPNAME, wutils.VERSION), ndnSIM_headers, relative_trick=True) |
Alexander Afanasyev | a65ab32 | 2012-10-23 21:43:39 -0700 | [diff] [blame] | 151 | # bld.install_files('$PREFIX/include', ndnSIM_headers) |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 152 | |
Alexander Afanasyev | 5662b36 | 2012-07-11 13:34:21 -0700 | [diff] [blame] | 153 | tests = bld.create_ns3_module_test_library('ndnSIM') |
Alexander Afanasyev | a65ab32 | 2012-10-23 21:43:39 -0700 | [diff] [blame] | 154 | tests.source = bld.path.ant_glob('test/*.cc') |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 155 | |
Alexander Afanasyev | f04d451 | 2012-02-14 18:42:47 -0800 | [diff] [blame] | 156 | if bld.env.ENABLE_EXAMPLES: |
| 157 | bld.add_subdirs('examples') |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 158 | |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 159 | bld.add_subdirs('tools') |
| 160 | |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 161 | bld.ns3_python_bindings() |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 162 | |
| 163 | |
| 164 | @TaskGen.feature('ns3fullmoduleheaders') |
| 165 | @TaskGen.after_method('process_rule') |
| 166 | def apply_ns3fullmoduleheaders(self): |
| 167 | # ## get all of the ns3 headers |
| 168 | ns3_dir_node = self.bld.path.find_dir("ns3") |
| 169 | |
| 170 | mode = getattr(self, "mode", "install") |
| 171 | |
| 172 | for filename in set(self.to_list(self.full_headers)): |
| 173 | src_node = self.path.find_resource(filename) |
| 174 | if src_node is None: |
| 175 | raise WafError("source ns3 header file %s not found" % (filename,)) |
| 176 | dst_node = ns3_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src'))) |
| 177 | assert dst_node is not None |
| 178 | |
| 179 | relpath = src_node.parent.path_from(self.bld.path.find_dir('src')) |
| 180 | |
| 181 | task = self.create_task('ns3header') |
| 182 | task.mode = getattr(self, 'mode', 'install') |
| 183 | if task.mode == 'install': |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 184 | self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/%s' % (wutils.APPNAME, wutils.VERSION, relpath), |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 185 | [src_node]) |
| 186 | task.set_inputs([src_node]) |
| 187 | task.set_outputs([dst_node]) |
| 188 | else: |
| 189 | task.header_to_remove = dst_node |
| 190 | |