blob: a14b085549755e0164d22556156091d4635a1c5d [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
Yingdi Yu06a678a2014-08-01 17:07:08 -07003from waflib import Logs, Utils, Context
4import os
Alexander Afanasyev182fdc22012-03-05 18:06:52 -08005
Yingdi Yu06a678a2014-08-01 17:07:08 -07006VERSION = '0.2'
7APPNAME = 'ChronoSync'
Alexander Afanasyev6af3c152012-06-07 21:14:24 -07008
Alexander Afanasyeve76f2632012-03-05 00:18:42 -08009def options(opt):
Yingdi Yu06a678a2014-08-01 17:07:08 -070010 opt.load(['compiler_c', 'compiler_cxx', 'gnu_dirs'])
11 opt.load(['boost', 'doxygen', 'sphinx_build', 'default-compiler-flags',
12 'pch', 'protoc'],
13 tooldir=['.waf-tools'])
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070014
15 syncopt = opt.add_option_group ("ChronoSync Options")
16
Yingdi Yu06a678a2014-08-01 17:07:08 -070017 syncopt.add_option('--debug', action='store_true', default=False, dest='debug',
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070018 help='''debugging mode''')
19 syncopt.add_option('--with-log4cxx', action='store_true', default=False, dest='log4cxx',
20 help='''Compile with log4cxx''')
Yingdi Yu06a678a2014-08-01 17:07:08 -070021 syncopt.add_option('--with-tests', action='store_true', default=False, dest='_tests',
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070022 help='''build unit tests''')
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080023
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080024def configure(conf):
Yingdi Yu06a678a2014-08-01 17:07:08 -070025 conf.load(['compiler_c', 'compiler_cxx', 'gnu_dirs', 'boost', 'pch',
26 'doxygen', 'sphinx_build', 'default-compiler-flags', 'protoc'])
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070027
Yingdi Yu06a678a2014-08-01 17:07:08 -070028 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
29 uselib_store='NDN_CXX', mandatory=True)
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070030
Yingdi Yu06a678a2014-08-01 17:07:08 -070031 boost_libs = 'system iostreams'
32 if conf.options._tests:
Yingdi Yu9d5679a2015-02-01 00:17:58 -080033 conf.env['CHRONOSYNC_HAVE_TESTS'] = 1
34 conf.define('CHRONOSYNC_HAVE_TESTS', 1);
Yingdi Yu06a678a2014-08-01 17:07:08 -070035 boost_libs += ' unit_test_framework'
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070036
Yingdi Yub20ae812014-08-15 11:20:19 -070037 conf.check_boost(lib=boost_libs)
38
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070039 if conf.options.log4cxx:
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070040 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX',
41 mandatory=True)
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070042
Yingdi Yub20ae812014-08-15 11:20:19 -070043 conf.write_config_header('config.hpp')
44
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070045def build(bld):
46 libsync = bld(
Alexander Afanasyevf46eac52013-07-26 11:27:39 -070047 target="ChronoSync",
Yingdi Yuce841ca2013-12-14 08:28:00 +080048 # vnum = "1.0.0",
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070049 features=['cxx', 'cxxshlib'],
Yingdi Yub20ae812014-08-15 11:20:19 -070050 source = bld.path.ant_glob(['src/**/*.cpp', 'src/**/*.proto']),
Yingdi Yuf7ede412014-08-30 20:37:52 -070051 use = 'BOOST NDN_CXX LOG4CXX',
Yingdi Yub20ae812014-08-15 11:20:19 -070052 includes = ['src', '.'],
Yingdi Yudea99be2014-08-15 10:45:43 -070053 export_includes=['src', '.'],
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070054 )
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070055
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070056 # Unit tests
Yingdi Yu9d5679a2015-02-01 00:17:58 -080057 if bld.env["CHRONOSYNC_HAVE_TESTS"]:
Yingdi Yub20ae812014-08-15 11:20:19 -070058 bld.recurse('tests')
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070059
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070060 bld.install_files(
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070061 dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
Yingdi Yuf7ede412014-08-30 20:37:52 -070062 files = bld.path.ant_glob(['src/**/*.hpp', 'src/**/*.h', 'common.hpp']),
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070063 cwd = bld.path.find_dir("src"),
Yingdi Yuf7ede412014-08-30 20:37:52 -070064 relative_trick = False,
Alexander Afanasyevce001692013-07-14 11:34:41 -070065 )
66
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070067 bld.install_files(
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070068 dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
Yingdi Yuf7ede412014-08-30 20:37:52 -070069 files = bld.path.get_bld().ant_glob(['src/**/*.hpp', 'src/**/*.h', 'common.hpp', 'config.hpp']),
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070070 cwd = bld.path.get_bld().find_dir("src"),
Yingdi Yuf7ede412014-08-30 20:37:52 -070071 relative_trick = False,
Alexander Afanasyevce001692013-07-14 11:34:41 -070072 )
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080073
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070074 pc = bld(
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070075 features = "subst",
Alexander Afanasyev7804c232013-07-14 12:15:41 -070076 source='ChronoSync.pc.in',
77 target='ChronoSync.pc',
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070078 install_path = '${LIBDIR}/pkgconfig',
79 PREFIX = bld.env['PREFIX'],
Alexander Afanasyevce001692013-07-14 11:34:41 -070080 INCLUDEDIR = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070081 VERSION = VERSION,
82 )
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070083
Yingdi Yu06a678a2014-08-01 17:07:08 -070084# docs
85def docs(bld):
86 from waflib import Options
87 Options.commands = ['doxygen', 'sphinx'] + Options.commands
88
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070089def doxygen(bld):
Yingdi Yu06a678a2014-08-01 17:07:08 -070090 version(bld)
91
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080092 if not bld.env.DOXYGEN:
Yingdi Yu06a678a2014-08-01 17:07:08 -070093 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
94 else:
95 bld(features="subst",
96 name="doxygen-conf",
97 source=["docs/doxygen.conf.in",
98 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
99 target=["docs/doxygen.conf",
100 "docs/named_data_theme/named_data_footer-with-analytics.html"],
101 VERSION=VERSION,
102 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
103 if os.getenv('GOOGLE_ANALYTICS', None) \
104 else "../docs/named_data_theme/named_data_footer.html",
105 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
106 )
107
108 bld(features="doxygen",
109 doxyfile='docs/doxygen.conf',
110 use="doxygen-conf")
111
112def sphinx(bld):
113 version(bld)
114
115 if not bld.env.SPHINX_BUILD:
116 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
117 else:
118 bld(features="sphinx",
119 outdir="docs",
120 source=bld.path.ant_glob("docs/**/*.rst"),
121 config="docs/conf.py",
122 VERSION=VERSION)
123
124def version(ctx):
125 if getattr(Context.g_module, 'VERSION_BASE', None):
126 return
127
128 Context.g_module.VERSION_BASE = Context.g_module.VERSION
129 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
130
131 try:
132 cmd = ['git', 'describe', '--match', 'ChronoSync-*']
133 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
134 stderr=None, stdin=None)
135 out = p.communicate()[0].strip()
136 if p.returncode == 0 and out != "":
137 Context.g_module.VERSION = out[11:]
138 except:
139 pass
140
141def dist(ctx):
142 version(ctx)
143
144def distcheck(ctx):
145 version(ctx)