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 | from waflib import Utils |
| 4 | import os |
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 | ed2f476 | 2019-01-25 00:40:46 -0500 | [diff] [blame] | 11 | opt.load(['default-compiler-flags', 'coverage', 'sanitizers', 'boost', 'sqlite3'], |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 12 | tooldir=['.waf-tools']) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 13 | |
Davide Pesavento | 1359cc3 | 2019-11-09 15:25:09 -0500 | [diff] [blame] | 14 | 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 Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 21 | |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 22 | def configure(conf): |
Davide Pesavento | f43a03e | 2018-02-21 22:04:21 -0500 | [diff] [blame] | 23 | conf.load(['compiler_cxx', 'gnu_dirs', |
| 24 | 'default-compiler-flags', 'boost', 'sqlite3']) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 25 | |
Weiqi Shi | 68f2cf6 | 2014-08-26 12:35:45 -0700 | [diff] [blame] | 26 | conf.env['WITH_EXAMPLES'] = conf.options.with_examples |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 27 | conf.env['WITH_TESTS'] = conf.options.with_tests |
| 28 | conf.env['WITH_TOOLS'] = conf.options.with_tools |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 29 | |
Davide Pesavento | 1359cc3 | 2019-11-09 15:25:09 -0500 | [diff] [blame] | 30 | 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 Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 36 | if conf.env['WITH_TESTS']: |
| 37 | USED_BOOST_LIBS += ['unit_test_framework'] |
Davide Pesavento | 1359cc3 | 2019-11-09 15:25:09 -0500 | [diff] [blame] | 38 | conf.check_boost(lib=USED_BOOST_LIBS, mt=True) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 39 | |
Davide Pesavento | f43a03e | 2018-02-21 22:04:21 -0500 | [diff] [blame] | 40 | conf.check_compiler_flags() |
| 41 | |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 42 | # Loading "late" to prevent tests from being compiled with profiling flags |
Alexander Afanasyev | f34a355 | 2017-08-13 21:17:05 -0400 | [diff] [blame] | 43 | conf.load('coverage') |
Alexander Afanasyev | f34a355 | 2017-08-13 21:17:05 -0400 | [diff] [blame] | 44 | conf.load('sanitizers') |
| 45 | |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 46 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/repo-ng.conf' % conf.env['SYSCONFDIR']) |
Davide Pesavento | ed2f476 | 2019-01-25 00:40:46 -0500 | [diff] [blame] | 47 | conf.define_cond('DISABLE_SQLITE3_FS_LOCKING', not conf.options.with_sqlite_locking) |
| 48 | conf.define_cond('HAVE_TESTS', conf.env['WITH_TESTS']) |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 49 | |
Alexander Afanasyev | 39d9807 | 2014-05-04 12:46:29 -0700 | [diff] [blame] | 50 | conf.write_config_header('src/config.hpp') |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 51 | |
| 52 | def build(bld): |
Davide Pesavento | ed2f476 | 2019-01-25 00:40:46 -0500 | [diff] [blame] | 53 | 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 Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 59 | |
Davide Pesavento | ed2f476 | 2019-01-25 00:40:46 -0500 | [diff] [blame] | 60 | bld.program(name='ndn-repo-ng', |
| 61 | target='bin/ndn-repo-ng', |
| 62 | source='src/main.cpp', |
| 63 | use='repo-objects') |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 64 | |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 65 | bld.recurse('tests') |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 66 | bld.recurse('tools') |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 67 | bld.recurse('examples') |
Weiqi Shi | 68f2cf6 | 2014-08-26 12:35:45 -0700 | [diff] [blame] | 68 | |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 69 | bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample') |
Davide Pesavento | df0bd34 | 2019-01-25 01:22:45 -0500 | [diff] [blame] | 70 | |
| 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') |