blob: 0f0ea36bd5a71953c010bd1e5b2f2530664816da [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', '.'],
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 Yub20ae812014-08-15 11:20:19 -070057 if bld.env["_TESTS"]:
58 bld.recurse('tests')
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'
Yingdi Yub20ae812014-08-15 11:20:19 -070062 if bld.env["_TESTS"]:
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
Yingdi Yu06a678a2014-08-01 17:07:08 -070089# docs
90def docs(bld):
91 from waflib import Options
92 Options.commands = ['doxygen', 'sphinx'] + Options.commands
93
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070094def doxygen(bld):
Yingdi Yu06a678a2014-08-01 17:07:08 -070095 version(bld)
96
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080097 if not bld.env.DOXYGEN:
Yingdi Yu06a678a2014-08-01 17:07:08 -070098 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
99 else:
100 bld(features="subst",
101 name="doxygen-conf",
102 source=["docs/doxygen.conf.in",
103 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
104 target=["docs/doxygen.conf",
105 "docs/named_data_theme/named_data_footer-with-analytics.html"],
106 VERSION=VERSION,
107 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
108 if os.getenv('GOOGLE_ANALYTICS', None) \
109 else "../docs/named_data_theme/named_data_footer.html",
110 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
111 )
112
113 bld(features="doxygen",
114 doxyfile='docs/doxygen.conf',
115 use="doxygen-conf")
116
117def sphinx(bld):
118 version(bld)
119
120 if not bld.env.SPHINX_BUILD:
121 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
122 else:
123 bld(features="sphinx",
124 outdir="docs",
125 source=bld.path.ant_glob("docs/**/*.rst"),
126 config="docs/conf.py",
127 VERSION=VERSION)
128
129def version(ctx):
130 if getattr(Context.g_module, 'VERSION_BASE', None):
131 return
132
133 Context.g_module.VERSION_BASE = Context.g_module.VERSION
134 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
135
136 try:
137 cmd = ['git', 'describe', '--match', 'ChronoSync-*']
138 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
139 stderr=None, stdin=None)
140 out = p.communicate()[0].strip()
141 if p.returncode == 0 and out != "":
142 Context.g_module.VERSION = out[11:]
143 except:
144 pass
145
146def dist(ctx):
147 version(ctx)
148
149def distcheck(ctx):
150 version(ctx)