blob: 48f296ae5229214555d32f178abadc6c7a778672 [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):
Davide Pesaventof43a03e2018-02-21 22:04:21 -050010 opt.load(['compiler_cxx', 'gnu_dirs'])
11 opt.load(['default-compiler-flags', 'coverage', 'sanitizers', 'boost',
12 'sqlite3', 'doxygen'],
Davide Pesaventob545aac2017-09-22 23:54:10 -040013 tooldir=['.waf-tools'])
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070014
Shuo Chen478204c2014-03-18 18:27:04 -070015 ropt = opt.add_option_group('ndn-repo-ng Options')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070016
Weiqi Shi68f2cf62014-08-26 12:35:45 -070017 ropt.add_option('--with-examples', action='store_true', default=False, dest='with_examples',
18 help='''Build examples''')
Davide Pesaventob545aac2017-09-22 23:54:10 -040019 ropt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
20 help='''Build unit tests''')
21 ropt.add_option('--without-tools', action='store_false', default=True, dest='with_tools',
22 help='''Do not build tools''')
Wentao Shangbcbc9292014-04-28 21:17:06 -070023
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070024def configure(conf):
Davide Pesaventof43a03e2018-02-21 22:04:21 -050025 conf.load(['compiler_cxx', 'gnu_dirs',
26 'default-compiler-flags', 'boost', 'sqlite3'])
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070027
Davide Pesaventob545aac2017-09-22 23:54:10 -040028 if 'PKG_CONFIG_PATH' not in os.environ:
29 os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
Wentao Shangbcbc9292014-04-28 21:17:06 -070030 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
31 uselib_store='NDN_CXX', mandatory=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070032
Shuo Chenccfbe242014-04-29 23:57:51 +080033 conf.check_sqlite3(mandatory=True)
34
Weiqi Shi68f2cf62014-08-26 12:35:45 -070035 conf.env['WITH_EXAMPLES'] = conf.options.with_examples
Davide Pesaventob545aac2017-09-22 23:54:10 -040036 conf.env['WITH_TESTS'] = conf.options.with_tests
37 conf.env['WITH_TOOLS'] = conf.options.with_tools
Wentao Shangbcbc9292014-04-28 21:17:06 -070038
Alexander Afanasyevbb058c02018-02-15 22:49:24 +000039 USED_BOOST_LIBS = ['system', 'iostreams', 'filesystem', 'thread', 'log', 'log_setup']
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070040 if conf.env['WITH_TESTS']:
Nick Gordon190e4dc2017-10-04 16:54:10 -050041 conf.define('HAVE_TESTS', 1)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070042 USED_BOOST_LIBS += ['unit_test_framework']
Alexander Afanasyevbb058c02018-02-15 22:49:24 +000043 conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True, mt=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070044
45 try:
46 conf.load("doxygen")
47 except:
48 pass
49
Davide Pesaventof43a03e2018-02-21 22:04:21 -050050 conf.check_compiler_flags()
51
Davide Pesaventob545aac2017-09-22 23:54:10 -040052 # Loading "late" to prevent tests from being compiled with profiling flags
Alexander Afanasyevf34a3552017-08-13 21:17:05 -040053 conf.load('coverage')
Alexander Afanasyevf34a3552017-08-13 21:17:05 -040054 conf.load('sanitizers')
55
Shuo Chen478204c2014-03-18 18:27:04 -070056 conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/repo-ng.conf' % conf.env['SYSCONFDIR'])
57
58 if not conf.options.with_sqlite_locking:
59 conf.define('DISABLE_SQLITE3_FS_LOCKING', 1)
60
Alexander Afanasyev39d98072014-05-04 12:46:29 -070061 conf.write_config_header('src/config.hpp')
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070062
63def build(bld):
Wentao Shangbcbc9292014-04-28 21:17:06 -070064 bld(target="ndn-repo-objects",
65 name="ndn-repo-objects",
66 features=["cxx"],
Alexander Afanasyev39d98072014-05-04 12:46:29 -070067 source=bld.path.ant_glob(['src/**/*.cpp'],
68 excl=['src/main.cpp']),
Wentao Shangbcbc9292014-04-28 21:17:06 -070069 use='NDN_CXX BOOST SQLITE3',
Alexander Afanasyev39d98072014-05-04 12:46:29 -070070 includes="src",
71 export_includes="src",
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070072 )
73
Wentao Shangbcbc9292014-04-28 21:17:06 -070074 bld(target="ndn-repo-ng",
75 features=["cxx", "cxxprogram"],
Alexander Afanasyev39d98072014-05-04 12:46:29 -070076 source=bld.path.ant_glob(['src/main.cpp']),
Wentao Shangbcbc9292014-04-28 21:17:06 -070077 use='ndn-repo-objects',
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070078 )
79
Shuo Chenca329182014-03-19 18:05:18 -070080 bld.recurse('tests')
Shuo Chenca329182014-03-19 18:05:18 -070081 bld.recurse('tools')
Davide Pesaventob545aac2017-09-22 23:54:10 -040082 bld.recurse('examples')
Weiqi Shi68f2cf62014-08-26 12:35:45 -070083
Shuo Chen478204c2014-03-18 18:27:04 -070084 bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample')