blob: 30ba2492be787d2feb5549ec985a6c0c350235b4 [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
Alexander Afanasyev152660b2013-01-08 09:33:05 -08004from waflib import Logs, Utils, Options, TaskGen, Task
Alexander Afanasyev9de011f2011-11-11 00:55:05 -08005from waflib.Errors import WafError
6
Alexander Afanasyeva65ab322012-10-23 21:43:39 -07007import wutils
8
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -07009REQUIRED_BOOST_LIBS = ['graph', 'thread', 'unit_test_framework',
10 'system', 'random', 'date_time', 'iostreams', 'regex', 'program_options', 'chrono', 'filesystem']
Alexander Afanasyev3b936292011-09-20 08:45:36 -070011
Alexander Afanasyev152660b2013-01-08 09:33:05 -080012def required_boost_libs(conf):
13 conf.env.REQUIRED_BOOST_LIBS += REQUIRED_BOOST_LIBS
14
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000015def options(opt):
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070016 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 Afanasyev8e60bcd2015-01-15 20:55:40 +000019
Alexander Afanasyev152660b2013-01-08 09:33:05 -080020def configure(conf):
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070021 conf.load(['doxygen', 'sphinx_build', 'type_traits', 'compiler-features', 'version', 'cryptopp', 'sqlite3'])
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000022
23 conf.env['ENABLE_NDNSIM']=False
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080024
Alexander Afanasyevce308b62015-01-20 18:17:28 -080025 if not os.environ.has_key('PKG_CONFIG_PATH'):
26 os.environ['PKG_CONFIG_PATH'] = ':'.join([
27 '/usr/local/lib/pkgconfig',
Alexander Afanasyevfee51a02015-03-31 23:18:56 -070028 '/usr/local/lib64/pkgconfig',
29 '/usr/local/lib32/pkgconfig',
Alexander Afanasyevce308b62015-01-20 18:17:28 -080030 '/opt/local/lib/pkgconfig'])
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070031
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 Afanasyev60c04622014-12-29 20:43:22 -080035
Alexander Afanasyev3b936292011-09-20 08:45:36 -070036 if not conf.env['LIB_BOOST']:
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080037 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070038 "Required boost libraries not found")
Alexander Afanasyev9ab7d672013-08-11 11:02:52 -070039 Logs.error ("ndnSIM will not be build as it requires boost libraries of version at least 1.48")
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070040 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070041 return
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080042 else:
Alexander Afanasyev152660b2013-01-08 09:33:05 -080043 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 Afanasyevcd38c842013-05-05 00:24:41 -070049 present_boost_libs.append(boost_lib_name)
Alexander Afanasyev152660b2013-01-08 09:33:05 -080050
51 missing_boost_libs = [lib for lib in REQUIRED_BOOST_LIBS if lib not in present_boost_libs]
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070052
Alexander Afanasyev152660b2013-01-08 09:33:05 -080053 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 Afanasyevb4921ec2013-08-07 17:45:01 -070061
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080062 boost_version = conf.env.BOOST_VERSION.split('_')
Alexander Afanasyev9ab7d672013-08-11 11:02:52 -070063 if int(boost_version[0]) < 1 or int(boost_version[1]) < 48:
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080064 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
Alexander Afanasyev9ab7d672013-08-11 11:02:52 -070065 "ndnSIM requires at least boost version 1.48")
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080066 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
67
Alexander Afanasyev9ab7d672013-08-11 11:02:52 -070068 Logs.error ("ndnSIM will not be build as it requires boost libraries of version at least 1.48")
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080069 Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
70 return
Alexander Afanasyevac46d452012-05-31 15:33:21 -070071
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080072 conf.env['ENABLE_NDNSIM']=True;
73 conf.env['MODULES_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070074
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080075 conf.report_optional_feature("ndnSIM", "ndnSIM", True, "")
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070076
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070077 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 Mastorakisa1d135b2015-08-20 20:24:59 -070079
Ilya Moiseenko1762af72011-07-18 16:43:10 -070080def build(bld):
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -070081 (base, build, split) = bld.getVersion('NFD')
82 bld(features="subst",
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070083 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 Mastorakisa1d135b2015-08-20 20:24:59 -070095 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 Afanasyev60c04622014-12-29 20:43:22 -0800101 deps = ['core', 'network', 'point-to-point', 'topology-read', 'mobility', 'internet']
Alexander Afanasyev0d584e32013-08-13 10:41:42 -0700102 if 'ns3-visualizer' in bld.env['NS3_ENABLED_MODULES']:
Alexander Afanasyev60c04622014-12-29 20:43:22 -0800103 deps.append('visualizer')
Alexander Afanasyev3bea3702011-11-16 10:27:18 -0800104
Alexander Afanasyev60c04622014-12-29 20:43:22 -0800105 if bld.env.ENABLE_EXAMPLES:
Alexander Afanasyev15db7722015-01-19 17:27:26 -0800106 deps += ['point-to-point-layout', 'csma', 'applications', 'wifi']
Alexander Afanasyev4a3b2be2012-06-29 14:29:13 -0700107
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700108 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 Afanasyev404c0792011-08-09 17:09:59 -0700111
Spyridon Mastorakis8fde22b2015-08-19 23:12:44 -0700112 nfdSrc = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in ['NFD/core', 'NFD/daemon', 'NFD/rib']],
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700113 excl=['NFD/daemon/main.cpp',
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700114 'NFD/daemon/nfd.cpp',
115 'NFD/daemon/face/ethernet*',
116 'NFD/daemon/face/multicast-udp*',
117 'NFD/daemon/face/tcp*',
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700118 'NFD/daemon/face/*udp*',
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700119 'NFD/daemon/face/unix-stream*',
Spyridon Mastorakis8fde22b2015-08-19 23:12:44 -0700120 'NFD/daemon/face/websocket*',
121 'NFD/rib/nrd.cpp'])
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700122
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 Mastorakis8fde22b2015-08-19 23:12:44 -0700127 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 Mastorakisf542c0b2015-08-11 22:59:18 -0700129
130 headers = bld(features='ns3header')
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700131 headers.module = 'ndnSIM'
Alexander Afanasyev60c04622014-12-29 20:43:22 -0800132 headers.source = ["ndn-all.hpp"]
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700133
Alexander Afanasyev1bfce322012-11-23 21:38:02 -0800134 if not bld.env['ENABLE_NDNSIM']:
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700135 bld.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700136 return
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800137
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700138 module_dirs = ['apps', 'helper', 'model', 'utils']
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -0700139 module.source = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in module_dirs],
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700140 excl=[
141 'apps/*',
Xuxiang Tian91018732016-08-17 16:24:47 -0700142 'model/ndn-app-face.cpp',
143 'model/ndn-app-link-service.cpp',
Alexander Afanasyeva91aab42016-09-08 15:47:38 -0700144 'helper/ndn-app-helper.cpp',
Alexander Afanasyeva91aab42016-09-08 15:47:38 -0700145 'helper/ndn-scenario-helper.cpp',
Xuxiang Tian91018732016-08-17 16:24:47 -0700146 'utils/topology/*',
147 'utils/tracers/*',
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700148 'model/ip-faces/*']) + ndnCxxSrc + nfdSrc
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700149
Spyridon Mastorakis8fde22b2015-08-19 23:12:44 -0700150 module_dirs = ['NFD/core', 'NFD/daemon', 'NFD/rib', 'apps', 'helper', 'model', 'utils']
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700151 module.full_headers = bld.path.ant_glob(['%s/**/*.hpp' % dir for dir in module_dirs])
152 module.full_headers += bld.path.ant_glob('NFD/common.hpp')
Alexander Afanasyev3b936292011-09-20 08:45:36 -0700153
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700154 module.ndncxx_headers = bld.path.ant_glob(['ndn-cxx/src/**/*.hpp'],
155 excl=['src/**/*-osx.hpp', 'src/detail/**/*'])
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700156 # if bld.env.ENABLE_EXAMPLES:
157 # bld.recurse('examples')
Lucas64b85362012-01-30 16:28:37 -0800158
Spyridon Mastorakisb4bd4b72015-01-05 17:41:12 -0800159 if bld.env.ENABLE_TESTS:
160 bld.recurse('tests')
161
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700162 # bld.ns3_python_bindings()
Alexander Afanasyev59314802012-11-26 14:56:04 -0800163
Alexander Afanasyev59314802012-11-26 14:56:04 -0800164@TaskGen.feature('ns3fullmoduleheaders')
165@TaskGen.after_method('process_rule')
166def apply_ns3fullmoduleheaders(self):
167 # ## get all of the ns3 headers
Alexander Afanasyev1a62e612013-05-02 16:50:48 -0700168 ns3_dir_node = self.bld.path.find_or_declare("ns3")
Alexander Afanasyev59314802012-11-26 14:56:04 -0800169
170 mode = getattr(self, "mode", "install")
171
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700172 for src_node in set(self.full_headers):
Alexander Afanasyev59314802012-11-26 14:56:04 -0800173 dst_node = ns3_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src')))
174 assert dst_node is not None
175
176 relpath = src_node.parent.path_from(self.bld.path.find_dir('src'))
177
178 task = self.create_task('ns3header')
179 task.mode = getattr(self, 'mode', 'install')
180 if task.mode == 'install':
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800181 self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/%s' % (wutils.APPNAME, wutils.VERSION, relpath),
Alexander Afanasyev59314802012-11-26 14:56:04 -0800182 [src_node])
183 task.set_inputs([src_node])
184 task.set_outputs([dst_node])
185 else:
186 task.header_to_remove = dst_node
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700187
188@TaskGen.feature('ndncxxheaders')
189@TaskGen.after_method('process_rule')
190def apply_ndnsim_moduleheaders(self):
191 # ## get all of the ns3 headers
192 ndncxx_dir_node = self.bld.path.find_or_declare("ns3/ndnSIM/ndn-cxx")
193
194 mode = getattr(self, "mode", "install")
195
196 for src_node in set(self.ndncxx_headers):
197 dst_node = ndncxx_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src/ndnSIM/ndn-cxx/src')))
198 assert dst_node is not None
199
200 relpath = src_node.parent.path_from(self.bld.path.find_dir('src/ndnSIM/ndn-cxx/src'))
201
202 task = self.create_task('ns3header')
203 task.mode = getattr(self, 'mode', 'install')
204 if task.mode == 'install':
205 self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/ndnSIM/ndn-cxx/%s' % (wutils.APPNAME, wutils.VERSION, relpath),
206 [src_node])
207 task.set_inputs([src_node])
208 task.set_outputs([dst_node])
209 else:
210 task.header_to_remove = dst_node