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 | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 6 | def options(opt): |
Zhenkai Zhu | 699d740 | 2012-05-29 16:47:39 -0700 | [diff] [blame] | 7 | 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] | 8 | 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 Afanasyev | 983b0e9 | 2012-04-26 12:44:18 -0700 | [diff] [blame] | 10 | 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] | 11 | 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] | 12 | opt.load('compiler_c') |
| 13 | opt.load('compiler_cxx') |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 14 | opt.load('boost') |
| 15 | opt.load('doxygen') |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 16 | opt.load('ccnx protobuf ns3', tooldir=["waf-tools"]) |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 17 | |
Alexander Afanasyev | 8f25cbb | 2012-03-01 23:53:40 -0800 | [diff] [blame] | 18 | def configure(conf): |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 19 | conf.load("compiler_cxx") |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 20 | |
| 21 | if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False): |
| 22 | libcrypto = conf.check_cc(lib='crypto', |
| 23 | header_name='openssl/crypto.h', |
| 24 | define_name='HAVE_SSL', |
| 25 | uselib_store='SSL') |
| 26 | if not conf.get_define ("HAVE_SSL"): |
| 27 | conf.fatal ("Cannot find SSL libraries") |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 28 | |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 29 | conf.load('boost') |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 30 | |
| 31 | if conf.options.ns3_enable: |
| 32 | conf.load('ns3') |
| 33 | conf.define('NS3_MODULE', 1) |
| 34 | conf.check_modules(['core', 'network', 'internet'], mandatory = True) |
| 35 | conf.check_modules(['NDNabstraction'], mandatory = True) |
| 36 | conf.check_modules(['point-to-point'], mandatory = False) |
| 37 | conf.check_modules(['point-to-point-layout'], mandatory = False) |
| 38 | |
| 39 | conf.check_boost(lib='system iostreams thread') |
Alexander Afanasyev | b550d6a | 2012-04-09 15:03:16 -0700 | [diff] [blame] | 40 | conf.define ('NS3_LOG_ENABLE', 1) |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 41 | else: |
| 42 | conf.check_boost(lib='system iostreams test thread') |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 43 | |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 44 | conf.load ('ccnx') |
| 45 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 46 | |
| 47 | if conf.options.log4cxx: |
| 48 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
| 49 | |
Zhenkai Zhu | 699d740 | 2012-05-29 16:47:39 -0700 | [diff] [blame] | 50 | if conf.options.debug: |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 51 | conf.define ('_DEBUG', 1) |
Alexander Afanasyev | a0c8a1d | 2012-04-05 13:55:42 -0700 | [diff] [blame] | 52 | conf.env.append_value('CXXFLAGS', ['-O0', '-g3']) |
| 53 | else: |
Zhenkai Zhu | dc70a29 | 2012-06-01 14:00:59 -0700 | [diff] [blame] | 54 | conf.env.append_value('CXXFLAGS', ['-O3', '-g']) |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 55 | |
Zhenkai Zhu | 43ae5c7 | 2012-05-31 23:18:45 -0700 | [diff] [blame] | 56 | if conf.options._test: |
| 57 | conf.define('_TEST', 1) |
| 58 | |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 59 | try: |
| 60 | conf.load('doxygen') |
| 61 | except: |
| 62 | pass |
| 63 | |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 64 | conf.load('protobuf') |
| 65 | conf.check_protobuf (path=conf.options.protobuf_dir) |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 66 | |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 67 | |
| 68 | def pre(bld): |
| 69 | bld.exec_command('protoc --cpp_out=. sync-state.proto') |
| 70 | bld.exec_command('mv sync-state.pb.h include/') |
| 71 | bld.exec_command('mv sync-state.pb.cc model/') |
| 72 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 73 | def build (bld): |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 74 | bld.add_pre_fun(pre) |
| 75 | |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 76 | if bld.get_define ("NS3_MODULE"): |
| 77 | sync_ns3 = bld.shlib ( |
| 78 | target = "sync-ns3", |
| 79 | features=['cxx', 'cxxshlib'], |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 80 | source = [ |
Alexander Afanasyev | 181d7e5 | 2012-04-09 13:54:11 -0700 | [diff] [blame] | 81 | 'ns3/sync-ccnx-wrapper.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 82 | 'ns3/sync-ns3-name-info.cc', |
Alexander Afanasyev | ca6f329 | 2012-04-09 10:03:30 -0700 | [diff] [blame] | 83 | 'ns3/sync-scheduler.cc', |
Alexander Afanasyev | 09e8d75 | 2012-04-10 16:05:55 -0700 | [diff] [blame] | 84 | 'ns3/sync-logic-helper.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 85 | |
Alexander Afanasyev | ca6f329 | 2012-04-09 10:03:30 -0700 | [diff] [blame] | 86 | # 'model/sync-app-data-fetch.cc', |
| 87 | # 'model/sync-app-data-publish.cc', |
| 88 | # 'ns3/sync-app.cc', |
| 89 | |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 90 | 'model/sync-diff-leaf.cc', |
| 91 | 'model/sync-diff-state.cc', |
| 92 | 'model/sync-digest.cc', |
| 93 | 'model/sync-full-leaf.cc', |
| 94 | 'model/sync-full-state.cc', |
| 95 | 'model/sync-interest-table.cc', |
| 96 | 'model/sync-leaf.cc', |
| 97 | 'model/sync-logic.cc', |
| 98 | 'model/sync-name-info.cc', |
| 99 | 'model/sync-seq-no.cc', |
| 100 | 'model/sync-state.cc', |
| 101 | 'model/sync-std-name-info.cc', |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 102 | 'model/sync-state.pb.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 103 | ], |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 104 | use = 'BOOST BOOST_IOSTREAMS SSL PROTOBUF ' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'NDNabstraction']]).upper (), |
Zhenkai Zhu | 9ec8f41 | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 105 | includes = ['include', 'include/ns3', 'helper'], |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 106 | ) |
Alexander Afanasyev | b550d6a | 2012-04-09 15:03:16 -0700 | [diff] [blame] | 107 | |
| 108 | example = bld.program ( |
| 109 | target = "sync-example", |
| 110 | features=['cxx', 'cxxprogram'], |
| 111 | source = ['examples/sync-example.cc'], |
| 112 | use = 'sync-ns3', |
Zhenkai Zhu | 9ec8f41 | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 113 | includes = ['include', 'include/ns3', 'helper'], |
Alexander Afanasyev | b550d6a | 2012-04-09 15:03:16 -0700 | [diff] [blame] | 114 | ) |
Alexander Afanasyev | d7fc7c0 | 2012-04-19 15:36:26 -0700 | [diff] [blame] | 115 | |
| 116 | sync_eval = bld.program ( |
| 117 | target = "sync-eval", |
| 118 | features=['cxx', 'cxxprogram'], |
| 119 | source = ['evaluation/sync-eval.cc', |
| 120 | 'evaluation/standard-muc.cc', |
Alexander Afanasyev | 40942f4 | 2012-04-21 20:53:16 -0700 | [diff] [blame] | 121 | 'evaluation/sync-muc.cc', |
Alexander Afanasyev | d7fc7c0 | 2012-04-19 15:36:26 -0700 | [diff] [blame] | 122 | ], |
| 123 | use = 'sync-ns3', |
Zhenkai Zhu | 9ec8f41 | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 124 | includes = ['include', 'include/ns3', 'helper'], |
Alexander Afanasyev | d7fc7c0 | 2012-04-19 15:36:26 -0700 | [diff] [blame] | 125 | ) |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 126 | # from waflib import Utils,Logs,Errors |
| 127 | # Logs.pprint ('CYAN', program.use) |
| 128 | |
| 129 | else: |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 130 | libsync = bld.shlib ( |
| 131 | target=APPNAME, |
| 132 | features=['cxx', 'cxxshlib'], |
| 133 | source = [ |
| 134 | 'ccnx/sync-ccnx-wrapper.cc', |
| 135 | 'ccnx/sync-scheduler.cc', |
| 136 | 'ccnx/sync-log.cc', |
Chaoyi Bian | 2f2d641 | 2012-06-04 16:53:08 -0700 | [diff] [blame] | 137 | 'ccnx/sync-app-socket-c.cc', |
Alexander Afanasyev | ca6f329 | 2012-04-09 10:03:30 -0700 | [diff] [blame] | 138 | 'ccnx/sync-app-socket.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 139 | 'model/sync-diff-leaf.cc', |
| 140 | 'model/sync-diff-state.cc', |
| 141 | 'model/sync-digest.cc', |
| 142 | 'model/sync-full-leaf.cc', |
| 143 | 'model/sync-full-state.cc', |
| 144 | 'model/sync-interest-table.cc', |
| 145 | 'model/sync-leaf.cc', |
| 146 | 'model/sync-logic.cc', |
| 147 | 'model/sync-name-info.cc', |
| 148 | 'model/sync-seq-no.cc', |
| 149 | 'model/sync-state.cc', |
| 150 | 'model/sync-std-name-info.cc', |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 151 | 'model/sync-state.pb.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 152 | ], |
Zhenkai Zhu | 3cfdcb9 | 2012-06-06 15:20:10 -0700 | [diff] [blame] | 153 | use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL PROTOBUF CCNX', |
Zhenkai Zhu | 9ec8f41 | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 154 | includes = ['include', 'helper'], |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 155 | ) |
| 156 | |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 157 | # Unit tests |
Zhenkai Zhu | 43ae5c7 | 2012-05-31 23:18:45 -0700 | [diff] [blame] | 158 | if bld.get_define("_TEST"): |
| 159 | unittests = bld.program ( |
| 160 | target="unit-tests", |
| 161 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 162 | features=['cxx', 'cxxprogram'], |
| 163 | use = 'BOOST_TEST sync', |
Zhenkai Zhu | 9ec8f41 | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 164 | includes = ['include', 'helper'], |
Zhenkai Zhu | 43ae5c7 | 2012-05-31 23:18:45 -0700 | [diff] [blame] | 165 | ) |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 166 | |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 167 | if bld.get_define ("HAVE_LOG4CXX"): |
| 168 | libsync.use += ' LOG4CXX' |
| 169 | unittests.use += ' LOG4CXX' |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 170 | |
Alexander Afanasyev | 150f14d | 2012-03-05 21:24:49 -0800 | [diff] [blame] | 171 | # doxygen docs |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 172 | from waflib.Build import BuildContext |
| 173 | class doxy (BuildContext): |
| 174 | cmd = "doxygen" |
| 175 | fun = "doxygen" |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 176 | |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 177 | def doxygen (bld): |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 178 | if not bld.env.DOXYGEN: |
| 179 | bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)") |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 180 | bld (features="doxygen", |
| 181 | doxyfile='doc/doxygen.conf', |
| 182 | output_dir = 'doc') |