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') |
| 9 | opt.load('boost default-compiler-flags doxygen', tooldir=['.waf-tools']) |
| 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''') |
| 18 | |
| 19 | ropt.add_option('--without-sqlite-locking', action='store_false', default=True, |
| 20 | dest='with_sqlite_locking', |
| 21 | help='''Disable filesystem locking in sqlite3 database (use unix-dot ''' |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 22 | '''locking mechanism instead). This option may be necessary if home ''' |
| 23 | '''directory is hosted on NFS.''') |
| 24 | |
| 25 | def configure(conf): |
| 26 | conf.load("compiler_c compiler_cxx gnu_dirs boost default-compiler-flags") |
| 27 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame^] | 28 | conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], |
| 29 | uselib_store='SQLITE3', mandatory=True) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 30 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame^] | 31 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 32 | uselib_store='NDN_CXX', mandatory=True) |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 33 | |
| 34 | if conf.options.with_tests: |
| 35 | conf.env['WITH_TESTS'] = True |
| 36 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame^] | 37 | conf.env['WITH_TOOLS'] = conf.options.with_tools |
| 38 | |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 39 | USED_BOOST_LIBS = ['system', 'iostreams', 'filesystem', 'thread'] |
| 40 | if conf.env['WITH_TESTS']: |
| 41 | USED_BOOST_LIBS += ['unit_test_framework'] |
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 | |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 49 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/repo-ng.conf' % conf.env['SYSCONFDIR']) |
| 50 | |
| 51 | if not conf.options.with_sqlite_locking: |
| 52 | conf.define('DISABLE_SQLITE3_FS_LOCKING', 1) |
| 53 | |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 54 | conf.write_config_header('config.hpp') |
| 55 | |
| 56 | def build(bld): |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame^] | 57 | bld(target="ndn-repo-objects", |
| 58 | name="ndn-repo-objects", |
| 59 | features=["cxx"], |
| 60 | source=bld.path.ant_glob(['ndn-handle/*.cpp', |
| 61 | 'storage/**/*.cpp', |
| 62 | 'helpers/*.cpp', |
| 63 | 'server/*.cpp'], |
| 64 | excl=['server/server.cpp']), |
| 65 | use='NDN_CXX BOOST SQLITE3', |
| 66 | includes=".", |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 67 | ) |
| 68 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame^] | 69 | bld(target="ndn-repo-ng", |
| 70 | features=["cxx", "cxxprogram"], |
| 71 | source=bld.path.ant_glob(['server/server.cpp']), |
| 72 | use='ndn-repo-objects', |
| 73 | includes=".", |
Alexander Afanasyev | 3fd14f0 | 2014-03-26 14:34:39 -0700 | [diff] [blame] | 74 | ) |
| 75 | |
| 76 | # Unit tests |
| 77 | if bld.env['WITH_TESTS']: |
| 78 | bld.recurse('tests') |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 79 | |
Wentao Shang | bcbc929 | 2014-04-28 21:17:06 -0700 | [diff] [blame^] | 80 | if bld.env['WITH_TOOLS']: |
| 81 | bld.recurse("tools") |
| 82 | |
Shuo Chen | 478204c | 2014-03-18 18:27:04 -0700 | [diff] [blame] | 83 | bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample') |