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' |
Alexander Afanasyev | d09871f | 2013-01-04 22:36:37 -0800 | [diff] [blame] | 5 | CCNXLIB='ccnxx' |
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 | |
Alexander Afanasyev | 3320698 | 2013-01-09 16:29:29 -0800 | [diff] [blame^] | 14 | opt.load('compiler_cxx boost ccnx protoc ice_cxx qt4') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 15 | |
| 16 | def configure(conf): |
| 17 | conf.load("compiler_cxx") |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 18 | |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 19 | conf.define ("CHRONOSHARE_VERSION", VERSION) |
| 20 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 21 | conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True) |
Zhenkai Zhu | bc2f628 | 2013-01-08 16:40:58 -0800 | [diff] [blame] | 22 | conf.check_cfg(package='libevent', args=['--cflags', '--libs'], uselib_store='LIBEVENT', mandatory=True) |
| 23 | conf.check_cfg(package='libevent_pthreads', args=['--cflags', '--libs'], uselib_store='LIBEVENT_PTHREADS', mandatory=True) |
| 24 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 25 | 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] | 26 | libcrypto = conf.check_cc(lib='crypto', |
| 27 | header_name='openssl/crypto.h', |
| 28 | define_name='HAVE_SSL', |
| 29 | uselib_store='SSL') |
| 30 | else: |
| 31 | conf.define ("HAVE_SSL", 1) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 32 | if not conf.get_define ("HAVE_SSL"): |
| 33 | conf.fatal ("Cannot find SSL libraries") |
| 34 | |
Zhenkai Zhu | 0a17aea | 2012-12-28 14:30:22 -0800 | [diff] [blame] | 35 | conf.load ('ccnx') |
Alexander Afanasyev | 3320698 | 2013-01-09 16:29:29 -0800 | [diff] [blame^] | 36 | |
| 37 | conf.load('protoc') |
| 38 | conf.load('ice_cxx') |
| 39 | |
| 40 | conf.load('qt4') |
| 41 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 42 | conf.load('boost') |
| 43 | |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 44 | conf.check_boost(lib='system test iostreams filesystem regex thread') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 45 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 46 | boost_version = conf.env.BOOST_VERSION.split('_') |
| 47 | if int(boost_version[0]) < 1 or int(boost_version[1]) < 46: |
| 48 | Logs.error ("Minumum required boost version is 1.46") |
| 49 | return |
| 50 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 51 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 52 | |
| 53 | if conf.options.debug: |
| 54 | conf.define ('_DEBUG', 1) |
Alexander Afanasyev | d09871f | 2013-01-04 22:36:37 -0800 | [diff] [blame] | 55 | conf.env.append_value('CXXFLAGS', ['-O0', '-Wall', '-Wno-unused-variable', '-fcolor-diagnostics', '-g3']) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 56 | else: |
| 57 | conf.env.append_value('CXXFLAGS', ['-O3', '-g']) |
| 58 | |
| 59 | if conf.options._test: |
Alexander Afanasyev | 72ac219 | 2013-01-03 19:33:43 -0800 | [diff] [blame] | 60 | conf.env.TEST = 1 |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 61 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 62 | conf.write_config_header('src/config.h') |
| 63 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 64 | def build (bld): |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 65 | common = bld.objects ( |
| 66 | target = "common", |
| 67 | features = ["cxx"], |
| 68 | source = ['src/hash-helper.cc', |
| 69 | 'src/chronoshare-client.ice', |
| 70 | ], |
| 71 | use = 'BOOST', |
| 72 | includes = ['include', 'src'], |
| 73 | ) |
| 74 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 75 | libccnx = bld ( |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 76 | target=CCNXLIB, |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 77 | features=['cxx', 'cxxshlib'], |
| 78 | source = [ |
| 79 | 'src/ccnx-wrapper.cpp', |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 80 | 'src/ccnx-pco.cpp', |
Zhenkai Zhu | 974c5a6 | 2012-12-28 14:15:30 -0800 | [diff] [blame] | 81 | 'src/ccnx-closure.cpp', |
Zhenkai Zhu | d492431 | 2012-12-28 11:35:12 -0800 | [diff] [blame] | 82 | 'src/ccnx-tunnel.cpp', |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 83 | 'src/object-db.cc', |
| 84 | 'src/object-manager.cc', |
Zhenkai Zhu | f47109b | 2013-01-02 19:41:34 -0800 | [diff] [blame] | 85 | 'src/ccnx-name.cpp', |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 86 | 'src/ccnx-selectors.cpp', |
Zhenkai Zhu | bc2f628 | 2013-01-08 16:40:58 -0800 | [diff] [blame] | 87 | 'src/event-scheduler.cpp', |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 88 | ], |
Zhenkai Zhu | 608f7b3 | 2013-01-08 19:57:11 -0800 | [diff] [blame] | 89 | use = 'BOOST BOOST_THREAD BOOST_FILESYSTEM SSL SQLITE3 CCNX common LIBEVENT LIBEVENT_PTHREADS', |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 90 | includes = ['include', 'src'], |
| 91 | ) |
| 92 | |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 93 | database = bld.objects ( |
| 94 | target = "database", |
| 95 | features = ["cxx"], |
| 96 | source = [ |
| 97 | 'src/db-helper.cc', |
| 98 | 'src/sync-log.cc', |
| 99 | 'src/action-log.cc', |
| 100 | 'src/action-item.proto', |
| 101 | 'src/sync-state.proto', |
| 102 | ], |
| 103 | use = "BOOST SQLITE3 SSL common", |
| 104 | includes = ['include', 'src'], |
| 105 | ) |
| 106 | |
| 107 | # Unit tests |
| 108 | if bld.env['TEST']: |
| 109 | unittests = bld.program ( |
| 110 | target="unit-tests", |
| 111 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 112 | features=['cxx', 'cxxprogram'], |
Alexander Afanasyev | d09871f | 2013-01-04 22:36:37 -0800 | [diff] [blame] | 113 | use = 'BOOST_TEST ccnxx database', |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 114 | includes = ['include', 'src'], |
| 115 | ) |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 116 | |
| 117 | client = bld ( |
| 118 | target="cs-client", |
| 119 | features=['cxx', 'cxxprogram'], |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 120 | source = ['client/client.cc', |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 121 | ], |
| 122 | use = "BOOST CCNX SSL ICE common", |
| 123 | includes = ['include', 'src'], |
| 124 | ) |
| 125 | |
| 126 | daemon = bld ( |
| 127 | target="cs-daemon", |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 128 | features=['cxx', 'cxxprogram'], |
| 129 | # source = bld.path.ant_glob(['src/**/*.cc']), |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 130 | source = ['daemon/daemon.cc', |
| 131 | 'daemon/notify-i.cc', |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 132 | ], |
Alexander Afanasyev | d09871f | 2013-01-04 22:36:37 -0800 | [diff] [blame] | 133 | use = "BOOST CCNX SSL SQLITE3 ICE common database ccnxx", |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 134 | includes = ['include', 'src'], |
| 135 | ) |
Alexander Afanasyev | 3320698 | 2013-01-09 16:29:29 -0800 | [diff] [blame^] | 136 | |
| 137 | qt = bld ( |
| 138 | target = "gui", |
| 139 | features = "qt4 cxx cxxprogram", |
| 140 | source = "filesystemwatcher/filesystemwatcher.cpp filesystemwatcher/filesystemwatcher.ui filesystemwatcher/main.cpp", |
| 141 | includes = "filesystemwatcher src include .", |
| 142 | use = "QTCORE QTGUI" |
| 143 | ) |