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; -*- |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 2 | VERSION = '0.1' |
| 3 | APPNAME = 'ndn-repo' |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 4 | |
| 5 | from waflib import Build, Logs, Utils, Task, TaskGen, Configure |
| 6 | |
| 7 | def options(opt): |
| 8 | opt.load('compiler_c compiler_cxx gnu_dirs') |
Shuo Chen | ccfbe24 | 2014-04-29 23:57:51 +0800 | [diff] [blame] | 9 | opt.load('boost default-compiler-flags doxygen sqlite3', tooldir=['.waf-tools']) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 10 | |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 11 | ropt = opt.add_option_group('ndn-repo-ng Options') |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 12 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 13 | ropt.add_option('--with-tests', action='store_true', default=False, dest='with_tests', |
| 14 | help='''build unit tests''') |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 15 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 16 | ropt.add_option('--without-tools', action='store_false', default=True, dest='with_tools', |
| 17 | help='''Do not build tools''') |
Weiqi Shi | 68f2cf6 | 2014-08-26 12:35:45 -0700 | [diff] [blame] | 18 | ropt.add_option('--with-examples', action='store_true', default=False, dest='with_examples', |
| 19 | help='''Build examples''') |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 20 | |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 21 | def configure(conf): |
Shuo Chen | ccfbe24 | 2014-04-29 23:57:51 +0800 | [diff] [blame] | 22 | 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] | 23 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 24 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 25 | uselib_store='NDN_CXX', mandatory=True) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 26 | |
Shuo Chen | ccfbe24 | 2014-04-29 23:57:51 +0800 | [diff] [blame] | 27 | conf.check_sqlite3(mandatory=True) |
| 28 | |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 29 | if conf.options.with_tests: |
| 30 | conf.env['WITH_TESTS'] = True |
| 31 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 32 | conf.env['WITH_TOOLS'] = conf.options.with_tools |
Weiqi Shi | 68f2cf6 | 2014-08-26 12:35:45 -0700 | [diff] [blame] | 33 | conf.env['WITH_EXAMPLES'] = conf.options.with_examples |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 34 | |
Shuo Chen | 9a43f16 | 2014-07-01 13:43:54 +0800 | [diff] [blame] | 35 | USED_BOOST_LIBS = ['system', 'iostreams', 'filesystem', 'random'] |
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'] |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 38 | conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 39 | |
| 40 | try: |
| 41 | conf.load("doxygen") |
| 42 | except: |
| 43 | pass |
| 44 | |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 45 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/repo-ng.conf' % conf.env['SYSCONFDIR']) |
| 46 | |
| 47 | if not conf.options.with_sqlite_locking: |
| 48 | conf.define('DISABLE_SQLITE3_FS_LOCKING', 1) |
| 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): |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 53 | bld(target="ndn-repo-objects", |
| 54 | name="ndn-repo-objects", |
| 55 | features=["cxx"], |
Alexander Afanasyev | 39d9807 | 2014-05-04 12:46:29 -0700 | [diff] [blame] | 56 | source=bld.path.ant_glob(['src/**/*.cpp'], |
| 57 | excl=['src/main.cpp']), |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 58 | use='NDN_CXX BOOST SQLITE3', |
Alexander Afanasyev | 39d9807 | 2014-05-04 12:46:29 -0700 | [diff] [blame] | 59 | includes="src", |
| 60 | export_includes="src", |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 61 | ) |
| 62 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 63 | bld(target="ndn-repo-ng", |
| 64 | features=["cxx", "cxxprogram"], |
Alexander Afanasyev | 39d9807 | 2014-05-04 12:46:29 -0700 | [diff] [blame] | 65 | source=bld.path.ant_glob(['src/main.cpp']), |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 66 | use='ndn-repo-objects', |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 67 | ) |
| 68 | |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 69 | # Tests |
| 70 | bld.recurse('tests') |
WeiqiShi | a79c778 | 2014-12-26 09:42:10 +0800 | [diff] [blame^] | 71 | bld.recurse("tests/other") |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 72 | |
Shuo Chen | ca32918 | 2014-03-19 18:05:18 -0700 | [diff] [blame] | 73 | # Tools |
| 74 | bld.recurse('tools') |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame] | 75 | |
Weiqi Shi | 68f2cf6 | 2014-08-26 12:35:45 -0700 | [diff] [blame] | 76 | bld.recurse("examples") |
| 77 | |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 78 | bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample') |