blob: 8cf1d852e2db374b09875f64a22016d13b01ade4 [file] [log] [blame]
shockjiange9c1ab92014-07-21 12:02:52 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyevab430ee2014-08-05 21:11:25 -07002
3VERSION='0.1.0'
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -07004APPNAME="ndns"
Alexander Afanasyevab430ee2014-08-05 21:11:25 -07005BUGREPORT = "http://redmine.named-data.net/projects/ndns"
6URL = "http://named-data.net/doc/NDNS/"
7
8from waflib import Logs, Utils, Context
shockjiange9c1ab92014-07-21 12:02:52 -07009
10def options(opt):
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070011 opt.load(['compiler_cxx', 'gnu_dirs'])
12 opt.load(['boost', 'default-compiler-flags', 'doxygen', 'sphinx_build',
13 'sqlite3', 'pch', 'coverage'], tooldir=['.waf-tools'])
14
15 ropt = opt.add_option_group('NDNS Options')
16
17 ropt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
18 help='''build unit tests''')
shockjiange9c1ab92014-07-21 12:02:52 -070019
20def configure(conf):
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070021 conf.load(['compiler_cxx', 'gnu_dirs',
Alexander Afanasyevab430ee2014-08-05 21:11:25 -070022 'boost', 'default-compiler-flags', 'doxygen', 'sphinx_build',
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070023 'sqlite3', 'pch', 'coverage'])
Alexander Afanasyevab430ee2014-08-05 21:11:25 -070024
shockjiang99ad3892014-08-03 14:56:13 -070025 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'],
26 uselib_store='LOG4CXX', mandatory=True)
Alexander Afanasyevab430ee2014-08-05 21:11:25 -070027
shockjiange9c1ab92014-07-21 12:02:52 -070028 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
29 uselib_store='NDN_CXX', mandatory=True)
30
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070031 conf.check_sqlite3(mandatory=True)
32
33 if conf.options.with_tests:
34 conf.env['WITH_TESTS'] = True
35
36 USED_BOOST_LIBS = ['system']
37 if conf.env['WITH_TESTS']:
38 USED_BOOST_LIBS += ['unit_test_framework']
39 conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True)
40
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070041 if not conf.options.with_sqlite_locking:
42 conf.define('DISABLE_SQLITE3_FS_LOCKING', 1)
43
44 conf.write_config_header('src/config.hpp')
45
shockjiange9c1ab92014-07-21 12:02:52 -070046def build (bld):
Alexander Afanasyevab430ee2014-08-05 21:11:25 -070047 version(bld)
48
49 bld(features="subst",
50 name='version',
51 source='src/version.hpp.in',
52 target='src/version.hpp',
53 install_path=None,
54 VERSION_STRING=VERSION_BASE,
55 VERSION_BUILD=VERSION,
56 VERSION=int(VERSION_SPLIT[0]) * 1000000 +
57 int(VERSION_SPLIT[1]) * 1000 +
58 int(VERSION_SPLIT[2]),
59 VERSION_MAJOR=VERSION_SPLIT[0],
60 VERSION_MINOR=VERSION_SPLIT[1],
61 VERSION_PATCH=VERSION_SPLIT[2],
62 )
63
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070064 bld(
65 features='cxx',
66 name='ndns-objects',
Alexander Afanasyevab430ee2014-08-05 21:11:25 -070067 source=bld.path.ant_glob(['src/**/*.cpp'],
68 excl=['src/main.cpp']),
69 use='version NDN_CXX BOOST',
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070070 includes='src',
71 export_includes='src',
72 )
Alexander Afanasyevab430ee2014-08-05 21:11:25 -070073
74 for app in bld.path.ant_glob('tools/*.cpp'):
75 bld(features=['cxx', 'cxxprogram'],
76 target='bin/%s' % (str(app.change_ext(''))),
77 source=['tools/%s' % (str(app))],
78 use='ndns-objects',
79 )
80
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070081 bld.recurse('tests')
82
83 # bld.install_files('${SYSCONFDIR}/ndn', 'ndns.conf.sample')
Alexander Afanasyevab430ee2014-08-05 21:11:25 -070084
85def docs(bld):
86 from waflib import Options
87 Options.commands = ['doxygen', 'sphinx'] + Options.commands
88
89def doxygen(bld):
90 version(bld)
91
92 if not bld.env.DOXYGEN:
93 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 target="docs/doxygen.conf",
99 VERSION=VERSION_BASE,
100 )
101
102 bld(features="doxygen",
103 doxyfile='docs/doxygen.conf',
104 use="doxygen-conf")
105
106def sphinx(bld):
107 version(bld)
108
109 if not bld.env.SPHINX_BUILD:
110 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
111 else:
112 bld(features="sphinx",
113 outdir="docs",
114 source=bld.path.ant_glob('docs/**/*.rst'),
115 config="docs/conf.py",
116 VERSION=VERSION_BASE)
117
118def version(ctx):
119 if getattr(Context.g_module, 'VERSION_BASE', None):
120 return
121
122 Context.g_module.VERSION_BASE = Context.g_module.VERSION
123 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
124
125 try:
126 cmd = ['git', 'describe', '--match', 'ndns-*']
127 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
128 stderr=None, stdin=None)
129 out = p.communicate()[0].strip()
130 if p.returncode == 0 and out != "":
131 Context.g_module.VERSION = out[4:]
132 except:
133 pass
134
135def dist(ctx):
136 version(ctx)
137
138def distcheck(ctx):
139 version(ctx)