Browse Source

docs: Updated installation instructions, AUTHORs, and other small updates

Change-Id: Ide2046742254255322e8cb84279ffd6a4ecb9b4b
pull/1/head
Alexander Afanasyev 12 years ago
parent
commit
5e1288efa6
  1. 108
      .waf-tools/cryptopp.py
  2. 60
      .waf-tools/default-compiler-flags.py
  3. 60
      .waf-tools/doxygen.py
  4. 63
      .waf-tools/openssl.py
  5. 21
      .waf-tools/sphinx_build.py
  6. 5
      AUTHORS
  7. 21
      AUTHORS.md
  8. 90
      INSTALL.md
  9. 11
      tests-integrated/wscript
  10. 11
      tests/wscript
  11. 224
      wscript

108
.waf-tools/cryptopp.py

@ -5,14 +5,14 @@
When using this tool, the wscript will look like:
def options(opt):
opt.tool_options('cryptopp', tooldir=["waf-tools"])
def options(opt):
opt.tool_options('cryptopp', tooldir=["waf-tools"])
def configure(conf):
conf.load('compiler_cxx cryptopp')
def configure(conf):
conf.load('compiler_cxx cryptopp')
def build(bld):
bld(source='main.cpp', target='app', use='CRYPTOPP')
def build(bld):
bld(source='main.cpp', target='app', use='CRYPTOPP')
Options are generated, in order to specify the location of cryptopp includes/libraries.
@ -22,56 +22,64 @@ import sys
import re
from waflib import Utils,Logs,Errors
from waflib.Configure import conf
CRYPTOPP_DIR=['/usr','/usr/local','/opt/local','/sw']
CRYPTOPP_VERSION_FILE='config.h'
CRYPTOPP_VERSION_CODE='''
#include <iostream>
#include <cryptopp/config.h>
int main() { std::cout << CRYPTOPP_VERSION; }
'''
CRYPTOPP_DIR = ['/usr', '/usr/local', '/opt/local', '/sw']
CRYPTOPP_VERSION_FILE = 'config.h'
def options(opt):
opt.add_option('--cryptopp',type='string',default='',dest='cryptopp_dir',help='''path to where cryptopp is installed, e.g. /opt/local''')
@conf
def __cryptopp_get_version_file(self,dir):
try:
return self.root.find_dir(dir).find_node('%s/%s' % ('include/cryptopp', CRYPTOPP_VERSION_FILE))
except:
return None
opt.add_option('--cryptopp', type='string', default='', dest='cryptopp_dir',
help='''Path to where CryptoPP is installed, e.g. /opt/local''')
@conf
def cryptopp_get_version(self,dir):
val=self.check_cxx(fragment=CRYPTOPP_VERSION_CODE,includes=['%s/%s' % (dir, 'include')], execute=True, define_ret = True, mandatory=True)
return val
def __cryptopp_get_version_file(self, dir):
try:
return self.root.find_dir(dir).find_node('%s/%s' % ('include/cryptopp',
CRYPTOPP_VERSION_FILE))
except:
return None
@conf
def cryptopp_get_root(self,*k,**kw):
root=k and k[0]or kw.get('path',None)
# Logs.pprint ('RED', ' %s' %root)
if root and self.__cryptopp_get_version_file(root):
return root
for dir in CRYPTOPP_DIR:
if self.__cryptopp_get_version_file(dir):
return dir
if root:
self.fatal('CryptoPP not found in %s'%root)
else:
self.fatal('CryptoPP not found, please provide a --cryptopp argument (see help)')
def __cryptopp_find_root_and_version_file(self, *k, **kw):
root = k and k[0]or kw.get('path', None)
file = self.__cryptopp_get_version_file(root)
if root and file:
return (root, file)
for dir in CRYPTOPP_DIR:
file = self.__cryptopp_get_version_file(dir)
if file:
return (dir, file)
if root:
self.fatal('CryptoPP not found in %s' % root)
else:
self.fatal('CryptoPP not found, please provide a --cryptopp argument (see help)')
@conf
def check_cryptopp(self,*k,**kw):
if not self.env['CXX']:
self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
def check_cryptopp(self, *k, **kw):
if not self.env['CXX']:
self.fatal('Load a c++ compiler first, e.g., conf.load("compiler_cxx")')
var=kw.get('uselib_store','CRYPTOPP')
self.start_msg('Checking Crypto++ lib')
root = self.cryptopp_get_root(*k,**kw)
self.env.CRYPTOPP_VERSION=self.cryptopp_get_version(root)
var = kw.get('uselib_store','CRYPTOPP')
self.start_msg('Checking Crypto++ lib')
(root, file) = self.__cryptopp_find_root_and_version_file(*k, **kw)
self.env['INCLUDES_%s'%var]= '%s/%s' % (root, "include")
self.env['LIB_%s'%var] = "cryptopp"
self.env['LIBPATH_%s'%var] = '%s/%s' % (root, "lib")
try:
txt = file.read()
re_version = re.compile('^#define\\s+CRYPTOPP_VERSION\\s+(.*)', re.M)
match = re_version.search(txt)
self.end_msg(self.env.CRYPTOPP_VERSION)
if Logs.verbose:
Logs.pprint('CYAN',' CRYPTOPP include : %s'%self.env['INCLUDES_%s'%var])
Logs.pprint('CYAN',' CRYPTOPP lib : %s'%self.env['LIB_%s'%var])
Logs.pprint('CYAN',' CRYPTOPP libpath : %s'%self.env['LIBPATH_%s'%var])
if match:
self.env.CRYPTOPP_VERSION = match.group(1)
self.end_msg(self.env.CRYPTOPP_VERSION)
else:
self.fatal('CryptoPP files are present, but are not recognizable')
except:
self.fatal('CryptoPP not found or is not usable')
val = self.check_cxx(msg='Checking if CryptoPP library works',
header_name='cryptopp/config.h',
lib='cryptopp',
cxxflags="-I%s/include" % root,
linkflags="-L%s/lib" % root,
mandatory=True,
uselib_store=var)

