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