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