60
.waf-tools/default-compiler-flags.py

@ -0,0 +1,60 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
#
# Copyright (c) 2014, Regents of the University of California
#
# GPL 3.0 license, see the COPYING.md file for more information
from waflib import Logs, Configure
def options(opt):
opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
help='''Compile in debugging mode without all optimizations (-O0)''')
def configure(conf):
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
if conf.options.debug:
conf.define('_DEBUG', 1)
defaultFlags = ['-O0', '-g3',
'-Werror',
'-Wall',
'-fcolor-diagnostics', # only clang supports
# to disable known warnings
'-Wno-unused-variable', # cryptopp
'-Wno-unused-function',
'-Wno-deprecated-declarations',
]
if areCustomCxxflagsPresent:
missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
if len(missingFlags) > 0:
Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
% " ".join(conf.env.CXXFLAGS))
Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
else:
conf.add_supported_cxxflags(cxxflags = defaultFlags)
else:
defaultFlags = ['-O2', '-g', '-Wall',
# to disable known warnings
'-Wno-unused-variable', # cryptopp
'-Wno-unused-function',
'-Wno-deprecated-declarations',
]
if not areCustomCxxflagsPresent:
conf.add_supported_cxxflags(cxxflags = defaultFlags)
@Configure.conf
def add_supported_cxxflags(self, cxxflags):
"""
Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
"""
self.start_msg('Checking allowed flags for c++ compiler')
supportedFlags = []
for flag in cxxflags:
if self.check_cxx(cxxflags=[flag], mandatory=False):
supportedFlags += [flag]
self.end_msg(' '.join (supportedFlags))
self.env.CXXFLAGS = supportedFlags + self.env.CXXFLAGS

60
.waf-tools/doxygen.py

