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 | |
Alexander Afanasyev | b66a89b | 2013-05-05 00:20:12 -0700 | [diff] [blame] | 9 | REQUIRED_BOOST_LIBS = ['graph'] |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 10 | |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 11 | def required_boost_libs(conf): |
| 12 | conf.env.REQUIRED_BOOST_LIBS += REQUIRED_BOOST_LIBS |
| 13 | |
Alexander Afanasyev | 8e60bcd | 2015-01-15 20:55:40 +0000 | [diff] [blame] | 14 | def options(opt): |
| 15 | opt.load(['dependency-checker', |
| 16 | 'doxygen', 'sphinx_build', 'type_traits', 'compiler-features'], |
| 17 | tooldir=['%s/.waf-tools' % opt.path.abspath()]) |
| 18 | |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 19 | def configure(conf): |
Alexander Afanasyev | 8e60bcd | 2015-01-15 20:55:40 +0000 | [diff] [blame] | 20 | conf.load(['dependency-checker', |
| 21 | 'doxygen', 'sphinx_build', 'type_traits', 'compiler-features']) |
| 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', |
| 28 | '/opt/local/lib/pkgconfig']) |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 29 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 30 | uselib_store='NDN_CXX', mandatory=True) |
| 31 | |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 32 | if not conf.env['LIB_BOOST']: |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 33 | conf.report_optional_feature("ndnSIM", "ndnSIM", False, |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 34 | "Required boost libraries not found") |
Alexander Afanasyev | 9ab7d67 | 2013-08-11 11:02:52 -0700 | [diff] [blame] | 35 | 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] | 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: |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 39 | present_boost_libs = [] |
| 40 | for boost_lib_name in conf.env['LIB_BOOST']: |
| 41 | if boost_lib_name.startswith("boost_"): |
| 42 | boost_lib_name = boost_lib_name[6:] |
| 43 | if boost_lib_name.endswith("-mt"): |
| 44 | boost_lib_name = boost_lib_name[:-3] |
Alexander Afanasyev | cd38c84 | 2013-05-05 00:24:41 -0700 | [diff] [blame] | 45 | present_boost_libs.append(boost_lib_name) |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 46 | |
| 47 | 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] | 48 | |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 49 | if missing_boost_libs != []: |
| 50 | conf.report_optional_feature("ndnSIM", "ndnSIM", False, |
| 51 | "ndnSIM requires boost libraries: %s" % ' '.join(missing_boost_libs)) |
| 52 | conf.env['MODULES_NOT_BUILT'].append('ndnSIM') |
| 53 | |
| 54 | Logs.error ("ndnSIM will not be build as it requires boost libraries: %s" % ' '.join(missing_boost_libs)) |
| 55 | Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)") |
| 56 | return |
Alexander Afanasyev | b4921ec | 2013-08-07 17:45:01 -0700 | [diff] [blame] | 57 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 58 | boost_version = conf.env.BOOST_VERSION.split('_') |
Alexander Afanasyev | 9ab7d67 | 2013-08-11 11:02:52 -0700 | [diff] [blame] | 59 | if int(boost_version[0]) < 1 or int(boost_version[1]) < 48: |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 60 | conf.report_optional_feature("ndnSIM", "ndnSIM", False, |
Alexander Afanasyev | 9ab7d67 | 2013-08-11 11:02:52 -0700 | [diff] [blame] | 61 | "ndnSIM requires at least boost version 1.48") |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 62 | conf.env['MODULES_NOT_BUILT'].append('ndnSIM') |
| 63 | |
Alexander Afanasyev | 9ab7d67 | 2013-08-11 11:02:52 -0700 | [diff] [blame] | 64 | 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] | 65 | Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)") |
| 66 | return |
Alexander Afanasyev | ac46d45 | 2012-05-31 15:33:21 -0700 | [diff] [blame] | 67 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 68 | conf.env['ENABLE_NDNSIM']=True; |
| 69 | conf.env['MODULES_BUILT'].append('ndnSIM') |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 70 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 71 | conf.report_optional_feature("ndnSIM", "ndnSIM", True, "") |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 72 | |
Ilya Moiseenko | 1762af7 | 2011-07-18 16:43:10 -0700 | [diff] [blame] | 73 | def build(bld): |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 74 | deps = ['core', 'network', 'point-to-point', 'topology-read', 'mobility', 'internet'] |
Alexander Afanasyev | 0d584e3 | 2013-08-13 10:41:42 -0700 | [diff] [blame] | 75 | if 'ns3-visualizer' in bld.env['NS3_ENABLED_MODULES']: |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 76 | deps.append('visualizer') |
Alexander Afanasyev | 3bea370 | 2011-11-16 10:27:18 -0800 | [diff] [blame] | 77 | |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 78 | if bld.env.ENABLE_EXAMPLES: |
Alexander Afanasyev | 15db772 | 2015-01-19 17:27:26 -0800 | [diff] [blame] | 79 | deps += ['point-to-point-layout', 'csma', 'applications', 'wifi'] |
Alexander Afanasyev | 4a3b2be | 2012-06-29 14:29:13 -0700 | [diff] [blame] | 80 | |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 81 | module = bld.create_ns3_module ('ndnSIM', deps) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 82 | module.module = 'ndnSIM' |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 83 | module.features += ' ns3fullmoduleheaders' |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 84 | module.uselib = 'NDN_CXX BOOST' |
| 85 | module.includes = [".", "./NFD", "./NFD/daemon", "./NFD/core"] |
| 86 | module.export_includes = [".", "./NFD", "./NFD/daemon", "./NFD/core"] |
Alexander Afanasyev | 404c079 | 2011-08-09 17:09:59 -0700 | [diff] [blame] | 87 | |
Alexander Afanasyev | 152660b | 2013-01-08 09:33:05 -0800 | [diff] [blame] | 88 | headers = bld (features='ns3header') |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 89 | headers.module = 'ndnSIM' |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 90 | headers.source = ["ndn-all.hpp"] |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 91 | |
Alexander Afanasyev | 1bfce32 | 2012-11-23 21:38:02 -0800 | [diff] [blame] | 92 | if not bld.env['ENABLE_NDNSIM']: |
Alexander Afanasyev | 57bcbc3 | 2012-06-01 01:46:24 -0700 | [diff] [blame] | 93 | bld.env['MODULES_NOT_BUILT'].append('ndnSIM') |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 94 | return |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 95 | |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 96 | module_dirs = ['NFD', 'apps', 'helper', 'model', 'utils'] |
Spyridon Mastorakis | b4bd4b7 | 2015-01-05 17:41:12 -0800 | [diff] [blame] | 97 | |
Spyridon Mastorakis | e4f0d3c | 2014-10-29 13:20:03 -0700 | [diff] [blame] | 98 | module.source = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in module_dirs], |
Alexander Afanasyev | dca091a | 2015-01-01 20:51:27 -0800 | [diff] [blame] | 99 | excl=['model/ip-faces/*']) |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 100 | |
Alexander Afanasyev | 60c0462 | 2014-12-29 20:43:22 -0800 | [diff] [blame] | 101 | module.full_headers = [p.path_from(bld.path) for p in bld.path.ant_glob( |
| 102 | ['%s/**/*.hpp' % dir for dir in module_dirs])] |
Alexander Afanasyev | 3b93629 | 2011-09-20 08:45:36 -0700 | [diff] [blame] | 103 | |
Spyridon Mastorakis | db8280f | 2014-11-21 20:00:17 -0800 | [diff] [blame] | 104 | if bld.env.ENABLE_EXAMPLES: |
| 105 | bld.recurse('examples') |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 106 | |
Spyridon Mastorakis | b4bd4b7 | 2015-01-05 17:41:12 -0800 | [diff] [blame] | 107 | if bld.env.ENABLE_TESTS: |
| 108 | bld.recurse('tests') |
| 109 | |
Alexander Afanasyev | 76b1157 | 2013-07-16 21:49:50 -0700 | [diff] [blame] | 110 | bld.ns3_python_bindings() |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 111 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 112 | @TaskGen.feature('ns3fullmoduleheaders') |
| 113 | @TaskGen.after_method('process_rule') |
| 114 | def apply_ns3fullmoduleheaders(self): |
| 115 | # ## get all of the ns3 headers |
Alexander Afanasyev | 1a62e61 | 2013-05-02 16:50:48 -0700 | [diff] [blame] | 116 | ns3_dir_node = self.bld.path.find_or_declare("ns3") |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 117 | |
| 118 | mode = getattr(self, "mode", "install") |
| 119 | |
| 120 | for filename in set(self.to_list(self.full_headers)): |
| 121 | src_node = self.path.find_resource(filename) |
| 122 | if src_node is None: |
| 123 | raise WafError("source ns3 header file %s not found" % (filename,)) |
| 124 | dst_node = ns3_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src'))) |
| 125 | assert dst_node is not None |
| 126 | |
| 127 | relpath = src_node.parent.path_from(self.bld.path.find_dir('src')) |
| 128 | |
| 129 | task = self.create_task('ns3header') |
| 130 | task.mode = getattr(self, 'mode', 'install') |
| 131 | if task.mode == 'install': |
Alexander Afanasyev | 957a84a | 2013-01-23 10:21:06 -0800 | [diff] [blame] | 132 | 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] | 133 | [src_node]) |
| 134 | task.set_inputs([src_node]) |
| 135 | task.set_outputs([dst_node]) |
| 136 | else: |
| 137 | task.header_to_remove = dst_node |