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 |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 4 | from waflib import Logs, Utils, Options, TaskGen, Task |
Alexander Afanasyev | 9de011f | 2011-11-11 00:55:05 -0800 | [diff] [blame] | 5 | from waflib.Errors import WafError |
| 6 | |
Alexander Afanasyev | a65ab32 | 2012-10-23 21:43:39 -0700 | [diff] [blame] | 7 | import wutils |
| 8 | |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 9 | REQUIRED_BOOST_LIBS = ['graph', 'thread', 'unit_test_framework', |
| 10 | 'system', 'random', 'date_time', 'iostreams', 'regex', 'program_options', 'chrono', 'filesystem'] |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 11 | |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 12 | def required_boost_libs(conf): |
| 13 | conf.env.REQUIRED_BOOST_LIBS += REQUIRED_BOOST_LIBS |
| 14 | |
Alexander Afanasyev | 8e60bcd | 2015-01-15 20:55:40 +0000 | [diff] [blame] | 15 | def options(opt): |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 16 | opt.load(['version'], tooldir=['%s/.waf-tools' % opt.path.abspath()]) |
| 17 | opt.load(['doxygen', 'sphinx_build', 'type_traits', 'compiler-features', 'cryptopp', 'sqlite3'], |
| 18 | tooldir=['%s/ndn-cxx/.waf-tools' % opt.path.abspath()]) |
Alexander Afanasyev | 8e60bcd | 2015-01-15 20:55:40 +0000 | [diff] [blame] | 19 | |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 20 | def configure(conf): |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 21 | conf.load(['doxygen', 'sphinx_build', 'type_traits', 'compiler-features', 'version', 'cryptopp', 'sqlite3']) |
Alexander Afanasyev | 8e60bcd | 2015-01-15 20:55:40 +0000 | [diff] [blame] | 22 | |
| 23 | conf.env['ENABLE_NDNSIM']=False |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 24 | |
Alexander Afanasyev | ce308b6 | 2015-01-20 18:17:28 -0800 | [diff] [blame] | 25 | if not os.environ.has_key('PKG_CONFIG_PATH'): |
| 26 | os.environ['PKG_CONFIG_PATH'] = ':'.join([ |
| 27 | '/usr/local/lib/pkgconfig', |
Alexander Afanasyev | fee51a0 | 2015-03-31 23:18:56 -0700 | [diff] [blame] | 28 | '/usr/local/lib64/pkgconfig', |
| 29 | '/usr/local/lib32/pkgconfig', |
Alexander Afanasyev | ce308b6 | 2015-01-20 18:17:28 -0800 | [diff] [blame] | 30 | '/opt/local/lib/pkgconfig']) |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 31 | |
| 32 | conf.check_cxx(lib='pthread', uselib_store='PTHREAD', define_name='HAVE_PTHREAD', mandatory=False) |
| 33 | conf.check_sqlite3(mandatory=True) |
| 34 | conf.check_cryptopp(mandatory=True, use='PTHREAD') |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 35 | |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 36 | if not conf.env['LIB_BOOST']: |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 37 | conf.report_optional_feature("ndnSIM", "ndnSIM", False, |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 38 | "Required boost libraries not found") |
Alexander Afanasyev | 9ab7d67 | 2013-08-11 11:02:52 -0700 | [diff] [blame] | 39 | Logs.error ("ndnSIM will not be build as it requires boost libraries of version at least 1.48") |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 40 | conf.env['MODULES_NOT_BUILT'].append('ndnSIM') |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 41 | return |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 42 | else: |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 43 | present_boost_libs = [] |
| 44 | for boost_lib_name in conf.env['LIB_BOOST']: |
| 45 | if boost_lib_name.startswith("boost_"): |
| 46 | boost_lib_name = boost_lib_name[6:] |
| 47 | if boost_lib_name.endswith("-mt"): |
| 48 | boost_lib_name = boost_lib_name[:-3] |
Alexander Afanasyev | cd38c84 | 2013-05-05 00:24:41 -0700 | [diff] [blame] | 49 | present_boost_libs.append(boost_lib_name) |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 50 | |
| 51 | missing_boost_libs = [lib for lib in REQUIRED_BOOST_LIBS if lib not in present_boost_libs] |
Alexander Afanasyev | b4921ec | 2013-08-07 17:45:01 -0700 | [diff] [blame] | 52 | |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 53 | if missing_boost_libs != []: |
| 54 | conf.report_optional_feature("ndnSIM", "ndnSIM", False, |
| 55 | "ndnSIM requires boost libraries: %s" % ' '.join(missing_boost_libs)) |
| 56 | conf.env['MODULES_NOT_BUILT'].append('ndnSIM') |
| 57 | |
| 58 | Logs.error ("ndnSIM will not be build as it requires boost libraries: %s" % ' '.join(missing_boost_libs)) |
| 59 | Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)") |
| 60 | return |
Alexander Afanasyev | b4921ec | 2013-08-07 17:45:01 -0700 | [diff] [blame] | 61 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 62 | boost_version = conf.env.BOOST_VERSION.split('_') |
Alexander Afanasyev | 9ab7d67 | 2013-08-11 11:02:52 -0700 | [diff] [blame] | 63 | if int(boost_version[0]) < 1 or int(boost_version[1]) < 48: |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 64 | conf.report_optional_feature("ndnSIM", "ndnSIM", False, |
Alexander Afanasyev | 9ab7d67 | 2013-08-11 11:02:52 -0700 | [diff] [blame] | 65 | "ndnSIM requires at least boost version 1.48") |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 66 | conf.env['MODULES_NOT_BUILT'].append('ndnSIM') |
| 67 | |
Alexander Afanasyev | 9ab7d67 | 2013-08-11 11:02:52 -0700 | [diff] [blame] | 68 | Logs.error ("ndnSIM will not be build as it requires boost libraries of version at least 1.48") |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 69 | Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)") |
| 70 | return |
Alexander Afanasyev | ac46d45 | 2012-05-31 15:33:21 -0700 | [diff] [blame] | 71 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 72 | conf.env['ENABLE_NDNSIM']=True; |
| 73 | conf.env['MODULES_BUILT'].append('ndnSIM') |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 74 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 75 | conf.report_optional_feature("ndnSIM", "ndnSIM", True, "") |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 76 | |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 77 | conf.write_config_header('../../ns3/ndnSIM/ndn-cxx/ndn-cxx-config.hpp', define_prefix='NDN_CXX_', remove=False) |
| 78 | conf.write_config_header('../../ns3/ndnSIM/NFD/config.hpp', remove=False) |
Spyridon Mastorakis | a1d135b | 2015-08-20 20:24:59 -0700 | [diff] [blame] | 79 | |
Ilya Moiseenko | 1762af7 | 2011-07-18 16:43:10 -0700 | [diff] [blame] | 80 | def build(bld): |
Spyridon Mastorakis | a1d135b | 2015-08-20 20:24:59 -0700 | [diff] [blame] | 81 | (base, build, split) = bld.getVersion('NFD') |
| 82 | bld(features="subst", |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 83 | name="version-NFD", |
| 84 | source='NFD/version.hpp.in', target='../../ns3/ndnSIM/NFD/version.hpp', |
| 85 | install_path=None, |
| 86 | VERSION_STRING=base, |
| 87 | VERSION_BUILD="%s-ndnSIM" % build, |
| 88 | VERSION=int(split[0]) * 1000000 + int(split[1]) * 1000 + int(split[2]), |
| 89 | VERSION_MAJOR=split[0], VERSION_MINOR=split[1], VERSION_PATCH=split[2]) |
| 90 | |
| 91 | (base, build, split) = bld.getVersion('ndn-cxx') |
| 92 | bld(features="subst", |
| 93 | name="version-ndn-cxx", |
| 94 | source='ndn-cxx/src/version.hpp.in', target='../../ns3/ndnSIM/ndn-cxx/version.hpp', |
Spyridon Mastorakis | a1d135b | 2015-08-20 20:24:59 -0700 | [diff] [blame] | 95 | install_path=None, |
| 96 | VERSION_STRING=base, |
| 97 | VERSION_BUILD="%s-ndnSIM" % build, |
| 98 | VERSION=int(split[0]) * 1000000 + int(split[1]) * 1000 + int(split[2]), |
| 99 | VERSION_MAJOR=split[0], VERSION_MINOR=split[1], VERSION_PATCH=split[2]) |
| 100 | |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 101 | deps = ['core', 'network', 'point-to-point', 'topology-read', 'mobility', 'internet'] |
Alexander Afanasyev | 0d584e3 | 2013-08-13 10:41:42 -0700 | [diff] [blame] | 102 | if 'ns3-visualizer' in bld.env['NS3_ENABLED_MODULES']: |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 103 | deps.append('visualizer') |
Alexander Afanasyev | 3bea370 | 2011-11-16 10:27:18 -0800 | [diff] [blame] | 104 | |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 105 | if bld.env.ENABLE_EXAMPLES: |
Alexander Afanasyev | 15db772 | 2015-01-19 17:27:26 -0800 | [diff] [blame] | 106 | deps += ['point-to-point-layout', 'csma', 'applications', 'wifi'] |
Alexander Afanasyev | 4a3b2be | 2012-06-29 14:29:13 -0700 | [diff] [blame] | 107 | |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 108 | ndnCxxSrc = bld.path.ant_glob('ndn-cxx/src/**/*.cpp', |
| 109 | excl=['ndn-cxx/src/**/*-osx.cpp', |
| 110 | 'ndn-cxx/src/util/dummy-client-face.cpp']) |
Alexander Afanasyev | 404c079 | 2011-08-09 17:09:59 -0700 | [diff] [blame] | 111 | |
Spyridon Mastorakis | 8fde22b | 2015-08-19 23:12:44 -0700 | [diff] [blame] | 112 | nfdSrc = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in ['NFD/core', 'NFD/daemon', 'NFD/rib']], |
Alexander Afanasyev | 325c253 | 2016-09-08 15:38:53 -0700 | [diff] [blame] | 113 | excl=['NFD/daemon/main.cpp', |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 114 | 'NFD/daemon/nfd.cpp', |
| 115 | 'NFD/daemon/face/ethernet*', |
| 116 | 'NFD/daemon/face/multicast-udp*', |
| 117 | 'NFD/daemon/face/tcp*', |
Alexander Afanasyev | 325c253 | 2016-09-08 15:38:53 -0700 | [diff] [blame] | 118 | 'NFD/daemon/face/*udp*', |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 119 | 'NFD/daemon/face/unix-stream*', |
Spyridon Mastorakis | 8fde22b | 2015-08-19 23:12:44 -0700 | [diff] [blame] | 120 | 'NFD/daemon/face/websocket*', |
| 121 | 'NFD/rib/nrd.cpp']) |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 122 | |
| 123 | module = bld.create_ns3_module('ndnSIM', deps) |
| 124 | module.module = 'ndnSIM' |
| 125 | module.features += ' ns3fullmoduleheaders ndncxxheaders' |
| 126 | module.use += ['version-ndn-cxx', 'version-NFD', 'BOOST', 'CRYPTOPP', 'SQLITE3', 'RT', 'PTHREAD'] |
Spyridon Mastorakis | 8fde22b | 2015-08-19 23:12:44 -0700 | [diff] [blame] | 127 | module.includes = ['../..', '../../ns3/ndnSIM/NFD', './NFD/core', './NFD/daemon', './NFD/rib', '../../ns3/ndnSIM', '../../ns3/ndnSIM/ndn-cxx'] |
| 128 | module.export_includes = ['../../ns3/ndnSIM/NFD', './NFD/core', './NFD/daemon', './NFD/rib', '../../ns3/ndnSIM'] |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 129 | |
| 130 | headers = bld(features='ns3header') |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 131 | headers.module = 'ndnSIM' |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 132 | headers.source = ["ndn-all.hpp"] |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 133 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 134 | if not bld.env['ENABLE_NDNSIM']: |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 135 | bld.env['MODULES_NOT_BUILT'].append('ndnSIM') |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 136 | return |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 137 | |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 138 | module_dirs = ['apps', 'helper', 'model', 'utils'] |
Spyridon Mastorakis | e4f0d3c | 2014-10-29 13:20:03 -0700 | [diff] [blame] | 139 | module.source = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in module_dirs], |
Alexander Afanasyev | 325c253 | 2016-09-08 15:38:53 -0700 | [diff] [blame] | 140 | excl=[ |
| 141 | 'apps/*', |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame^] | 142 | 'model/ndn-global-router.cpp', |
| 143 | 'model/ndn-app-face.cpp', |
| 144 | 'model/ndn-app-link-service.cpp', |
| 145 | 'model/ndn-l3-protocol.cpp', |
Alexander Afanasyev | 325c253 | 2016-09-08 15:38:53 -0700 | [diff] [blame] | 146 | 'helper/*', |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame^] | 147 | 'utils/topology/*', |
| 148 | 'utils/tracers/*', |
Alexander Afanasyev | 325c253 | 2016-09-08 15:38:53 -0700 | [diff] [blame] | 149 | 'model/ip-faces/*']) + ndnCxxSrc + nfdSrc |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 150 | |
Spyridon Mastorakis | 8fde22b | 2015-08-19 23:12:44 -0700 | [diff] [blame] | 151 | module_dirs = ['NFD/core', 'NFD/daemon', 'NFD/rib', 'apps', 'helper', 'model', 'utils'] |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 152 | module.full_headers = bld.path.ant_glob(['%s/**/*.hpp' % dir for dir in module_dirs]) |
| 153 | module.full_headers += bld.path.ant_glob('NFD/common.hpp') |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 154 | |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 155 | module.ndncxx_headers = bld.path.ant_glob(['ndn-cxx/src/**/*.hpp'], |
| 156 | excl=['src/**/*-osx.hpp', 'src/detail/**/*']) |
Alexander Afanasyev | 325c253 | 2016-09-08 15:38:53 -0700 | [diff] [blame] | 157 | # if bld.env.ENABLE_EXAMPLES: |
| 158 | # bld.recurse('examples') |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 159 | |
Spyridon Mastorakis | b4bd4b7 | 2015-01-05 17:41:12 -0800 | [diff] [blame] | 160 | if bld.env.ENABLE_TESTS: |
| 161 | bld.recurse('tests') |
| 162 | |
Alexander Afanasyev | 325c253 | 2016-09-08 15:38:53 -0700 | [diff] [blame] | 163 | # bld.ns3_python_bindings() |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 164 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 165 | @TaskGen.feature('ns3fullmoduleheaders') |
| 166 | @TaskGen.after_method('process_rule') |
| 167 | def apply_ns3fullmoduleheaders(self): |
| 168 | # ## get all of the ns3 headers |
Alexander Afanasyev | 1a62e61 | 2013-05-02 16:50:48 -0700 | [diff] [blame] | 169 | ns3_dir_node = self.bld.path.find_or_declare("ns3") |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 170 | |
| 171 | mode = getattr(self, "mode", "install") |
| 172 | |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 173 | for src_node in set(self.full_headers): |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 174 | dst_node = ns3_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src'))) |
| 175 | assert dst_node is not None |
| 176 | |
| 177 | relpath = src_node.parent.path_from(self.bld.path.find_dir('src')) |
| 178 | |
| 179 | task = self.create_task('ns3header') |
| 180 | task.mode = getattr(self, 'mode', 'install') |
| 181 | if task.mode == 'install': |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 182 | 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] | 183 | [src_node]) |
| 184 | task.set_inputs([src_node]) |
| 185 | task.set_outputs([dst_node]) |
| 186 | else: |
| 187 | task.header_to_remove = dst_node |
Spyridon Mastorakis | f542c0b | 2015-08-11 22:59:18 -0700 | [diff] [blame] | 188 | |
| 189 | @TaskGen.feature('ndncxxheaders') |
| 190 | @TaskGen.after_method('process_rule') |
| 191 | def apply_ndnsim_moduleheaders(self): |
| 192 | # ## get all of the ns3 headers |
| 193 | ndncxx_dir_node = self.bld.path.find_or_declare("ns3/ndnSIM/ndn-cxx") |
| 194 | |
| 195 | mode = getattr(self, "mode", "install") |
| 196 | |
| 197 | for src_node in set(self.ndncxx_headers): |
| 198 | dst_node = ndncxx_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src/ndnSIM/ndn-cxx/src'))) |
| 199 | assert dst_node is not None |
| 200 | |
| 201 | relpath = src_node.parent.path_from(self.bld.path.find_dir('src/ndnSIM/ndn-cxx/src')) |
| 202 | |
| 203 | task = self.create_task('ns3header') |
| 204 | task.mode = getattr(self, 'mode', 'install') |
| 205 | if task.mode == 'install': |
| 206 | self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/ndnSIM/ndn-cxx/%s' % (wutils.APPNAME, wutils.VERSION, relpath), |
| 207 | [src_node]) |
| 208 | task.set_inputs([src_node]) |
| 209 | task.set_outputs([dst_node]) |
| 210 | else: |
| 211 | task.header_to_remove = dst_node |