@ -9,15 +9,30 @@ Doxygen support
Variables passed to bld():
* doxyfile -- the Doxyfile to use
ported from waf 1.5 (incomplete)
When using this tool, the wscript will look like:
def options(opt):
opt.load('doxygen')
def configure(conf):
conf.load('doxygen')
# check conf.env.DOXYGEN, if it is mandatory
def build(bld):
if bld.env.DOXYGEN:
bld(features="doxygen", doxyfile='Doxyfile', ...)
def doxygen(bld):
if bld.env.DOXYGEN:
bld(features="doxygen", doxyfile='Doxyfile', ...)
"""
from fnmatch import fnmatchcase
import os, os.path, re, stat
from waflib import Task, Utils, Node, Logs
from waflib import Task, Utils, Node, Logs, Errors, Build
from waflib.TaskGen import feature
DOXY_STR = '${DOXYGEN} - '
DOXY_STR = '"${DOXYGEN}" - '
DOXY_FMTS = 'html latex man rft xml'.split()
DOXY_FILE_PATTERNS = '*.' + ' *.'.join('''
c cc cxx cpp c++ java ii ixx ipp i++ inl h hh hxx hpp h++ idl odl cs php php3
@ -68,6 +83,11 @@ class doxygen(Task.Task):
if not self.pars.get('OUTPUT_DIRECTORY'):
self.pars['OUTPUT_DIRECTORY'] = self.inputs[0].parent.get_bld().abspath()
# Override with any parameters passed to the task generator
if getattr(self.generator, 'pars', None):
for k, v in self.generator.pars.iteritems():
self.pars[k] = v
self.doxy_inputs = getattr(self, 'doxy_inputs', [])
if not self.pars.get('INPUT'):
self.doxy_inputs.append(self.inputs[0].parent)
@ -92,19 +112,17 @@ class doxygen(Task.Task):
return Task.Task.runnable_status(self)
def scan(self):
if self.pars.get('RECURSIVE') == 'YES':
Logs.warn("Doxygen RECURSIVE dependencies are not supported")
exclude_patterns = self.pars.get('EXCLUDE_PATTERNS', '').split()
file_patterns = self.pars.get('FILE_PATTERNS', '').split()
exclude_patterns = self.pars.get('EXCLUDE_PATTERNS','').split()
file_patterns = self.pars.get('FILE_PATTERNS','').split()
if not file_patterns:
file_patterns = DOXY_FILE_PATTERNS
if self.pars.get('RECURSIVE') == 'YES':
file_patterns = ["**/%s" % pattern for pattern in file_patterns]
nodes = []
names = []
for node in self.doxy_inputs:
if os.path.isdir(node.abspath()):
for m in node.ant_glob(file_patterns):
for m in node.ant_glob(incl=file_patterns, excl=exclude_patterns):
nodes.append(m)
else:
nodes.append(node)
@ -112,8 +130,7 @@ class doxygen(Task.Task):
def run(self):
dct = self.pars.copy()
# TODO will break if paths have spaces
dct['INPUT'] = ' '.join([x.abspath() for x in self.doxy_inputs])
dct['INPUT'] = ' '.join(['"%s"' % x.abspath() for x in self.doxy_inputs])
code = '\n'.join(['%s = %s' % (x, dct[x]) for x in self.pars])
code = code.encode() # for python 3
#fmt = DOXY_STR % (self.inputs[0].parent.abspath())
@ -179,6 +196,19 @@ def process_doxy(self):
tsk.env['TAROPTS'] = ['cf']
def configure(conf):
conf.find_program('doxygen', var='DOXYGEN')
conf.find_program('tar', var='TAR')
'''
Check if doxygen and tar commands are present in the system
If the commands are present, then conf.env.DOXYGEN and conf.env.TAR
variables will be set. Detection can be controlled by setting DOXYGEN and
TAR environmental variables.
'''
conf.find_program('doxygen', var='DOXYGEN', mandatory=False)
conf.find_program('tar', var='TAR', mandatory=False)
# doxygen docs
from waflib.Build import BuildContext
class doxy(BuildContext):
cmd = "doxygen"
fun = "doxygen"

63
.waf-tools/openssl.py

@ -5,16 +5,16 @@
When using this tool, the wscript will look like:
def options(opt):
opt.tool_options('openssl')
def options(opt):
opt.tool_options('openssl')
def configure(conf):
conf.load('compiler_c openssl')
def configure(conf):
conf.load('compiler_c openssl')
conf.check_openssl()
conf.check_openssl()
def build(bld):
bld(source='main.cpp', target='app', use='OPENSSL')
def build(bld):
bld(source='main.cpp', target='app', use='OPENSSL')
'''
@ -23,37 +23,38 @@ from waflib.Configure import conf
@conf
def check_openssl(self,*k,**kw):
root = k and k[0] or kw.get('path',None) or Options.options.with_openssl
mandatory = kw.get('mandatory', True)
var = kw.get('var', 'OPENSSL')
root = k and k[0] or kw.get('path',None) or Options.options.with_openssl
mandatory = kw.get('mandatory', True)
var = kw.get('var', 'OPENSSL')
CODE = """
CODE = """
#include <openssl/crypto.h>
#include <stdio.h>
int main(int argc, char **argv) {
(void)argc;
printf ("%s", argv[0]);
(void)argc;
printf("%s", argv[0]);
return 0;
return 0;
}
"""
if root:
libcrypto = self.check_cc (lib=['ssl', 'crypto'],
header_name='openssl/crypto.h',
define_name='HAVE_%s' % var,
uselib_store=var,
mandatory = mandatory,
cflags="-I%s/include" % root,
linkflags="-L%s/lib" % root,
execute = True, fragment = CODE, define_ret = True)
else:
libcrypto = self.check_cc (lib=['ssl', 'crypto'],
header_name='openssl/crypto.h',
define_name='HAVE_%s' % var,
uselib_store=var,
mandatory = mandatory,
execute = True, fragment = CODE, define_ret = True)
if root:
libcrypto = self.check_cxx(lib=['ssl', 'crypto'],
msg='Checking for OpenSSL library',
define_name='HAVE_%s' % var,
uselib_store=var,
mandatory=mandatory,
cflags="-I%s/include" % root,
linkflags="-L%s/lib" % root,
fragment=CODE)
else:
libcrypto = self.check_cxx(lib=['ssl', 'crypto'],
msg='Checking for OpenSSL library',
define_name='HAVE_%s' % var,
uselib_store=var,
mandatory=mandatory,
fragment=CODE)
def options(opt):
opt.add_option('--with-openssl',type='string',default='',dest='with_openssl',help='''Path to OpenSSL''')
opt.add_option('--with-openssl', type='string', default='',
dest='with_openssl', help='''Path to OpenSSL''')

21
.waf-tools/sphinx_build.py

