blob: dd92cafcb451cc3cd0ed782665bce86238290fbb [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 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
Davide Pesavento1359cc32019-11-09 15:25:09 -050014 optgrp = opt.add_option_group('Repo-ng Options')
15 optgrp.add_option('--with-examples', action='store_true', default=False,
16 help='Build examples')
17 optgrp.add_option('--with-tests', action='store_true', default=False,
18 help='Build unit tests')
19 optgrp.add_option('--without-tools', action='store_false', default=True, dest='with_tools',
20 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
Weiqi Shi68f2cf62014-08-26 12:35:45 -070026 conf.env['WITH_EXAMPLES'] = conf.options.with_examples
Davide Pesaventob545aac2017-09-22 23:54:10 -040027 conf.env['WITH_TESTS'] = conf.options.with_tests
28 conf.env['WITH_TOOLS'] = conf.options.with_tools
Wentao Shangbcbc9292014-04-28 21:17:06 -070029
Davide Pesavento1359cc32019-11-09 15:25:09 -050030 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDN_CXX',
31 pkg_config_path=os.environ.get('PKG_CONFIG_PATH', '%s/pkgconfig' % conf.env.LIBDIR))
32
33 conf.check_sqlite3()
34
35 USED_BOOST_LIBS = ['system', 'program_options', 'iostreams', 'filesystem', 'thread', 'log']
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070036 if conf.env['WITH_TESTS']:
37 USED_BOOST_LIBS += ['unit_test_framework']
Davide Pesavento1359cc32019-11-09 15:25:09 -050038 conf.check_boost(lib=USED_BOOST_LIBS, mt=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070039
Davide Pesaventof43a03e2018-02-21 22:04:21 -050040 conf.check_compiler_flags()
41
Davide Pesaventob545aac2017-09-22 23:54:10 -040042 # Loading "late" to prevent tests from being compiled with profiling flags
Alexander Afanasyevf34a3552017-08-13 21:17:05 -040043 conf.load('coverage')
Alexander Afanasyevf34a3552017-08-13 21:17:05 -040044 conf.load('sanitizers')
45
Shuo Chen478204c2014-03-18 18:27:04 -070046 conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/repo-ng.conf' % conf.env['SYSCONFDIR'])
Davide Pesaventoed2f4762019-01-25 00:40:46 -050047 conf.define_cond('DISABLE_SQLITE3_FS_LOCKING', not conf.options.with_sqlite_locking)
48 conf.define_cond('HAVE_TESTS', conf.env['WITH_TESTS'])
Shuo Chen478204c2014-03-18 18:27:04 -070049
Alexander Afanasyev39d98072014-05-04 12:46:29 -070050 conf.write_config_header('src/config.hpp')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070051
52def build(bld):
Davide Pesaventoed2f4762019-01-25 00:40:46 -050053 bld.objects(target='repo-objects',
54 source=bld.path.ant_glob('src/**/*.cpp',
55 excl=['src/main.cpp']),
56 use='NDN_CXX BOOST SQLITE3',
57 includes='src',
58 export_includes='src')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070059
Davide Pesaventoed2f4762019-01-25 00:40:46 -050060 bld.program(name='ndn-repo-ng',
61 target='bin/ndn-repo-ng',
62 source='src/main.cpp',
63 use='repo-objects')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070064
Shuo Chenca329182014-03-19 18:05:18 -070065 bld.recurse('tests')
Shuo Chenca329182014-03-19 18:05:18 -070066 bld.recurse('tools')
Davide Pesaventob545aac2017-09-22 23:54:10 -040067 bld.recurse('examples')
Weiqi Shi68f2cf62014-08-26 12:35:45 -070068
Shuo Chen478204c2014-03-18 18:27:04 -070069 bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample')
Davide Pesaventodf0bd342019-01-25 01:22:45 -050070
71 if Utils.unversioned_sys_platform() == 'linux':
72 bld(features='subst',
73 name='repo-ng.service',
74 source='systemd/repo-ng.service.in',
75 target='systemd/repo-ng.service')