blob: fed01bfeee84cebce55cb215434562502016fbc7 [file] [log] [blame]
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Wentao Shangbcbc9292014-04-28 21:17:06 -07002VERSION = '0.1'
3APPNAME = 'ndn-repo'
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -07004
5from waflib import Build, Logs, Utils, Task, TaskGen, Configure
6
7def options(opt):
8 opt.load('compiler_c compiler_cxx gnu_dirs')
Alexander Afanasyevf34a3552017-08-13 21:17:05 -04009 opt.load('boost default-compiler-flags doxygen sqlite3 coverage sanitizers', tooldir=['.waf-tools'])
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070010
Shuo Chen478204c2014-03-18 18:27:04 -070011 ropt = opt.add_option_group('ndn-repo-ng Options')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070012
Wentao Shangbcbc9292014-04-28 21:17:06 -070013 ropt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
14 help='''build unit tests''')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070015
Wentao Shangbcbc9292014-04-28 21:17:06 -070016 ropt.add_option('--without-tools', action='store_false', default=True, dest='with_tools',
17 help='''Do not build tools''')
Weiqi Shi68f2cf62014-08-26 12:35:45 -070018 ropt.add_option('--with-examples', action='store_true', default=False, dest='with_examples',
19 help='''Build examples''')
Wentao Shangbcbc9292014-04-28 21:17:06 -070020
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070021def configure(conf):
Shuo Chenccfbe242014-04-29 23:57:51 +080022 conf.load("compiler_c compiler_cxx gnu_dirs boost default-compiler-flags sqlite3")
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070023
Wentao Shangbcbc9292014-04-28 21:17:06 -070024 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
25 uselib_store='NDN_CXX', mandatory=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070026
Shuo Chenccfbe242014-04-29 23:57:51 +080027 conf.check_sqlite3(mandatory=True)
28
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070029 if conf.options.with_tests:
30 conf.env['WITH_TESTS'] = True
31
Wentao Shangbcbc9292014-04-28 21:17:06 -070032 conf.env['WITH_TOOLS'] = conf.options.with_tools
Weiqi Shi68f2cf62014-08-26 12:35:45 -070033 conf.env['WITH_EXAMPLES'] = conf.options.with_examples
Wentao Shangbcbc9292014-04-28 21:17:06 -070034
Shuo Chen9a43f162014-07-01 13:43:54 +080035 USED_BOOST_LIBS = ['system', 'iostreams', 'filesystem', 'random']
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070036 if conf.env['WITH_TESTS']:
37 USED_BOOST_LIBS += ['unit_test_framework']
Wentao Shangbcbc9292014-04-28 21:17:06 -070038 conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070039
40 try:
41 conf.load("doxygen")
42 except:
43 pass
44
Alexander Afanasyevf34a3552017-08-13 21:17:05 -040045 conf.load('coverage')
46
47 conf.load('sanitizers')
48
Shuo Chen478204c2014-03-18 18:27:04 -070049 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 Afanasyev39d98072014-05-04 12:46:29 -070054 conf.write_config_header('src/config.hpp')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070055
56def build(bld):
Wentao Shangbcbc9292014-04-28 21:17:06 -070057 bld(target="ndn-repo-objects",
58 name="ndn-repo-objects",
59 features=["cxx"],
Alexander Afanasyev39d98072014-05-04 12:46:29 -070060 source=bld.path.ant_glob(['src/**/*.cpp'],
61 excl=['src/main.cpp']),
Wentao Shangbcbc9292014-04-28 21:17:06 -070062 use='NDN_CXX BOOST SQLITE3',
Alexander Afanasyev39d98072014-05-04 12:46:29 -070063 includes="src",
64 export_includes="src",
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070065 )
66
Wentao Shangbcbc9292014-04-28 21:17:06 -070067 bld(target="ndn-repo-ng",
68 features=["cxx", "cxxprogram"],
Alexander Afanasyev39d98072014-05-04 12:46:29 -070069 source=bld.path.ant_glob(['src/main.cpp']),
Wentao Shangbcbc9292014-04-28 21:17:06 -070070 use='ndn-repo-objects',
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070071 )
72
Shuo Chenca329182014-03-19 18:05:18 -070073 # Tests
74 bld.recurse('tests')
WeiqiShia79c7782014-12-26 09:42:10 +080075 bld.recurse("tests/other")
Shuo Chen478204c2014-03-18 18:27:04 -070076
Shuo Chenca329182014-03-19 18:05:18 -070077 # Tools
78 bld.recurse('tools')
Wentao Shangbcbc9292014-04-28 21:17:06 -070079
Weiqi Shi68f2cf62014-08-26 12:35:45 -070080 bld.recurse("examples")
81
Shuo Chen478204c2014-03-18 18:27:04 -070082 bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample')