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 | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 12 | opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx logging support''') |
Alexander Afanasyev | 5f9d09e | 2012-12-28 19:43:08 -0800 | [diff] [blame] | 13 | |
Alexander Afanasyev | 9c9c301 | 2013-01-25 23:44:25 -0800 | [diff] [blame] | 14 | opt.load('compiler_cxx boost ccnx protoc 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 | |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 35 | if conf.options.log4cxx: |
| 36 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
| 37 | conf.define ("HAVE_LOG4CXX", 1) |
| 38 | |
Zhenkai Zhu | 0a17aea | 2012-12-28 14:30:22 -0800 | [diff] [blame] | 39 | conf.load ('ccnx') |
Alexander Afanasyev | 3320698 | 2013-01-09 16:29:29 -0800 | [diff] [blame] | 40 | |
| 41 | conf.load('protoc') |
Alexander Afanasyev | 3320698 | 2013-01-09 16:29:29 -0800 | [diff] [blame] | 42 | |
| 43 | conf.load('qt4') |
| 44 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 45 | conf.load('boost') |
| 46 | |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 47 | conf.check_boost(lib='system test iostreams filesystem regex thread') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 48 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 49 | boost_version = conf.env.BOOST_VERSION.split('_') |
| 50 | if int(boost_version[0]) < 1 or int(boost_version[1]) < 46: |
| 51 | Logs.error ("Minumum required boost version is 1.46") |
| 52 | return |
| 53 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 54 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 55 | |
| 56 | if conf.options.debug: |
| 57 | conf.define ('_DEBUG', 1) |
Alexander Afanasyev | d724581 | 2013-02-13 21:06:57 -0800 | [diff] [blame] | 58 | conf.env.append_value('CXXFLAGS', ['-O0', '-Wall', '-Wno-unused-variable', '-g3']) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 59 | else: |
Alexander Afanasyev | d724581 | 2013-02-13 21:06:57 -0800 | [diff] [blame] | 60 | conf.env.append_value('CXXFLAGS', ['-O3', '-g']) |
| 61 | |
| 62 | if conf.env["CXX"] == ["clang++"]: |
| 63 | conf.env.append_value('CXXFLAGS', ['-fcolor-diagnostics', '-Qunused-arguments']) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 64 | |
| 65 | if conf.options._test: |
Alexander Afanasyev | 9e5a470 | 2013-01-24 13:15:23 -0800 | [diff] [blame] | 66 | conf.define ('_TESTS', 1) |
Alexander Afanasyev | 72ac219 | 2013-01-03 19:33:43 -0800 | [diff] [blame] | 67 | conf.env.TEST = 1 |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 68 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 69 | conf.write_config_header('src/config.h') |
| 70 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 71 | def build (bld): |
Zhenkai Zhu | e840942 | 2013-01-28 12:52:17 -0800 | [diff] [blame] | 72 | executor = bld.objects ( |
| 73 | target = "executor", |
| 74 | features = ["cxx"], |
| 75 | source = bld.path.ant_glob(['executor/**/*.cc']), |
| 76 | use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS LOG4CXX', |
| 77 | includes = "executor src", |
| 78 | ) |
| 79 | |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 80 | scheduler = bld.objects ( |
| 81 | target = "scheduler", |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 82 | features = ["cxx"], |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 83 | source = bld.path.ant_glob(['scheduler/**/*.cc']), |
Zhenkai Zhu | e840942 | 2013-01-28 12:52:17 -0800 | [diff] [blame] | 84 | use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS LOG4CXX executor', |
Zhenkai Zhu | 1888f74 | 2013-01-28 12:47:33 -0800 | [diff] [blame] | 85 | includes = "scheduler executor src", |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 86 | ) |
| 87 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 88 | libccnx = bld ( |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 89 | target="ccnx", |
| 90 | features=['cxx'], |
| 91 | source = bld.path.ant_glob(['ccnx/**/*.cc', 'ccnx/**/*.cpp']), |
Zhenkai Zhu | e840942 | 2013-01-28 12:52:17 -0800 | [diff] [blame] | 92 | use = 'BOOST BOOST_THREAD SSL CCNX LOG4CXX scheduler executor', |
Zhenkai Zhu | 1888f74 | 2013-01-28 12:47:33 -0800 | [diff] [blame] | 93 | includes = "ccnx src scheduler executor", |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 94 | ) |
| 95 | |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 96 | chornoshare = bld ( |
| 97 | target="chronoshare", |
| 98 | features=['cxx'], |
| 99 | source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.cpp', 'src/**/*.proto']), |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 100 | use = "BOOST BOOST_FILESYSTEM SQLITE3 LOG4CXX scheduler ccnx", |
Zhenkai Zhu | 1888f74 | 2013-01-28 12:47:33 -0800 | [diff] [blame] | 101 | includes = "ccnx scheduler src executor", |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 102 | ) |
Alexander Afanasyev | b2fe74e | 2013-01-20 16:06:43 -0800 | [diff] [blame] | 103 | |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 104 | fs_watcher = bld ( |
| 105 | target = "fs_watcher", |
| 106 | features = "qt4 cxx", |
| 107 | defines = "WAF", |
| 108 | source = bld.path.ant_glob(['fs-watcher/*.cc']), |
| 109 | use = "SQLITE3 LOG4CXX scheduler executor QTCORE", |
| 110 | includes = "fs-watcher scheduler executor src", |
| 111 | ) |
| 112 | |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 113 | # Unit tests |
| 114 | if bld.env['TEST']: |
| 115 | unittests = bld.program ( |
| 116 | target="unit-tests", |
Zhenkai Zhu | d175627 | 2013-02-01 17:02:18 -0800 | [diff] [blame] | 117 | features = "qt4 cxx cxxprogram", |
| 118 | defines = "WAF", |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 119 | source = bld.path.ant_glob(['test/*.cc']), |
| 120 | use = 'BOOST_TEST BOOST_FILESYSTEM LOG4CXX SQLITE3 QTCORE QTGUI ccnx database fs_watcher chronoshare', |
| 121 | includes = "ccnx scheduler src executor gui fs-watcher", |
Alexander Afanasyev | 4f62f44 | 2013-02-07 22:36:08 -0800 | [diff] [blame] | 122 | install_prefix = None, |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 123 | ) |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 124 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 125 | app_plist = '''<?xml version="1.0" encoding="UTF-8"?> |
| 126 | <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> |
| 127 | <plist version="0.9"> |
| 128 | <dict> |
| 129 | <key>CFBundlePackageType</key> |
| 130 | <string>APPL</string> |
| 131 | <key>CFBundleGetInfoString</key> |
| 132 | <string>Created by Waf</string> |
| 133 | <key>CFBundleSignature</key> |
| 134 | <string>????</string> |
| 135 | <key>NOTE</key> |
| 136 | <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string> |
| 137 | <key>CFBundleExecutable</key> |
| 138 | <string>%s</string> |
| 139 | <key>LSUIElement</key> |
| 140 | <string>1</string> |
| 141 | </dict> |
| 142 | </plist>''' |
| 143 | |
Jared Lindblom | dc845f0 | 2013-01-18 17:29:40 -0800 | [diff] [blame] | 144 | qt = bld ( |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 145 | target = "ChronoShare", |
| 146 | mac_app = "ChronoShare.app", |
| 147 | mac_plist = app_plist % "ChronoShare", |
Jared Lindblom | dc845f0 | 2013-01-18 17:29:40 -0800 | [diff] [blame] | 148 | features = "qt4 cxx cxxprogram", |
| 149 | defines = "WAF", |
Alexander Afanasyev | 9ca444e | 2013-01-25 16:29:35 -0800 | [diff] [blame] | 150 | source = bld.path.ant_glob(['gui/*.cpp', 'gui/*.cc', 'gui/*.qrc']), |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 151 | includes = "ccnx scheduler executor fs-watcher gui src . ", |
| 152 | use = "BOOST BOOST_FILESYSTEM SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ccnx database chronoshare" |
Jared Lindblom | dc845f0 | 2013-01-18 17:29:40 -0800 | [diff] [blame] | 153 | ) |
Alexander Afanasyev | 548d38d | 2013-01-26 16:36:06 -0800 | [diff] [blame] | 154 | |
| 155 | cmdline = bld ( |
| 156 | target = "csd", |
| 157 | features = "qt4 cxx cxxprogram", |
| 158 | defines = "WAF", |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 159 | source = "cmd/csd.cc", |
| 160 | includes = "ccnx scheduler executor gui fs-watcher src . ", |
| 161 | use = "BOOST BOOST_FILESYSTEM SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ccnx database chronoshare" |
Alexander Afanasyev | 548d38d | 2013-01-26 16:36:06 -0800 | [diff] [blame] | 162 | ) |
| 163 | |
Alexander Afanasyev | eb575e0 | 2013-01-26 17:14:51 -0800 | [diff] [blame] | 164 | dump_db = bld ( |
| 165 | target = "dump-db", |
| 166 | features = "cxx cxxprogram", |
| 167 | source = "cmd/dump-db.cc", |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 168 | includes = "ccnx scheduler executor gui fs-watcher src . ", |
| 169 | use = "BOOST BOOST_FILESYSTEM SQLITE3 QTCORE LOG4CXX fs_watcher ccnx database chronoshare" |
Alexander Afanasyev | eb575e0 | 2013-01-26 17:14:51 -0800 | [diff] [blame] | 170 | ) |
| 171 | |
| 172 | |
Alexander Afanasyev | 548d38d | 2013-01-26 16:36:06 -0800 | [diff] [blame] | 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |