blob: 1cfebefbbde6ba178b4e9706e96d926cce4d30fe [file] [log] [blame]
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyev7804c232013-07-14 12:15:41 -07003VERSION='0.1'
4APPNAME='ChronoSync'
Alexander Afanasyev182fdc22012-03-05 18:06:52 -08005
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -07006from waflib import Configure, Build, Logs
Alexander Afanasyev6af3c152012-06-07 21:14:24 -07007
Alexander Afanasyeve76f2632012-03-05 00:18:42 -08008def options(opt):
Alexander Afanasyev7eb59112014-07-02 14:21:11 -07009 opt.load('compiler_c compiler_cxx gnu_dirs')
10 opt.load('boost doxygen sphinx_build protoc default-compiler-flags pch',
11 tooldir='.waf-tools')
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070012
13 syncopt = opt.add_option_group ("ChronoSync Options")
14
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070015 syncopt.add_option('--debug',action='store_true', default=False, dest='debug',
16 help='''debugging mode''')
17 syncopt.add_option('--with-log4cxx', action='store_true', default=False, dest='log4cxx',
18 help='''Compile with log4cxx''')
19 syncopt.add_option('--with-tests', action='store_true', default=False, dest='_test',
20 help='''build unit tests''')
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080021
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080022def configure(conf):
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070023 conf.load('compiler_c compiler_cxx gnu_dirs boost default-compiler-flags pch')
24 conf.load('doxygen sphinx_build')
25 conf.load('protoc')
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070026
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070027 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX',
28 mandatory=True)
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070029
Yingdi Yu280bb962014-01-30 09:52:43 -080030 conf.check_boost(lib='system iostreams thread unit_test_framework')
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070031
32 if conf.options.log4cxx:
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070033 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX',
34 mandatory=True)
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070035
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -070036 if conf.options._test:
37 conf.define('_TEST', 1)
38
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070039def build(bld):
40 libsync = bld(
Alexander Afanasyevf46eac52013-07-26 11:27:39 -070041 target="ChronoSync",
Yingdi Yuce841ca2013-12-14 08:28:00 +080042 # vnum = "1.0.0",
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070043 features=['cxx', 'cxxshlib'],
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070044 source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.proto']),
Alexander Afanasyev7c97cfa2014-07-02 12:10:13 -070045 use = 'BOOST NDNCXX',
Alexander Afanasyevce001692013-07-14 11:34:41 -070046 includes = ['src'],
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070047 )
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070048
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070049 # Unit tests
50 if bld.get_define("_TEST"):
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070051 unittests = bld.program(
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070052 target="unit-tests",
53 source = bld.path.ant_glob(['tests/**/*.cc']),
54 features=['cxx', 'cxxprogram'],
Yingdi Yu280bb962014-01-30 09:52:43 -080055 use = 'ChronoSync',
Alexander Afanasyevce001692013-07-14 11:34:41 -070056 includes = ['src'],
Yingdi Yu0eee6002014-02-11 15:54:17 -080057 install_path = None,
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070058 )
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070059
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070060 if bld.get_define("HAVE_LOG4CXX"):
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070061 libsync.use += ' LOG4CXX'
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -070062 if bld.get_define("_TEST"):
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070063 unittests.use += ' LOG4CXX'
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070064
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070065 bld.install_files(
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070066 dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
67 files = bld.path.ant_glob(['src/**/*.h']),
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070068 cwd = bld.path.find_dir("src"),
Alexander Afanasyevce001692013-07-14 11:34:41 -070069 relative_trick = True,
70 )
71
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070072 bld.install_files(
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070073 dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
74 files = bld.path.get_bld().ant_glob(['src/**/*.h']),
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070075 cwd = bld.path.get_bld().find_dir("src"),
Alexander Afanasyevce001692013-07-14 11:34:41 -070076 relative_trick = True,
77 )
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080078
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070079 pc = bld(
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070080 features = "subst",
Alexander Afanasyev7804c232013-07-14 12:15:41 -070081 source='ChronoSync.pc.in',
82 target='ChronoSync.pc',
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070083 install_path = '${LIBDIR}/pkgconfig',
84 PREFIX = bld.env['PREFIX'],
Alexander Afanasyevce001692013-07-14 11:34:41 -070085 INCLUDEDIR = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070086 VERSION = VERSION,
87 )
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070088
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070089def doxygen(bld):
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080090 if not bld.env.DOXYGEN:
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070091 bld.fatal("ERROR: cannot build documentation(`doxygen' is not found in $PATH)")
92 bld(features="doxygen",
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080093 doxyfile='doc/doxygen.conf',
94 output_dir = 'doc')