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 | VERSION = '0.1' |
| 4 | APPNAME = 'ndn-repo-ng' |
| 5 | |
| 6 | from waflib import Utils |
| 7 | import os |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 8 | |
| 9 | def options(opt): |
| 10 | opt.load('compiler_c compiler_cxx gnu_dirs') |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 11 | opt.load('boost default-compiler-flags doxygen sqlite3 coverage sanitizers', |
| 12 | tooldir=['.waf-tools']) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 13 | |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 14 | ropt = opt.add_option_group('ndn-repo-ng Options') |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 15 | |
Weiqi Shi | 68f2cf6 | 2014-08-26 12:35:45 -0700 | [diff] [blame] | 16 | ropt.add_option('--with-examples', action='store_true', default=False, dest='with_examples', |
| 17 | help='''Build examples''') |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 18 | ropt.add_option('--with-tests', action='store_true', default=False, dest='with_tests', |
| 19 | help='''Build unit tests''') |
| 20 | ropt.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): |
Shuo Chen | ccfbe24 | 2014-04-29 23:57:51 +0800 | [diff] [blame] | 24 | conf.load("compiler_c compiler_cxx gnu_dirs boost default-compiler-flags sqlite3") |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 25 | |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 26 | if 'PKG_CONFIG_PATH' not in os.environ: |
| 27 | os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env) |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 28 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 29 | uselib_store='NDN_CXX', mandatory=True) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 30 | |
Shuo Chen | ccfbe24 | 2014-04-29 23:57:51 +0800 | [diff] [blame] | 31 | conf.check_sqlite3(mandatory=True) |
| 32 | |
Weiqi Shi | 68f2cf6 | 2014-08-26 12:35:45 -0700 | [diff] [blame] | 33 | conf.env['WITH_EXAMPLES'] = conf.options.with_examples |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 34 | conf.env['WITH_TESTS'] = conf.options.with_tests |
| 35 | conf.env['WITH_TOOLS'] = conf.options.with_tools |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 36 | |
Davide Pesavento | 49f3a5f | 2017-09-23 01:36:33 -0400 | [diff] [blame] | 37 | USED_BOOST_LIBS = ['system', 'iostreams', 'filesystem'] |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 38 | if conf.env['WITH_TESTS']: |
Nick Gordon | 190e4dc | 2017-10-04 16:54:10 -0500 | [diff] [blame] | 39 | conf.define('HAVE_TESTS', 1) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 40 | USED_BOOST_LIBS += ['unit_test_framework'] |
Nick Gordon | 190e4dc | 2017-10-04 16:54:10 -0500 | [diff] [blame] | 41 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 42 | conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 43 | |
| 44 | try: |
| 45 | conf.load("doxygen") |
| 46 | except: |
| 47 | pass |
| 48 | |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 49 | # Loading "late" to prevent tests from being compiled with profiling flags |
Alexander Afanasyev | f34a355 | 2017-08-13 21:17:05 -0400 | [diff] [blame] | 50 | conf.load('coverage') |
| 51 | |
| 52 | conf.load('sanitizers') |
| 53 | |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 54 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/repo-ng.conf' % conf.env['SYSCONFDIR']) |
| 55 | |
| 56 | if not conf.options.with_sqlite_locking: |
| 57 | conf.define('DISABLE_SQLITE3_FS_LOCKING', 1) |
| 58 | |
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): |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 62 | bld(target="ndn-repo-objects", |
| 63 | name="ndn-repo-objects", |
| 64 | features=["cxx"], |
Alexander Afanasyev | 39d9807 | 2014-05-04 12:46:29 -0700 | [diff] [blame] | 65 | source=bld.path.ant_glob(['src/**/*.cpp'], |
| 66 | excl=['src/main.cpp']), |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 67 | use='NDN_CXX BOOST SQLITE3', |
Alexander Afanasyev | 39d9807 | 2014-05-04 12:46:29 -0700 | [diff] [blame] | 68 | includes="src", |
| 69 | export_includes="src", |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 70 | ) |
| 71 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 72 | bld(target="ndn-repo-ng", |
| 73 | features=["cxx", "cxxprogram"], |
Alexander Afanasyev | 39d9807 | 2014-05-04 12:46:29 -0700 | [diff] [blame] | 74 | source=bld.path.ant_glob(['src/main.cpp']), |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 75 | use='ndn-repo-objects', |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 76 | ) |
| 77 | |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 78 | bld.recurse('tests') |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 79 | bld.recurse('tests/other') |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 80 | bld.recurse('tools') |
Davide Pesavento | b545aac | 2017-09-22 23:54:10 -0400 | [diff] [blame] | 81 | bld.recurse('examples') |
Weiqi Shi | 68f2cf6 | 2014-08-26 12:35:45 -0700 | [diff] [blame] | 82 | |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 83 | bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample') |