blob: 7c3300b28c6dfadf3e5f1bb929824f14d3582366 [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')
Shuo Chenccfbe242014-04-29 23:57:51 +08009 opt.load('boost default-compiler-flags doxygen sqlite3', 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''')
18
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070019def configure(conf):
Shuo Chenccfbe242014-04-29 23:57:51 +080020 conf.load("compiler_c compiler_cxx gnu_dirs boost default-compiler-flags sqlite3")
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070021
Wentao Shangbcbc9292014-04-28 21:17:06 -070022 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
23 uselib_store='NDN_CXX', mandatory=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070024
Shuo Chenccfbe242014-04-29 23:57:51 +080025 conf.check_sqlite3(mandatory=True)
26
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070027 if conf.options.with_tests:
28 conf.env['WITH_TESTS'] = True
29
Wentao Shangbcbc9292014-04-28 21:17:06 -070030 conf.env['WITH_TOOLS'] = conf.options.with_tools
31
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070032 USED_BOOST_LIBS = ['system', 'iostreams', 'filesystem', 'thread']
33 if conf.env['WITH_TESTS']:
34 USED_BOOST_LIBS += ['unit_test_framework']
Wentao Shangbcbc9292014-04-28 21:17:06 -070035 conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070036
37 try:
38 conf.load("doxygen")
39 except:
40 pass
41
Shuo Chen478204c2014-03-18 18:27:04 -070042 conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/repo-ng.conf' % conf.env['SYSCONFDIR'])
43
44 if not conf.options.with_sqlite_locking:
45 conf.define('DISABLE_SQLITE3_FS_LOCKING', 1)
46
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070047 conf.write_config_header('config.hpp')
48
49def build(bld):
Wentao Shangbcbc9292014-04-28 21:17:06 -070050 bld(target="ndn-repo-objects",
51 name="ndn-repo-objects",
52 features=["cxx"],
53 source=bld.path.ant_glob(['ndn-handle/*.cpp',
54 'storage/**/*.cpp',
55 'helpers/*.cpp',
56 'server/*.cpp'],
57 excl=['server/server.cpp']),
58 use='NDN_CXX BOOST SQLITE3',
59 includes=".",
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070060 )
61
Wentao Shangbcbc9292014-04-28 21:17:06 -070062 bld(target="ndn-repo-ng",
63 features=["cxx", "cxxprogram"],
64 source=bld.path.ant_glob(['server/server.cpp']),
65 use='ndn-repo-objects',
66 includes=".",
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070067 )
68
69 # Unit tests
70 if bld.env['WITH_TESTS']:
71 bld.recurse('tests')
Shuo Chen478204c2014-03-18 18:27:04 -070072
Wentao Shangbcbc9292014-04-28 21:17:06 -070073 if bld.env['WITH_TOOLS']:
74 bld.recurse("tools")
75
Shuo Chen478204c2014-03-18 18:27:04 -070076 bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample')