blob: e3e3b1ea5058ec2d04c88fad5138cd5a917b5621 [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
Alexander Afanasyevf3192eb2016-12-19 17:11:20 -08006VERSION = '0.3.0'
Yingdi Yu06a678a2014-08-01 17:07:08 -07007APPNAME = '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'])
Alexander Afanasyevf3192eb2016-12-19 17:11:20 -080011 opt.load(['default-compiler-flags', 'boost', 'doxygen', 'sphinx_build',
12 'sanitizers', 'coverage', 'pch'],
Yingdi Yu06a678a2014-08-01 17:07:08 -070013 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''')
Yingdi Yu06a678a2014-08-01 17:07:08 -070019 syncopt.add_option('--with-tests', action='store_true', default=False, dest='_tests',
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070020 help='''build unit tests''')
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080021
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080022def configure(conf):
Alexander Afanasyevf3192eb2016-12-19 17:11:20 -080023 conf.load(['compiler_c', 'compiler_cxx', 'gnu_dirs',
24 'default-compiler-flags', 'boost', 'pch', 'sanitizers', 'coverage',
25 'doxygen', 'sphinx_build'])
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070026
Yingdi Yu06a678a2014-08-01 17:07:08 -070027 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
28 uselib_store='NDN_CXX', mandatory=True)
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070029
Alexander Afanasyev36eb3ed2017-01-11 12:35:58 -080030 boost_libs = 'system iostreams thread log log_setup'
Yingdi Yu06a678a2014-08-01 17:07:08 -070031 if conf.options._tests:
Yingdi Yu9d5679a2015-02-01 00:17:58 -080032 conf.env['CHRONOSYNC_HAVE_TESTS'] = 1
33 conf.define('CHRONOSYNC_HAVE_TESTS', 1);
Yingdi Yu06a678a2014-08-01 17:07:08 -070034 boost_libs += ' unit_test_framework'
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070035
Alexander Afanasyev36eb3ed2017-01-11 12:35:58 -080036 conf.check_boost(lib=boost_libs, mt=True)
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070037
Alexander Afanasyevf3192eb2016-12-19 17:11:20 -080038 # If there happens to be a static library, waf will put the corresponding -L flags
39 # before dynamic library flags. This can result in compilation failure when the
40 # system has a different version of the ChronoSync library installed.
41 conf.env['STLIBPATH'] = ['.'] + conf.env['STLIBPATH']
42
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",
Alexander Afanasyevf3192eb2016-12-19 17:11:20 -080048 vnum = VERSION,
49 cnum = VERSION,
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070050 features=['cxx', 'cxxshlib'],
Yingdi Yub20ae812014-08-15 11:20:19 -070051 source = bld.path.ant_glob(['src/**/*.cpp', 'src/**/*.proto']),
Alexander Afanasyev36eb3ed2017-01-11 12:35:58 -080052 use = 'BOOST NDN_CXX',
Yingdi Yub20ae812014-08-15 11:20:19 -070053 includes = ['src', '.'],
Yingdi Yudea99be2014-08-15 10:45:43 -070054 export_includes=['src', '.'],
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070055 )
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070056
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070057 # Unit tests
Yingdi Yu9d5679a2015-02-01 00:17:58 -080058 if bld.env["CHRONOSYNC_HAVE_TESTS"]:
Yingdi Yub20ae812014-08-15 11:20:19 -070059 bld.recurse('tests')
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070060
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070061 bld.install_files(
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070062 dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
Yingdi Yuf7ede412014-08-30 20:37:52 -070063 files = bld.path.ant_glob(['src/**/*.hpp', 'src/**/*.h', 'common.hpp']),
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070064 cwd = bld.path.find_dir("src"),
Yingdi Yuf7ede412014-08-30 20:37:52 -070065 relative_trick = False,
Alexander Afanasyevce001692013-07-14 11:34:41 -070066 )
67
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070068 bld.install_files(
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070069 dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
Yingdi Yuf7ede412014-08-30 20:37:52 -070070 files = bld.path.get_bld().ant_glob(['src/**/*.hpp', 'src/**/*.h', 'common.hpp', 'config.hpp']),
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070071 cwd = bld.path.get_bld().find_dir("src"),
Yingdi Yuf7ede412014-08-30 20:37:52 -070072 relative_trick = False,
Alexander Afanasyevce001692013-07-14 11:34:41 -070073 )
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080074
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070075 pc = bld(
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070076 features = "subst",
Alexander Afanasyev7804c232013-07-14 12:15:41 -070077 source='ChronoSync.pc.in',
78 target='ChronoSync.pc',
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070079 install_path = '${LIBDIR}/pkgconfig',
80 PREFIX = bld.env['PREFIX'],
Alexander Afanasyevce001692013-07-14 11:34:41 -070081 INCLUDEDIR = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070082 VERSION = VERSION,
83 )
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070084
Yingdi Yu06a678a2014-08-01 17:07:08 -070085# docs
86def docs(bld):
87 from waflib import Options
88 Options.commands = ['doxygen', 'sphinx'] + Options.commands
89
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070090def doxygen(bld):
Yingdi Yu06a678a2014-08-01 17:07:08 -070091 version(bld)
92
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080093 if not bld.env.DOXYGEN:
Yingdi Yu06a678a2014-08-01 17:07:08 -070094 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
95 else:
96 bld(features="subst",
97 name="doxygen-conf",
98 source=["docs/doxygen.conf.in",
99 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
100 target=["docs/doxygen.conf",
101 "docs/named_data_theme/named_data_footer-with-analytics.html"],
102 VERSION=VERSION,
103 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
104 if os.getenv('GOOGLE_ANALYTICS', None) \
105 else "../docs/named_data_theme/named_data_footer.html",
106 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
107 )
108
109 bld(features="doxygen",
110 doxyfile='docs/doxygen.conf',
111 use="doxygen-conf")
112
113def sphinx(bld):
114 version(bld)
115
116 if not bld.env.SPHINX_BUILD:
117 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
118 else:
119 bld(features="sphinx",
120 outdir="docs",
121 source=bld.path.ant_glob("docs/**/*.rst"),
122 config="docs/conf.py",
123 VERSION=VERSION)
124
125def version(ctx):
126 if getattr(Context.g_module, 'VERSION_BASE', None):
127 return
128
129 Context.g_module.VERSION_BASE = Context.g_module.VERSION
130 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
131
132 try:
133 cmd = ['git', 'describe', '--match', 'ChronoSync-*']
134 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
135 stderr=None, stdin=None)
136 out = p.communicate()[0].strip()
137 if p.returncode == 0 and out != "":
138 Context.g_module.VERSION = out[11:]
139 except:
140 pass
141
142def dist(ctx):
143 version(ctx)
144
145def distcheck(ctx):
146 version(ctx)