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') |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 16 | opt.load('ccnx tinyxml 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 | |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 64 | conf.load('tinyxml') |
| 65 | conf.check_tinyxml () |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 66 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 67 | def build (bld): |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 68 | if bld.get_define ("NS3_MODULE"): |
| 69 | sync_ns3 = bld.shlib ( |
| 70 | target = "sync-ns3", |
| 71 | features=['cxx', 'cxxshlib'], |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 72 | source = [ |
Alexander Afanasyev | 181d7e5 | 2012-04-09 13:54:11 -0700 | [diff] [blame] | 73 | 'ns3/sync-ccnx-wrapper.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 74 | 'ns3/sync-ns3-name-info.cc', |
Alexander Afanasyev | ca6f329 | 2012-04-09 10:03:30 -0700 | [diff] [blame] | 75 | 'ns3/sync-scheduler.cc', |
Alexander Afanasyev | 09e8d75 | 2012-04-10 16:05:55 -0700 | [diff] [blame] | 76 | 'ns3/sync-logic-helper.cc', |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 77 | |
Alexander Afanasyev | ca6f329 | 2012-04-09 10:03:30 -0700 | [diff] [blame] | 78 | # 'model/sync-app-data-fetch.cc', |
| 79 | # 'model/sync-app-data-publish.cc', |
| 80 | # 'ns3/sync-app.cc', |
| 81 | |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 82 | 'model/sync-diff-leaf.cc', |
| 83 | 'model/sync-diff-state.cc', |
| 84 | 'model/sync-digest.cc', |
| 85 | 'model/sync-full-leaf.cc', |
| 86 | 'model/sync-full-state.cc', |
| 87 | 'model/sync-interest-table.cc', |
| 88 | 'model/sync-leaf.cc', |
| 89 | 'model/sync-logic.cc', |
| 90 | 'model/sync-name-info.cc', |
| 91 | 'model/sync-seq-no.cc', |
| 92 | 'model/sync-state.cc', |
| 93 | 'model/sync-std-name-info.cc', |
| 94 | ], |
Alexander Afanasyev | aced8ad | 2012-04-10 12:49:29 -0700 | [diff] [blame] | 95 | use = 'BOOST BOOST_IOSTREAMS SSL TINYXML ' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'NDNabstraction']]).upper (), |
Zhenkai Zhu | 9ec8f41 | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 96 | includes = ['include', 'include/ns3', 'helper'], |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 97 | ) |
Alexander Afanasyev | b550d6a | 2012-04-09 15:03:16 -0700 | [diff] [blame] | 98 | |
| 99 | example = bld.program ( |
| 100 | target = "sync-example", |
| 101 | features=['cxx', 'cxxprogram'], |
| 102 | source = ['examples/sync-example.cc'], |
| 103 | use = 'sync-ns3', |
Zhenkai Zhu | 9ec8f41 | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 104 | includes = ['include', 'include/ns3', 'helper'], |
Alexander Afanasyev | b550d6a | 2012-04-09 15:03:16 -0700 | [diff] [blame] | 105 | ) |
Alexander Afanasyev | d7fc7c0 | 2012-04-19 15:36:26 -0700 | [diff] [blame] | 106 | |
| 107 | sync_eval = bld.program ( |
| 108 | target = "sync-eval", |
| 109 | features=['cxx', 'cxxprogram'], |
| 110 | source = ['evaluation/sync-eval.cc', |
| 111 | 'evaluation/standard-muc.cc', |
Alexander Afanasyev | 40942f4 | 2012-04-21 20:53:16 -0700 | [diff] [blame] | 112 | 'evaluation/sync-muc.cc', |
Alexander Afanasyev | d7fc7c0 | 2012-04-19 15:36:26 -0700 | [diff] [blame] | 113 | ], |
| 114 | use = 'sync-ns3', |
Zhenkai Zhu | 9ec8f41 | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 115 | includes = ['include', 'include/ns3', 'helper'], |
Alexander Afanasyev | d7fc7c0 | 2012-04-19 15:36:26 -0700 | [diff] [blame] | 116 | ) |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 117 | # from waflib import Utils,Logs,Errors |
| 118 | # Logs.pprint ('CYAN', program.use) |
| 119 | |
| 120 | else: |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 121 | libsync = bld.shlib ( |
| 122 | target=APPNAME, |
| 123 | features=['cxx', 'cxxshlib'], |
| 124 | source = [ |
| 125 | 'ccnx/sync-ccnx-wrapper.cc', |
| 126 | 'ccnx/sync-scheduler.cc', |
| 127 | 'ccnx/sync-log.cc', |
Chaoyi Bian | 2f2d641 | 2012-06-04 16:53:08 -0700 | [diff] [blame^] | 128 | 'ccnx/sync-app-socket-c.cc', |
Alexander Afanasyev | ca6f329 | 2012-04-09 10:03:30 -0700 | [diff] [blame] | 129 | 'ccnx/sync-app-socket.cc', |
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', |
Zhenkai Zhu | 9ec8f41 | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 144 | includes = ['include', 'helper'], |
Alexander Afanasyev | 158ec0d | 2012-04-05 13:48:55 -0700 | [diff] [blame] | 145 | ) |
| 146 | |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 147 | # Unit tests |
Zhenkai Zhu | 43ae5c7 | 2012-05-31 23:18:45 -0700 | [diff] [blame] | 148 | if bld.get_define("_TEST"): |
| 149 | unittests = bld.program ( |
| 150 | target="unit-tests", |
| 151 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 152 | features=['cxx', 'cxxprogram'], |
| 153 | use = 'BOOST_TEST sync', |
Zhenkai Zhu | 9ec8f41 | 2012-06-01 15:44:36 -0700 | [diff] [blame] | 154 | includes = ['include', 'helper'], |
Zhenkai Zhu | 43ae5c7 | 2012-05-31 23:18:45 -0700 | [diff] [blame] | 155 | ) |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 156 | |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 157 | if bld.get_define ("HAVE_LOG4CXX"): |
| 158 | libsync.use += ' LOG4CXX' |
| 159 | unittests.use += ' LOG4CXX' |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 160 | |
Alexander Afanasyev | 150f14d | 2012-03-05 21:24:49 -0800 | [diff] [blame] | 161 | # doxygen docs |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 162 | from waflib.Build import BuildContext |
| 163 | class doxy (BuildContext): |
| 164 | cmd = "doxygen" |
| 165 | fun = "doxygen" |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 166 | |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 167 | def doxygen (bld): |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 168 | if not bld.env.DOXYGEN: |
| 169 | bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)") |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 170 | bld (features="doxygen", |
| 171 | doxyfile='doc/doxygen.conf', |
| 172 | output_dir = 'doc') |