Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 3 | VERSION='0.1' |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 4 | APPNAME='chronoshare' |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 5 | CCNXLIB='ccnx' |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 6 | |
| 7 | from waflib import Build, Logs |
| 8 | |
| 9 | def options(opt): |
| 10 | opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''') |
| 11 | opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''') |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 12 | opt.add_option('--yes',action='store_true',default=False) # for autoconf/automake/make compatibility |
Alexander Afanasyev | 5f9d09e | 2012-12-28 19:43:08 -0800 | [diff] [blame] | 13 | |
| 14 | opt.load('compiler_cxx boost ccnx protoc') |
Alexander Afanasyev | 8811b35 | 2013-01-02 12:51:15 -0800 | [diff] [blame^] | 15 | opt.load('ice_cxx', tooldir=["."]) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 16 | |
| 17 | def configure(conf): |
| 18 | conf.load("compiler_cxx") |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 19 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 20 | conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True) |
| 21 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 22 | if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False): |
Alexander Afanasyev | 5f9d09e | 2012-12-28 19:43:08 -0800 | [diff] [blame] | 23 | libcrypto = conf.check_cc(lib='crypto', |
| 24 | header_name='openssl/crypto.h', |
| 25 | define_name='HAVE_SSL', |
| 26 | uselib_store='SSL') |
| 27 | else: |
| 28 | conf.define ("HAVE_SSL", 1) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 29 | if not conf.get_define ("HAVE_SSL"): |
| 30 | conf.fatal ("Cannot find SSL libraries") |
| 31 | |
Zhenkai Zhu | 0a17aea | 2012-12-28 14:30:22 -0800 | [diff] [blame] | 32 | conf.load ('ccnx') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 33 | conf.load('boost') |
| 34 | |
Zhenkai Zhu | 9bdb625 | 2012-12-28 14:32:47 -0800 | [diff] [blame] | 35 | conf.check_boost(lib='system iostreams regex thread') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 36 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 37 | boost_version = conf.env.BOOST_VERSION.split('_') |
| 38 | if int(boost_version[0]) < 1 or int(boost_version[1]) < 46: |
| 39 | Logs.error ("Minumum required boost version is 1.46") |
| 40 | return |
| 41 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 42 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 43 | |
| 44 | if conf.options.debug: |
| 45 | conf.define ('_DEBUG', 1) |
| 46 | conf.env.append_value('CXXFLAGS', ['-O0', '-g3']) |
| 47 | else: |
| 48 | conf.env.append_value('CXXFLAGS', ['-O3', '-g']) |
| 49 | |
| 50 | if conf.options._test: |
| 51 | conf.define('_TEST', 1) |
| 52 | |
Alexander Afanasyev | 5f9d09e | 2012-12-28 19:43:08 -0800 | [diff] [blame] | 53 | conf.load('protoc') |
Alexander Afanasyev | 8811b35 | 2013-01-02 12:51:15 -0800 | [diff] [blame^] | 54 | conf.load('ice_cxx') |
| 55 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 56 | conf.write_config_header('src/config.h') |
| 57 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 58 | def build (bld): |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 59 | libccnx = bld ( |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 60 | target=CCNXLIB, |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 61 | features=['cxx', 'cxxshlib'], |
| 62 | source = [ |
| 63 | 'src/ccnx-wrapper.cpp', |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 64 | 'src/ccnx-pco.cpp', |
Zhenkai Zhu | 974c5a6 | 2012-12-28 14:15:30 -0800 | [diff] [blame] | 65 | 'src/ccnx-closure.cpp', |
Zhenkai Zhu | d492431 | 2012-12-28 11:35:12 -0800 | [diff] [blame] | 66 | 'src/ccnx-tunnel.cpp', |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 67 | ], |
| 68 | use = 'BOOST BOOST_THREAD SSL CCNX', |
| 69 | includes = ['include', ], |
| 70 | ) |
| 71 | |
| 72 | # Unit tests |
| 73 | if bld.get_define("_TEST"): |
| 74 | unittests = bld.program ( |
| 75 | target="unit-tests", |
| 76 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 77 | features=['cxx', 'cxxprogram'], |
| 78 | use = 'BOOST_TEST', |
| 79 | includes = ['include', ], |
| 80 | ) |
| 81 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 82 | chronoshare = bld ( |
Alexander Afanasyev | 5f9d09e | 2012-12-28 19:43:08 -0800 | [diff] [blame] | 83 | target="tmp", |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 84 | features=['cxx', 'cxxprogram'], |
| 85 | # source = bld.path.ant_glob(['src/**/*.cc']), |
Alexander Afanasyev | de1cdd0 | 2012-12-29 14:41:46 -0800 | [diff] [blame] | 86 | source = ['src/main.cc', |
Alexander Afanasyev | 242f877 | 2013-01-01 23:26:31 -0800 | [diff] [blame] | 87 | 'src/db-helper.cc', |
Alexander Afanasyev | 8811b35 | 2013-01-02 12:51:15 -0800 | [diff] [blame^] | 88 | 'src/hash-string-converter.cc', |
| 89 | 'src/chronoshare-client.ice'], |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 90 | use = 'BOOST BOOST_IOSTREAMS BOOST_REGEX CCNX SSL SQLITE3', |
| 91 | includes = ['include', 'src'], |
| 92 | ) |