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 | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 8 | opt.add_option('--log4cxx',action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx support''') |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 9 | opt.load('compiler_c') |
| 10 | opt.load('compiler_cxx') |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 11 | opt.load('boost') |
| 12 | opt.load('doxygen') |
Alexander Afanasyev | 250a4c4 | 2012-03-07 13:40:18 -0800 | [diff] [blame] | 13 | opt.load('ccnx tinyxml', tooldir=["waf-tools"]) |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 14 | |
Alexander Afanasyev | 8f25cbb | 2012-03-01 23:53:40 -0800 | [diff] [blame] | 15 | def configure(conf): |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 16 | conf.load("compiler_cxx") |
Chaoyi Bian | 9813519 | 2012-03-27 18:34:11 -0700 | [diff] [blame] | 17 | conf.env.append_value('CXXFLAGS', ['-O0', '-g3']) |
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') |
Chaoyi Bian | ee5b884 | 2012-03-07 13:43:27 -0800 | [diff] [blame] | 28 | conf.check_boost(lib='system iostreams test thread') |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 29 | |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 30 | try: |
| 31 | conf.load('doxygen') |
| 32 | except: |
| 33 | pass |
| 34 | |
Alexander Afanasyev | 250a4c4 | 2012-03-07 13:40:18 -0800 | [diff] [blame] | 35 | conf.load('ccnx tinyxml') |
| 36 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 37 | conf.check_tinyxml (path=conf.options.ccnx_dir) |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 38 | |
Alexander Afanasyev | 250a4c4 | 2012-03-07 13:40:18 -0800 | [diff] [blame] | 39 | conf.define ('STANDALONE', 1) |
Alexander Afanasyev | 87c9b5d | 2012-03-07 17:23:21 -0800 | [diff] [blame] | 40 | if not conf.options.no_debug: |
| 41 | conf.define ('_DEBUG', 1) |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 42 | |
| 43 | if conf.options.log4cxx: |
| 44 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
| 45 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 46 | def build (bld): |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 47 | libsync = bld.shlib (target=APPNAME, |
| 48 | features=['cxx', 'cxxshlib'], |
| 49 | source = bld.path.ant_glob(['model/sync-*.cc', |
| 50 | 'helper/sync-*.cc']), |
| 51 | use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL TINYXML CCNX') |
Alexander Afanasyev | ec1d4a7 | 2012-03-05 11:06:54 -0800 | [diff] [blame] | 52 | |
Alexander Afanasyev | 150f14d | 2012-03-05 21:24:49 -0800 | [diff] [blame] | 53 | # Unit tests |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 54 | unittests = bld.program (target="unit-tests", |
| 55 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 56 | features=['cxx', 'cxxprogram'], |
| 57 | use = 'BOOST_TEST sync') |
| 58 | |
| 59 | if bld.get_define ("HAVE_LOG4CXX"): |
| 60 | libsync.use += ' LOG4CXX' |
| 61 | unittests.use += ' LOG4CXX' |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 62 | |
Alexander Afanasyev | 150f14d | 2012-03-05 21:24:49 -0800 | [diff] [blame] | 63 | # doxygen docs |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 64 | from waflib.Build import BuildContext |
| 65 | class doxy (BuildContext): |
| 66 | cmd = "doxygen" |
| 67 | fun = "doxygen" |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 68 | |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 69 | def doxygen (bld): |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 70 | if not bld.env.DOXYGEN: |
| 71 | bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)") |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 72 | bld (features="doxygen", |
| 73 | doxyfile='doc/doxygen.conf', |
| 74 | output_dir = 'doc') |