blob: fece357947b0d2c107378f4591734a61b54d31ff [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
37 if conf.options.log4cxx:
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070038 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX',
39 mandatory=True)
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070040
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070041def build(bld):
42 libsync = bld(
Alexander Afanasyevf46eac52013-07-26 11:27:39 -070043 target="ChronoSync",
Yingdi Yuce841ca2013-12-14 08:28:00 +080044 # vnum = "1.0.0",
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070045 features=['cxx', 'cxxshlib'],
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070046 source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.proto']),
Yingdi Yu06a678a2014-08-01 17:07:08 -070047 use = 'BOOST NDN_CXX',
Alexander Afanasyevce001692013-07-14 11:34:41 -070048 includes = ['src'],
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070049 )
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070050
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070051 # Unit tests
Yingdi Yu06a678a2014-08-01 17:07:08 -070052 if bld.get_define("_TESTS"):
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070053 unittests = bld.program(
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070054 target="unit-tests",
55 source = bld.path.ant_glob(['tests/**/*.cc']),
56 features=['cxx', 'cxxprogram'],
Yingdi Yu280bb962014-01-30 09:52:43 -080057 use = 'ChronoSync',
Alexander Afanasyevce001692013-07-14 11:34:41 -070058 includes = ['src'],
Yingdi Yu0eee6002014-02-11 15:54:17 -080059 install_path = None,
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070060 )
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070061
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070062 if bld.get_define("HAVE_LOG4CXX"):
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070063 libsync.use += ' LOG4CXX'
Yingdi Yu06a678a2014-08-01 17:07:08 -070064 if bld.get_define("_TESTS"):
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070065 unittests.use += ' LOG4CXX'
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070066
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'],
69 files = bld.path.ant_glob(['src/**/*.h']),
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070070 cwd = bld.path.find_dir("src"),
Alexander Afanasyevce001692013-07-14 11:34:41 -070071 relative_trick = True,
72 )
73
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070074 bld.install_files(
Yingdi Yu7c64e5c2014-04-30 14:06:37 -070075 dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
76 files = bld.path.get_bld().ant_glob(['src/**/*.h']),
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070077 cwd = bld.path.get_bld().find_dir("src"),
Alexander Afanasyevce001692013-07-14 11:34:41 -070078 relative_trick = True,
79 )
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080080
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070081 pc = bld(
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070082 features = "subst",
Alexander Afanasyev7804c232013-07-14 12:15:41 -070083 source='ChronoSync.pc.in',
84 target='ChronoSync.pc',
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070085 install_path = '${LIBDIR}/pkgconfig',
86 PREFIX = bld.env['PREFIX'],
Alexander Afanasyevce001692013-07-14 11:34:41 -070087 INCLUDEDIR = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070088 VERSION = VERSION,
89 )
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070090
Yingdi Yu06a678a2014-08-01 17:07:08 -070091# docs
92def docs(bld):
93 from waflib import Options
94 Options.commands = ['doxygen', 'sphinx'] + Options.commands
95
Alexander Afanasyev7eb59112014-07-02 14:21:11 -070096def doxygen(bld):
Yingdi Yu06a678a2014-08-01 17:07:08 -070097 version(bld)
98
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080099 if not bld.env.DOXYGEN:
Yingdi Yu06a678a2014-08-01 17:07:08 -0700100 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
101 else:
102 bld(features="subst",
103 name="doxygen-conf",
104 source=["docs/doxygen.conf.in",
105 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
106 target=["docs/doxygen.conf",
107 "docs/named_data_theme/named_data_footer-with-analytics.html"],
108 VERSION=VERSION,
109 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
110 if os.getenv('GOOGLE_ANALYTICS', None) \
111 else "../docs/named_data_theme/named_data_footer.html",
112 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
113 )
114
115 bld(features="doxygen",
116 doxyfile='docs/doxygen.conf',
117 use="doxygen-conf")
118
119def sphinx(bld):
120 version(bld)
121
122 if not bld.env.SPHINX_BUILD:
123 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
124 else:
125 bld(features="sphinx",
126 outdir="docs",
127 source=bld.path.ant_glob("docs/**/*.rst"),
128 config="docs/conf.py",
129 VERSION=VERSION)
130
131def version(ctx):
132 if getattr(Context.g_module, 'VERSION_BASE', None):
133 return
134
135 Context.g_module.VERSION_BASE = Context.g_module.VERSION
136 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
137
138 try:
139 cmd = ['git', 'describe', '--match', 'ChronoSync-*']
140 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
141 stderr=None, stdin=None)
142 out = p.communicate()[0].strip()
143 if p.returncode == 0 and out != "":
144 Context.g_module.VERSION = out[11:]
145 except:
146 pass
147
148def dist(ctx):
149 version(ctx)
150
151def distcheck(ctx):
152 version(ctx)