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' |
| 5 | |
| 6 | from waflib import Build, Logs |
| 7 | |
| 8 | def options(opt): |
| 9 | opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''') |
| 10 | 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] | 11 | 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] | 12 | |
Alexander Afanasyev | 3320698 | 2013-01-09 16:29:29 -0800 | [diff] [blame] | 13 | opt.load('compiler_cxx boost ccnx protoc ice_cxx qt4') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 14 | |
| 15 | def configure(conf): |
| 16 | conf.load("compiler_cxx") |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 17 | |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 18 | conf.define ("CHRONOSHARE_VERSION", VERSION) |
| 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) |
Zhenkai Zhu | bc2f628 | 2013-01-08 16:40:58 -0800 | [diff] [blame] | 21 | conf.check_cfg(package='libevent', args=['--cflags', '--libs'], uselib_store='LIBEVENT', mandatory=True) |
| 22 | conf.check_cfg(package='libevent_pthreads', args=['--cflags', '--libs'], uselib_store='LIBEVENT_PTHREADS', mandatory=True) |
| 23 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 24 | 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] | 25 | libcrypto = conf.check_cc(lib='crypto', |
| 26 | header_name='openssl/crypto.h', |
| 27 | define_name='HAVE_SSL', |
| 28 | uselib_store='SSL') |
| 29 | else: |
| 30 | conf.define ("HAVE_SSL", 1) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 31 | if not conf.get_define ("HAVE_SSL"): |
| 32 | conf.fatal ("Cannot find SSL libraries") |
| 33 | |
Zhenkai Zhu | 0a17aea | 2012-12-28 14:30:22 -0800 | [diff] [blame] | 34 | conf.load ('ccnx') |
Alexander Afanasyev | 3320698 | 2013-01-09 16:29:29 -0800 | [diff] [blame] | 35 | |
| 36 | conf.load('protoc') |
| 37 | conf.load('ice_cxx') |
| 38 | |
| 39 | conf.load('qt4') |
| 40 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 41 | conf.load('boost') |
| 42 | |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 43 | conf.check_boost(lib='system test iostreams filesystem regex thread') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 44 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 45 | boost_version = conf.env.BOOST_VERSION.split('_') |
| 46 | if int(boost_version[0]) < 1 or int(boost_version[1]) < 46: |
| 47 | Logs.error ("Minumum required boost version is 1.46") |
| 48 | return |
| 49 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 50 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 51 | |
| 52 | if conf.options.debug: |
| 53 | conf.define ('_DEBUG', 1) |
Alexander Afanasyev | d09871f | 2013-01-04 22:36:37 -0800 | [diff] [blame] | 54 | 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] | 55 | else: |
| 56 | conf.env.append_value('CXXFLAGS', ['-O3', '-g']) |
| 57 | |
| 58 | if conf.options._test: |
Alexander Afanasyev | 72ac219 | 2013-01-03 19:33:43 -0800 | [diff] [blame] | 59 | conf.env.TEST = 1 |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 60 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 61 | conf.write_config_header('src/config.h') |
| 62 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 63 | def build (bld): |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 64 | scheduler = bld.objects ( |
| 65 | target = "scheduler", |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 66 | features = ["cxx"], |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 67 | source = bld.path.ant_glob(['scheduler/**/*.cc']), |
| 68 | use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS', |
| 69 | includes = ['scheduler'], |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 70 | ) |
| 71 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 72 | libccnx = bld ( |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 73 | target="ccnx", |
| 74 | features=['cxx'], |
| 75 | source = bld.path.ant_glob(['ccnx/**/*.cc', 'ccnx/**/*.cpp']), |
| 76 | use = 'BOOST BOOST_THREAD SSL CCNX scheduler', |
| 77 | includes = ['ccnx', 'scheduler'], |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 78 | ) |
| 79 | |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 80 | chornoshare = bld ( |
| 81 | target="chronoshare", |
| 82 | features=['cxx'], |
| 83 | source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.cpp', 'src/**/*.proto']), |
Alexander Afanasyev | abe952a | 2013-01-17 17:06:32 -0800 | [diff] [blame] | 84 | use = "BOOST BOOST_FILESYSTEM SQLITE3 scheduler ccnx", |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 85 | includes = "ccnx scheduler src", |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 86 | ) |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 87 | |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 88 | # Unit tests |
| 89 | if bld.env['TEST']: |
| 90 | unittests = bld.program ( |
| 91 | target="unit-tests", |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 92 | source = bld.path.ant_glob(['test/*.cc']), |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 93 | features=['cxx', 'cxxprogram'], |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 94 | use = 'BOOST_TEST BOOST_FILESYSTEM ccnx database chronoshare', |
| 95 | includes = "ccnx scheduler src", |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 96 | ) |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 97 | |
Alexander Afanasyev | abe952a | 2013-01-17 17:06:32 -0800 | [diff] [blame] | 98 | qt = bld ( |
| 99 | target = "filewatcher", |
| 100 | features = "qt4 cxx cxxprogram", |
| 101 | defines = "WAF", |
| 102 | source = bld.path.ant_glob(['filesystemwatcher/*.cpp']), |
| 103 | includes = "filesystemwatcher . ", |
| 104 | use = "QTCORE QTGUI" |
| 105 | ) |
Jared Lindblom | dc845f0 | 2013-01-18 17:29:40 -0800 | [diff] [blame] | 106 | |
| 107 | qt = bld ( |
| 108 | target = "gui", |
| 109 | features = "qt4 cxx cxxprogram", |
| 110 | defines = "WAF", |
| 111 | source = bld.path.ant_glob(['gui/*.cpp']), |
Alexander Afanasyev | fb4c43f | 2013-01-18 17:43:25 -0800 | [diff] [blame^] | 112 | includes = "gui . ", |
Jared Lindblom | dc845f0 | 2013-01-18 17:29:40 -0800 | [diff] [blame] | 113 | use = "QTCORE QTGUI" |
| 114 | ) |