blob: fc3de3ba4de4d0a65109790559b43bc21da09151 [file] [log] [blame]
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -07002
Davide Pesaventob545aac2017-09-22 23:54:10 -04003VERSION = '0.1'
4APPNAME = 'ndn-repo-ng'
5
6from waflib import Utils
7import os
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -07008
9def options(opt):
10 opt.load('compiler_c compiler_cxx gnu_dirs')
Davide Pesaventob545aac2017-09-22 23:54:10 -040011 opt.load('boost default-compiler-flags doxygen sqlite3 coverage sanitizers',
12 tooldir=['.waf-tools'])
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070013
Shuo Chen478204c2014-03-18 18:27:04 -070014 ropt = opt.add_option_group('ndn-repo-ng Options')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070015
Weiqi Shi68f2cf62014-08-26 12:35:45 -070016 ropt.add_option('--with-examples', action='store_true', default=False, dest='with_examples',
17 help='''Build examples''')
Davide Pesaventob545aac2017-09-22 23:54:10 -040018 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 Shangbcbc9292014-04-28 21:17:06 -070022
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070023def configure(conf):
Shuo Chenccfbe242014-04-29 23:57:51 +080024 conf.load("compiler_c compiler_cxx gnu_dirs boost default-compiler-flags sqlite3")
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070025
Davide Pesaventob545aac2017-09-22 23:54:10 -040026 if 'PKG_CONFIG_PATH' not in os.environ:
27 os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
Wentao Shangbcbc9292014-04-28 21:17:06 -070028 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
29 uselib_store='NDN_CXX', mandatory=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070030
Shuo Chenccfbe242014-04-29 23:57:51 +080031 conf.check_sqlite3(mandatory=True)
32
Weiqi Shi68f2cf62014-08-26 12:35:45 -070033 conf.env['WITH_EXAMPLES'] = conf.options.with_examples
Davide Pesaventob545aac2017-09-22 23:54:10 -040034 conf.env['WITH_TESTS'] = conf.options.with_tests
35 conf.env['WITH_TOOLS'] = conf.options.with_tools
Wentao Shangbcbc9292014-04-28 21:17:06 -070036
Davide Pesavento49f3a5f2017-09-23 01:36:33 -040037 USED_BOOST_LIBS = ['system', 'iostreams', 'filesystem']
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070038 if conf.env['WITH_TESTS']:
Nick Gordon190e4dc2017-10-04 16:54:10 -050039 conf.define('HAVE_TESTS', 1)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070040 USED_BOOST_LIBS += ['unit_test_framework']
Nick Gordon190e4dc2017-10-04 16:54:10 -050041
Wentao Shangbcbc9292014-04-28 21:17:06 -070042 conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070043
44 try:
45 conf.load("doxygen")
46 except:
47 pass
48
Davide Pesaventob545aac2017-09-22 23:54:10 -040049 # Loading "late" to prevent tests from being compiled with profiling flags
Alexander Afanasyevf34a3552017-08-13 21:17:05 -040050 conf.load('coverage')
51
52 conf.load('sanitizers')
53
Shuo Chen478204c2014-03-18 18:27:04 -070054 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 Afanasyev39d98072014-05-04 12:46:29 -070059 conf.write_config_header('src/config.hpp')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070060
61def build(bld):
Wentao Shangbcbc9292014-04-28 21:17:06 -070062 bld(target="ndn-repo-objects",
63 name="ndn-repo-objects",
64 features=["cxx"],
Alexander Afanasyev39d98072014-05-04 12:46:29 -070065 source=bld.path.ant_glob(['src/**/*.cpp'],
66 excl=['src/main.cpp']),
Wentao Shangbcbc9292014-04-28 21:17:06 -070067 use='NDN_CXX BOOST SQLITE3',
Alexander Afanasyev39d98072014-05-04 12:46:29 -070068 includes="src",
69 export_includes="src",
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070070 )
71
Wentao Shangbcbc9292014-04-28 21:17:06 -070072 bld(target="ndn-repo-ng",
73 features=["cxx", "cxxprogram"],
Alexander Afanasyev39d98072014-05-04 12:46:29 -070074 source=bld.path.ant_glob(['src/main.cpp']),
Wentao Shangbcbc9292014-04-28 21:17:06 -070075 use='ndn-repo-objects',
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070076 )
77
Shuo Chenca329182014-03-19 18:05:18 -070078 bld.recurse('tests')
Davide Pesaventob545aac2017-09-22 23:54:10 -040079 bld.recurse('tests/other')
Shuo Chenca329182014-03-19 18:05:18 -070080 bld.recurse('tools')
Davide Pesaventob545aac2017-09-22 23:54:10 -040081 bld.recurse('examples')
Weiqi Shi68f2cf62014-08-26 12:35:45 -070082
Shuo Chen478204c2014-03-18 18:27:04 -070083 bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample')