akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 2 | """ |
Davide Pesavento | 5a1d77a | 2024-03-13 19:24:11 -0400 | [diff] [blame] | 3 | Copyright (c) 2014-2024, The University of Memphis, |
Vince Lehman | c2e51f6 | 2015-01-20 15:03:11 -0600 | [diff] [blame] | 4 | Regents of the University of California, |
| 5 | Arizona Board of Regents. |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 6 | |
| 7 | This file is part of NLSR (Named-data Link State Routing). |
| 8 | See AUTHORS.md for complete list of NLSR authors and contributors. |
| 9 | |
| 10 | NLSR is free software: you can redistribute it and/or modify it under the terms |
| 11 | of the GNU General Public License as published by the Free Software Foundation, |
| 12 | either version 3 of the License, or (at your option) any later version. |
| 13 | |
| 14 | NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 15 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | PURPOSE. See the GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License along with |
| 19 | NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 20 | """ |
| 21 | |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 22 | import os |
| 23 | import subprocess |
Davide Pesavento | f75bfda | 2019-11-10 18:34:13 -0500 | [diff] [blame] | 24 | from waflib import Context, Logs, Utils |
Davide Pesavento | f75bfda | 2019-11-10 18:34:13 -0500 | [diff] [blame] | 25 | |
Saurab Dulal | ecb0b71 | 2023-08-18 01:48:54 +0000 | [diff] [blame] | 26 | VERSION = '0.7.0' |
Davide Pesavento | fa54ee9 | 2023-02-20 04:16:51 -0500 | [diff] [blame] | 27 | APPNAME = 'nlsr' |
| 28 | GIT_TAG_PREFIX = 'NLSR-' |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 29 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 30 | def options(opt): |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 31 | opt.load(['compiler_cxx', 'gnu_dirs']) |
Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 32 | opt.load(['default-compiler-flags', |
| 33 | 'coverage', 'sanitizers', 'boost', |
Davide Pesavento | 5a1d77a | 2024-03-13 19:24:11 -0400 | [diff] [blame] | 34 | 'doxygen', 'sphinx'], |
Davide Pesavento | e556991 | 2019-01-29 19:39:06 -0500 | [diff] [blame] | 35 | tooldir=['.waf-tools']) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 36 | |
Davide Pesavento | f75bfda | 2019-11-10 18:34:13 -0500 | [diff] [blame] | 37 | optgrp = opt.add_option_group('NLSR Options') |
Varun Patil | 7d2d689 | 2022-10-14 12:50:30 -0700 | [diff] [blame] | 38 | |
| 39 | optgrp.add_option('--with-chronosync', dest='with_chronosync', action='store_true', default=False, |
Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 40 | help='Build with ChronoSync support') |
Varun Patil | 7d2d689 | 2022-10-14 12:50:30 -0700 | [diff] [blame] | 41 | optgrp.add_option('--without-chronosync', dest='with_chronosync', action='store_false', default=False, |
| 42 | help='Build without ChronoSync support') |
| 43 | |
| 44 | optgrp.add_option('--with-psync', dest='with_psync', action='store_true', default=True, |
| 45 | help='Build with PSync support') |
| 46 | optgrp.add_option('--without-psync', dest='with_psync', action='store_false', default=True, |
| 47 | help='Build without PSync support') |
| 48 | |
| 49 | optgrp.add_option('--with-svs', dest='with_svs', action='store_true', default=False, |
| 50 | help='Build with State Vector Sync support') |
| 51 | optgrp.add_option('--without-svs', dest='with_svs', action='store_false', default=False, |
| 52 | help='Build without State Vector Sync support') |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 53 | |
Davide Pesavento | fcef058 | 2022-12-06 15:00:02 -0500 | [diff] [blame] | 54 | optgrp.add_option('--with-tests', action='store_true', default=False, |
| 55 | help='Build unit tests') |
| 56 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 57 | def configure(conf): |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 58 | conf.load(['compiler_cxx', 'gnu_dirs', |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 59 | 'default-compiler-flags', 'boost', |
Davide Pesavento | 5a1d77a | 2024-03-13 19:24:11 -0400 | [diff] [blame] | 60 | 'doxygen', 'sphinx']) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 61 | |
Davide Pesavento | f75bfda | 2019-11-10 18:34:13 -0500 | [diff] [blame] | 62 | conf.env.WITH_TESTS = conf.options.with_tests |
Alexander Afanasyev | fb2adee | 2015-03-30 10:56:55 -0700 | [diff] [blame] | 63 | |
Davide Pesavento | ede5963 | 2022-08-26 20:35:44 -0400 | [diff] [blame] | 64 | conf.find_program('dot', mandatory=False) |
| 65 | |
| 66 | # Prefer pkgconf if it's installed, because it gives more correct results |
| 67 | # on Fedora/CentOS/RHEL/etc. See https://bugzilla.redhat.com/show_bug.cgi?id=1953348 |
| 68 | # Store the result in env.PKGCONFIG, which is the variable used inside check_cfg() |
| 69 | conf.find_program(['pkgconf', 'pkg-config'], var='PKGCONFIG') |
Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 70 | |
Davide Pesavento | d1f1df8 | 2022-03-12 16:40:37 -0500 | [diff] [blame] | 71 | pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig') |
Davide Pesavento | 1e9faf1 | 2023-01-21 16:04:50 -0500 | [diff] [blame] | 72 | conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.1', '--cflags', '--libs'], |
Davide Pesavento | d1f1df8 | 2022-03-12 16:40:37 -0500 | [diff] [blame] | 73 | uselib_store='NDN_CXX', pkg_config_path=pkg_config_path) |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 74 | |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 75 | conf.check_boost(lib='filesystem', mt=True) |
| 76 | if conf.env.BOOST_VERSION_NUMBER < 107100: |
| 77 | conf.fatal('The minimum supported version of Boost is 1.71.0.\n' |
Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 78 | 'Please upgrade your distribution or manually install a newer version of Boost.\n' |
| 79 | 'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost') |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 80 | |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 81 | if conf.env.WITH_TESTS: |
| 82 | conf.check_boost(lib='unit_test_framework', mt=True, uselib_store='BOOST_TESTS') |
| 83 | |
Ashlesh Gawande | 30d96e4 | 2021-03-21 19:15:33 -0700 | [diff] [blame] | 84 | if conf.options.with_chronosync: |
Davide Pesavento | 1e9faf1 | 2023-01-21 16:04:50 -0500 | [diff] [blame] | 85 | conf.check_cfg(package='ChronoSync', args=['ChronoSync >= 0.5.5', '--cflags', '--libs'], |
Ashlesh Gawande | 30d96e4 | 2021-03-21 19:15:33 -0700 | [diff] [blame] | 86 | uselib_store='CHRONOSYNC', pkg_config_path=pkg_config_path) |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 87 | |
Varun Patil | 7d2d689 | 2022-10-14 12:50:30 -0700 | [diff] [blame] | 88 | if conf.options.with_psync: |
Davide Pesavento | 1e9faf1 | 2023-01-21 16:04:50 -0500 | [diff] [blame] | 89 | conf.check_cfg(package='PSync', args=['PSync >= 0.4.0', '--cflags', '--libs'], |
Varun Patil | 7d2d689 | 2022-10-14 12:50:30 -0700 | [diff] [blame] | 90 | uselib_store='PSYNC', pkg_config_path=pkg_config_path) |
| 91 | |
| 92 | if conf.options.with_svs: |
| 93 | conf.check_cfg(package='libndn-svs', args=['libndn-svs >= 0.1.0', '--cflags', '--libs'], |
| 94 | uselib_store='SVS', pkg_config_path=pkg_config_path) |
| 95 | |
| 96 | if not any((conf.options.with_chronosync, conf.options.with_psync, conf.options.with_svs)): |
| 97 | conf.fatal('Cannot compile without any Sync protocol. ' |
| 98 | 'Specify at least one of --with-psync or --with-svs or --with-chronosync') |
Ashlesh Gawande | 32ec3fd | 2018-07-18 13:42:32 -0500 | [diff] [blame] | 99 | |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 100 | conf.check_compiler_flags() |
| 101 | |
Davide Pesavento | e556991 | 2019-01-29 19:39:06 -0500 | [diff] [blame] | 102 | # Loading "late" to prevent tests from being compiled with profiling flags |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 103 | conf.load('coverage') |
Davide Pesavento | c58cc7f | 2017-08-08 16:51:28 -0500 | [diff] [blame] | 104 | conf.load('sanitizers') |
| 105 | |
Davide Pesavento | f75bfda | 2019-11-10 18:34:13 -0500 | [diff] [blame] | 106 | conf.define_cond('WITH_TESTS', conf.env.WITH_TESTS) |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 107 | conf.define('DEFAULT_CONFIG_FILE', f'{conf.env.SYSCONFDIR}/ndn/nlsr.conf') |
Davide Pesavento | f75bfda | 2019-11-10 18:34:13 -0500 | [diff] [blame] | 108 | # The config header will contain all defines that were added using conf.define() |
| 109 | # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES |
| 110 | # will not appear in the config header, but will instead be passed directly to the |
| 111 | # compiler on the command line. |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 112 | conf.write_config_header('config.hpp') |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 113 | |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 114 | def build(bld): |
| 115 | version(bld) |
| 116 | |
Davide Pesavento | e556991 | 2019-01-29 19:39:06 -0500 | [diff] [blame] | 117 | bld(features='subst', |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 118 | name='version.hpp', |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 119 | source='src/version.hpp.in', |
| 120 | target='src/version.hpp', |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 121 | install_path=None, |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 122 | VERSION_STRING=VERSION_BASE, |
| 123 | VERSION_BUILD=VERSION, |
| 124 | VERSION=int(VERSION_SPLIT[0]) * 1000000 + |
| 125 | int(VERSION_SPLIT[1]) * 1000 + |
| 126 | int(VERSION_SPLIT[2]), |
| 127 | VERSION_MAJOR=VERSION_SPLIT[0], |
| 128 | VERSION_MINOR=VERSION_SPLIT[1], |
Davide Pesavento | c58cc7f | 2017-08-08 16:51:28 -0500 | [diff] [blame] | 129 | VERSION_PATCH=VERSION_SPLIT[2]) |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 130 | |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 131 | bld.objects( |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 132 | target='nlsr-objects', |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 133 | source=bld.path.ant_glob('src/**/*.cpp', excl=['src/main.cpp']), |
| 134 | use='BOOST NDN_CXX CHRONOSYNC PSYNC SVS', |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 135 | includes='. src', |
Davide Pesavento | c58cc7f | 2017-08-08 16:51:28 -0500 | [diff] [blame] | 136 | export_includes='. src') |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 137 | |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 138 | bld.program( |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 139 | name='nlsr', |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 140 | target='bin/nlsr', |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 141 | source='src/main.cpp', |
Davide Pesavento | c58cc7f | 2017-08-08 16:51:28 -0500 | [diff] [blame] | 142 | use='nlsr-objects') |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 143 | |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 144 | bld.program( |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 145 | name='nlsrc', |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 146 | target='bin/nlsrc', |
Vince Lehman | c439d66 | 2015-04-27 10:56:00 -0500 | [diff] [blame] | 147 | source='tools/nlsrc.cpp', |
Davide Pesavento | e556991 | 2019-01-29 19:39:06 -0500 | [diff] [blame] | 148 | use='nlsr-objects') |
Vince Lehman | c439d66 | 2015-04-27 10:56:00 -0500 | [diff] [blame] | 149 | |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 150 | if bld.env.WITH_TESTS: |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 151 | bld.recurse('tests') |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 152 | |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 153 | # Install sample config |
Davide Pesavento | 0da3eab | 2019-01-31 01:10:00 -0500 | [diff] [blame] | 154 | bld.install_as('${SYSCONFDIR}/ndn/nlsr.conf.sample', 'nlsr.conf') |
| 155 | |
| 156 | if Utils.unversioned_sys_platform() == 'linux': |
| 157 | bld(features='subst', |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 158 | name='systemd-units', |
Davide Pesavento | 0da3eab | 2019-01-31 01:10:00 -0500 | [diff] [blame] | 159 | source='systemd/nlsr.service.in', |
| 160 | target='systemd/nlsr.service') |
| 161 | |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 162 | if bld.env.SPHINX_BUILD: |
| 163 | bld(features='sphinx', |
| 164 | name='manpages', |
| 165 | builder='man', |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 166 | config='docs/conf.py', |
Davide Pesavento | 0da3eab | 2019-01-31 01:10:00 -0500 | [diff] [blame] | 167 | outdir='docs/manpages', |
Davide Pesavento | f75bfda | 2019-11-10 18:34:13 -0500 | [diff] [blame] | 168 | source=bld.path.ant_glob('docs/manpages/*.rst'), |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 169 | install_path='${MANDIR}', |
Davide Pesavento | f75bfda | 2019-11-10 18:34:13 -0500 | [diff] [blame] | 170 | version=VERSION_BASE, |
| 171 | release=VERSION) |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 172 | |
| 173 | def docs(bld): |
| 174 | from waflib import Options |
| 175 | Options.commands = ['doxygen', 'sphinx'] + Options.commands |
| 176 | |
| 177 | def doxygen(bld): |
| 178 | version(bld) |
| 179 | |
| 180 | if not bld.env.DOXYGEN: |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 181 | bld.fatal('Cannot build documentation ("doxygen" not found in PATH)') |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 182 | |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 183 | bld(features='subst', |
| 184 | name='doxygen.conf', |
| 185 | source=['docs/doxygen.conf.in', |
| 186 | 'docs/named_data_theme/named_data_footer-with-analytics.html.in'], |
| 187 | target=['docs/doxygen.conf', |
| 188 | 'docs/named_data_theme/named_data_footer-with-analytics.html'], |
| 189 | VERSION=VERSION, |
Davide Pesavento | 7ae8b08 | 2021-10-12 21:45:47 -0400 | [diff] [blame] | 190 | HAVE_DOT='YES' if bld.env.DOT else 'NO', |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 191 | HTML_FOOTER='../build/docs/named_data_theme/named_data_footer-with-analytics.html' \ |
| 192 | if os.getenv('GOOGLE_ANALYTICS', None) \ |
| 193 | else '../docs/named_data_theme/named_data_footer.html', |
| 194 | GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', '')) |
| 195 | |
| 196 | bld(features='doxygen', |
| 197 | doxyfile='docs/doxygen.conf', |
| 198 | use='doxygen.conf') |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 199 | |
| 200 | def sphinx(bld): |
| 201 | version(bld) |
| 202 | |
| 203 | if not bld.env.SPHINX_BUILD: |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 204 | bld.fatal('Cannot build documentation ("sphinx-build" not found in PATH)') |
| 205 | |
| 206 | bld(features='sphinx', |
| 207 | config='docs/conf.py', |
| 208 | outdir='docs', |
| 209 | source=bld.path.ant_glob('docs/**/*.rst'), |
Davide Pesavento | f75bfda | 2019-11-10 18:34:13 -0500 | [diff] [blame] | 210 | version=VERSION_BASE, |
| 211 | release=VERSION) |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 212 | |
| 213 | def version(ctx): |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 214 | # don't execute more than once |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 215 | if getattr(Context.g_module, 'VERSION_BASE', None): |
| 216 | return |
| 217 | |
| 218 | Context.g_module.VERSION_BASE = Context.g_module.VERSION |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 219 | Context.g_module.VERSION_SPLIT = VERSION_BASE.split('.') |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 220 | |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 221 | # first, try to get a version string from git |
| 222 | gotVersionFromGit = False |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 223 | try: |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 224 | cmd = ['git', 'describe', '--always', '--match', f'{GIT_TAG_PREFIX}*'] |
| 225 | out = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip() |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 226 | if out: |
| 227 | gotVersionFromGit = True |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 228 | if out.startswith(GIT_TAG_PREFIX): |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 229 | Context.g_module.VERSION = out.lstrip(GIT_TAG_PREFIX) |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 230 | else: |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 231 | # no tags matched |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 232 | Context.g_module.VERSION = f'{VERSION_BASE}-commit-{out}' |
| 233 | except (OSError, subprocess.SubprocessError): |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 234 | pass |
| 235 | |
Alexander Afanasyev | 96ebd9b | 2020-06-01 19:16:52 -0400 | [diff] [blame] | 236 | versionFile = ctx.path.find_node('VERSION.info') |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 237 | if not gotVersionFromGit and versionFile is not None: |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 238 | try: |
| 239 | Context.g_module.VERSION = versionFile.read() |
| 240 | return |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 241 | except EnvironmentError: |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 242 | pass |
| 243 | |
| 244 | # version was obtained from git, update VERSION file if necessary |
| 245 | if versionFile is not None: |
| 246 | try: |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 247 | if versionFile.read() == Context.g_module.VERSION: |
| 248 | # already up-to-date |
| 249 | return |
| 250 | except EnvironmentError as e: |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 251 | Logs.warn(f'{versionFile} exists but is not readable ({e.strerror})') |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 252 | else: |
Alexander Afanasyev | 96ebd9b | 2020-06-01 19:16:52 -0400 | [diff] [blame] | 253 | versionFile = ctx.path.make_node('VERSION.info') |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 254 | |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 255 | try: |
| 256 | versionFile.write(Context.g_module.VERSION) |
Alexander Afanasyev | 67758b1 | 2018-03-06 18:36:44 -0500 | [diff] [blame] | 257 | except EnvironmentError as e: |
Davide Pesavento | 5849ee7 | 2023-11-12 20:00:21 -0500 | [diff] [blame] | 258 | Logs.warn(f'{versionFile} is not writable ({e.strerror})') |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 259 | |
| 260 | def dist(ctx): |
Davide Pesavento | fa54ee9 | 2023-02-20 04:16:51 -0500 | [diff] [blame] | 261 | ctx.algo = 'tar.xz' |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 262 | version(ctx) |
| 263 | |
| 264 | def distcheck(ctx): |
Davide Pesavento | fa54ee9 | 2023-02-20 04:16:51 -0500 | [diff] [blame] | 265 | ctx.algo = 'tar.xz' |
Vince Lehman | b722b10 | 2014-08-24 16:33:49 -0500 | [diff] [blame] | 266 | version(ctx) |