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