shockjiang | e9c1ab9 | 2014-07-21 12:02:52 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Alexander Afanasyev | ab430ee | 2014-08-05 21:11:25 -0700 | [diff] [blame] | 2 | |
| 3 | VERSION='0.1.0' |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 4 | APPNAME="ndns" |
Alexander Afanasyev | ab430ee | 2014-08-05 21:11:25 -0700 | [diff] [blame] | 5 | BUGREPORT = "http://redmine.named-data.net/projects/ndns" |
| 6 | URL = "http://named-data.net/doc/NDNS/" |
| 7 | |
| 8 | from waflib import Logs, Utils, Context |
shockjiang | e9c1ab9 | 2014-07-21 12:02:52 -0700 | [diff] [blame] | 9 | |
| 10 | def options(opt): |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 11 | 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''') |
shockjiang | e9c1ab9 | 2014-07-21 12:02:52 -0700 | [diff] [blame] | 19 | |
| 20 | def configure(conf): |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 21 | conf.load(['compiler_cxx', 'gnu_dirs', |
Alexander Afanasyev | ab430ee | 2014-08-05 21:11:25 -0700 | [diff] [blame] | 22 | 'boost', 'default-compiler-flags', 'doxygen', 'sphinx_build', |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 23 | 'sqlite3', 'pch', 'coverage']) |
Alexander Afanasyev | ab430ee | 2014-08-05 21:11:25 -0700 | [diff] [blame] | 24 | |
shockjiang | 99ad389 | 2014-08-03 14:56:13 -0700 | [diff] [blame] | 25 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], |
| 26 | uselib_store='LOG4CXX', mandatory=True) |
Alexander Afanasyev | ab430ee | 2014-08-05 21:11:25 -0700 | [diff] [blame] | 27 | |
shockjiang | e9c1ab9 | 2014-07-21 12:02:52 -0700 | [diff] [blame] | 28 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 29 | uselib_store='NDN_CXX', mandatory=True) |
| 30 | |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 31 | 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 Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 41 | 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 | |
shockjiang | e9c1ab9 | 2014-07-21 12:02:52 -0700 | [diff] [blame] | 46 | def build (bld): |
Alexander Afanasyev | ab430ee | 2014-08-05 21:11:25 -0700 | [diff] [blame] | 47 | 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 Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 64 | bld( |
| 65 | features='cxx', |
| 66 | name='ndns-objects', |
Alexander Afanasyev | ab430ee | 2014-08-05 21:11:25 -0700 | [diff] [blame] | 67 | source=bld.path.ant_glob(['src/**/*.cpp'], |
| 68 | excl=['src/main.cpp']), |
| 69 | use='version NDN_CXX BOOST', |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 70 | includes='src', |
| 71 | export_includes='src', |
| 72 | ) |
Alexander Afanasyev | ab430ee | 2014-08-05 21:11:25 -0700 | [diff] [blame] | 73 | |
| 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 Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 81 | bld.recurse('tests') |
| 82 | |
| 83 | # bld.install_files('${SYSCONFDIR}/ndn', 'ndns.conf.sample') |
Alexander Afanasyev | ab430ee | 2014-08-05 21:11:25 -0700 | [diff] [blame] | 84 | |
| 85 | def docs(bld): |
| 86 | from waflib import Options |
| 87 | Options.commands = ['doxygen', 'sphinx'] + Options.commands |
| 88 | |
| 89 | def 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 | |
| 106 | def 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 | |
| 118 | def 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 | |
| 135 | def dist(ctx): |
| 136 | version(ctx) |
| 137 | |
| 138 | def distcheck(ctx): |
| 139 | version(ctx) |