blob: 01f7faa58a3e48ea198acc2376f82380f7261d3c [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',
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080010 'system', 'random', 'date_time', 'iostreams', 'regex',
11 'program_options', 'chrono', 'filesystem']
Alexander Afanasyev3b936292011-09-20 08:45:36 -070012
Alexander Afanasyev152660b2013-01-08 09:33:05 -080013def required_boost_libs(conf):
14 conf.env.REQUIRED_BOOST_LIBS += REQUIRED_BOOST_LIBS
15
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000016def options(opt):
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070017 opt.load(['version'], tooldir=['%s/.waf-tools' % opt.path.abspath()])
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -050018 opt.load(['doxygen', 'sphinx_build', 'compiler-features', 'sqlite3', 'openssl'],
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070019 tooldir=['%s/ndn-cxx/.waf-tools' % opt.path.abspath()])
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000020
Alexander Afanasyev152660b2013-01-08 09:33:05 -080021def configure(conf):
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -050022 conf.load(['doxygen', 'sphinx_build', 'compiler-features', 'version', 'sqlite3', 'openssl'])
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000023
24 conf.env['ENABLE_NDNSIM']=False
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080025
Alexander Afanasyeve932a212018-03-11 12:40:07 -040026 if 'PKG_CONFIG_PATH' not in os.environ:
27 os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070028
29 conf.check_cxx(lib='pthread', uselib_store='PTHREAD', define_name='HAVE_PTHREAD', mandatory=False)
30 conf.check_sqlite3(mandatory=True)
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080031 conf.check_openssl(mandatory=True, use='OPENSSL', atleast_version=0x10001000)
Alexander Afanasyev60c04622014-12-29 20:43:22 -080032
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")
Spyridon Mastorakisf6d32852017-09-27 20:28:52 -070036 Logs.error ("ndnSIM will not be built as it requires boost libraries of version at least 1.54.0")
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070037 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070038 return
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080039 else:
Alexander Afanasyev152660b2013-01-08 09:33:05 -080040 present_boost_libs = []
41 for boost_lib_name in conf.env['LIB_BOOST']:
42 if boost_lib_name.startswith("boost_"):
43 boost_lib_name = boost_lib_name[6:]
44 if boost_lib_name.endswith("-mt"):
45 boost_lib_name = boost_lib_name[:-3]
Alexander Afanasyevcd38c842013-05-05 00:24:41 -070046 present_boost_libs.append(boost_lib_name)
Alexander Afanasyev152660b2013-01-08 09:33:05 -080047
48 missing_boost_libs = [lib for lib in REQUIRED_BOOST_LIBS if lib not in present_boost_libs]
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070049
Alexander Afanasyev152660b2013-01-08 09:33:05 -080050 if missing_boost_libs != []:
51 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
52 "ndnSIM requires boost libraries: %s" % ' '.join(missing_boost_libs))
53 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
54
55 Logs.error ("ndnSIM will not be build as it requires boost libraries: %s" % ' '.join(missing_boost_libs))
56 Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
57 return
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070058
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080059 boost_version = conf.env.BOOST_VERSION.split('_')
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080060 if int(boost_version[0]) < 1 or int(boost_version[1]) < 54:
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080061 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080062 "ndnSIM requires at least boost version 1.54")
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080063 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
64
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080065 Logs.error ("ndnSIM will not be build as it requires boost libraries of version at least 1.54")
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080066 Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
67 return
Alexander Afanasyevac46d452012-05-31 15:33:21 -070068
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080069 conf.env['ENABLE_NDNSIM']=True;
70 conf.env['MODULES_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070071
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080072 conf.report_optional_feature("ndnSIM", "ndnSIM", True, "")
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070073
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -050074 conf.write_config_header('../../ns3/ndnSIM/ndn-cxx/detail/config.hpp', define_prefix='NDN_CXX_', remove=False)
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080075 conf.write_config_header('../../ns3/ndnSIM/NFD/core/config.hpp', remove=False)
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -070076
Ilya Moiseenko1762af72011-07-18 16:43:10 -070077def build(bld):
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -070078 (base, build, split) = bld.getVersion('NFD')
79 bld(features="subst",
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070080 name="version-NFD",
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080081 source='NFD/core/version.hpp.in', target='../../ns3/ndnSIM/NFD/core/version.hpp',
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070082 install_path=None,
83 VERSION_STRING=base,
84 VERSION_BUILD="%s-ndnSIM" % build,
85 VERSION=int(split[0]) * 1000000 + int(split[1]) * 1000 + int(split[2]),
86 VERSION_MAJOR=split[0], VERSION_MINOR=split[1], VERSION_PATCH=split[2])
87
Alexander Afanasyev11dfcb72019-07-27 17:47:32 -040088 bld(features="subst",
89 name="versioncpp-NFD",
90 source='NFD/core/version.cpp.in', target='NFD/core/version.cpp',
91 install_path=None,
92 VERSION_STRING=base,
93 VERSION_BUILD="%s-ndnSIM" % build,
94 VERSION=int(split[0]) * 1000000 + int(split[1]) * 1000 + int(split[2]),
95 VERSION_MAJOR=split[0], VERSION_MINOR=split[1], VERSION_PATCH=split[2])
96
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070097 (base, build, split) = bld.getVersion('ndn-cxx')
98 bld(features="subst",
99 name="version-ndn-cxx",
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -0500100 source='ndn-cxx/ndn-cxx/version.hpp.in', target='../../ns3/ndnSIM/ndn-cxx/version.hpp',
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -0700101 install_path=None,
102 VERSION_STRING=base,
103 VERSION_BUILD="%s-ndnSIM" % build,
104 VERSION=int(split[0]) * 1000000 + int(split[1]) * 1000 + int(split[2]),
105 VERSION_MAJOR=split[0], VERSION_MINOR=split[1], VERSION_PATCH=split[2])
106
Alexander Afanasyev11dfcb72019-07-27 17:47:32 -0400107 bld.objects(
108 target='version-NFD-objects',
109 source='NFD/core/version.cpp',
110 includes='../../ns3/ndnSIM/NFD',
111 use='version-NFD versioncpp-NFD')
112
Alexander Afanasyev60c04622014-12-29 20:43:22 -0800113 deps = ['core', 'network', 'point-to-point', 'topology-read', 'mobility', 'internet']
Alexander Afanasyev0d584e32013-08-13 10:41:42 -0700114 if 'ns3-visualizer' in bld.env['NS3_ENABLED_MODULES']:
Alexander Afanasyev60c04622014-12-29 20:43:22 -0800115 deps.append('visualizer')
Alexander Afanasyev3bea3702011-11-16 10:27:18 -0800116
Alexander Afanasyev60c04622014-12-29 20:43:22 -0800117 if bld.env.ENABLE_EXAMPLES:
Alexander Afanasyev15db7722015-01-19 17:27:26 -0800118 deps += ['point-to-point-layout', 'csma', 'applications', 'wifi']
Alexander Afanasyev4a3b2be2012-06-29 14:29:13 -0700119
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -0500120 ndnCxxSrc = bld.path.ant_glob('ndn-cxx/ndn-cxx/**/*.cpp',
121 excl=['ndn-cxx/ndn-cxx/net/impl/*.cpp',
122 'ndn-cxx/ndn-cxx/net/network-monitor*.cpp',
123 'ndn-cxx/ndn-cxx/util/dummy-client-face.cpp',
124 'ndn-cxx/ndn-cxx/security/tpm/*osx.cpp',
125 'ndn-cxx/ndn-cxx/detail/*osx.cpp',
126 'ndn-cxx/ndn-cxx/net/network-interface.cpp'])
Alexander Afanasyev404c0792011-08-09 17:09:59 -0700127
Alexander Afanasyev11dfcb72019-07-27 17:47:32 -0400128 nfdSrc = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in ['NFD/core', 'NFD/daemon']],
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700129 excl=['NFD/daemon/main.cpp',
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700130 'NFD/daemon/nfd.cpp',
Spyridon Mastorakisf6d32852017-09-27 20:28:52 -0700131 'NFD/daemon/face/*ethernet*',
132 'NFD/daemon/face/*pcap*.cpp',
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700133 'NFD/daemon/face/tcp*',
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700134 'NFD/daemon/face/*udp*',
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700135 'NFD/daemon/face/unix-stream*',
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -0500136 'NFD/daemon/face/websocket*'])
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700137
138 module = bld.create_ns3_module('ndnSIM', deps)
139 module.module = 'ndnSIM'
140 module.features += ' ns3fullmoduleheaders ndncxxheaders'
Alexander Afanasyev11dfcb72019-07-27 17:47:32 -0400141 module.use += ['version-ndn-cxx', 'version-NFD-objects', 'BOOST', 'SQLITE3', 'RT', 'PTHREAD', 'OPENSSL']
Spyridon Mastorakis8fde22b2015-08-19 23:12:44 -0700142 module.includes = ['../..', '../../ns3/ndnSIM/NFD', './NFD/core', './NFD/daemon', './NFD/rib', '../../ns3/ndnSIM', '../../ns3/ndnSIM/ndn-cxx']
143 module.export_includes = ['../../ns3/ndnSIM/NFD', './NFD/core', './NFD/daemon', './NFD/rib', '../../ns3/ndnSIM']
Alexander Afanasyev6995bb72019-02-23 15:53:26 -0500144 if 'ns3-visualizer' in bld.env['NS3_ENABLED_MODULES']:
145 module.defines = ['HAVE_NS3_VISUALIZER=1']
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700146
147 headers = bld(features='ns3header')
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700148 headers.module = 'ndnSIM'
Alexander Afanasyev60c04622014-12-29 20:43:22 -0800149 headers.source = ["ndn-all.hpp"]
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700150
Alexander Afanasyev1bfce322012-11-23 21:38:02 -0800151 if not bld.env['ENABLE_NDNSIM']:
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700152 bld.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700153 return
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800154
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -0800155 module_dirs = ['apps', 'helper', 'model', 'utils', 'bindings']
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -0700156 module.source = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in module_dirs],
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700157 excl=[
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700158 'model/ip-faces/*']) + ndnCxxSrc + nfdSrc
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700159
Alexander Afanasyev11dfcb72019-07-27 17:47:32 -0400160 module_dirs = ['NFD/core', 'NFD/daemon', 'apps', 'helper', 'model', 'utils', 'bindings']
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700161 module.full_headers = bld.path.ant_glob(['%s/**/*.hpp' % dir for dir in module_dirs])
162 module.full_headers += bld.path.ant_glob('NFD/common.hpp')
Alexander Afanasyev3b936292011-09-20 08:45:36 -0700163
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -0500164 module.ndncxx_headers = bld.path.ant_glob(['ndn-cxx/ndn-cxx/**/*.hpp'],
165 excl=['src/**/*-osx.hpp', 'src/impl/**/*'])
Spyridon Mastorakisf6d32852017-09-27 20:28:52 -0700166
Alexander Afanasyev50ea1a32016-09-08 15:44:08 -0700167 if bld.env.ENABLE_EXAMPLES:
168 bld.recurse('examples')
Lucas64b85362012-01-30 16:28:37 -0800169
Spyridon Mastorakisb4bd4b72015-01-05 17:41:12 -0800170 if bld.env.ENABLE_TESTS:
171 bld.recurse('tests')
172
Alexander Afanasyevc018a562016-09-08 16:27:31 -0700173 bld.ns3_python_bindings()
Alexander Afanasyev59314802012-11-26 14:56:04 -0800174
Alexander Afanasyev59314802012-11-26 14:56:04 -0800175@TaskGen.feature('ns3fullmoduleheaders')
176@TaskGen.after_method('process_rule')
177def apply_ns3fullmoduleheaders(self):
178 # ## get all of the ns3 headers
Alexander Afanasyev1a62e612013-05-02 16:50:48 -0700179 ns3_dir_node = self.bld.path.find_or_declare("ns3")
Alexander Afanasyev59314802012-11-26 14:56:04 -0800180
181 mode = getattr(self, "mode", "install")
182
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700183 for src_node in set(self.full_headers):
Alexander Afanasyev59314802012-11-26 14:56:04 -0800184 dst_node = ns3_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src')))
185 assert dst_node is not None
186
187 relpath = src_node.parent.path_from(self.bld.path.find_dir('src'))
188
189 task = self.create_task('ns3header')
190 task.mode = getattr(self, 'mode', 'install')
191 if task.mode == 'install':
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800192 self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/%s' % (wutils.APPNAME, wutils.VERSION, relpath),
Alexander Afanasyev59314802012-11-26 14:56:04 -0800193 [src_node])
194 task.set_inputs([src_node])
195 task.set_outputs([dst_node])
196 else:
197 task.header_to_remove = dst_node
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700198
199@TaskGen.feature('ndncxxheaders')
200@TaskGen.after_method('process_rule')
201def apply_ndnsim_moduleheaders(self):
202 # ## get all of the ns3 headers
203 ndncxx_dir_node = self.bld.path.find_or_declare("ns3/ndnSIM/ndn-cxx")
204
205 mode = getattr(self, "mode", "install")
206
207 for src_node in set(self.ndncxx_headers):
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -0500208 dst_node = ndncxx_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src/ndnSIM/ndn-cxx/ndn-cxx')))
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700209 assert dst_node is not None
210
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -0500211 relpath = src_node.parent.path_from(self.bld.path.find_dir('src/ndnSIM/ndn-cxx/ndn-cxx'))
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700212
213 task = self.create_task('ns3header')
214 task.mode = getattr(self, 'mode', 'install')
215 if task.mode == 'install':
216 self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/ndnSIM/ndn-cxx/%s' % (wutils.APPNAME, wutils.VERSION, relpath),
217 [src_node])
218 task.set_inputs([src_node])
219 task.set_outputs([dst_node])
220 else:
221 task.header_to_remove = dst_node