Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 3 | VERSION='0.0.1' |
| 4 | APPNAME='sync' |
| 5 | |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 6 | from waflib import Build, Logs |
| 7 | |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 8 | def options(opt): |
Zhenkai Zhu | 699d740 | 2012-05-29 16:47:39 -0700 | [diff] [blame] | 9 | opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''') |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 10 | opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx/native NS3 logging support''') |
| 11 | opt.add_option('--ns3', action='store_true',default=False,dest='ns3_enable',help='''Compile as NS-3 module''') |
Alexander Afanasyev | 983b0e9 | 2012-04-26 12:44:18 -0700 | [diff] [blame] | 12 | opt.add_option('--ns3-debug', action='store_true',default=False,dest='ns3_debug',help='''Link against debug NS3 libraries. Optimized version will be used otherwise''') |
Zhenkai Zhu | 43ae5c7 | 2012-05-31 23:18:45 -0700 | [diff] [blame] | 13 | opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''') |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 14 | opt.load('compiler_c') |
| 15 | opt.load('compiler_cxx') |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 16 | opt.load('boost') |
| 17 | opt.load('doxygen') |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 18 | opt.load('gnu_dirs') |
| 19 | opt.load('ccnx ns3 protobuf', tooldir=["waf-tools"]) |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 20 | |
Alexander Afanasyev | 8f25cbb | 2012-03-01 23:53:40 -0800 | [diff] [blame] | 21 | def configure(conf): |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 22 | conf.load("compiler_cxx") |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 23 | conf.load('gnu_dirs') |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 24 | |
| 25 | if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False): |
| 26 | libcrypto = conf.check_cc(lib='crypto', |
| 27 | header_name='openssl/crypto.h', |
| 28 | define_name='HAVE_SSL', |
| 29 | uselib_store='SSL') |
| 30 | if not conf.get_define ("HAVE_SSL"): |
| 31 | conf.fatal ("Cannot find SSL libraries") |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 32 | |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 33 | conf.load('boost') |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 34 | |
| 35 | if conf.options.ns3_enable: |
| 36 | conf.load('ns3') |
| 37 | conf.define('NS3_MODULE', 1) |
| 38 | conf.check_modules(['core', 'network', 'internet'], mandatory = True) |
| 39 | conf.check_modules(['NDNabstraction'], mandatory = True) |
| 40 | conf.check_modules(['point-to-point'], mandatory = False) |
| 41 | conf.check_modules(['point-to-point-layout'], mandatory = False) |
| 42 | |
| 43 | conf.check_boost(lib='system iostreams thread') |
Alexander Afanasyev | b550d6a | 2012-04-09 15:03:16 -0700 | [diff] [blame] | 44 | conf.define ('NS3_LOG_ENABLE', 1) |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 45 | else: |
| 46 | conf.check_boost(lib='system iostreams test thread') |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 47 | |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 48 | conf.load ('ccnx') |
| 49 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 50 | |
| 51 | if conf.options.log4cxx: |
| 52 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
| 53 | |
Zhenkai Zhu | 699d740 | 2012-05-29 16:47:39 -0700 | [diff] [blame] | 54 | if conf.options.debug: |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 55 | conf.define ('_DEBUG', 1) |
Alexander Afanasyev | a0c8a1d | 2012-04-05 13:55:42 -0700 | [diff] [blame] | 56 | conf.env.append_value('CXXFLAGS', ['-O0', '-g3']) |
| 57 | else: |
Zhenkai Zhu | dc70a29 | 2012-06-01 14:00:59 -0700 | [diff] [blame] | 58 | conf.env.append_value('CXXFLAGS', ['-O3', '-g']) |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 59 | |
Zhenkai Zhu | 43ae5c7 | 2012-05-31 23:18:45 -0700 | [diff] [blame] | 60 | if conf.options._test: |
| 61 | conf.define('_TEST', 1) |
| 62 | |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 63 | try: |
| 64 | conf.load('doxygen') |
| 65 | except: |
| 66 | pass |
| 67 | |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 68 | conf.load('protobuf') |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 69 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 70 | def build (bld): |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 71 | bld.post_mode = Build.POST_LAZY |
| 72 | |
| 73 | bld.add_group ("protobuf") |
| 74 | |
| 75 | x = bld ( |
| 76 | features = ["protobuf"], |
| 77 | source = ["model/sync-state.proto"], |
| 78 | target = ["model/sync-state.pb"], |
| 79 | ) |
| 80 | |
| 81 | bld.add_group ("code") |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 82 | |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 83 | if bld.get_define ("NS3_MODULE"): |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 84 | libsync = bld.shlib ( |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 85 | target = "sync-ns3", |
| 86 | features=['cxx', 'cxxshlib'], |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 87 | source = [ |
Alexander Afanasyev | 181d7e5 | 2012-04-09 13:54:11 -0700 | [diff] [blame] | 88 | 'ns3/sync-ccnx-wrapper.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 89 | 'ns3/sync-ns3-name-info.cc', |
Alexander Afanasyev | ca6f329 | 2012-04-09 10:03:30 -0700 | [diff] [blame] | 90 | 'ns3/sync-scheduler.cc', |
Alexander Afanasyev | 09e8d75 | 2012-04-10 16:05:55 -0700 | [diff] [blame] | 91 | 'ns3/sync-logic-helper.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 92 | |
Alexander Afanasyev | ca6f329 | 2012-04-09 10:03:30 -0700 | [diff] [blame] | 93 | # 'model/sync-app-data-fetch.cc', |
| 94 | # 'model/sync-app-data-publish.cc', |
| 95 | # 'ns3/sync-app.cc', |
| 96 | |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 97 | 'model/sync-diff-leaf.cc', |
| 98 | 'model/sync-diff-state.cc', |
| 99 | 'model/sync-digest.cc', |
| 100 | 'model/sync-full-leaf.cc', |
| 101 | 'model/sync-full-state.cc', |
| 102 | 'model/sync-interest-table.cc', |
| 103 | 'model/sync-leaf.cc', |
| 104 | 'model/sync-logic.cc', |
| 105 | 'model/sync-name-info.cc', |
| 106 | 'model/sync-seq-no.cc', |
| 107 | 'model/sync-state.cc', |
| 108 | 'model/sync-std-name-info.cc', |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 109 | ], |
| 110 | dynamic_source = [ |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 111 | 'model/sync-state.pb.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 112 | ], |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 113 | use = 'BOOST BOOST_IOSTREAMS SSL PROTOBUF ' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'NDNabstraction']]).upper (), |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 114 | includes = ['include', 'model', 'include/ns3', 'helper'], |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 115 | ) |
Alexander Afanasyev | b550d6a | 2012-04-09 15:03:16 -0700 | [diff] [blame] | 116 | |
| 117 | example = bld.program ( |
| 118 | target = "sync-example", |
| 119 | features=['cxx', 'cxxprogram'], |
| 120 | source = ['examples/sync-example.cc'], |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 121 | use = 'libsync', |
| 122 | includes = ['include', 'model', 'include/ns3', 'helper'], |
Alexander Afanasyev | b550d6a | 2012-04-09 15:03:16 -0700 | [diff] [blame] | 123 | ) |
Alexander Afanasyev | d7fc7c0 | 2012-04-19 15:36:26 -0700 | [diff] [blame] | 124 | |
| 125 | sync_eval = bld.program ( |
| 126 | target = "sync-eval", |
| 127 | features=['cxx', 'cxxprogram'], |
| 128 | source = ['evaluation/sync-eval.cc', |
| 129 | 'evaluation/standard-muc.cc', |
Alexander Afanasyev | 40942f4 | 2012-04-21 20:53:16 -0700 | [diff] [blame] | 130 | 'evaluation/sync-muc.cc', |
Alexander Afanasyev | d7fc7c0 | 2012-04-19 15:36:26 -0700 | [diff] [blame] | 131 | ], |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 132 | use = 'libsync', |
| 133 | includes = ['include', 'model', 'include/ns3', 'helper'], |
Alexander Afanasyev | d7fc7c0 | 2012-04-19 15:36:26 -0700 | [diff] [blame] | 134 | ) |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 135 | # from waflib import Utils,Logs,Errors |
| 136 | # Logs.pprint ('CYAN', program.use) |
| 137 | |
| 138 | else: |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 139 | libsync = bld ( |
| 140 | target=APPNAME, |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 141 | features=['cxx', 'cxxshlib'], |
| 142 | source = [ |
| 143 | 'ccnx/sync-ccnx-wrapper.cc', |
| 144 | 'ccnx/sync-scheduler.cc', |
| 145 | 'ccnx/sync-log.cc', |
Chaoyi Bian | 2f2d641 | 2012-06-04 16:53:08 -0700 | [diff] [blame] | 146 | 'ccnx/sync-app-socket-c.cc', |
Alexander Afanasyev | ca6f329 | 2012-04-09 10:03:30 -0700 | [diff] [blame] | 147 | 'ccnx/sync-app-socket.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 148 | 'model/sync-diff-leaf.cc', |
| 149 | 'model/sync-diff-state.cc', |
| 150 | 'model/sync-digest.cc', |
| 151 | 'model/sync-full-leaf.cc', |
| 152 | 'model/sync-full-state.cc', |
| 153 | 'model/sync-interest-table.cc', |
| 154 | 'model/sync-leaf.cc', |
| 155 | 'model/sync-logic.cc', |
| 156 | 'model/sync-name-info.cc', |
| 157 | 'model/sync-seq-no.cc', |
| 158 | 'model/sync-state.cc', |
| 159 | 'model/sync-std-name-info.cc', |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 160 | ], |
| 161 | dynamic_source = [ |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 162 | 'model/sync-state.pb.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 163 | ], |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 164 | use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL PROTOBUF CCNX', |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 165 | includes = ['include', 'model', 'helper'], |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 166 | ) |
| 167 | |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 168 | # Unit tests |
Zhenkai Zhu | 43ae5c7 | 2012-05-31 23:18:45 -0700 | [diff] [blame] | 169 | if bld.get_define("_TEST"): |
| 170 | unittests = bld.program ( |
| 171 | target="unit-tests", |
| 172 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 173 | features=['cxx', 'cxxprogram'], |
| 174 | use = 'BOOST_TEST sync', |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 175 | includes = ['include', 'model', 'helper'], |
Zhenkai Zhu | 43ae5c7 | 2012-05-31 23:18:45 -0700 | [diff] [blame] | 176 | ) |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 177 | |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 178 | if bld.get_define ("HAVE_LOG4CXX"): |
| 179 | libsync.use += ' LOG4CXX' |
Alexander Afanasyev | 03ec7bf | 2012-10-04 10:21:31 -0700 | [diff] [blame] | 180 | if bld.get_define("_TEST"): |
| 181 | unittests.use += ' LOG4CXX' |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 182 | |
Alexander Afanasyev | 6af3c15 | 2012-06-07 21:14:24 -0700 | [diff] [blame] | 183 | headers = bld.path.ant_glob(['include/*.h']) |
| 184 | headers.extend (bld.path.get_bld().ant_glob(['model/sync-state.pb.h'])) |
| 185 | bld.install_files ("%s/sync" % bld.env['INCLUDEDIR'], headers) |
| 186 | |
| 187 | pc = bld ( |
| 188 | features = "subst", |
| 189 | source='libsync.pc.in', |
| 190 | target='libsync.pc', |
| 191 | install_path = '${LIBDIR}/pkgconfig', |
| 192 | PREFIX = bld.env['PREFIX'], |
| 193 | INCLUDEDIR = "%s/sync" % bld.env['INCLUDEDIR'], |
| 194 | VERSION = VERSION, |
| 195 | ) |
| 196 | |
Alexander Afanasyev | 150f14d | 2012-03-05 21:24:49 -0800 | [diff] [blame] | 197 | # doxygen docs |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 198 | from waflib.Build import BuildContext |
| 199 | class doxy (BuildContext): |
| 200 | cmd = "doxygen" |
| 201 | fun = "doxygen" |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 202 | |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 203 | def doxygen (bld): |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 204 | if not bld.env.DOXYGEN: |
| 205 | bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)") |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 206 | bld (features="doxygen", |
| 207 | doxyfile='doc/doxygen.conf', |
| 208 | output_dir = 'doc') |