blob: 1357ce8309c4aac014b7c5488395b872c9d34cbb [file] [log] [blame]
Alexander Afanasyev2aa39622014-01-22 11:51:11 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -07002"""
Davide Pesaventof392b8f2019-01-08 20:51:55 -05003Copyright (c) 2014-2019, Regents of the University of California,
taylorchu5ae28772015-03-08 17:45:52 -07004 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 Afanasyev9bcbc7c2014-04-06 19:37:37 -070010
11This file is part of NFD (Named Data Networking Forwarding Daemon).
12See AUTHORS.md for complete list of NFD authors and contributors.
13
14NFD is free software: you can redistribute it and/or modify it under the terms
15of the GNU General Public License as published by the Free Software Foundation,
16either version 3 of the License, or (at your option) any later version.
17
18NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20PURPOSE. See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License along with
23NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24"""
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080025
Davide Pesavento0064c1d2018-03-03 18:43:53 -050026from waflib import Context, Logs, Utils
27import os, subprocess
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070028
Alexander Afanasyev65c494a2019-04-25 18:00:44 -040029VERSION = '0.6.6'
Davide Pesavento0064c1d2018-03-03 18:43:53 -050030APPNAME = 'nfd'
31BUGREPORT = 'https://redmine.named-data.net/projects/nfd'
32URL = 'https://named-data.net/doc/NFD/'
33GIT_TAG_PREFIX = 'NFD-'
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080034
35def options(opt):
Alexander Afanasyev5cda2e02014-04-11 13:58:44 -070036 opt.load(['compiler_cxx', 'gnu_dirs'])
Davide Pesavento5f35f642018-05-10 19:36:03 -040037 opt.load(['default-compiler-flags', 'compiler-features',
38 'coverage', 'pch', 'sanitizers', 'boost',
Davide Pesavento67f30272016-08-10 01:55:16 +000039 'dependency-checker', 'unix-socket', 'websocket',
40 'doxygen', 'sphinx_build'],
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070041 tooldir=['.waf-tools'])
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080042
43 nfdopt = opt.add_option_group('NFD Options')
Davide Pesavento67f30272016-08-10 01:55:16 +000044
Davide Pesavento774071c2018-11-15 21:33:23 -050045 opt.addUnixOptions(nfdopt)
46 opt.addDependencyOptions(nfdopt, 'libresolv')
47 opt.addDependencyOptions(nfdopt, 'librt')
Alexander Afanasyev885a85b2014-04-12 21:01:13 -070048 opt.addDependencyOptions(nfdopt, 'libpcap')
49 nfdopt.add_option('--without-libpcap', action='store_true', default=False,
Davide Pesavento0064c1d2018-03-03 18:43:53 -050050 help='Disable libpcap (Ethernet face support will be disabled)')
Davide Pesavento774071c2018-11-15 21:33:23 -050051 nfdopt.add_option('--without-systemd', action='store_true', default=False,
52 help='Disable systemd integration')
53 opt.addWebsocketOptions(nfdopt)
Alexander Afanasyev5cda2e02014-04-11 13:58:44 -070054
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070055 nfdopt.add_option('--with-tests', action='store_true', default=False,
Davide Pesavento0064c1d2018-03-03 18:43:53 -050056 help='Build unit tests')
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040057 nfdopt.add_option('--with-other-tests', action='store_true', default=False,
Davide Pesavento0064c1d2018-03-03 18:43:53 -050058 help='Build other tests')
Steve DiBenedetto84da5bf2014-03-11 14:51:29 -060059
Davide Pesavento0064c1d2018-03-03 18:43:53 -050060PRIVILEGE_CHECK_CODE = '''
61#include <unistd.h>
62#include <grp.h>
63#include <pwd.h>
64int 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 Afanasyev8269a052015-02-09 16:25:36 -080084
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080085def configure(conf):
Beichuan Zhang55b8ed42014-04-26 22:25:44 -070086 conf.load(['compiler_cxx', 'gnu_dirs',
Davide Pesavento5f35f642018-05-10 19:36:03 -040087 'default-compiler-flags', 'compiler-features',
88 'pch', 'boost', 'dependency-checker', 'websocket',
Davide Pesavento67f30272016-08-10 01:55:16 +000089 'doxygen', 'sphinx_build'])
Alexander Afanasyevefea8fe2014-03-23 00:00:35 -070090
Davide Pesavento6ecc3f82019-02-17 22:23:08 -050091 conf.env.WITH_TESTS = conf.options.with_tests
92 conf.env.WITH_OTHER_TESTS = conf.options.with_other_tests
Davide Pesavento774071c2018-11-15 21:33:23 -050093
Davide Pesaventof0ae4422014-05-05 16:32:12 +020094 conf.find_program('bash', var='BASH')
95
Davide Pesaventof7d20502019-11-07 10:48:44 -050096 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDN_CXX',
97 pkg_config_path=os.environ.get('PKG_CONFIG_PATH', '%s/pkgconfig' % conf.env.LIBDIR))
Davide Pesavento44deacc2014-02-19 10:48:07 +010098
Davide Pesavento6ecc3f82019-02-17 22:23:08 -050099 if not conf.options.without_systemd:
100 conf.check_cfg(package='libsystemd', args=['--cflags', '--libs'],
101 uselib_store='SYSTEMD', mandatory=False)
Davide Pesavento774071c2018-11-15 21:33:23 -0500102
Davide Pesaventob499a602014-11-18 22:36:56 +0100103 conf.checkDependency(name='librt', lib='rt', mandatory=False)
104 conf.checkDependency(name='libresolv', lib='resolv', mandatory=False)
105
Davide Pesavento6ecc3f82019-02-17 22:23:08 -0500106 conf.check_cxx(msg='Checking if privilege drop/elevation is supported', mandatory=False,
107 define_name='HAVE_PRIVILEGE_DROP_AND_ELEVATE', fragment=PRIVILEGE_CHECK_CODE)
Alexander Afanasyev748e9892015-01-28 15:07:41 -0800108
Davide Pesaventoaaa5dd32016-09-02 12:33:33 +0000109 conf.check_cxx(header_name='valgrind/valgrind.h', define_name='HAVE_VALGRIND', mandatory=False)
Alexander Afanasyev49343f62015-01-26 21:58:07 -0800110
Davide Pesavento2bdf60c2019-02-19 18:23:45 -0500111 boost_libs = ['system', 'program_options', 'filesystem']
Davide Pesavento6ecc3f82019-02-17 22:23:08 -0500112 if conf.env.WITH_TESTS or conf.env.WITH_OTHER_TESTS:
113 boost_libs.append('unit_test_framework')
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400114
Yumin Xiaab497452016-05-10 20:23:24 +0800115 conf.check_boost(lib=boost_libs, mt=True)
Davide Pesavento5f35f642018-05-10 19:36:03 -0400116 if conf.env.BOOST_VERSION_NUMBER < 105800:
117 conf.fatal('Minimum required Boost version is 1.58.0\n'
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500118 'Please upgrade your distribution or manually install a newer version of Boost'
119 ' (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)')
Alexander Afanasyevc78b1412014-02-19 14:08:26 -0800120
121 conf.load('unix-socket')
Davide Pesavento44deacc2014-02-19 10:48:07 +0100122
Alexander Afanasyev885a85b2014-04-12 21:01:13 -0700123 if not conf.options.without_libpcap:
Davide Pesavento6ecc3f82019-02-17 22:23:08 -0500124 conf.checkDependency(name='libpcap', lib='pcap',
Davide Pesavento5f35f642018-05-10 19:36:03 -0400125 errmsg='not found, but required for Ethernet face support. '
126 'Specify --without-libpcap to disable Ethernet face support.')
Alexander Afanasyevefea8fe2014-03-23 00:00:35 -0700127
Davide Pesavento6ecc3f82019-02-17 22:23:08 -0500128 conf.checkWebsocket()
Davide Pesavento774071c2018-11-15 21:33:23 -0500129
Alexander Afanasyevb5220702017-09-21 18:57:00 -0400130 conf.check_compiler_flags()
131
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500132 # Loading "late" to prevent tests from being compiled with profiling flags
Alexander Afanasyev689569b2014-02-16 20:20:07 -0800133 conf.load('coverage')
Eric Newberry27bdd1a2016-11-01 18:02:54 -0700134 conf.load('sanitizers')
135
Davide Pesavento6ecc3f82019-02-17 22:23:08 -0500136 conf.define_cond('WITH_TESTS', conf.env.WITH_TESTS)
137 conf.define_cond('WITH_OTHER_TESTS', conf.env.WITH_OTHER_TESTS)
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500138 conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nfd.conf' % conf.env.SYSCONFDIR)
Davide Pesavento6ecc3f82019-02-17 22:23:08 -0500139 # The config header will contain all defines that were added using conf.define()
140 # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
141 # will not appear in the config header, but will instead be passed directly to the
142 # compiler on the command line.
Junxiao Shi9f5b01d2016-08-05 03:54:28 +0000143 conf.write_config_header('core/config.hpp')
Alexander Afanasyev2aa39622014-01-22 11:51:11 -0800144
Junxiao Shi09bf7c42014-01-31 11:10:25 -0700145def build(bld):
Davide Pesavento03f45d22019-04-04 12:34:26 -0400146 versionhpp(bld)
Alexander Afanasyevb47d5382014-05-05 14:35:03 -0700147
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500148 bld(features='subst',
Davide Pesavento03f45d22019-04-04 12:34:26 -0400149 name='version.cpp',
150 source='core/version.cpp.in',
151 target='core/version.cpp',
Alexander Afanasyevb47d5382014-05-05 14:35:03 -0700152 install_path=None,
153 VERSION_STRING=VERSION_BASE,
Davide Pesavento03f45d22019-04-04 12:34:26 -0400154 VERSION_BUILD=VERSION)
Alexander Afanasyevb47d5382014-05-05 14:35:03 -0700155
Davide Pesaventoa3148082018-04-12 18:21:54 -0400156 bld.objects(
Alexander Afanasyev613e2a92014-04-15 13:36:58 -0700157 target='core-objects',
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500158 features='pch',
Davide Pesavento03f45d22019-04-04 12:34:26 -0400159 source=bld.path.find_node('core').ant_glob('*.cpp') + ['core/version.cpp'],
160 use='version.cpp version.hpp NDN_CXX BOOST LIBRT',
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500161 includes='.',
Junxiao Shi9f5b01d2016-08-05 03:54:28 +0000162 export_includes='.',
Davide Pesavento67f30272016-08-10 01:55:16 +0000163 headers='core/common.hpp')
Alexander Afanasyev613e2a92014-04-15 13:36:58 -0700164
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500165 nfd_objects = bld.objects(
Alexander Afanasyev613e2a92014-04-15 13:36:58 -0700166 target='daemon-objects',
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500167 source=bld.path.ant_glob('daemon/**/*.cpp',
Davide Pesaventofe0580c2017-05-12 02:02:10 -0400168 excl=['daemon/face/*ethernet*.cpp',
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500169 'daemon/face/pcap*.cpp',
170 'daemon/face/unix*.cpp',
171 'daemon/face/websocket*.cpp',
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -0700172 'daemon/main.cpp']),
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500173 use='core-objects',
Steve DiBenedettoef04f272014-06-04 14:28:31 -0600174 includes='daemon',
Davide Pesavento67f30272016-08-10 01:55:16 +0000175 export_includes='daemon')
Junxiao Shi0fcb41e2014-01-24 10:29:43 -0700176
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500177 if bld.env.HAVE_LIBPCAP:
Davide Pesaventofe0580c2017-05-12 02:02:10 -0400178 nfd_objects.source += bld.path.ant_glob('daemon/face/*ethernet*.cpp')
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500179 nfd_objects.source += bld.path.ant_glob('daemon/face/pcap*.cpp')
Alexander Afanasyev5cda2e02014-04-11 13:58:44 -0700180 nfd_objects.use += ' LIBPCAP'
Davide Pesavento44deacc2014-02-19 10:48:07 +0100181
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500182 if bld.env.HAVE_UNIX_SOCKETS:
183 nfd_objects.source += bld.path.ant_glob('daemon/face/unix*.cpp')
Alexander Afanasyevc78b1412014-02-19 14:08:26 -0800184
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500185 if bld.env.HAVE_WEBSOCKET:
186 nfd_objects.source += bld.path.ant_glob('daemon/face/websocket*.cpp')
187 nfd_objects.use += ' WEBSOCKET'
Wentao Shang53df1632014-04-21 12:01:32 -0700188
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500189 if bld.env.WITH_OTHER_TESTS:
Eric Newberry69b63dc2017-11-04 15:42:46 -0700190 nfd_objects.source += bld.path.ant_glob('tests/other/fw/*.cpp')
191
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500192 bld.program(name='nfd',
193 target='bin/nfd',
194 source='daemon/main.cpp',
Davide Pesavento1b077f62019-02-19 19:19:44 -0500195 use='daemon-objects SYSTEMD')
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700196
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500197 bld.recurse('tools')
198 bld.recurse('tests')
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400199
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500200 bld(features='subst',
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -0700201 source='nfd.conf.sample.in',
202 target='nfd.conf.sample',
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500203 install_path='${SYSCONFDIR}/ndn',
204 IF_HAVE_LIBPCAP='' if bld.env.HAVE_LIBPCAP else '; ',
205 IF_HAVE_WEBSOCKET='' if bld.env.HAVE_WEBSOCKET else '; ')
Alexander Afanasyev35fc2b72014-02-13 16:56:21 -0800206
Davide Pesaventof392b8f2019-01-08 20:51:55 -0500207 bld.install_files('${SYSCONFDIR}/ndn', 'autoconfig.conf.sample')
208
Davide Pesavento6ecc3f82019-02-17 22:23:08 -0500209 if bld.env.HAVE_SYSTEMD:
Davide Pesaventof392b8f2019-01-08 20:51:55 -0500210 systemd_units = bld.path.ant_glob('systemd/*.in')
211 bld(features='subst',
212 name='systemd-units',
213 source=systemd_units,
214 target=[u.change_ext('') for u in systemd_units])
215
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500216 if bld.env.SPHINX_BUILD:
217 bld(features='sphinx',
218 name='manpages',
219 builder='man',
220 config='docs/conf.py',
221 outdir='docs/manpages',
Davide Pesavento08b91c82019-04-13 19:42:10 -0400222 source=bld.path.ant_glob('docs/manpages/*.rst'),
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500223 install_path='${MANDIR}',
Davide Pesavento08b91c82019-04-13 19:42:10 -0400224 version=VERSION_BASE,
225 release=VERSION)
Junxiao Shi6c135622016-11-21 14:30:33 +0000226 bld.symlink_as('${MANDIR}/man1/nfdc-channel.1', 'nfdc-face.1')
Junxiao Shi6c135622016-11-21 14:30:33 +0000227 bld.symlink_as('${MANDIR}/man1/nfdc-fib.1', 'nfdc-route.1')
228 bld.symlink_as('${MANDIR}/man1/nfdc-register.1', 'nfdc-route.1')
229 bld.symlink_as('${MANDIR}/man1/nfdc-unregister.1', 'nfdc-route.1')
230 bld.symlink_as('${MANDIR}/man1/nfdc-set-strategy.1', 'nfdc-strategy.1')
231 bld.symlink_as('${MANDIR}/man1/nfdc-unset-strategy.1', 'nfdc-strategy.1')
Alexander Afanasyev49272f72014-04-06 21:49:46 -0700232
Davide Pesavento03f45d22019-04-04 12:34:26 -0400233def versionhpp(bld):
234 version(bld)
235
236 bld(features='subst',
237 name='version.hpp',
238 source='core/version.hpp.in',
239 target='core/version.hpp',
240 install_path=None,
241 VERSION=int(VERSION_SPLIT[0]) * 1000000 +
242 int(VERSION_SPLIT[1]) * 1000 +
243 int(VERSION_SPLIT[2]),
244 VERSION_MAJOR=VERSION_SPLIT[0],
245 VERSION_MINOR=VERSION_SPLIT[1],
246 VERSION_PATCH=VERSION_SPLIT[2])
247
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700248def docs(bld):
249 from waflib import Options
250 Options.commands = ['doxygen', 'sphinx'] + Options.commands
251
Alexander Afanasyev35fc2b72014-02-13 16:56:21 -0800252def doxygen(bld):
Davide Pesavento03f45d22019-04-04 12:34:26 -0400253 versionhpp(bld)
Alexander Afanasyevb47d5382014-05-05 14:35:03 -0700254
Alexander Afanasyev35fc2b72014-02-13 16:56:21 -0800255 if not bld.env.DOXYGEN:
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500256 bld.fatal('Cannot build documentation ("doxygen" not found in PATH)')
Beichuan Zhang55b8ed42014-04-26 22:25:44 -0700257
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500258 bld(features='subst',
259 name='doxygen.conf',
260 source=['docs/doxygen.conf.in',
261 'docs/named_data_theme/named_data_footer-with-analytics.html.in'],
262 target=['docs/doxygen.conf',
263 'docs/named_data_theme/named_data_footer-with-analytics.html'],
264 VERSION=VERSION,
265 HTML_FOOTER='../build/docs/named_data_theme/named_data_footer-with-analytics.html' \
266 if os.getenv('GOOGLE_ANALYTICS', None) \
267 else '../docs/named_data_theme/named_data_footer.html',
268 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ''))
269
270 bld(features='doxygen',
271 doxyfile='docs/doxygen.conf',
Davide Pesavento03f45d22019-04-04 12:34:26 -0400272 use='doxygen.conf version.hpp')
Alexander Afanasyev49272f72014-04-06 21:49:46 -0700273
274def sphinx(bld):
Alexander Afanasyevb47d5382014-05-05 14:35:03 -0700275 version(bld)
276
Beichuan Zhang55b8ed42014-04-26 22:25:44 -0700277 if not bld.env.SPHINX_BUILD:
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500278 bld.fatal('Cannot build documentation ("sphinx-build" not found in PATH)')
279
280 bld(features='sphinx',
281 config='docs/conf.py',
282 outdir='docs',
283 source=bld.path.ant_glob('docs/**/*.rst'),
Davide Pesavento08b91c82019-04-13 19:42:10 -0400284 version=VERSION_BASE,
285 release=VERSION)
Alexander Afanasyevb47d5382014-05-05 14:35:03 -0700286
287def version(ctx):
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500288 # don't execute more than once
Alexander Afanasyev26181532014-05-07 23:38:51 -0700289 if getattr(Context.g_module, 'VERSION_BASE', None):
290 return
291
Alexander Afanasyevb47d5382014-05-05 14:35:03 -0700292 Context.g_module.VERSION_BASE = Context.g_module.VERSION
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500293 Context.g_module.VERSION_SPLIT = VERSION_BASE.split('.')
Alexander Afanasyevb47d5382014-05-05 14:35:03 -0700294
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500295 # first, try to get a version string from git
296 gotVersionFromGit = False
Alexander Afanasyevb47d5382014-05-05 14:35:03 -0700297 try:
Alexander Afanasyev48f5a3c2014-08-22 22:33:01 -0700298 cmd = ['git', 'describe', '--always', '--match', '%s*' % GIT_TAG_PREFIX]
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500299 out = subprocess.check_output(cmd, universal_newlines=True).strip()
300 if out:
301 gotVersionFromGit = True
Alexander Afanasyev48f5a3c2014-08-22 22:33:01 -0700302 if out.startswith(GIT_TAG_PREFIX):
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500303 Context.g_module.VERSION = out.lstrip(GIT_TAG_PREFIX)
Alexander Afanasyev48f5a3c2014-08-22 22:33:01 -0700304 else:
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500305 # no tags matched
306 Context.g_module.VERSION = '%s-commit-%s' % (VERSION_BASE, out)
Davide Pesavento5f35f642018-05-10 19:36:03 -0400307 except (OSError, subprocess.CalledProcessError):
Alexander Afanasyevb47d5382014-05-05 14:35:03 -0700308 pass
309
Alexander Afanasyev48f5a3c2014-08-22 22:33:01 -0700310 versionFile = ctx.path.find_node('VERSION')
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500311 if not gotVersionFromGit and versionFile is not None:
Alexander Afanasyev48f5a3c2014-08-22 22:33:01 -0700312 try:
313 Context.g_module.VERSION = versionFile.read()
314 return
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500315 except EnvironmentError:
Alexander Afanasyev48f5a3c2014-08-22 22:33:01 -0700316 pass
317
318 # version was obtained from git, update VERSION file if necessary
319 if versionFile is not None:
320 try:
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500321 if versionFile.read() == Context.g_module.VERSION:
322 # already up-to-date
323 return
324 except EnvironmentError as e:
325 Logs.warn('%s exists but is not readable (%s)' % (versionFile, e.strerror))
Alexander Afanasyev48f5a3c2014-08-22 22:33:01 -0700326 else:
327 versionFile = ctx.path.make_node('VERSION')
328
Alexander Afanasyev48f5a3c2014-08-22 22:33:01 -0700329 try:
330 versionFile.write(Context.g_module.VERSION)
Davide Pesavento0064c1d2018-03-03 18:43:53 -0500331 except EnvironmentError as e:
332 Logs.warn('%s is not writable (%s)' % (versionFile, e.strerror))
Alexander Afanasyev48f5a3c2014-08-22 22:33:01 -0700333
Alexander Afanasyevb47d5382014-05-05 14:35:03 -0700334def dist(ctx):
335 version(ctx)
336
337def distcheck(ctx):
338 version(ctx)