forked from named-data/ndn.cxx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwscript
152 lines (122 loc) · 5.52 KB
/
wscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
VERSION='0.6.0'
from waflib import Build, Logs, Utils, Task, TaskGen, Configure
def options(opt):
opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx logging support''')
opt.load('compiler_c compiler_cxx boost ccnx doxygen gnu_dirs')
opt.load('tinyxml', tooldir=['waf-tools'])
def configure(conf):
conf.load("compiler_c compiler_cxx boost ccnx gnu_dirs tinyxml doxygen")
if conf.options.debug:
conf.define ('_DEBUG', 1)
conf.add_supported_cxxflags (cxxflags = ['-O0',
'-Wall',
'-Wno-unused-variable',
'-g3',
'-Wno-unused-private-field', # only clang supports
'-fcolor-diagnostics', # only clang supports
'-Qunused-arguments' # only clang supports
])
else:
conf.add_supported_cxxflags (cxxflags = ['-O3', '-g'])
conf.define ("CCNX_CPP_VERSION", VERSION)
conf.check_cfg(package='libevent', args=['--cflags', '--libs'], uselib_store='LIBEVENT', mandatory=True)
conf.check_cfg(package='libevent_pthreads', args=['--cflags', '--libs'], uselib_store='LIBEVENT_PTHREADS', mandatory=True)
if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
libcrypto = conf.check_cc(lib='crypto',
header_name='openssl/crypto.h',
define_name='HAVE_SSL',
uselib_store='SSL')
else:
conf.define ("HAVE_SSL", 1)
if not conf.get_define ("HAVE_SSL"):
conf.fatal ("Cannot find SSL libraries")
conf.check_cfg(package="libcrypto", args=['--cflags', '--libs'], uselib_store='CRYPTO', 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_tinyxml(path=conf.options.tinyxml_dir)
conf.check_doxygen(mandatory=False)
conf.check_boost(lib='system test iostreams filesystem thread date_time')
boost_version = conf.env.BOOST_VERSION.split('_')
if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
Logs.error ("Minumum required boost version is 1.46")
return
conf.check_ccnx (path=conf.options.ccnx_dir)
if conf.options._test:
conf.define ('_TESTS', 1)
conf.env.TEST = 1
conf.write_config_header('config.h')
def build (bld):
executor = bld.objects (
target = "executor",
features = ["cxx"],
cxxflags = "-fPIC",
source = bld.path.ant_glob(['executor/**/*.cc']),
use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS LOG4CXX',
includes = ".",
)
scheduler = bld.objects (
target = "scheduler",
features = ["cxx"],
cxxflags = "-fPIC",
source = bld.path.ant_glob(['scheduler/**/*.cc']),
use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS LOG4CXX executor',
includes = ".",
)
libndn_cxx = bld (
target="ndn.cxx",
features=['cxx', 'cxxshlib'],
source = bld.path.ant_glob(['ndn.cxx/**/*.cpp', 'ndn.cxx/**/*.cc',
'logging.cc',
'libndn.cxx.pc.in']),
use = 'CRYPTO TINYXML BOOST BOOST_THREAD SSL CCNX LOG4CXX scheduler executor',
includes = ".",
)
# Unit tests
if bld.env['TEST']:
unittests = bld.program (
target="unit-tests",
features = "cxx cxxprogram",
defines = "WAF",
source = bld.path.ant_glob(['test/*.cc']),
use = 'BOOST_TEST BOOST_FILESYSTEM BOOST_DATE_TIME LOG4CXX ndn.cxx',
includes = ".",
install_prefix = None,
)
headers = bld.path.ant_glob(['ndn.cxx.h', 'ndn.cxx/**/*.h'])
bld.install_files("%s" % bld.env['INCLUDEDIR'], headers, relative_trick=True)
@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='doc/doxygen.conf')
# doxygen docs
from waflib.Build import BuildContext
class sphinx (BuildContext):
cmd = "sphinx"
fun = "sphinx"
def sphinx (bld):
bld.load('sphinx_build', tooldir=['waf-tools'])
bld (features="sphinx",
outdir = "doc/html",
source = "doc/source/conf.py")