blob: 81083879f4664910f4764ea4b4068854bdf79e71 [file] [log] [blame]
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -07002
Davide Pesaventob545aac2017-09-22 23:54:10 -04003from waflib import Utils
4import os
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -07005
Davide Pesavento1359cc32019-11-09 15:25:09 -05006VERSION = '0.1'
7APPNAME = 'ndn-repo-ng'
8
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -07009def options(opt):
Davide Pesaventof43a03e2018-02-21 22:04:21 -050010 opt.load(['compiler_cxx', 'gnu_dirs'])
Davide Pesavento333e3eb2021-10-12 19:30:51 -040011 opt.load(['default-compiler-flags',
12 'coverage', 'sanitizers', 'boost', 'sqlite3'],
Davide Pesaventob545aac2017-09-22 23:54:10 -040013 tooldir=['.waf-tools'])
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070014
Davide Pesavento1359cc32019-11-09 15:25:09 -050015 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 Shangbcbc9292014-04-28 21:17:06 -070022
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070023def configure(conf):
Davide Pesaventof43a03e2018-02-21 22:04:21 -050024 conf.load(['compiler_cxx', 'gnu_dirs',
25 'default-compiler-flags', 'boost', 'sqlite3'])
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070026
Davide Pesavento333e3eb2021-10-12 19:30:51 -040027 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 Shangbcbc9292014-04-28 21:17:06 -070030
Davide Pesavento9c0bd8d2022-03-14 16:48:12 -040031 pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig')
32 conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.0', '--cflags', '--libs'],
33 uselib_store='NDN_CXX', pkg_config_path=pkg_config_path)
Davide Pesavento1359cc32019-11-09 15:25:09 -050034
35 conf.check_sqlite3()
36
Davide Pesavento9c0bd8d2022-03-14 16:48:12 -040037 boost_libs = ['system', 'program_options', 'filesystem', 'iostreams']
Davide Pesavento333e3eb2021-10-12 19:30:51 -040038 if conf.env.WITH_TESTS:
39 boost_libs.append('unit_test_framework')
40 conf.check_boost(lib=boost_libs, mt=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070041
Davide Pesaventof43a03e2018-02-21 22:04:21 -050042 conf.check_compiler_flags()
43
Davide Pesaventob545aac2017-09-22 23:54:10 -040044 # Loading "late" to prevent tests from being compiled with profiling flags
Alexander Afanasyevf34a3552017-08-13 21:17:05 -040045 conf.load('coverage')
Alexander Afanasyevf34a3552017-08-13 21:17:05 -040046 conf.load('sanitizers')
47
Davide Pesavento333e3eb2021-10-12 19:30:51 -040048 conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS)
Davide Pesaventoed2f4762019-01-25 00:40:46 -050049 conf.define_cond('DISABLE_SQLITE3_FS_LOCKING', not conf.options.with_sqlite_locking)
Davide Pesavento333e3eb2021-10-12 19:30:51 -040050 conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/repo-ng.conf' % conf.env.SYSCONFDIR)
Alexander Afanasyev39d98072014-05-04 12:46:29 -070051 conf.write_config_header('src/config.hpp')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070052
53def build(bld):
Davide Pesaventoed2f4762019-01-25 00:40:46 -050054 bld.objects(target='repo-objects',
55 source=bld.path.ant_glob('src/**/*.cpp',
56 excl=['src/main.cpp']),
57 use='NDN_CXX BOOST SQLITE3',
58 includes='src',
59 export_includes='src')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070060
Davide Pesaventoed2f4762019-01-25 00:40:46 -050061 bld.program(name='ndn-repo-ng',
62 target='bin/ndn-repo-ng',
63 source='src/main.cpp',
64 use='repo-objects')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070065
Davide Pesaventoe4b74bd2022-03-09 18:56:37 -050066 if bld.env.WITH_TOOLS:
67 bld.recurse('tools')
68
69 if bld.env.WITH_TESTS:
70 bld.recurse('tests')
71
72 if bld.env.WITH_EXAMPLES:
73 bld.recurse('examples')
Weiqi Shi68f2cf62014-08-26 12:35:45 -070074
Shuo Chen478204c2014-03-18 18:27:04 -070075 bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample')
Davide Pesaventodf0bd342019-01-25 01:22:45 -050076
77 if Utils.unversioned_sys_platform() == 'linux':
78 bld(features='subst',
79 name='repo-ng.service',
80 source='systemd/repo-ng.service.in',
81 target='systemd/repo-ng.service')