Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 2 | """ |
Davide Pesavento | f392b8f | 2019-01-08 20:51:55 -0500 | [diff] [blame] | 3 | Copyright (c) 2014-2019, Regents of the University of California, |
taylorchu | 5ae2877 | 2015-03-08 17:45:52 -0700 | [diff] [blame] | 4 | Arizona Board of Regents, |
| 5 | Colorado State University, |
| 6 | University Pierre & Marie Curie, Sorbonne University, |
| 7 | Washington University in St. Louis, |
| 8 | Beijing Institute of Technology, |
| 9 | The University of Memphis. |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 10 | |
| 11 | This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | |
| 14 | NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | of the GNU General Public License as published by the Free Software Foundation, |
| 16 | either version 3 of the License, or (at your option) any later version. |
| 17 | |
| 18 | NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | PURPOSE. See the GNU General Public License for more details. |
| 21 | |
| 22 | You should have received a copy of the GNU General Public License along with |
| 23 | NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | """ |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 25 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 26 | from waflib import Context, Logs, Utils |
| 27 | import os, subprocess |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 28 | |
Alexander Afanasyev | 77cddbc | 2019-01-28 14:38:16 -0500 | [diff] [blame] | 29 | VERSION = '0.6.5' |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 30 | APPNAME = 'nfd' |
| 31 | BUGREPORT = 'https://redmine.named-data.net/projects/nfd' |
| 32 | URL = 'https://named-data.net/doc/NFD/' |
| 33 | GIT_TAG_PREFIX = 'NFD-' |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 34 | |
| 35 | def options(opt): |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 36 | opt.load(['compiler_cxx', 'gnu_dirs']) |
Davide Pesavento | 5f35f64 | 2018-05-10 19:36:03 -0400 | [diff] [blame] | 37 | opt.load(['default-compiler-flags', 'compiler-features', |
| 38 | 'coverage', 'pch', 'sanitizers', 'boost', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 39 | 'dependency-checker', 'unix-socket', 'websocket', |
| 40 | 'doxygen', 'sphinx_build'], |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 41 | tooldir=['.waf-tools']) |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 42 | |
| 43 | nfdopt = opt.add_option_group('NFD Options') |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 44 | |
Davide Pesavento | 774071c | 2018-11-15 21:33:23 -0500 | [diff] [blame] | 45 | opt.addUnixOptions(nfdopt) |
| 46 | opt.addDependencyOptions(nfdopt, 'libresolv') |
| 47 | opt.addDependencyOptions(nfdopt, 'librt') |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 48 | opt.addDependencyOptions(nfdopt, 'libpcap') |
| 49 | nfdopt.add_option('--without-libpcap', action='store_true', default=False, |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 50 | help='Disable libpcap (Ethernet face support will be disabled)') |
Davide Pesavento | 774071c | 2018-11-15 21:33:23 -0500 | [diff] [blame] | 51 | nfdopt.add_option('--without-systemd', action='store_true', default=False, |
| 52 | help='Disable systemd integration') |
| 53 | opt.addWebsocketOptions(nfdopt) |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 54 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 55 | nfdopt.add_option('--with-tests', action='store_true', default=False, |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 56 | help='Build unit tests') |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 57 | nfdopt.add_option('--with-other-tests', action='store_true', default=False, |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 58 | help='Build other tests') |
Steve DiBenedetto | 84da5bf | 2014-03-11 14:51:29 -0600 | [diff] [blame] | 59 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 60 | PRIVILEGE_CHECK_CODE = ''' |
| 61 | #include <unistd.h> |
| 62 | #include <grp.h> |
| 63 | #include <pwd.h> |
| 64 | int main() |
| 65 | { |
| 66 | sysconf(_SC_GETGR_R_SIZE_MAX); |
| 67 | |
| 68 | char buffer[100]; |
| 69 | group grp; |
| 70 | group* grpRes; |
| 71 | getgrnam_r("nogroup", &grp, buffer, 100, &grpRes); |
| 72 | passwd pwd; |
| 73 | passwd* pwdRes; |
| 74 | getpwnam_r("nobody", &pwd, buffer, 100, &pwdRes); |
| 75 | |
| 76 | int ret = setegid(grp.gr_gid); |
| 77 | ret = seteuid(pwd.pw_uid); |
| 78 | (void)(ret); |
| 79 | |
| 80 | getegid(); |
| 81 | geteuid(); |
| 82 | } |
| 83 | ''' |
Alexander Afanasyev | 8269a05 | 2015-02-09 16:25:36 -0800 | [diff] [blame] | 84 | |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 85 | def configure(conf): |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 86 | conf.load(['compiler_cxx', 'gnu_dirs', |
Davide Pesavento | 5f35f64 | 2018-05-10 19:36:03 -0400 | [diff] [blame] | 87 | 'default-compiler-flags', 'compiler-features', |
| 88 | 'pch', 'boost', 'dependency-checker', 'websocket', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 89 | 'doxygen', 'sphinx_build']) |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 90 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 91 | conf.env.WITH_TESTS = conf.options.with_tests |
| 92 | conf.env.WITH_OTHER_TESTS = conf.options.with_other_tests |
Davide Pesavento | 774071c | 2018-11-15 21:33:23 -0500 | [diff] [blame] | 93 | |
Davide Pesavento | f0ae442 | 2014-05-05 16:32:12 +0200 | [diff] [blame] | 94 | conf.find_program('bash', var='BASH') |
| 95 | |
taylorchu | 5ae2877 | 2015-03-08 17:45:52 -0700 | [diff] [blame] | 96 | if 'PKG_CONFIG_PATH' not in os.environ: |
Alexander Afanasyev | cdb8f36 | 2015-03-30 10:52:54 -0700 | [diff] [blame] | 97 | os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env) |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 98 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDN_CXX') |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 99 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 100 | if not conf.options.without_systemd: |
| 101 | conf.check_cfg(package='libsystemd', args=['--cflags', '--libs'], |
| 102 | uselib_store='SYSTEMD', mandatory=False) |
Davide Pesavento | 774071c | 2018-11-15 21:33:23 -0500 | [diff] [blame] | 103 | |
Davide Pesavento | b499a60 | 2014-11-18 22:36:56 +0100 | [diff] [blame] | 104 | conf.checkDependency(name='librt', lib='rt', mandatory=False) |
| 105 | conf.checkDependency(name='libresolv', lib='resolv', mandatory=False) |
| 106 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 107 | conf.check_cxx(msg='Checking if privilege drop/elevation is supported', mandatory=False, |
| 108 | define_name='HAVE_PRIVILEGE_DROP_AND_ELEVATE', fragment=PRIVILEGE_CHECK_CODE) |
Alexander Afanasyev | 748e989 | 2015-01-28 15:07:41 -0800 | [diff] [blame] | 109 | |
Davide Pesavento | aaa5dd3 | 2016-09-02 12:33:33 +0000 | [diff] [blame] | 110 | conf.check_cxx(header_name='valgrind/valgrind.h', define_name='HAVE_VALGRIND', mandatory=False) |
Alexander Afanasyev | 49343f6 | 2015-01-26 21:58:07 -0800 | [diff] [blame] | 111 | |
Davide Pesavento | 2bdf60c | 2019-02-19 18:23:45 -0500 | [diff] [blame] | 112 | boost_libs = ['system', 'program_options', 'filesystem'] |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 113 | if conf.env.WITH_TESTS or conf.env.WITH_OTHER_TESTS: |
| 114 | boost_libs.append('unit_test_framework') |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 115 | |
Yumin Xia | ab49745 | 2016-05-10 20:23:24 +0800 | [diff] [blame] | 116 | conf.check_boost(lib=boost_libs, mt=True) |
Davide Pesavento | 5f35f64 | 2018-05-10 19:36:03 -0400 | [diff] [blame] | 117 | if conf.env.BOOST_VERSION_NUMBER < 105800: |
| 118 | conf.fatal('Minimum required Boost version is 1.58.0\n' |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 119 | 'Please upgrade your distribution or manually install a newer version of Boost' |
| 120 | ' (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)') |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 121 | |
| 122 | conf.load('unix-socket') |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 123 | |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 124 | if not conf.options.without_libpcap: |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 125 | conf.checkDependency(name='libpcap', lib='pcap', |
Davide Pesavento | 5f35f64 | 2018-05-10 19:36:03 -0400 | [diff] [blame] | 126 | errmsg='not found, but required for Ethernet face support. ' |
| 127 | 'Specify --without-libpcap to disable Ethernet face support.') |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 128 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 129 | conf.checkWebsocket() |
Davide Pesavento | 774071c | 2018-11-15 21:33:23 -0500 | [diff] [blame] | 130 | |
Alexander Afanasyev | b522070 | 2017-09-21 18:57:00 -0400 | [diff] [blame] | 131 | conf.check_compiler_flags() |
| 132 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 133 | # Loading "late" to prevent tests from being compiled with profiling flags |
Alexander Afanasyev | 689569b | 2014-02-16 20:20:07 -0800 | [diff] [blame] | 134 | conf.load('coverage') |
Eric Newberry | 27bdd1a | 2016-11-01 18:02:54 -0700 | [diff] [blame] | 135 | conf.load('sanitizers') |
| 136 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 137 | conf.define_cond('WITH_TESTS', conf.env.WITH_TESTS) |
| 138 | conf.define_cond('WITH_OTHER_TESTS', conf.env.WITH_OTHER_TESTS) |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 139 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nfd.conf' % conf.env.SYSCONFDIR) |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 140 | # The config header will contain all defines that were added using conf.define() |
| 141 | # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES |
| 142 | # will not appear in the config header, but will instead be passed directly to the |
| 143 | # compiler on the command line. |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 144 | conf.write_config_header('core/config.hpp') |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 145 | |
Junxiao Shi | 09bf7c4 | 2014-01-31 11:10:25 -0700 | [diff] [blame] | 146 | def build(bld): |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 147 | versionhpp(bld) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 148 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 149 | bld(features='subst', |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 150 | name='version.cpp', |
| 151 | source='core/version.cpp.in', |
| 152 | target='core/version.cpp', |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 153 | install_path=None, |
| 154 | VERSION_STRING=VERSION_BASE, |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 155 | VERSION_BUILD=VERSION) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 156 | |
Davide Pesavento | a314808 | 2018-04-12 18:21:54 -0400 | [diff] [blame] | 157 | bld.objects( |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 158 | target='core-objects', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 159 | features='pch', |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 160 | source=bld.path.find_node('core').ant_glob('*.cpp') + ['core/version.cpp'], |
| 161 | use='version.cpp version.hpp NDN_CXX BOOST LIBRT', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 162 | includes='.', |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 163 | export_includes='.', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 164 | headers='core/common.hpp') |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 165 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 166 | nfd_objects = bld.objects( |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 167 | target='daemon-objects', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 168 | source=bld.path.ant_glob('daemon/**/*.cpp', |
Davide Pesavento | fe0580c | 2017-05-12 02:02:10 -0400 | [diff] [blame] | 169 | excl=['daemon/face/*ethernet*.cpp', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 170 | 'daemon/face/pcap*.cpp', |
| 171 | 'daemon/face/unix*.cpp', |
| 172 | 'daemon/face/websocket*.cpp', |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 173 | 'daemon/main.cpp']), |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 174 | use='core-objects', |
Steve DiBenedetto | ef04f27 | 2014-06-04 14:28:31 -0600 | [diff] [blame] | 175 | includes='daemon', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 176 | export_includes='daemon') |
Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 177 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 178 | if bld.env.HAVE_LIBPCAP: |
Davide Pesavento | fe0580c | 2017-05-12 02:02:10 -0400 | [diff] [blame] | 179 | nfd_objects.source += bld.path.ant_glob('daemon/face/*ethernet*.cpp') |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 180 | nfd_objects.source += bld.path.ant_glob('daemon/face/pcap*.cpp') |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 181 | nfd_objects.use += ' LIBPCAP' |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 182 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 183 | if bld.env.HAVE_UNIX_SOCKETS: |
| 184 | nfd_objects.source += bld.path.ant_glob('daemon/face/unix*.cpp') |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 185 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 186 | if bld.env.HAVE_WEBSOCKET: |
| 187 | nfd_objects.source += bld.path.ant_glob('daemon/face/websocket*.cpp') |
| 188 | nfd_objects.use += ' WEBSOCKET' |
Wentao Shang | 53df163 | 2014-04-21 12:01:32 -0700 | [diff] [blame] | 189 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 190 | if bld.env.WITH_OTHER_TESTS: |
Eric Newberry | 69b63dc | 2017-11-04 15:42:46 -0700 | [diff] [blame] | 191 | nfd_objects.source += bld.path.ant_glob('tests/other/fw/*.cpp') |
| 192 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 193 | bld.program(name='nfd', |
| 194 | target='bin/nfd', |
| 195 | source='daemon/main.cpp', |
Davide Pesavento | 1b077f6 | 2019-02-19 19:19:44 -0500 | [diff] [blame] | 196 | use='daemon-objects SYSTEMD') |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 197 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 198 | bld.recurse('tools') |
| 199 | bld.recurse('tests') |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 200 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 201 | bld(features='subst', |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 202 | source='nfd.conf.sample.in', |
| 203 | target='nfd.conf.sample', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 204 | install_path='${SYSCONFDIR}/ndn', |
| 205 | IF_HAVE_LIBPCAP='' if bld.env.HAVE_LIBPCAP else '; ', |
| 206 | IF_HAVE_WEBSOCKET='' if bld.env.HAVE_WEBSOCKET else '; ') |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 207 | |
Davide Pesavento | f392b8f | 2019-01-08 20:51:55 -0500 | [diff] [blame] | 208 | bld.install_files('${SYSCONFDIR}/ndn', 'autoconfig.conf.sample') |
| 209 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 210 | if bld.env.HAVE_SYSTEMD: |
Davide Pesavento | f392b8f | 2019-01-08 20:51:55 -0500 | [diff] [blame] | 211 | systemd_units = bld.path.ant_glob('systemd/*.in') |
| 212 | bld(features='subst', |
| 213 | name='systemd-units', |
| 214 | source=systemd_units, |
| 215 | target=[u.change_ext('') for u in systemd_units]) |
| 216 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 217 | if bld.env.SPHINX_BUILD: |
| 218 | bld(features='sphinx', |
| 219 | name='manpages', |
| 220 | builder='man', |
| 221 | config='docs/conf.py', |
| 222 | outdir='docs/manpages', |
Davide Pesavento | 08b91c8 | 2019-04-13 19:42:10 -0400 | [diff] [blame] | 223 | source=bld.path.ant_glob('docs/manpages/*.rst'), |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 224 | install_path='${MANDIR}', |
Davide Pesavento | 08b91c8 | 2019-04-13 19:42:10 -0400 | [diff] [blame] | 225 | version=VERSION_BASE, |
| 226 | release=VERSION) |
Junxiao Shi | 6c13562 | 2016-11-21 14:30:33 +0000 | [diff] [blame] | 227 | bld.symlink_as('${MANDIR}/man1/nfdc-channel.1', 'nfdc-face.1') |
Junxiao Shi | 6c13562 | 2016-11-21 14:30:33 +0000 | [diff] [blame] | 228 | bld.symlink_as('${MANDIR}/man1/nfdc-fib.1', 'nfdc-route.1') |
| 229 | bld.symlink_as('${MANDIR}/man1/nfdc-register.1', 'nfdc-route.1') |
| 230 | bld.symlink_as('${MANDIR}/man1/nfdc-unregister.1', 'nfdc-route.1') |
| 231 | bld.symlink_as('${MANDIR}/man1/nfdc-set-strategy.1', 'nfdc-strategy.1') |
| 232 | bld.symlink_as('${MANDIR}/man1/nfdc-unset-strategy.1', 'nfdc-strategy.1') |
Alexander Afanasyev | 49272f7 | 2014-04-06 21:49:46 -0700 | [diff] [blame] | 233 | |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 234 | def versionhpp(bld): |
| 235 | version(bld) |
| 236 | |
| 237 | bld(features='subst', |
| 238 | name='version.hpp', |
| 239 | source='core/version.hpp.in', |
| 240 | target='core/version.hpp', |
| 241 | install_path=None, |
| 242 | VERSION=int(VERSION_SPLIT[0]) * 1000000 + |
| 243 | int(VERSION_SPLIT[1]) * 1000 + |
| 244 | int(VERSION_SPLIT[2]), |
| 245 | VERSION_MAJOR=VERSION_SPLIT[0], |
| 246 | VERSION_MINOR=VERSION_SPLIT[1], |
| 247 | VERSION_PATCH=VERSION_SPLIT[2]) |
| 248 | |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 249 | def docs(bld): |
| 250 | from waflib import Options |
| 251 | Options.commands = ['doxygen', 'sphinx'] + Options.commands |
| 252 | |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 253 | def doxygen(bld): |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 254 | versionhpp(bld) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 255 | |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 256 | if not bld.env.DOXYGEN: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 257 | bld.fatal('Cannot build documentation ("doxygen" not found in PATH)') |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 258 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 259 | bld(features='subst', |
| 260 | name='doxygen.conf', |
| 261 | source=['docs/doxygen.conf.in', |
| 262 | 'docs/named_data_theme/named_data_footer-with-analytics.html.in'], |
| 263 | target=['docs/doxygen.conf', |
| 264 | 'docs/named_data_theme/named_data_footer-with-analytics.html'], |
| 265 | VERSION=VERSION, |
| 266 | HTML_FOOTER='../build/docs/named_data_theme/named_data_footer-with-analytics.html' \ |
| 267 | if os.getenv('GOOGLE_ANALYTICS', None) \ |
| 268 | else '../docs/named_data_theme/named_data_footer.html', |
| 269 | GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', '')) |
| 270 | |
| 271 | bld(features='doxygen', |
| 272 | doxyfile='docs/doxygen.conf', |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 273 | use='doxygen.conf version.hpp') |
Alexander Afanasyev | 49272f7 | 2014-04-06 21:49:46 -0700 | [diff] [blame] | 274 | |
| 275 | def sphinx(bld): |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 276 | version(bld) |
| 277 | |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 278 | if not bld.env.SPHINX_BUILD: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 279 | bld.fatal('Cannot build documentation ("sphinx-build" not found in PATH)') |
| 280 | |
| 281 | bld(features='sphinx', |
| 282 | config='docs/conf.py', |
| 283 | outdir='docs', |
| 284 | source=bld.path.ant_glob('docs/**/*.rst'), |
Davide Pesavento | 08b91c8 | 2019-04-13 19:42:10 -0400 | [diff] [blame] | 285 | version=VERSION_BASE, |
| 286 | release=VERSION) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 287 | |
| 288 | def version(ctx): |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 289 | # don't execute more than once |
Alexander Afanasyev | 2618153 | 2014-05-07 23:38:51 -0700 | [diff] [blame] | 290 | if getattr(Context.g_module, 'VERSION_BASE', None): |
| 291 | return |
| 292 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 293 | Context.g_module.VERSION_BASE = Context.g_module.VERSION |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 294 | Context.g_module.VERSION_SPLIT = VERSION_BASE.split('.') |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 295 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 296 | # first, try to get a version string from git |
| 297 | gotVersionFromGit = False |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 298 | try: |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 299 | cmd = ['git', 'describe', '--always', '--match', '%s*' % GIT_TAG_PREFIX] |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 300 | out = subprocess.check_output(cmd, universal_newlines=True).strip() |
| 301 | if out: |
| 302 | gotVersionFromGit = True |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 303 | if out.startswith(GIT_TAG_PREFIX): |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 304 | Context.g_module.VERSION = out.lstrip(GIT_TAG_PREFIX) |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 305 | else: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 306 | # no tags matched |
| 307 | Context.g_module.VERSION = '%s-commit-%s' % (VERSION_BASE, out) |
Davide Pesavento | 5f35f64 | 2018-05-10 19:36:03 -0400 | [diff] [blame] | 308 | except (OSError, subprocess.CalledProcessError): |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 309 | pass |
| 310 | |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 311 | versionFile = ctx.path.find_node('VERSION') |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 312 | if not gotVersionFromGit and versionFile is not None: |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 313 | try: |
| 314 | Context.g_module.VERSION = versionFile.read() |
| 315 | return |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 316 | except EnvironmentError: |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 317 | pass |
| 318 | |
| 319 | # version was obtained from git, update VERSION file if necessary |
| 320 | if versionFile is not None: |
| 321 | try: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 322 | if versionFile.read() == Context.g_module.VERSION: |
| 323 | # already up-to-date |
| 324 | return |
| 325 | except EnvironmentError as e: |
| 326 | Logs.warn('%s exists but is not readable (%s)' % (versionFile, e.strerror)) |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 327 | else: |
| 328 | versionFile = ctx.path.make_node('VERSION') |
| 329 | |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 330 | try: |
| 331 | versionFile.write(Context.g_module.VERSION) |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 332 | except EnvironmentError as e: |
| 333 | Logs.warn('%s is not writable (%s)' % (versionFile, e.strerror)) |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 334 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 335 | def dist(ctx): |
| 336 | version(ctx) |
| 337 | |
| 338 | def distcheck(ctx): |
| 339 | version(ctx) |