blob: c00e79ae21d58ad3a4e981d4e35b332c23e3d0e3 [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')
9 opt.load('boost default-compiler-flags doxygen', tooldir=['.waf-tools'])
10
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
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 Afanasyev3fd14f02014-03-26 14:34:39 -070022 '''locking mechanism instead). This option may be necessary if home '''
23 '''directory is hosted on NFS.''')
24
25def configure(conf):
26 conf.load("compiler_c compiler_cxx gnu_dirs boost default-compiler-flags")
27
Wentao Shangbcbc9292014-04-28 21:17:06 -070028 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'],
29 uselib_store='SQLITE3', mandatory=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070030
Wentao Shangbcbc9292014-04-28 21:17:06 -070031 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
32 uselib_store='NDN_CXX', mandatory=True)
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070033
34 if conf.options.with_tests:
35 conf.env['WITH_TESTS'] = True
36
Wentao Shangbcbc9292014-04-28 21:17:06 -070037 conf.env['WITH_TOOLS'] = conf.options.with_tools
38
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -070039 USED_BOOST_LIBS = ['system', 'iostreams', 'filesystem', 'thread']
40 if conf.env['WITH_TESTS']:
41 USED_BOOST_LIBS += ['unit_test_framework']
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
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 Afanasyev3fd14f02014-03-26 14:34:39 -070054 conf.write_config_header('config.hpp')
55
56def build(bld):
Wentao Shangbcbc9292014-04-28 21:17:06 -070057 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 Afanasyev3fd14f02014-03-26 14:34:39 -070067 )
68
Wentao Shangbcbc9292014-04-28 21:17:06 -070069 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 Afanasyev3fd14f02014-03-26 14:34:39 -070074 )
75
76 # Unit tests
77 if bld.env['WITH_TESTS']:
78 bld.recurse('tests')
Shuo Chen478204c2014-03-18 18:27:04 -070079
Wentao Shangbcbc9292014-04-28 21:17:06 -070080 if bld.env['WITH_TOOLS']:
81 bld.recurse("tools")
82
Shuo Chen478204c2014-03-18 18:27:04 -070083 bld.install_files('${SYSCONFDIR}/ndn', 'repo-ng.conf.sample')