blob: ee2684a11f84c60b90b4748fd125ca92c3d54829 [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:
33 conf.env['_TESTS'] = 1
34 conf.define('_TESTS', 1);
35 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 Yu06a678a2014-08-01 17:07:08 -070051 use = 'BOOST NDN_CXX',
Yingdi Yub20ae812014-08-15 11:20:19 -070052 includes = ['src', '.'],
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070053 )
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070054
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070055 # Unit tests
Yingdi Yub20ae812014-08-15 11:20:19 -070056 if bld.env["_TESTS"]:
57 bld.recurse('tests')
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070058
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070059 if bld.get_define("HAVE_LOG4CXX"):
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070060 libsync.use += ' LOG4CXX'
Yingdi Yub20ae812014-08-15 11:20:19 -070061 if bld.env["_TESTS"]:
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070062 unittests.use += ' LOG4CXX'
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070063
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070064 bld.install_files(
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070065 dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
66 files = bld.path.ant_glob(['src/**/*.h']),
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070067 cwd = bld.path.find_dir("src"),
Alexander Afanasyevce001692013-07-14 11:34:41 -070068 relative_trick = True,
69 )
70
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070071 bld.install_files(
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070072 dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
73 files = bld.path.get_bld().ant_glob(['src/**/*.h']),
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070074 cwd = bld.path.get_bld().find_dir("src"),
Alexander Afanasyevce001692013-07-14 11:34:41 -070075 relative_trick = True,
76 )
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080077
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070078 pc = bld(
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070079 features = "subst",
Alexander Afanasyev7804c232013-07-14 12:15:41 -070080 source='ChronoSync.pc.in',
81 target='ChronoSync.pc',
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070082 install_path = '${LIBDIR}/pkgconfig',
83 PREFIX = bld.env['PREFIX'],
Alexander Afanasyevce001692013-07-14 11:34:41 -070084 INCLUDEDIR = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070085 VERSION = VERSION,
86 )
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070087
Yingdi Yu06a678a2014-08-01 17:07:08 -070088# docs
89def docs(bld):
90 from waflib import Options
91 Options.commands = ['doxygen', 'sphinx'] + Options.commands
92
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070093def doxygen(bld):
Yingdi Yu06a678a2014-08-01 17:07:08 -070094 version(bld)
95
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080096 if not bld.env.DOXYGEN:
Yingdi Yu06a678a2014-08-01 17:07:08 -070097 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
98 else:
99 bld(features="subst",
100 name="doxygen-conf",
101 source=["docs/doxygen.conf.in",
102 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
103 target=["docs/doxygen.conf",
104 "docs/named_data_theme/named_data_footer-with-analytics.html"],
105 VERSION=VERSION,
106 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
107 if os.getenv('GOOGLE_ANALYTICS', None) \
108 else "../docs/named_data_theme/named_data_footer.html",
109 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
110 )
111
112 bld(features="doxygen",
113 doxyfile='docs/doxygen.conf',
114 use="doxygen-conf")
115
116def sphinx(bld):
117 version(bld)
118
119 if not bld.env.SPHINX_BUILD:
120 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
121 else:
122 bld(features="sphinx",
123 outdir="docs",
124 source=bld.path.ant_glob("docs/**/*.rst"),
125 config="docs/conf.py",
126 VERSION=VERSION)
127
128def version(ctx):
129 if getattr(Context.g_module, 'VERSION_BASE', None):
130 return
131
132 Context.g_module.VERSION_BASE = Context.g_module.VERSION
133 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
134
135 try:
136 cmd = ['git', 'describe', '--match', 'ChronoSync-*']
137 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
138 stderr=None, stdin=None)
139 out = p.communicate()[0].strip()
140 if p.returncode == 0 and out != "":
141 Context.g_module.VERSION = out[11:]
142 except:
143 pass
144
145def dist(ctx):
146 version(ctx)
147
148def distcheck(ctx):
149 version(ctx)