@ -10,8 +10,13 @@ else has defaults, passing in the parameters is optional.
Usage for getting both html and pdf docs:
ctx(features='sphinx', source='docs/conf.py')
ctx(features='sphinx', source='docs/conf.py', buildername='latex')
def build(ctx):
ctx(features='sphinx', source='docs/conf.py')
ctx(features='sphinx', source='docs/conf.py', buildername='latex')
def sphinx(ctx):
ctx(features='sphinx', source='docs/conf.py')
ctx(features='sphinx', source='docs/conf.py', buildername='latex')
Optional parameters and their defaults:
@ -25,7 +30,7 @@ Optional parameters and their defaults:
import os
from waflib import Task, TaskGen, Errors, Logs
from waflib import Task, TaskGen, Errors, Logs, Build
class RunSphinxBuild(Task.Task):
def scan(self):
@ -84,7 +89,7 @@ def apply_sphinx(tg):
buildername = getattr(tg, "buildername", "html")
srcdir = getattr(tg, "srcdir", confdir)
outdir = tg.path.find_or_declare (getattr(tg, "outdir", os.path.join(conf.parent.get_bld().abspath(), buildername))).abspath ()
doctreedir = getattr(tg, "doctreedir", os.path.join(outdir, ".doctrees"))
# Set up the Sphinx instance.
@ -93,7 +98,7 @@ def apply_sphinx(tg):
# Get the main targets of the Sphinx build.
tgt_nodes = _get_main_targets(tg, s)
# Create the task and set the required attributes.
# Create the task and set the required attributes.
task = tg.create_task("RunSphinxBuild", src=conf, tgt=tgt_nodes)
task.srcdir = tg.bld.root.find_node(s.srcdir)
task.outdir = tg.bld.root.find_node(s.outdir)
@ -106,3 +111,9 @@ def apply_sphinx(tg):
# Bypass the execution of process_source by setting the source to an empty list
tg.source = []
# sphinx docs
from waflib.Build import BuildContext
class sphinx (BuildContext):
cmd = "sphinx"
fun = "sphinx"

5
AUTHORS

