blob: db7b242a43024c29121cc36672e64a3eeab4beb6 [file] [log] [blame]
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyev182fdc22012-03-05 18:06:52 -08003VERSION='0.0.1'
4APPNAME='sync'
5
Alexander Afanasyeve76f2632012-03-05 00:18:42 -08006def options(opt):
Alexander Afanasyev87c9b5d2012-03-07 17:23:21 -08007 opt.add_option('--no-debug',action='store_true',default=False,dest='no_debug',help='''Make an optimized build of the library (remove debugging code)''')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -07008 opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx/native NS3 logging support''')
9 opt.add_option('--ns3', action='store_true',default=False,dest='ns3_enable',help='''Compile as NS-3 module''')
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080010 opt.load('compiler_c')
11 opt.load('compiler_cxx')
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080012 opt.load('boost')
13 opt.load('doxygen')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070014 opt.load('ccnx tinyxml ns3', tooldir=["waf-tools"])
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080015
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080016def configure(conf):
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080017 conf.load("compiler_cxx")
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080018
19 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
20 libcrypto = conf.check_cc(lib='crypto',
21 header_name='openssl/crypto.h',
22 define_name='HAVE_SSL',
23 uselib_store='SSL')
24 if not conf.get_define ("HAVE_SSL"):
25 conf.fatal ("Cannot find SSL libraries")
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080026
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080027 conf.load('boost')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070028
29 if conf.options.ns3_enable:
30 conf.load('ns3')
31 conf.define('NS3_MODULE', 1)
32 conf.check_modules(['core', 'network', 'internet'], mandatory = True)
33 conf.check_modules(['NDNabstraction'], mandatory = True)
34 conf.check_modules(['point-to-point'], mandatory = False)
35 conf.check_modules(['point-to-point-layout'], mandatory = False)
36
37 conf.check_boost(lib='system iostreams thread')
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -070038 conf.define ('NS3_LOG_ENABLE', 1)
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070039 else:
40 conf.check_boost(lib='system iostreams test thread')
41 conf.define ('STANDALONE', 1)
42
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070043 conf.load ('ccnx')
44 conf.check_ccnx (path=conf.options.ccnx_dir)
45
46 if conf.options.log4cxx:
47 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
48
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070049 if not conf.options.no_debug:
50 conf.define ('_DEBUG', 1)
Alexander Afanasyeva0c8a1d2012-04-05 13:55:42 -070051 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
52 else:
53 conf.env.append_value('CXXFLAGS', ['-O3'])
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070054
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080055 try:
56 conf.load('doxygen')
57 except:
58 pass
59
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070060 conf.load('tinyxml')
61 conf.check_tinyxml ()
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070062
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080063def build (bld):
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070064 if bld.get_define ("NS3_MODULE"):
65 sync_ns3 = bld.shlib (
66 target = "sync-ns3",
67 features=['cxx', 'cxxshlib'],
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070068 source = [
Alexander Afanasyev181d7e52012-04-09 13:54:11 -070069 'ns3/sync-ccnx-wrapper.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070070 'ns3/sync-ns3-name-info.cc',
Alexander Afanasyevca6f3292012-04-09 10:03:30 -070071 'ns3/sync-scheduler.cc',
Alexander Afanasyev09e8d752012-04-10 16:05:55 -070072 'ns3/sync-logic-helper.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070073
Alexander Afanasyevca6f3292012-04-09 10:03:30 -070074 # 'model/sync-app-data-fetch.cc',
75 # 'model/sync-app-data-publish.cc',
76 # 'ns3/sync-app.cc',
77
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070078 'model/sync-diff-leaf.cc',
79 'model/sync-diff-state.cc',
80 'model/sync-digest.cc',
81 'model/sync-full-leaf.cc',
82 'model/sync-full-state.cc',
83 'model/sync-interest-table.cc',
84 'model/sync-leaf.cc',
85 'model/sync-logic.cc',
86 'model/sync-name-info.cc',
87 'model/sync-seq-no.cc',
88 'model/sync-state.cc',
89 'model/sync-std-name-info.cc',
90 ],
Alexander Afanasyevaced8ad2012-04-10 12:49:29 -070091 use = 'BOOST BOOST_IOSTREAMS SSL TINYXML ' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'NDNabstraction']]).upper (),
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070092 includes = ['model', 'ns3', 'helper'],
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070093 )
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -070094
95 example = bld.program (
96 target = "sync-example",
97 features=['cxx', 'cxxprogram'],
98 source = ['examples/sync-example.cc'],
99 use = 'sync-ns3',
Alexander Afanasyevaced8ad2012-04-10 12:49:29 -0700100 includes = ['model', 'ns3', 'helper'],
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -0700101 )
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700102
103 sync_eval = bld.program (
104 target = "sync-eval",
105 features=['cxx', 'cxxprogram'],
106 source = ['evaluation/sync-eval.cc',
107 'evaluation/standard-muc.cc',
Alexander Afanasyev40942f42012-04-21 20:53:16 -0700108 'evaluation/sync-muc.cc',
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700109 ],
110 use = 'sync-ns3',
111 includes = ['model', 'ns3', 'helper'],
112 )
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700113 # from waflib import Utils,Logs,Errors
114 # Logs.pprint ('CYAN', program.use)
115
116 else:
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700117 libsync = bld.shlib (
118 target=APPNAME,
119 features=['cxx', 'cxxshlib'],
120 source = [
121 'ccnx/sync-ccnx-wrapper.cc',
122 'ccnx/sync-scheduler.cc',
123 'ccnx/sync-log.cc',
Alexander Afanasyevca6f3292012-04-09 10:03:30 -0700124 'ccnx/sync-app-data-fetch.cc',
125 'ccnx/sync-app-data-publish.cc',
126 'ccnx/sync-app-socket-c.cc',
127 'ccnx/sync-app-socket.cc',
Alexander Afanasyev181d7e52012-04-09 13:54:11 -0700128
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700129 'model/sync-diff-leaf.cc',
130 'model/sync-diff-state.cc',
131 'model/sync-digest.cc',
132 'model/sync-full-leaf.cc',
133 'model/sync-full-state.cc',
134 'model/sync-interest-table.cc',
135 'model/sync-leaf.cc',
136 'model/sync-logic.cc',
137 'model/sync-name-info.cc',
138 'model/sync-seq-no.cc',
139 'model/sync-state.cc',
140 'model/sync-std-name-info.cc',
141 ],
142 use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL TINYXML CCNX',
143 includes = ['model', 'ccnx', 'helper'],
144 )
145
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700146 # Unit tests
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700147 unittests = bld.program (
148 target="unit-tests",
149 source = bld.path.ant_glob(['test/**/*.cc']),
150 features=['cxx', 'cxxprogram'],
151 use = 'BOOST_TEST sync',
152 includes = ['model', 'ccnx', 'helper'],
153 )
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -0700154
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700155 if bld.get_define ("HAVE_LOG4CXX"):
156 libsync.use += ' LOG4CXX'
157 unittests.use += ' LOG4CXX'
Alexander Afanasyeve76f2632012-03-05 00:18:42 -0800158
Alexander Afanasyev150f14d2012-03-05 21:24:49 -0800159# doxygen docs
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800160from waflib.Build import BuildContext
161class doxy (BuildContext):
162 cmd = "doxygen"
163 fun = "doxygen"
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -0800164
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800165def doxygen (bld):
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -0800166 if not bld.env.DOXYGEN:
167 bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800168 bld (features="doxygen",
169 doxyfile='doc/doxygen.conf',
170 output_dir = 'doc')