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; -*- |
Zhenkai Zhu | b9f0208 | 2013-03-14 12:45:15 -0700 | [diff] [blame] | 2 | VERSION='0.4' |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 3 | APPNAME='chronoshare' |
| 4 | |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 5 | from waflib import Build, Logs, Utils, Task, TaskGen, Configure |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 6 | |
| 7 | def options(opt): |
| 8 | opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''') |
| 9 | 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] | 10 | 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] | 11 | 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] | 12 | |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 13 | if Utils.unversioned_sys_platform () == "darwin": |
Zhenkai Zhu | bb170d4 | 2013-02-25 13:48:59 -0800 | [diff] [blame] | 14 | opt.add_option('--auto-update', action='store_true',default=False,dest='autoupdate',help='''(OSX) Download sparkle framework and enable autoupdate feature''') |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 15 | |
Alexander Afanasyev | 0b38ad0 | 2013-03-19 13:42:22 -0700 | [diff] [blame] | 16 | opt.load('compiler_c compiler_cxx boost ccnx protoc qt4 gnu_dirs') |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 17 | opt.load('tinyxml', tooldir=['waf-tools']) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 18 | |
| 19 | def configure(conf): |
Alexander Afanasyev | 0b38ad0 | 2013-03-19 13:42:22 -0700 | [diff] [blame] | 20 | conf.load("compiler_c compiler_cxx gnu_dirs") |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 21 | |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 22 | if conf.options.debug: |
| 23 | conf.define ('_DEBUG', 1) |
| 24 | conf.add_supported_cxxflags (cxxflags = ['-O0', |
| 25 | '-Wall', |
| 26 | '-Wno-unused-variable', |
| 27 | '-g3', |
| 28 | '-Wno-unused-private-field', # only clang supports |
| 29 | '-fcolor-diagnostics', # only clang supports |
| 30 | '-Qunused-arguments' # only clang supports |
| 31 | ]) |
| 32 | else: |
Alexander Afanasyev | d985a85 | 2013-03-04 10:34:33 -0800 | [diff] [blame] | 33 | conf.add_supported_cxxflags (cxxflags = ['-O3', '-g']) |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 34 | |
Alexander Afanasyev | a1b7bb5 | 2013-02-26 17:04:02 -0800 | [diff] [blame] | 35 | # I wish I could use it, but there is some weirdness with boost tests. Give up for now |
| 36 | # try: |
| 37 | # conf.check(features='cxx cxxprogram', cxxflags="-std=c++11") |
| 38 | # conf.env.append_value ('CXXFLAGS', ["-std=c++11"]) |
| 39 | # except: |
| 40 | # try: |
| 41 | # conf.check(features='cxx cxxprogram', cxxflags="-std=c++0x") |
| 42 | # conf.env.append_value ('CXXFLAGS', ["-std=c++0x"]) |
| 43 | # except: |
| 44 | # conf.fatal ("You compiler doesn't support C++11. You can try GCC >= 4.4 or recent version of Clang.") |
| 45 | |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 46 | conf.define ("CHRONOSHARE_VERSION", VERSION) |
| 47 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 48 | 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] | 49 | conf.check_cfg(package='libevent', args=['--cflags', '--libs'], uselib_store='LIBEVENT', mandatory=True) |
| 50 | conf.check_cfg(package='libevent_pthreads', args=['--cflags', '--libs'], uselib_store='LIBEVENT_PTHREADS', mandatory=True) |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 51 | conf.load('tinyxml') |
| 52 | conf.check_tinyxml(path=conf.options.tinyxml_dir) |
Zhenkai Zhu | bc2f628 | 2013-01-08 16:40:58 -0800 | [diff] [blame] | 53 | |
Alexander Afanasyev | cf77114 | 2013-03-19 11:15:27 -0700 | [diff] [blame] | 54 | conf.define ("TRAY_ICON", "chronoshare-big.png") |
| 55 | if Utils.unversioned_sys_platform () == "linux": |
| 56 | conf.define ("TRAY_ICON", "chronoshare-ubuntu.png") |
| 57 | |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 58 | if Utils.unversioned_sys_platform () == "darwin": |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 59 | conf.check_cxx(framework_name='Foundation', uselib_store='OSX_FOUNDATION', mandatory=False, compile_filename='test.mm') |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 60 | conf.check_cxx(framework_name='AppKit', uselib_store='OSX_APPKIT', mandatory=False, compile_filename='test.mm') |
| 61 | conf.check_cxx(framework_name='CoreWLAN', uselib_store='OSX_COREWLAN', define_name='HAVE_COREWLAN', |
| 62 | use="OSX_FOUNDATION", mandatory=False, compile_filename='test.mm') |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 63 | |
| 64 | if conf.options.autoupdate: |
Zhenkai Zhu | bb170d4 | 2013-02-25 13:48:59 -0800 | [diff] [blame] | 65 | def check_sparkle(**kwargs): |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 66 | conf.check_cxx (framework_name="Sparkle", header_name=["Foundation/Foundation.h", "AppKit/AppKit.h"], |
Zhenkai Zhu | bb170d4 | 2013-02-25 13:48:59 -0800 | [diff] [blame] | 67 | uselib_store='OSX_SPARKLE', define_name='HAVE_SPARKLE', mandatory=True, |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 68 | compile_filename='test.mm', use="OSX_FOUNDATION OSX_APPKIT", |
Zhenkai Zhu | bb170d4 | 2013-02-25 13:48:59 -0800 | [diff] [blame] | 69 | **kwargs |
| 70 | ) |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 71 | try: |
| 72 | # Try standard paths first |
Zhenkai Zhu | bb170d4 | 2013-02-25 13:48:59 -0800 | [diff] [blame] | 73 | check_sparkle() |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 74 | except: |
| 75 | try: |
| 76 | # Try local path |
| 77 | Logs.info ("Check local version of Sparkle framework") |
Alexander Afanasyev | 7c85d57 | 2013-02-26 22:06:54 -0800 | [diff] [blame] | 78 | check_sparkle(cxxflags="-F%s/osx/Frameworks/" % conf.path.abspath(), |
| 79 | linkflags="-F%s/osx/Frameworks/" % conf.path.abspath()) |
| 80 | conf.env.HAVE_LOCAL_SPARKLE = 1 |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 81 | except: |
Alexander Afanasyev | a1b7bb5 | 2013-02-26 17:04:02 -0800 | [diff] [blame] | 82 | import urllib, subprocess, os, shutil |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 83 | if not os.path.exists('osx/Frameworks/Sparkle.framework'): |
| 84 | # Download to local path and retry |
| 85 | Logs.info ("Sparkle framework not found, trying to download it to 'build/'") |
Alexander Afanasyev | a1b7bb5 | 2013-02-26 17:04:02 -0800 | [diff] [blame] | 86 | |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 87 | urllib.urlretrieve ("http://sparkle.andymatuschak.org/files/Sparkle%201.5b6.zip", "build/Sparkle.zip") |
| 88 | if os.path.exists('build/Sparkle.zip'): |
| 89 | try: |
| 90 | subprocess.check_call (['unzip', '-qq', 'build/Sparkle.zip', '-d', 'build/Sparkle']) |
| 91 | os.remove ("build/Sparkle.zip") |
| 92 | if not os.path.exists("osx/Frameworks"): |
| 93 | os.mkdir ("osx/Frameworks") |
| 94 | os.rename ("build/Sparkle/Sparkle.framework", "osx/Frameworks/Sparkle.framework") |
| 95 | shutil.rmtree("build/Sparkle", ignore_errors=True) |
| 96 | |
| 97 | check_sparkle(cxxflags="-F%s/osx/Frameworks/" % conf.path.abspath(), |
| 98 | linkflags="-F%s/osx/Frameworks/" % conf.path.abspath()) |
| 99 | conf.env.HAVE_LOCAL_SPARKLE = 1 |
| 100 | except subprocess.CalledProcessError as e: |
| 101 | conf.fatal("Cannot find Sparkle framework. Auto download failed: '%s' returned %s" % (' '.join(e.cmd), e.returncode)) |
| 102 | except: |
| 103 | conf.fatal("Unknown Error happened when auto downloading Sparkle framework") |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 104 | |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 105 | if conf.is_defined('HAVE_SPARKLE'): |
| 106 | conf.env.HAVE_SPARKLE = 1 # small cheat for wscript |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 107 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 108 | 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] | 109 | libcrypto = conf.check_cc(lib='crypto', |
| 110 | header_name='openssl/crypto.h', |
| 111 | define_name='HAVE_SSL', |
| 112 | uselib_store='SSL') |
| 113 | else: |
| 114 | conf.define ("HAVE_SSL", 1) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 115 | if not conf.get_define ("HAVE_SSL"): |
| 116 | conf.fatal ("Cannot find SSL libraries") |
| 117 | |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 118 | if conf.options.log4cxx: |
| 119 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
| 120 | conf.define ("HAVE_LOG4CXX", 1) |
| 121 | |
Zhenkai Zhu | 0a17aea | 2012-12-28 14:30:22 -0800 | [diff] [blame] | 122 | conf.load ('ccnx') |
Alexander Afanasyev | 3320698 | 2013-01-09 16:29:29 -0800 | [diff] [blame] | 123 | |
| 124 | conf.load('protoc') |
Alexander Afanasyev | 3320698 | 2013-01-09 16:29:29 -0800 | [diff] [blame] | 125 | |
| 126 | conf.load('qt4') |
| 127 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 128 | conf.load('boost') |
| 129 | |
Alexander Afanasyev | e1c9504 | 2013-02-27 01:02:36 -0800 | [diff] [blame] | 130 | conf.check_boost(lib='system test iostreams filesystem regex thread date_time') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 131 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 132 | boost_version = conf.env.BOOST_VERSION.split('_') |
| 133 | if int(boost_version[0]) < 1 or int(boost_version[1]) < 46: |
| 134 | Logs.error ("Minumum required boost version is 1.46") |
| 135 | return |
| 136 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 137 | conf.check_ccnx (path=conf.options.ccnx_dir) |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 138 | conf.define ('CCNX_PATH', conf.env.CCNX_ROOT) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 139 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 140 | if conf.options._test: |
Alexander Afanasyev | 9e5a470 | 2013-01-24 13:15:23 -0800 | [diff] [blame] | 141 | conf.define ('_TESTS', 1) |
Alexander Afanasyev | 72ac219 | 2013-01-03 19:33:43 -0800 | [diff] [blame] | 142 | conf.env.TEST = 1 |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 143 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 144 | conf.write_config_header('src/config.h') |
| 145 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 146 | def build (bld): |
Zhenkai Zhu | e840942 | 2013-01-28 12:52:17 -0800 | [diff] [blame] | 147 | executor = bld.objects ( |
| 148 | target = "executor", |
| 149 | features = ["cxx"], |
| 150 | source = bld.path.ant_glob(['executor/**/*.cc']), |
| 151 | use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS LOG4CXX', |
| 152 | includes = "executor src", |
| 153 | ) |
| 154 | |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 155 | scheduler = bld.objects ( |
| 156 | target = "scheduler", |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 157 | features = ["cxx"], |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 158 | source = bld.path.ant_glob(['scheduler/**/*.cc']), |
Zhenkai Zhu | e840942 | 2013-01-28 12:52:17 -0800 | [diff] [blame] | 159 | use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS LOG4CXX executor', |
Zhenkai Zhu | 1888f74 | 2013-01-28 12:47:33 -0800 | [diff] [blame] | 160 | includes = "scheduler executor src", |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 161 | ) |
| 162 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 163 | libccnx = bld ( |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 164 | target="ccnx", |
| 165 | features=['cxx'], |
| 166 | source = bld.path.ant_glob(['ccnx/**/*.cc', 'ccnx/**/*.cpp']), |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 167 | use = 'TINYXML BOOST BOOST_THREAD SSL CCNX LOG4CXX scheduler executor', |
Zhenkai Zhu | 1888f74 | 2013-01-28 12:47:33 -0800 | [diff] [blame] | 168 | includes = "ccnx src scheduler executor", |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 169 | ) |
| 170 | |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 171 | adhoc = bld ( |
| 172 | target = "adhoc", |
| 173 | features=['cxx'], |
| 174 | includes = "ccnx src", |
| 175 | ) |
| 176 | if Utils.unversioned_sys_platform () == "darwin": |
| 177 | adhoc.mac_app = True |
| 178 | adhoc.source = 'adhoc/adhoc-osx.mm' |
Alexander Afanasyev | 02a86ec | 2013-03-04 13:09:31 -0800 | [diff] [blame] | 179 | adhoc.use = "BOOST BOOST_THREAD BOOST_DATE_TIME LOG4CXX OSX_FOUNDATION OSX_COREWLAN" |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 180 | |
Alexander Afanasyev | 3f101ec | 2013-01-17 16:58:03 -0800 | [diff] [blame] | 181 | chornoshare = bld ( |
| 182 | target="chronoshare", |
| 183 | features=['cxx'], |
| 184 | source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.cpp', 'src/**/*.proto']), |
Alexander Afanasyev | e1c9504 | 2013-02-27 01:02:36 -0800 | [diff] [blame] | 185 | use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 LOG4CXX scheduler ccnx", |
Zhenkai Zhu | 1888f74 | 2013-01-28 12:47:33 -0800 | [diff] [blame] | 186 | includes = "ccnx scheduler src executor", |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 187 | ) |
Alexander Afanasyev | b2fe74e | 2013-01-20 16:06:43 -0800 | [diff] [blame] | 188 | |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 189 | fs_watcher = bld ( |
| 190 | target = "fs_watcher", |
| 191 | features = "qt4 cxx", |
| 192 | defines = "WAF", |
| 193 | source = bld.path.ant_glob(['fs-watcher/*.cc']), |
| 194 | use = "SQLITE3 LOG4CXX scheduler executor QTCORE", |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame] | 195 | includes = "fs-watcher scheduler executor src ccnx", |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 196 | ) |
| 197 | |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 198 | # Unit tests |
| 199 | if bld.env['TEST']: |
| 200 | unittests = bld.program ( |
| 201 | target="unit-tests", |
Zhenkai Zhu | d175627 | 2013-02-01 17:02:18 -0800 | [diff] [blame] | 202 | features = "qt4 cxx cxxprogram", |
| 203 | defines = "WAF", |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 204 | source = bld.path.ant_glob(['test/*.cc']), |
Alexander Afanasyev | e1c9504 | 2013-02-27 01:02:36 -0800 | [diff] [blame] | 205 | use = 'BOOST_TEST BOOST_FILESYSTEM BOOST_DATE_TIME LOG4CXX SQLITE3 QTCORE QTGUI ccnx database fs_watcher chronoshare', |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 206 | includes = "ccnx scheduler src executor gui fs-watcher", |
Alexander Afanasyev | 4f62f44 | 2013-02-07 22:36:08 -0800 | [diff] [blame] | 207 | install_prefix = None, |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 208 | ) |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 209 | |
Zhenkai Zhu | a9a7e1d | 2013-02-25 18:29:07 -0800 | [diff] [blame] | 210 | http_server = bld ( |
| 211 | target = "http_server", |
Zhenkai Zhu | d942922 | 2013-02-25 22:34:09 -0800 | [diff] [blame] | 212 | features = "qt4 cxx", |
Zhenkai Zhu | a9a7e1d | 2013-02-25 18:29:07 -0800 | [diff] [blame] | 213 | source = bld.path.ant_glob(['server/*.cpp']), |
Zhenkai Zhu | d942922 | 2013-02-25 22:34:09 -0800 | [diff] [blame] | 214 | includes = "server src .", |
| 215 | use = "BOOST QTCORE" |
Zhenkai Zhu | a9a7e1d | 2013-02-25 18:29:07 -0800 | [diff] [blame] | 216 | ) |
| 217 | |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 218 | qt = bld ( |
| 219 | target = "ChronoShare", |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 220 | features = "qt4 cxx cxxprogram html_resources", |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 221 | defines = "WAF", |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 222 | source = bld.path.ant_glob(['gui/*.cpp', 'gui/*.cc', 'gui/images.qrc']), |
Zhenkai Zhu | d942922 | 2013-02-25 22:34:09 -0800 | [diff] [blame] | 223 | includes = "ccnx scheduler executor fs-watcher gui src adhoc server . ", |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 224 | use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ccnx database chronoshare http_server", |
| 225 | |
| 226 | html_resources = bld.path.find_dir ("gui/html").ant_glob([ |
| 227 | '**/*.js', '**/*.png', '**/*.css', |
| 228 | '**/*.html', '**/*.gif', '**/*.ico' |
| 229 | ]), |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 230 | ) |
| 231 | |
| 232 | if Utils.unversioned_sys_platform () == "darwin": |
| 233 | app_plist = '''<?xml version="1.0" encoding="UTF-8"?> |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 234 | <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> |
| 235 | <plist version="0.9"> |
| 236 | <dict> |
| 237 | <key>CFBundlePackageType</key> |
| 238 | <string>APPL</string> |
Zhenkai Zhu | d5d311a | 2013-03-04 15:12:46 -0800 | [diff] [blame] | 239 | <key>CFBundleIconFile</key> |
| 240 | <string>chronoshare.icns</string> |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 241 | <key>CFBundleGetInfoString</key> |
| 242 | <string>Created by Waf</string> |
Zhenkai Zhu | 3857d71 | 2013-02-27 22:51:25 -0800 | [diff] [blame] | 243 | <key>CFBundleIdentifier</key> |
| 244 | <string>edu.ucla.cs.irl.Chronoshare</string> |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 245 | <key>CFBundleSignature</key> |
| 246 | <string>????</string> |
| 247 | <key>NOTE</key> |
| 248 | <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string> |
| 249 | <key>CFBundleExecutable</key> |
| 250 | <string>%s</string> |
| 251 | <key>LSUIElement</key> |
| 252 | <string>1</string> |
Zhenkai Zhu | 8e3e907 | 2013-02-28 15:40:51 -0800 | [diff] [blame] | 253 | <key>SUPublicDSAKeyFile</key> |
| 254 | <string>dsa_pub.pem</string> |
Zhenkai Zhu | d5d311a | 2013-03-04 15:12:46 -0800 | [diff] [blame] | 255 | <key>CFBundleIconFile</key> |
| 256 | <string>chronoshare.icns</string> |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 257 | </dict> |
| 258 | </plist>''' |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 259 | qt.mac_app = "ChronoShare.app" |
| 260 | qt.mac_plist = app_plist % "ChronoShare" |
Zhenkai Zhu | d5d311a | 2013-03-04 15:12:46 -0800 | [diff] [blame] | 261 | qt.mac_resources = 'chronoshare.icns' |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 262 | qt.use += " OSX_FOUNDATION OSX_COREWLAN adhoc" |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 263 | |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 264 | if bld.env['HAVE_SPARKLE']: |
| 265 | qt.use += " OSX_SPARKLE" |
| 266 | qt.source += ["osx/auto-update/sparkle-auto-update.mm"] |
| 267 | qt.includes += " osx/auto-update" |
Alexander Afanasyev | 7c85d57 | 2013-02-26 22:06:54 -0800 | [diff] [blame] | 268 | if bld.env['HAVE_LOCAL_SPARKLE']: |
| 269 | qt.mac_frameworks = "osx/Frameworks/Sparkle.framework" |
Alexander Afanasyev | 548d38d | 2013-01-26 16:36:06 -0800 | [diff] [blame] | 270 | |
Alexander Afanasyev | 0b38ad0 | 2013-03-19 13:42:22 -0700 | [diff] [blame] | 271 | if Utils.unversioned_sys_platform () == "linux": |
| 272 | bld ( |
| 273 | features = "process_in", |
| 274 | target = "ChronoShare.desktop", |
| 275 | source = "ChronoShare.desktop.in", |
| 276 | install_prefix = "${DATADIR}/applications", |
| 277 | ) |
| 278 | bld.install_files ("${DATADIR}/applications", "ChronoShare.desktop") |
| 279 | bld.install_files ("${DATADIR}/ChronoShare", "gui/images/chronoshare-big.png") |
| 280 | |
Alexander Afanasyev | 548d38d | 2013-01-26 16:36:06 -0800 | [diff] [blame] | 281 | cmdline = bld ( |
| 282 | target = "csd", |
| 283 | features = "qt4 cxx cxxprogram", |
| 284 | defines = "WAF", |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 285 | source = "cmd/csd.cc", |
| 286 | includes = "ccnx scheduler executor gui fs-watcher src . ", |
Alexander Afanasyev | e1c9504 | 2013-02-27 01:02:36 -0800 | [diff] [blame] | 287 | use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ccnx database chronoshare" |
Alexander Afanasyev | 548d38d | 2013-01-26 16:36:06 -0800 | [diff] [blame] | 288 | ) |
| 289 | |
Alexander Afanasyev | eb575e0 | 2013-01-26 17:14:51 -0800 | [diff] [blame] | 290 | dump_db = bld ( |
| 291 | target = "dump-db", |
| 292 | features = "cxx cxxprogram", |
| 293 | source = "cmd/dump-db.cc", |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 294 | includes = "ccnx scheduler executor gui fs-watcher src . ", |
Alexander Afanasyev | e1c9504 | 2013-02-27 01:02:36 -0800 | [diff] [blame] | 295 | use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE LOG4CXX fs_watcher ccnx database chronoshare" |
Alexander Afanasyev | eb575e0 | 2013-01-26 17:14:51 -0800 | [diff] [blame] | 296 | ) |
| 297 | |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 298 | from waflib import TaskGen |
| 299 | @TaskGen.extension('.mm') |
| 300 | def m_hook(self, node): |
| 301 | """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing.""" |
| 302 | return self.create_compiled_task('cxx', node) |
Zhenkai Zhu | 6b53f93 | 2013-03-02 20:46:02 -0800 | [diff] [blame] | 303 | |
Alexander Afanasyev | 0b38ad0 | 2013-03-19 13:42:22 -0700 | [diff] [blame] | 304 | @TaskGen.extension('.js', '.png', '.css', '.html', '.gif', '.ico', '.in') |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 305 | def sig_hook(self, node): |
| 306 | node.sig=Utils.h_file (node.abspath()) |
Zhenkai Zhu | 6b53f93 | 2013-03-02 20:46:02 -0800 | [diff] [blame] | 307 | |
Alexander Afanasyev | 0b38ad0 | 2013-03-19 13:42:22 -0700 | [diff] [blame] | 308 | @TaskGen.feature('process_in') |
| 309 | @TaskGen.after_method('process_source') |
| 310 | def create_process_in(self): |
| 311 | dst = self.bld.path.find_or_declare (self.target) |
| 312 | tsk = self.create_task ('process_in', self.source, dst) |
| 313 | |
| 314 | class process_in(Task.Task): |
| 315 | color='PINK' |
| 316 | |
| 317 | def run (self): |
| 318 | self.outputs[0].write (Utils.subst_vars(self.inputs[0].read (), self.env)) |
| 319 | |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 320 | @TaskGen.feature('html_resources') |
| 321 | @TaskGen.before_method('process_source') |
| 322 | def create_qrc_task(self): |
| 323 | output = self.bld.path.find_or_declare ("gui/html.qrc") |
| 324 | tsk = self.create_task('html_resources', self.html_resources, output) |
Alexander Afanasyev | 1cb641f | 2013-03-03 17:49:02 -0800 | [diff] [blame] | 325 | tsk.base_path = output.parent.get_src () |
| 326 | self.create_rcc_task (output.get_src ()) |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 327 | |
| 328 | class html_resources(Task.Task): |
| 329 | color='PINK' |
| 330 | |
| 331 | def __str__ (self): |
Alexander Afanasyev | 1cb641f | 2013-03-03 17:49:02 -0800 | [diff] [blame] | 332 | return "%s: Generating %s\n" % (self.__class__.__name__.replace('_task',''), self.outputs[0].nice_path ()) |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 333 | |
| 334 | def run (self): |
| 335 | out = self.outputs[0] |
Alexander Afanasyev | 9cc6c21 | 2013-03-04 12:45:38 -0800 | [diff] [blame] | 336 | bld_out = out.get_bld () |
| 337 | src_out = out.get_src () |
| 338 | bld_out.write('<RCC>\n <qresource prefix="/">\n') |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 339 | for f in self.inputs: |
Alexander Afanasyev | 9cc6c21 | 2013-03-04 12:45:38 -0800 | [diff] [blame] | 340 | bld_out.write (' <file>%s</file>\n' % f.path_from (self.base_path), 'a') |
| 341 | bld_out.write(' </qresource>\n</RCC>', 'a') |
Alexander Afanasyev | 1cb641f | 2013-03-03 17:49:02 -0800 | [diff] [blame] | 342 | |
Alexander Afanasyev | 9cc6c21 | 2013-03-04 12:45:38 -0800 | [diff] [blame] | 343 | src_out.write (bld_out.read(), 'w') |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 344 | return 0 |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 345 | |
| 346 | @Configure.conf |
| 347 | def add_supported_cxxflags(self, cxxflags): |
| 348 | """ |
| 349 | Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable |
| 350 | """ |
| 351 | self.start_msg('Checking allowed flags for c++ compiler') |
| 352 | |
| 353 | supportedFlags = [] |
| 354 | for flag in cxxflags: |
| 355 | if self.check_cxx (cxxflags=[flag], mandatory=False): |
| 356 | supportedFlags += [flag] |
| 357 | |
| 358 | self.end_msg (' '.join (supportedFlags)) |
| 359 | self.env.CXXFLAGS += supportedFlags |