Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
| 3 | """ |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 4 | Copyright (c) 2014-2017, Regents of the University of California |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 5 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 6 | This file is part of NDN DeLorean, An Authentication System for Data Archives in |
| 7 | Named Data Networking. See AUTHORS.md for complete list of NDN DeLorean authors |
| 8 | and contributors. |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 9 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 10 | NDN DeLorean is free software: you can redistribute it and/or modify it under |
| 11 | the terms of the GNU General Public License as published by the Free Software |
| 12 | Foundation, either version 3 of the License, or (at your option) any later |
| 13 | version. |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 14 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 15 | NDN DeLorean is distributed in the hope that it will be useful, but WITHOUT ANY |
| 16 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 17 | PARTICULAR PURPOSE. See the GNU General Public License for more details. |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 18 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 19 | You should have received a copy of the GNU General Public License along with NDN |
| 20 | DeLorean, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 21 | """ |
| 22 | |
| 23 | from waflib import Logs, Utils, Context |
| 24 | import os |
| 25 | |
| 26 | VERSION = "0.1.0" |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 27 | APPNAME = "ndn-delorean" |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 28 | |
| 29 | def options(opt): |
| 30 | opt.load(['compiler_cxx', 'gnu_dirs', 'c_osx']) |
| 31 | opt.load(['default-compiler-flags', 'boost', 'cryptopp', |
| 32 | 'sqlite3', 'doxygen', 'sphinx_build'], |
| 33 | tooldir=['.waf-tools']) |
| 34 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 35 | opt = opt.add_option_group('NDN DeLorean Options') |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 36 | |
| 37 | opt.add_option('--with-tests', action='store_true', default=False, dest='with_tests', |
| 38 | help='''build unit tests''') |
| 39 | |
| 40 | opt.add_option('--without-tools', action='store_false', default=True, dest='with_tools', |
| 41 | help='''Do not build tools''') |
| 42 | |
| 43 | opt.add_option('--without-sqlite-locking', action='store_false', default=True, |
| 44 | dest='with_sqlite_locking', |
| 45 | help='''Disable filesystem locking in sqlite3 database ''' |
| 46 | '''(use unix-dot locking mechanism instead). ''' |
| 47 | '''This option may be necessary if home directory is hosted on NFS.''') |
| 48 | |
| 49 | def configure(conf): |
| 50 | conf.load(['compiler_cxx', 'gnu_dirs', 'c_osx', |
| 51 | 'default-compiler-flags', 'boost', 'cryptopp', |
| 52 | 'sqlite3', 'doxygen', 'sphinx_build']) |
| 53 | |
| 54 | conf.env['WITH_TESTS'] = conf.options.with_tests |
| 55 | conf.env['WITH_TOOLS'] = conf.options.with_tools |
| 56 | |
| 57 | conf.find_program('sh', var='SH', mandatory=True) |
| 58 | |
| 59 | conf.check_cxx(lib='pthread', uselib_store='PTHREAD', define_name='HAVE_PTHREAD', |
| 60 | mandatory=False) |
| 61 | conf.check_sqlite3(mandatory=True) |
| 62 | conf.check_cryptopp(mandatory=True, use='PTHREAD') |
| 63 | |
| 64 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 65 | uselib_store='NDN_CXX', mandatory=True) |
| 66 | |
| 67 | USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams', |
| 68 | 'program_options', 'chrono'] |
| 69 | if conf.env['WITH_TESTS']: |
| 70 | USED_BOOST_LIBS += ['unit_test_framework'] |
| 71 | conf.define('HAVE_TESTS', 1) |
| 72 | |
| 73 | conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True) |
| 74 | if conf.env.BOOST_VERSION_NUMBER < 104800: |
| 75 | Logs.error("Minimum required boost version is 1.48.0") |
| 76 | Logs.error("Please upgrade your distribution or install custom boost libraries" + |
| 77 | " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)") |
| 78 | return |
| 79 | |
| 80 | if not conf.options.with_sqlite_locking: |
| 81 | conf.define('DISABLE_SQLITE3_FS_LOCKING', 1) |
| 82 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 83 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/ndn-delorean.conf' % conf.env['SYSCONFDIR']) |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 84 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 85 | conf.write_config_header('config.hpp', define_prefix='NDN_DELOREAN_') |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 86 | |
| 87 | def build(bld): |
| 88 | version(bld) |
| 89 | |
| 90 | bld(features="subst", |
| 91 | name='version', |
| 92 | source='version.hpp.in', |
| 93 | target='version.hpp', |
| 94 | install_path=None, |
| 95 | VERSION_STRING=VERSION_BASE, |
| 96 | VERSION_BUILD=VERSION, |
| 97 | VERSION=int(VERSION_SPLIT[0]) * 1000000 + |
| 98 | int(VERSION_SPLIT[1]) * 1000 + |
| 99 | int(VERSION_SPLIT[2]), |
| 100 | VERSION_MAJOR=VERSION_SPLIT[0], |
| 101 | VERSION_MINOR=VERSION_SPLIT[1], |
| 102 | VERSION_PATCH=VERSION_SPLIT[2], |
| 103 | ) |
| 104 | |
| 105 | core = bld( |
| 106 | target='core-objects', |
| 107 | name='core-objects', |
| 108 | features='cxx', |
| 109 | source=bld.path.ant_glob(['core/**/*.cpp']), |
| 110 | use='version BOOST NDN_CXX CRYPTOPP SQLITE3', |
| 111 | includes='. core', |
| 112 | export_includes='. core', |
| 113 | headers='common.hpp', |
| 114 | ) |
| 115 | |
| 116 | logger_objects = bld( |
| 117 | target='daemon-objects', |
| 118 | name='daemon-objects', |
| 119 | features='cxx', |
| 120 | source=bld.path.ant_glob(['daemon/**/*.cpp'], |
| 121 | excl=['daemon/main.cpp']), |
| 122 | use='core-objects', |
| 123 | includes='daemon', |
| 124 | export_includes='daemon', |
| 125 | ) |
| 126 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 127 | bld(target='bin/ndn-delorean', |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 128 | features='cxx cxxprogram', |
| 129 | source='daemon/main.cpp', |
| 130 | use='daemon-objects', |
| 131 | ) |
| 132 | |
| 133 | if bld.env['WITH_TESTS']: |
| 134 | bld.recurse('tests') |
| 135 | |
| 136 | if bld.env['WITH_TOOLS']: |
| 137 | bld.recurse("tools") |
| 138 | |
| 139 | bld(features="subst", |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 140 | source='ndn-delorean.conf.sample.in', |
| 141 | target='ndn-delorean.conf.sample', |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 142 | install_path="${SYSCONFDIR}/ndn", |
| 143 | ) |
| 144 | |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 145 | # if bld.env['SPHINX_BUILD']: |
| 146 | # bld(features="sphinx", |
| 147 | # builder="man", |
| 148 | # outdir="docs/manpages", |
| 149 | # config="docs/conf.py", |
| 150 | # source=bld.path.ant_glob('docs/manpages/**/*.rst'), |
| 151 | # install_path="${MANDIR}/", |
| 152 | # VERSION=VERSION) |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 153 | |
| 154 | def docs(bld): |
| 155 | from waflib import Options |
| 156 | Options.commands = ['doxygen', 'sphinx'] + Options.commands |
| 157 | |
| 158 | def doxygen(bld): |
| 159 | version(bld) |
| 160 | |
| 161 | if not bld.env.DOXYGEN: |
| 162 | Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)") |
| 163 | else: |
| 164 | bld(features="subst", |
| 165 | name="doxygen-conf", |
| 166 | source=["docs/doxygen.conf.in", |
| 167 | "docs/named_data_theme/named_data_footer-with-analytics.html.in"], |
| 168 | target=["docs/doxygen.conf", |
| 169 | "docs/named_data_theme/named_data_footer-with-analytics.html"], |
| 170 | VERSION=VERSION, |
| 171 | HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \ |
| 172 | if os.getenv('GOOGLE_ANALYTICS', None) \ |
| 173 | else "../docs/named_data_theme/named_data_footer.html", |
| 174 | GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""), |
| 175 | ) |
| 176 | |
| 177 | bld(features="doxygen", |
| 178 | doxyfile='docs/doxygen.conf', |
| 179 | use="doxygen-conf") |
| 180 | |
| 181 | def sphinx(bld): |
| 182 | version(bld) |
| 183 | |
| 184 | if not bld.env.SPHINX_BUILD: |
| 185 | bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)") |
| 186 | else: |
| 187 | bld(features="sphinx", |
| 188 | outdir="docs", |
| 189 | source=bld.path.ant_glob("docs/**/*.rst"), |
| 190 | config="docs/conf.py", |
| 191 | VERSION=VERSION) |
| 192 | |
| 193 | |
| 194 | def version(ctx): |
| 195 | if getattr(Context.g_module, 'VERSION_BASE', None): |
| 196 | return |
| 197 | |
| 198 | Context.g_module.VERSION_BASE = Context.g_module.VERSION |
| 199 | Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')] |
| 200 | |
| 201 | try: |
Alexander Afanasyev | be998ac | 2017-05-06 13:11:42 -0700 | [diff] [blame^] | 202 | cmd = ['git', 'describe', '--match', 'ndn-delorean-*'] |
Yingdi Yu | c9843cf | 2014-08-04 17:52:19 -0700 | [diff] [blame] | 203 | p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE, |
| 204 | stderr=None, stdin=None) |
| 205 | out = p.communicate()[0].strip() |
| 206 | if p.returncode == 0 and out != "": |
| 207 | Context.g_module.VERSION = out[8:] |
| 208 | except: |
| 209 | pass |