@ -1,5 +0,0 @@
Jeff Thompson <jefft0@gmail.com>
Alexander Afanasyev (http://lasr.cs.ucla.edu/afanasyev/index.html)
Yingdi Yu (http://irl.cs.ucla.edu/~yingdi/)
Wentao Shang (http://irl.cs.ucla.edu/~wentao/)
Junxiao Shi (http://www.cs.arizona.edu/people/shijunxiao/)

21
AUTHORS.md

@ -0,0 +1,21 @@
ndn-cpp-dev authors
===================
## The primary authors are (and/or have been):
* Jeff Thompson <jefft0@remap.ucla.edu>
* Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
* Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
## All project authors and contributors
The following is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS,
people who have reported bugs, submitted patches, and implemented new features
in the library:
* Wentao Shang <http://irl.cs.ucla.edu/~wentao/>
* Junxiao Shi <http://www.cs.arizona.edu/people/shijunxiao/>
* Steve DiBenedetto <http://www.cs.colostate.edu/~dibenede/>
* Syed Obaid Amin <http://obaidamin.weebly.com/>
* Shuo Chen <chenatu2006@gmail.com>
* Hila Ben Abraham <http://research.engineering.wustl.edu/~abrahamh/>

90
INSTALL.md

@ -1,6 +1,17 @@
ndn-cpp-dev: A dev version of Named Data Networking client library for C++
===========================================================================
Supported platforms
-------------------
ndn-cpp-dev is tested on the following platforms:
* Ubuntu 12.04 (64 bit and 32 bit)
* Ubuntu 13.10 (64 bit and 32 bit)
* Mac OS X 10.8
* Mac OS X 10.9
Prerequisites
-------------
@ -9,42 +20,37 @@ Prerequisites
Required:
* libcrypto
* libsqlite3
* libcrypto++
* boost libraries (>= 1.48)
* `python` >= 2.6
* `libcrypto`
* `libsqlite3`
* `libcrypto++`
* `pkg-config`
* Boost libraries >= 1.48
* OSX Security framework (on OSX platform only)
Following are the detailed steps for each platform to install the prerequisites.
* Mac OS X 10.7.3, Mac OS X 10.8.4
* Mac OS X
Install Xcode.
In Xcode Preferences > Downloads, install "Command Line Tools".
* Mac OS X 10.9
Install Xcode. (Xcode on OS X 10.9 seems to already have the Command Line Tools.)
If using macports, dependencies can be installed using the following commands:
sudo port install boost sqlite3 libcryptopp
sudo port install pkgconfig boost sqlite3 libcryptopp
* Ubuntu 12.04, Ubuntu 13.10
In a terminal, enter:
sudo apt-get install build-essential
sudo apt-get install libssl-dev libsqlite3-dev libcrypto++-dev
# For Ubuntu 12.04
sudo apt-get install libboost1.48-all-dev
# For Ubuntu 13.10
sudo apt-get install libboost-all-dev
sudo apt-get install libssl-dev libsqlite3-dev libcrypto++-dev
* Windows Cygwin
Cygwin is tested on Windows 7 64-bit with the "Devel" packages selected to install at the top level of the
cygwin installer. This includes libcrypto and libsqlite3.
Build
-----
@ -58,22 +64,24 @@ To build in a terminal, change directory to the ndn-cpp-dev root. Enter:
./waf
sudo ./waf install
This makes and installs the following items:
This builds and installs the following items:
* ``<LIBPATH>/libndn-cpp-dev.*``: static and dynamic NDN C++ libraries
* ``<LIBPATH>/pkgconfig/libndn-cpp-dev.pc``: pkgconfig file storing all neccessary flags
* `<LIBPATH>/libndn-cpp-dev.a`: static NDN C++ library
* `<LIBPATH>/pkgconfig/libndn-cpp-dev.pc`: pkgconfig file storing all neccessary flags
to build against the library. For example, if pkgconfig or pkgconf package is
installed and PKG_CONFIG_PATH is configured properly (or ``<LIBPATH>/pkgconfig`` is a
default path), ``pkgconfig --libs --clflags libndn-cpp-dev`` will return all necessary
installed and `PKG_CONFIG_PATH` is configured properly (or `<LIBPATH>/pkgconfig` is a
default path), `pkgconfig --libs --clflags libndn-cpp-dev` will return all necessary
compile and link flags for the library.
* ``<BINPATH>/tlvdump``: a simple tool to dump contents of TLV-formatted data
* ``<BINPATH>/ndncatchunks3``: a simplified equivalent to ndncatchunks2 in NDNx package
* ``<BINPATH>/ndnputchunks3``: a simplified equivalent to ndnputchunks2 in NDNx package
* `<BINPATH>/tlvdump`: a simple tool to dump contents of TLV-formatted data
* `<BINPATH>/ndncatchunks3`: a simplified equivalent to ndncatchunks2 in NDNx package
* `<BINPATH>/ndnputchunks3`: a simplified equivalent to ndnputchunks2 in NDNx package
* `<BINPATH>/ndnsec`: tool to manage NDN keys and certificates
* `<BINPATH>/ndnsec-*`: convenience scripts for `ndnsec` tools
If configured with tests: ``./waf configure --with-tests``), the above commands will
If configured with tests: `./waf configure --with-tests`), the above commands will
also produce:
* ``build/tests/unit-tests``: A tool to run unit tests for the library
* `build/unit-tests`: A unit test binary for the library
Documentation
-------------
@ -84,19 +92,7 @@ To make documentation, enter:
This will produce doxygen API code documentation in:
* build/doc/html
Supported platforms
-------------------
(to be confirmed)
ndn-cpp-dev is tested on the following platforms:
* Ubuntu 12.04 (64 bit and 32 bit)
* Ubuntu 13.10 (64 bit and 32 bit)
* Mac OS X 10.8
* Mac OS X 10.9
* `build/doc/html`
Development Prerequisites
-------------------------
@ -117,7 +113,17 @@ First follow the Prerequisites above for your platforms.
sudo apt-get install doxygen
Development
-----------
Development Build
-----------------
The following is the suggested configure commands for development build.
./waf configure --debug --with-tests
./waf
sudo ./waf install
In the development build all compiler optimizations are disabled by default and all warnings are treated as error.
The default behavior can be overridden by setting CXXFLAGS environment variable before running `./waf configure`:
Follow Development Prerequisites above for your platform.
CXXFLAGS="-O1 -g3" ./waf configure --debug --with-tests
...

11
tests-integrated/wscript

@ -7,11 +7,11 @@ top = '..'
def build(bld):
unittests = bld.program (
target="../integrated-tests",
features = "cxx cxxprogram",
source = bld.path.ant_glob(['**/*.cpp'],
excl = ['**/*-osx.cpp', '**/*-sqlite3.cpp']),
use = 'ndn-cpp-dev',
install_path = None,
features="cxx cxxprogram",
source=bld.path.ant_glob(['**/*.cpp'],
excl=['**/*-osx.cpp', '**/*-sqlite3.cpp']),
use='ndn-cpp-dev',
install_path=None,
)
if Utils.unversioned_sys_platform () == "darwin":
@ -22,4 +22,3 @@ def build(bld):
if bld.env['WITH_PCH']:
unittests.pch = "test-all.hpp"

11
tests/wscript

@ -7,11 +7,11 @@ top = '..'
def build(bld):
unittests = bld.program (
target="../unit-tests",
features = "cxx cxxprogram",
source = bld.path.ant_glob(['**/*.cpp'],
excl = ['**/*-osx.cpp', '**/*-sqlite3.cpp']),
use = 'ndn-cpp-dev',
install_path = None,
features="cxx cxxprogram",
source=bld.path.ant_glob(['**/*.cpp'],
excl=['**/*-osx.cpp', '**/*-sqlite3.cpp']),
use='ndn-cpp-dev',
install_path=None,
)
if Utils.unversioned_sys_platform () == "darwin":
@ -22,4 +22,3 @@ def build(bld):
if bld.env['WITH_PCH']:
unittests.pch = "test-all.hpp"

224
wscript

@ -1,21 +1,27 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
VERSION='0.3~dev0'
NAME="ndn-cpp-dev"
#
# Copyright (c) 2014, Regents of the University of California
#
# GPL 3.0 license, see the COPYING.md file for more information
from waflib import Build, Logs, Utils, Task, TaskGen, Configure
VERSION = '0.4.0'
APPNAME = "ndn-cpp-dev"
PACKAGE_BUGREPORT = "http://redmine.named-data.net/projects/ndn-cpp-dev"
PACKAGE_URL = "https://github.com/named-data/ndn-cpp-dev"
from waflib import Logs, Utils, Task, TaskGen
from waflib.Tools import c_preproc
def options(opt):
opt.load('compiler_c compiler_cxx gnu_dirs c_osx')
opt.load('boost doxygen openssl cryptopp coverage', tooldir=['.waf-tools'])
opt = opt.add_option_group('NDN-CPP Options')
opt.load('compiler_cxx gnu_dirs c_osx')
opt.load('boost doxygen openssl cryptopp coverage default-compiler-flags',
tooldir=['.waf-tools'])
opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
opt = opt.add_option_group('Library Options')
opt.add_option('--with-tests', action='store_true',default=False,dest='with_tests',
opt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
help='''build unit tests''')
opt.add_option('--with-log4cxx', action='store_true',default=False,dest='log4cxx',
opt.add_option('--with-log4cxx', action='store_true', default=False, dest='log4cxx',
help='''Compile with log4cxx logging support''')
opt.add_option('--with-c++11', action='store_true', default=False, dest='use_cxx11',
@ -23,20 +29,22 @@ def options(opt):
opt.add_option('--without-tools', action='store_false', default=True, dest='with_tools',
help='''Do not build tools''')
opt.add_option('--without-sqlite-locking', action='store_false', default=True, dest='with_sqlite_locking',
help='''Disable filesystem locking in sqlite3 database (use unix-dot locking mechanism instead). '''
opt.add_option('--without-sqlite-locking', action='store_false', default=True,
dest='with_sqlite_locking',
help='''Disable filesystem locking in sqlite3 database '''
'''(use unix-dot locking mechanism instead). '''
'''This option may be necessary if home directory is hosted on NFS.''')
opt.add_option('--with-pch', action='store_true', default=False, dest='with_pch',
help='''Try to use precompiled header to speed up compilation (only gcc and clang)''')
opt.add_option('--without-osx-keychain', action='store_false', default=True, dest='with_osx_keychain',
help='''Try to use precompiled header to speed up compilation '''
'''(only gcc and clang)''')
opt.add_option('--without-osx-keychain', action='store_false', default=True,
dest='with_osx_keychain',
help='''On Darwin, do not use OSX keychain as a default TPM''')
def configure(conf):
conf.load("compiler_c compiler_cxx boost gnu_dirs c_osx openssl cryptopp")
try:
conf.load("doxygen")
except:
pass
conf.load("compiler_cxx boost gnu_dirs c_osx openssl cryptopp")
try: conf.load("doxygen")
except: pass
if conf.options.with_tests:
conf.env['WITH_TESTS'] = True
@ -46,80 +54,52 @@ def configure(conf):
conf.check_openssl()
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
if conf.options.debug:
conf.define('_DEBUG', 1)
defaultFlags = ['-O0', '-g3',
'-Werror',
'-Wall',
'-fcolor-diagnostics', # only clang supports
# to disable known warnings
'-Wno-unused-variable', # cryptopp
'-Wno-unused-function',
'-Wno-deprecated-declarations',
]
if areCustomCxxflagsPresent:
missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
if len(missingFlags) > 0:
Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
% " ".join(conf.env.CXXFLAGS))
Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
else:
conf.add_supported_cxxflags(cxxflags = defaultFlags)
else:
defaultFlags = ['-O2', '-g', '-Wall',
# to disable known warnings
'-Wno-unused-variable', # cryptopp
'-Wno-unused-function',
'-Wno-deprecated-declarations',
]
if not areCustomCxxflagsPresent:
conf.add_supported_cxxflags(cxxflags = defaultFlags)
if Utils.unversioned_sys_platform () == "darwin":
conf.check_cxx(framework_name='CoreFoundation', uselib_store='OSX_COREFOUNDATION', mandatory=True)
conf.check_cxx(framework_name='CoreServices', uselib_store='OSX_CORESERVICES', mandatory=True)
conf.check_cxx(framework_name='Security', uselib_store='OSX_SECURITY', define_name='HAVE_SECURITY',
use="OSX_COREFOUNDATION", mandatory=True)
conf.define('HAVE_OSX_SECURITY', 1)
conf.load('default-compiler-flags')
conf.define ("PACKAGE_BUGREPORT", "ndn-lib@lists.cs.ucla.edu")
conf.define ("PACKAGE_NAME", NAME)
conf.define ("PACKAGE_VERSION", VERSION)
conf.define ("PACKAGE_URL", "https://github.com/named-data/ndn-cpp")
if Utils.unversioned_sys_platform() == "darwin":
conf.check_cxx(framework_name='CoreFoundation', uselib_store='OSX_COREFOUNDATION',
mandatory=True)
conf.check_cxx(framework_name='CoreServices', uselib_store='OSX_CORESERVICES',
mandatory=True)
conf.check_cxx(framework_name='Security', uselib_store='OSX_SECURITY',
define_name='HAVE_SECURITY', use="OSX_COREFOUNDATION", mandatory=True)
conf.define('HAVE_OSX_SECURITY', 1)
conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3',
mandatory=True)
if conf.options.log4cxx:
conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
conf.define ("HAVE_LOG4CXX", 1)
conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX',
mandatory=True)
conf.define("HAVE_LOG4CXX", 1)
conf.check_cryptopp(path=conf.options.cryptopp_dir, mandatory=True)
if conf.options.use_cxx11:
conf.add_supported_cxxflags(cxxflags = ['-std=c++11', '-std=c++0x'])
conf.add_supported_cxxflags(cxxflags=['-std=c++11', '-std=c++0x'])
conf.check(msg='Checking for type std::shared_ptr',
type_name="std::shared_ptr<int>", header_name="memory", define_name='HAVE_STD_SHARED_PTR')
type_name="std::shared_ptr<int>", header_name="memory",
define_name='HAVE_STD_SHARED_PTR')
conf.check(msg='Checking for type std::function',
type_name="std::function<void()>", header_name="functional", define_name='HAVE_STD_FUNCTION')
type_name="std::function<void()>", header_name="functional",
define_name='HAVE_STD_FUNCTION')
conf.define('HAVE_CXX11', 1)
USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams', 'regex', 'program_options', 'chrono']
USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams',
'regex', 'program_options', 'chrono']
if conf.env['WITH_TESTS']:
USED_BOOST_LIBS += ['unit_test_framework']
conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True)
if conf.env.BOOST_VERSION_NUMBER < 104800:
Logs.error ("Minimum required boost version is 1.48.0")
Logs.error ("Please upgrade your distribution or install custom boost libraries" +
Logs.error("Minimum required boost version is 1.48.0")
Logs.error("Please upgrade your distribution or install custom boost libraries" +
" (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
return
conf.check_cxx(lib='pthread', uselib_store='PTHREAD', define_name='HAVE_PTHREAD', mandatory=False)
conf.check_cxx(lib='pthread', uselib_store='PTHREAD', define_name='HAVE_PTHREAD',
mandatory=False)
conf.check_cxx(lib='rt', uselib_store='RT', define_name='HAVE_RT', mandatory=False)
conf.check_cxx(cxxflags=['-fPIC'], uselib_store='cxxstlib', mandatory=False)
@ -128,7 +108,7 @@ def configure(conf):
conf.env['WITH_PCH'] = conf.options.with_pch
if Utils.unversioned_sys_platform () == "darwin":
if Utils.unversioned_sys_platform() == "darwin":
conf.env['WITH_OSX_KEYCHAIN'] = conf.options.with_osx_keychain
if conf.options.with_osx_keychain:
conf.define('WITH_OSX_KEYCHAIN', 1)
@ -141,24 +121,24 @@ def configure(conf):
conf.write_config_header('src/ndn-cpp-config.h', define_prefix='NDN_CPP_')
def build (bld):
libndn_cpp = bld (
def build(bld):
libndn_cpp = bld(
features=['cxx', 'cxxstlib'], # 'cxxshlib',
# vnum = "0.3.0",
# vnum="0.3.0",
target="ndn-cpp-dev",
name = "ndn-cpp-dev",
source = bld.path.ant_glob('src/**/*.cpp',
excl = ['src/**/*-osx.cpp', 'src/**/*-sqlite3.cpp']),
use = 'BOOST OPENSSL LOG4CXX CRYPTOPP SQLITE3 RT PIC PTHREAD',
includes = ". src",
export_includes = "src",
install_path = '${LIBDIR}',
name="ndn-cpp-dev",
source=bld.path.ant_glob('src/**/*.cpp',
excl=['src/**/*-osx.cpp', 'src/**/*-sqlite3.cpp']),
use='BOOST OPENSSL LOG4CXX CRYPTOPP SQLITE3 RT PIC PTHREAD',
includes=". src",
export_includes="src",
install_path='${LIBDIR}',
)
if bld.env['WITH_PCH']:
libndn_cpp.pch = "src/common.hpp"
libndn_cpp.pch="src/common.hpp"
if Utils.unversioned_sys_platform () == "darwin":
if Utils.unversioned_sys_platform() == "darwin":
libndn_cpp.source += bld.path.ant_glob('src/**/*-osx.cpp')
libndn_cpp.mac_app = True
libndn_cpp.use += " OSX_COREFOUNDATION OSX_SECURITY"
@ -166,7 +146,7 @@ def build (bld):
# In case we want to make it optional later
libndn_cpp.source += bld.path.ant_glob('src/**/*-sqlite3.cpp')
# Prepare flags that should go to pkgconfig file
pkgconfig_libs = []
pkgconfig_ldflags = []
pkgconfig_linkflags = []
@ -185,27 +165,27 @@ def build (bld):
pkgconfig_cxxflags += Utils.to_list(bld.env['CXXFLAGS_%s' % lib])
EXTRA_FRAMEWORKS = "";
if Utils.unversioned_sys_platform () == "darwin":
if Utils.unversioned_sys_platform() == "darwin":
EXTRA_FRAMEWORKS = "-framework CoreFoundation -framework Security"
def uniq(alist):
set = {}
return [set.setdefault(e,e) for e in alist if e not in set]
pkconfig = bld (features = "subst",
source = "libndn-cpp-dev.pc.in",
target = "libndn-cpp-dev.pc",
install_path = "${LIBDIR}/pkgconfig",
VERSION = VERSION,
pkconfig = bld(features="subst",
source="libndn-cpp-dev.pc.in",
target="libndn-cpp-dev.pc",
install_path="${LIBDIR}/pkgconfig",
VERSION=VERSION,
# This probably not the right thing to do, but to simplify life of apps
# that use the library
EXTRA_LIBS = " ".join([('-l%s' % i) for i in uniq(pkgconfig_libs)]),
EXTRA_LDFLAGS = " ".join([('-L%s' % i) for i in uniq(pkgconfig_ldflags)]),
EXTRA_LINKFLAGS = " ".join(uniq(pkgconfig_linkflags)),
EXTRA_INCLUDES = " ".join([('-I%s' % i) for i in uniq(pkgconfig_includes)]),
EXTRA_CXXFLAGS = " ".join(uniq(pkgconfig_cxxflags)),
EXTRA_FRAMEWORKS = EXTRA_FRAMEWORKS,
EXTRA_LIBS=" ".join([('-l%s' % i) for i in uniq(pkgconfig_libs)]),
EXTRA_LDFLAGS=" ".join([('-L%s' % i) for i in uniq(pkgconfig_ldflags)]),
EXTRA_LINKFLAGS=" ".join(uniq(pkgconfig_linkflags)),
EXTRA_INCLUDES=" ".join([('-I%s' % i) for i in uniq(pkgconfig_includes)]),
EXTRA_CXXFLAGS=" ".join(uniq(pkgconfig_cxxflags)),
EXTRA_FRAMEWORKS=EXTRA_FRAMEWORKS,
)
# Unit tests
@ -219,51 +199,26 @@ def build (bld):
bld.recurse("examples")
headers = bld.path.ant_glob(['src/**/*.hpp'])
bld.install_files("%s/ndn-cpp-dev" % bld.env['INCLUDEDIR'], headers, relative_trick=True, cwd=bld.path.find_node('src'))
bld.install_files("%s/ndn-cpp-dev" % bld.env['INCLUDEDIR'], headers,
relative_trick=True, cwd=bld.path.find_node('src'))
bld.install_files("%s/ndn-cpp-dev" % bld.env['INCLUDEDIR'], bld.path.find_resource('src/ndn-cpp-config.h'))
bld.install_files("%s/ndn-cpp-dev" % bld.env['INCLUDEDIR'],
bld.path.find_resource('src/ndn-cpp-config.h'))
bld.install_files("${SYSCONFDIR}/ndn", "client.conf.sample")
@Configure.conf
def add_supported_cxxflags(self, cxxflags):
"""
Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
"""
self.start_msg('Checking allowed flags for c++ compiler')
supportedFlags = []
for flag in cxxflags:
if self.check_cxx (cxxflags=[flag], mandatory=False):
supportedFlags += [flag]
self.end_msg (' '.join (supportedFlags))
self.env.CXXFLAGS += supportedFlags
# doxygen docs
from waflib.Build import BuildContext
class doxy(BuildContext):
cmd = "doxygen"
fun = "doxygen"
def doxygen(bld):
if not bld.env.DOXYGEN:
bld.fatal("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
bld(features="doxygen",
doxyfile='docs/doxygen.conf')
# doxygen docs
from waflib.Build import BuildContext
class sphinx (BuildContext):
cmd = "sphinx"
fun = "sphinx"
def sphinx (bld):
def sphinx(bld):
bld.load('sphinx_build', tooldir=['waf-tools'])
bld (features="sphinx",
outdir = "doc/html",
source = "doc/source/conf.py")
bld(features="sphinx",
outdir="doc/html",
source="doc/source/conf.py")
@TaskGen.feature('cxx')
@ -278,11 +233,14 @@ def process_pch(self):
z.orig_self = self
class gchx(Task.Task):
run_str = '${CXX} -x c++-header ${CXXFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT}'
run_str = '${CXX} -x c++-header ${CXXFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ' + \
'${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ' + \
'${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT}'
scan = c_preproc.scan
ext_out = ['.hpp']
color = 'BLUE'
def post_run(self):
super(gchx, self).post_run()
self.orig_self.env['CXXFLAGS'] = ['-include', self.inputs[0].relpath()] + self.env['CXXFLAGS']
self.orig_self.env['CXXFLAGS'] = ['-include', self.inputs[0].relpath()] + \
self.env['CXXFLAGS']

Loading…
Cancel
Save