Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
Alexander Afanasyev | 7804c23 | 2013-07-14 12:15:41 -0700 | [diff] [blame] | 3 | VERSION='0.1' |
| 4 | APPNAME='ChronoSync' |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 5 | |
Alexander Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 6 | from waflib import Configure, Build, Logs |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 7 | |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 8 | def options(opt): |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 9 | 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 Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 12 | |
| 13 | syncopt = opt.add_option_group ("ChronoSync Options") |
| 14 | |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 15 | 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 Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 21 | |
Alexander Afanasyev | 8f25cbb | 2012-03-01 23:53:40 -0800 | [diff] [blame] | 22 | def configure(conf): |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 23 | conf.load('compiler_c compiler_cxx gnu_dirs boost default-compiler-flags pch') |
| 24 | conf.load('doxygen sphinx_build') |
| 25 | conf.load('protoc') |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 26 | |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 27 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX', |
| 28 | mandatory=True) |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 29 | |
Yingdi Yu | 280bb96 | 2014-01-30 09:52:43 -0800 | [diff] [blame] | 30 | conf.check_boost(lib='system iostreams thread unit_test_framework') |
Alexander Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 31 | |
| 32 | if conf.options.log4cxx: |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 33 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', |
| 34 | mandatory=True) |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 35 | |
Zhenkai Zhu | 43ae5c7 | 2012-05-31 23:18:45 -0700 | [diff] [blame] | 36 | if conf.options._test: |
| 37 | conf.define('_TEST', 1) |
| 38 | |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 39 | def build(bld): |
| 40 | libsync = bld( |
Alexander Afanasyev | f46eac5 | 2013-07-26 11:27:39 -0700 | [diff] [blame] | 41 | target="ChronoSync", |
Yingdi Yu | ce841ca | 2013-12-14 08:28:00 +0800 | [diff] [blame] | 42 | # vnum = "1.0.0", |
Alexander Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 43 | features=['cxx', 'cxxshlib'], |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 44 | source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.proto']), |
Alexander Afanasyev | 7c97cfa | 2014-07-02 12:10:13 -0700 | [diff] [blame] | 45 | use = 'BOOST NDNCXX', |
Alexander Afanasyev | ce00169 | 2013-07-14 11:34:41 -0700 | [diff] [blame] | 46 | includes = ['src'], |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 47 | ) |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 48 | |
Alexander Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 49 | # Unit tests |
| 50 | if bld.get_define("_TEST"): |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 51 | unittests = bld.program( |
Alexander Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 52 | target="unit-tests", |
| 53 | source = bld.path.ant_glob(['tests/**/*.cc']), |
| 54 | features=['cxx', 'cxxprogram'], |
Yingdi Yu | 280bb96 | 2014-01-30 09:52:43 -0800 | [diff] [blame] | 55 | use = 'ChronoSync', |
Alexander Afanasyev | ce00169 | 2013-07-14 11:34:41 -0700 | [diff] [blame] | 56 | includes = ['src'], |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 57 | install_path = None, |
Alexander Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 58 | ) |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 59 | |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 60 | if bld.get_define("HAVE_LOG4CXX"): |
Alexander Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 61 | libsync.use += ' LOG4CXX' |
Zhenkai Zhu | 43ae5c7 | 2012-05-31 23:18:45 -0700 | [diff] [blame] | 62 | if bld.get_define("_TEST"): |
Alexander Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 63 | unittests.use += ' LOG4CXX' |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 64 | |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 65 | bld.install_files( |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 66 | dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'], |
| 67 | files = bld.path.ant_glob(['src/**/*.h']), |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 68 | cwd = bld.path.find_dir("src"), |
Alexander Afanasyev | ce00169 | 2013-07-14 11:34:41 -0700 | [diff] [blame] | 69 | relative_trick = True, |
| 70 | ) |
| 71 | |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 72 | bld.install_files( |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 73 | dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'], |
| 74 | files = bld.path.get_bld().ant_glob(['src/**/*.h']), |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 75 | cwd = bld.path.get_bld().find_dir("src"), |
Alexander Afanasyev | ce00169 | 2013-07-14 11:34:41 -0700 | [diff] [blame] | 76 | relative_trick = True, |
| 77 | ) |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 78 | |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 79 | pc = bld( |
Alexander Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 80 | features = "subst", |
Alexander Afanasyev | 7804c23 | 2013-07-14 12:15:41 -0700 | [diff] [blame] | 81 | source='ChronoSync.pc.in', |
| 82 | target='ChronoSync.pc', |
Alexander Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 83 | install_path = '${LIBDIR}/pkgconfig', |
| 84 | PREFIX = bld.env['PREFIX'], |
Alexander Afanasyev | ce00169 | 2013-07-14 11:34:41 -0700 | [diff] [blame] | 85 | INCLUDEDIR = "%s/ChronoSync" % bld.env['INCLUDEDIR'], |
Alexander Afanasyev | 6133f9a | 2013-07-14 10:58:26 -0700 | [diff] [blame] | 86 | VERSION = VERSION, |
| 87 | ) |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 88 | |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 89 | def doxygen(bld): |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 90 | if not bld.env.DOXYGEN: |
Alexander Afanasyev | 7eb5911 | 2014-07-02 14:21:11 -0700 | [diff] [blame^] | 91 | bld.fatal("ERROR: cannot build documentation(`doxygen' is not found in $PATH)") |
| 92 | bld(features="doxygen", |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 93 | doxyfile='doc/doxygen.conf', |
| 94 | output_dir = 'doc') |