Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 2 | |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 3 | import os |
Davide Pesavento | 399f4d9 | 2023-09-17 14:03:51 -0400 | [diff] [blame^] | 4 | from waflib import Utils |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 5 | |
Davide Pesavento | 1359cc3 | 2019-11-09 15:25:09 -0500 | [diff] [blame] | 6 | VERSION = '0.1' |
| 7 | APPNAME = 'ndn-repo-ng' |
| 8 | |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 9 | def options(opt): |
Davide Pesavento | f43a03e | 2018-02-21 22:04:21 -0500 | [diff] [blame] | 10 | opt.load(['compiler_cxx', 'gnu_dirs']) |
Davide Pesavento | 333e3eb | 2021-10-12 19:30:51 -0400 | [diff] [blame] | 11 | opt.load(['default-compiler-flags', |
| 12 | 'coverage', 'sanitizers', 'boost', 'sqlite3'], |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 13 | tooldir=['.waf-tools']) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 14 | |
Davide Pesavento | 1359cc3 | 2019-11-09 15:25:09 -0500 | [diff] [blame] | 15 | optgrp = opt.add_option_group('Repo-ng Options') |
| 16 | optgrp.add_option('--with-examples', action='store_true', default=False, |
| 17 | help='Build examples') |
| 18 | optgrp.add_option('--with-tests', action='store_true', default=False, |
| 19 | help='Build unit tests') |
| 20 | optgrp.add_option('--without-tools', action='store_false', default=True, dest='with_tools', |
| 21 | help='Do not build tools') |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 22 | |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 23 | def configure(conf): |
Davide Pesavento | f43a03e | 2018-02-21 22:04:21 -0500 | [diff] [blame] | 24 | conf.load(['compiler_cxx', 'gnu_dirs', |
| 25 | 'default-compiler-flags', 'boost', 'sqlite3']) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 26 | |
Davide Pesavento | 333e3eb | 2021-10-12 19:30:51 -0400 | [diff] [blame] | 27 | conf.env.WITH_EXAMPLES = conf.options.with_examples |
| 28 | conf.env.WITH_TESTS = conf.options.with_tests |
| 29 | conf.env.WITH_TOOLS = conf.options.with_tools |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 30 | |
Davide Pesavento | 1d48453 | 2022-08-19 22:08:31 -0400 | [diff] [blame] | 31 | # Prefer pkgconf if it's installed, because it gives more correct results |
| 32 | # on Fedora/CentOS/RHEL/etc. See https://bugzilla.redhat.com/show_bug.cgi?id=1953348 |
| 33 | # Store the result in env.PKGCONFIG, which is the variable used inside check_cfg() |
| 34 | conf.find_program(['pkgconf', 'pkg-config'], var='PKGCONFIG') |
| 35 | |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame] | 36 | pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig') |
Davide Pesavento | e9b09b8 | 2023-01-19 13:30:07 -0500 | [diff] [blame] | 37 | conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.1', '--cflags', '--libs'], |
Davide Pesavento | 9c0bd8d | 2022-03-14 16:48:12 -0400 | [diff] [blame] | 38 | uselib_store='NDN_CXX', pkg_config_path=pkg_config_path) |
Davide Pesavento | 1359cc3 | 2019-11-09 15:25:09 -0500 | [diff] [blame] | 39 | |
| 40 | conf.check_sqlite3() |
| 41 | |
Davide Pesavento | 399f4d9 | 2023-09-17 14:03:51 -0400 | [diff] [blame^] | 42 | conf.check_boost(lib='filesystem program_options', mt=True) |
Davide Pesavento | 1d48453 | 2022-08-19 22:08:31 -0400 | [diff] [blame] | 43 | |
Davide Pesavento | 399f4d9 | 2023-09-17 14:03:51 -0400 | [diff] [blame^] | 44 | if conf.env.WITH_TESTS: |
| 45 | conf.check_boost(lib='unit_test_framework', mt=True, uselib_store='BOOST_TESTS') |
| 46 | |
| 47 | if conf.env.WITH_TOOLS: |
| 48 | conf.check_boost(lib='iostreams', mt=True, uselib_store='BOOST_TOOLS') |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 49 | |
Davide Pesavento | f43a03e | 2018-02-21 22:04:21 -0500 | [diff] [blame] | 50 | conf.check_compiler_flags() |
| 51 | |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 52 | # Loading "late" to prevent tests from being compiled with profiling flags |
Alexander Afanasyev | f34a355 | 2017-08-13 21:17:05 -0400 | [diff] [blame] | 53 | conf.load('coverage') |
Alexander Afanasyev | f34a355 | 2017-08-13 21:17:05 -0400 | [diff] [blame] | 54 | conf.load('sanitizers') |
| 55 | |
Davide Pesavento | 333e3eb | 2021-10-12 19:30:51 -0400 | [diff] [blame] | 56 | conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS) |
Davide Pesavento | ed2f476 | 2019-01-25 00:40:46 -0500 | [diff] [blame] | 57 | conf.define_cond('DISABLE_SQLITE3_FS_LOCKING', not conf.options.with_sqlite_locking) |
Davide Pesavento | 399f4d9 | 2023-09-17 14:03:51 -0400 | [diff] [blame^] | 58 | conf.define('DEFAULT_CONFIG_FILE', f'{conf.env.SYSCONFDIR}/ndn/repo-ng.conf') |
Alexander Afanasyev | 39d9807 | 2014-05-04 12:46:29 -0700 | [diff] [blame] | 59 | conf.write_config_header('src/config.hpp') |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 60 | |
| 61 | def build(bld): |
Davide Pesavento | 399f4d9 | 2023-09-17 14:03:51 -0400 | [diff] [blame^] | 62 | bld.objects( |
| 63 | target='repo-objects', |
| 64 | source=bld.path.ant_glob('src/**/*.cpp', excl=['src/main.cpp']), |
| 65 | use='BOOST NDN_CXX SQLITE3', |
| 66 | includes='src', |
| 67 | export_includes='src') |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 68 | |
Davide Pesavento | 399f4d9 | 2023-09-17 14:03:51 -0400 | [diff] [blame^] | 69 | bld.program( |
| 70 | name='ndn-repo-ng', |
| 71 | target='bin/ndn-repo-ng', |
| 72 | source='src/main.cpp', |
| 73 | use='repo-objects') |
Davide Pesavento | e4b74bd | 2022-03-09 18:56:37 -0500 | [diff] [blame] | 74 | |
| 75 | if bld.env.WITH_TESTS: |
| 76 | bld.recurse('tests') |
| 77 | |
Davide Pesavento | 399f4d9 | 2023-09-17 14:03:51 -0400 | [diff] [blame^] | 78 | if bld.env.WITH_TOOLS: |
| 79 | bld.recurse('tools') |
| 80 | |
Davide Pesavento | e4b74bd | 2022-03-09 18:56:37 -0500 | [diff] [blame] | 81 | if bld.env.WITH_EXAMPLES: |
| 82 | bld.recurse('examples') |
Weiqi Shi | 68f2cf6 | 2014-08-26 12:35:45 -0700 | [diff] [blame] | 83 | |
Davide Pesavento | 399f4d9 | 2023-09-17 14:03:51 -0400 | [diff] [blame^] | 84 | # Install sample config |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 85 | bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample') |
Davide Pesavento | df0bd34 | 2019-01-25 01:22:45 -0500 | [diff] [blame] | 86 | |
| 87 | if Utils.unversioned_sys_platform() == 'linux': |
| 88 | bld(features='subst', |
Davide Pesavento | 399f4d9 | 2023-09-17 14:03:51 -0400 | [diff] [blame^] | 89 | name='systemd-units', |
Davide Pesavento | df0bd34 | 2019-01-25 01:22:45 -0500 | [diff] [blame] | 90 | source='systemd/repo-ng.service.in', |
| 91 | target='systemd/repo-ng.service') |