blob: 2a5e4c38841176169153db0068834ee0c41cc570 [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 -04003VERSION = '0.1'
4APPNAME = 'ndn-repo-ng'
5
6from waflib import Utils
7import os
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -07008
9def options(opt):
Davide Pesaventof43a03e2018-02-21 22:04:21 -050010 opt.load(['compiler_cxx', 'gnu_dirs'])
Davide Pesaventoed2f4762019-01-25 00:40:46 -050011 opt.load(['default-compiler-flags', 'coverage', 'sanitizers', 'boost', 'sqlite3'],
Davide Pesaventob545aac2017-09-22 23:54:10 -040012 tooldir=['.waf-tools'])
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070013
Shuo Chen478204c2014-03-18 18:27:04 -070014 ropt = opt.add_option_group('ndn-repo-ng Options')
Davide Pesaventoed2f4762019-01-25 00:40:46 -050015 ropt.add_option('--with-examples', action='store_true', default=False,
16 help='Build examples')
17 ropt.add_option('--with-tests', action='store_true', default=False,
18 help='Build unit tests')
Davide Pesaventob545aac2017-09-22 23:54:10 -040019 ropt.add_option('--without-tools', action='store_false', default=True, dest='with_tools',
Davide Pesaventoed2f4762019-01-25 00:40:46 -050020 help='Do not build tools')
Wentao Shangbcbc9292014-04-28 21:17:06 -070021
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070022def configure(conf):
Davide Pesaventof43a03e2018-02-21 22:04:21 -050023 conf.load(['compiler_cxx', 'gnu_dirs',
24 'default-compiler-flags', 'boost', 'sqlite3'])
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070025
Davide Pesaventob545aac2017-09-22 23:54:10 -040026 if 'PKG_CONFIG_PATH' not in os.environ:
27 os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
Wentao Shangbcbc9292014-04-28 21:17:06 -070028 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
29 uselib_store='NDN_CXX', mandatory=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070030
Shuo Chenccfbe242014-04-29 23:57:51 +080031 conf.check_sqlite3(mandatory=True)
32
Weiqi Shi68f2cf62014-08-26 12:35:45 -070033 conf.env['WITH_EXAMPLES'] = conf.options.with_examples
Davide Pesaventob545aac2017-09-22 23:54:10 -040034 conf.env['WITH_TESTS'] = conf.options.with_tests
35 conf.env['WITH_TOOLS'] = conf.options.with_tools
Wentao Shangbcbc9292014-04-28 21:17:06 -070036
Alexander Afanasyevbb058c02018-02-15 22:49:24 +000037 USED_BOOST_LIBS = ['system', 'iostreams', 'filesystem', 'thread', 'log', 'log_setup']
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070038 if conf.env['WITH_TESTS']:
39 USED_BOOST_LIBS += ['unit_test_framework']
Alexander Afanasyevbb058c02018-02-15 22:49:24 +000040 conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True, 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
Shuo Chen478204c2014-03-18 18:27:04 -070048 conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/repo-ng.conf' % conf.env['SYSCONFDIR'])
Davide Pesaventoed2f4762019-01-25 00:40:46 -050049 conf.define_cond('DISABLE_SQLITE3_FS_LOCKING', not conf.options.with_sqlite_locking)
50 conf.define_cond('HAVE_TESTS', conf.env['WITH_TESTS'])
Shuo Chen478204c2014-03-18 18:27:04 -070051
Alexander Afanasyev39d98072014-05-04 12:46:29 -070052 conf.write_config_header('src/config.hpp')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070053
54def build(bld):
Davide Pesaventoed2f4762019-01-25 00:40:46 -050055 bld.objects(target='repo-objects',
56 source=bld.path.ant_glob('src/**/*.cpp',
57 excl=['src/main.cpp']),
58 use='NDN_CXX BOOST SQLITE3',
59 includes='src',
60 export_includes='src')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070061
Davide Pesaventoed2f4762019-01-25 00:40:46 -050062 bld.program(name='ndn-repo-ng',
63 target='bin/ndn-repo-ng',
64 source='src/main.cpp',
65 use='repo-objects')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070066
Shuo Chenca329182014-03-19 18:05:18 -070067 bld.recurse('tests')
Shuo Chenca329182014-03-19 18:05:18 -070068 bld.recurse('tools')
Davide Pesaventob545aac2017-09-22 23:54:10 -040069 bld.recurse('examples')
Weiqi Shi68f2cf62014-08-26 12:35:45 -070070
Shuo Chen478204c2014-03-18 18:27:04 -070071 bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample')
Davide Pesaventodf0bd342019-01-25 01:22:45 -050072
73 if Utils.unversioned_sys_platform() == 'linux':
74 bld(features='subst',
75 name='repo-ng.service',
76 source='systemd/repo-ng.service.in',
77 target='systemd/repo-ng.service')