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; -*- |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 2 | VERSION='1.0' |
| 3 | APPNAME='ChronoShare' |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 4 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 5 | from waflib import Logs, Utils, Task, TaskGen |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 6 | |
| 7 | def options(opt): |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 8 | opt.add_option('--with-tests', action='store_true', default=False, dest='with_tests', |
| 9 | 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 | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 13 | opt.add_option('--without-sqlite-locking', action='store_false', default=True, |
| 14 | dest='with_sqlite_locking', |
| 15 | help='''Disable filesystem locking in sqlite3 database ''' |
| 16 | '''(use unix-dot locking mechanism instead). ''' |
| 17 | '''This option may be necessary if home directory is hosted on NFS.''') |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 18 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 19 | if Utils.unversioned_sys_platform() == "darwin": |
| 20 | opt.add_option('--with-auto-update', action='store_true', default=False, dest='autoupdate', |
| 21 | help='''(OSX) Download sparkle framework and enable autoupdate feature''') |
| 22 | |
| 23 | opt.load(['compiler_c', 'compiler_cxx', 'gnu_dirs', 'qt5']) |
| 24 | opt.load(['default-compiler-flags', |
| 25 | 'osx-frameworks', 'boost', 'sqlite3', 'protoc', 'tinyxml', |
| 26 | 'coverage', 'sanitizers', |
| 27 | 'doxygen', 'sphinx_build'], tooldir=['.waf-tools']) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 28 | |
| 29 | def configure(conf): |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 30 | conf.load(['compiler_c', 'compiler_cxx', 'gnu_dirs', |
| 31 | 'default-compiler-flags', |
| 32 | 'osx-frameworks', 'boost', 'sqlite3', 'protoc', 'tinyxml', |
| 33 | 'doxygen', 'sphinx_build']) |
Alexander Afanasyev | a1b7bb5 | 2013-02-26 17:04:02 -0800 | [diff] [blame] | 34 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 35 | if 'PKG_CONFIG_PATH' not in conf.environ: |
| 36 | conf.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env) |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 37 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 38 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 39 | uselib_store='NDN_CXX') |
| 40 | |
| 41 | # add homebrew path, as qt5 is no longer linked |
| 42 | conf.environ['PKG_CONFIG_PATH'] += ":/usr/local/opt/qt5/lib/pkgconfig:/opt/qt5/5.8/clang_64/lib/pkgconfig" |
| 43 | conf.environ['PATH'] += ":/usr/local/opt/qt5/bin:/opt/qt5/5.8/clang_64/bin" |
| 44 | |
| 45 | conf.load('qt5') |
| 46 | |
| 47 | conf.define("CHRONOSHARE_VERSION", VERSION) |
| 48 | |
| 49 | conf.check_sqlite3(mandatory=True) |
| 50 | if not conf.options.with_sqlite_locking: |
| 51 | conf.define('DISABLE_SQLITE3_FS_LOCKING', 1) |
| 52 | |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 53 | conf.check_tinyxml(path=conf.options.tinyxml_dir) |
Zhenkai Zhu | bc2f628 | 2013-01-08 16:40:58 -0800 | [diff] [blame] | 54 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 55 | conf.define("TRAY_ICON", "chronoshare-big.png") |
| 56 | if Utils.unversioned_sys_platform() == "linux": |
| 57 | conf.define("TRAY_ICON", "chronoshare-ubuntu.png") |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 58 | |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 59 | if conf.options.log4cxx: |
| 60 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 61 | conf.define("HAVE_LOG4CXX", 1) |
Alexander Afanasyev | c507ac2 | 2013-01-21 16:01:58 -0800 | [diff] [blame] | 62 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 63 | USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams', |
| 64 | 'regex', 'program_options', 'thread'] |
Alexander Afanasyev | 3320698 | 2013-01-09 16:29:29 -0800 | [diff] [blame] | 65 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 66 | conf.env['WITH_TESTS'] = conf.options.with_tests |
| 67 | if conf.env['WITH_TESTS']: |
| 68 | USED_BOOST_LIBS += ['unit_test_framework'] |
| 69 | conf.define('HAVE_TESTS', 1) |
Alexander Afanasyev | 3320698 | 2013-01-09 16:29:29 -0800 | [diff] [blame] | 70 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 71 | conf.check_boost(lib=USED_BOOST_LIBS) |
| 72 | if conf.env.BOOST_VERSION_NUMBER < 105400: |
| 73 | Logs.error("Minimum required boost version is 1.54.0") |
| 74 | Logs.error("Please upgrade your distribution or install custom boost libraries" + |
| 75 | " (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)") |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 76 | return |
| 77 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 78 | # Loading "late" to prevent tests to be compiled with profiling flags |
| 79 | conf.load('coverage') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 80 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 81 | conf.load('sanitizers') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 82 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 83 | conf.define('SYSCONFDIR', conf.env['SYSCONFDIR']) |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 84 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 85 | conf.write_config_header('core/chronoshare-config.hpp') |
Zhenkai Zhu | e840942 | 2013-01-28 12:52:17 -0800 | [diff] [blame] | 86 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 87 | def build(bld): |
| 88 | # if Utils.unversioned_sys_platform() == 'darwin': |
| 89 | # bld( |
| 90 | # target='adhoc', |
| 91 | # mac_app = True, |
| 92 | # features=['cxx'], |
| 93 | # source='adhoc/adhoc-osx.mm' |
| 94 | # includes='. src', |
| 95 | # use='OSX_FOUNDATION OSX_COREWLAN', |
| 96 | # ) |
| 97 | Logs.error("Ad hoc network creation routines are temporary disabled") |
Alexander Afanasyev | 68f2a95 | 2013-01-08 14:34:16 -0800 | [diff] [blame] | 98 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 99 | # chornoshare = bld( |
| 100 | # target="chronoshare", |
| 101 | # features=['cxx'], |
| 102 | # source=bld.path.ant_glob(['src/**/*.cpp', 'src/*.proto']), |
| 103 | # use='core adhoc BOOST LOG4CXX NDN_CXX TINYXML SQLITE3', |
| 104 | # includes="src", |
| 105 | # export_includes="src", |
| 106 | # ) |
| 107 | Logs.error("Chronoshare source compilation is temporary disabled") |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 108 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 109 | # fs_watcher = bld( |
| 110 | # features=['qt5', 'cxx'], |
| 111 | # target='fs-watcher', |
| 112 | # defines='WAF', |
| 113 | # source=bld.path.ant_glob('fs-watcher/*.cpp'), |
| 114 | # use='chronoshare QT5CORE', |
| 115 | # includes='fs-watcher', |
| 116 | # export_includes='fs-watcher', |
| 117 | # ) |
| 118 | Logs.error("fs-watcher compilation is temporary disabled") |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 119 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 120 | # http_server = bld( |
| 121 | # target = "http_server", |
| 122 | # features = "qt5 cxx", |
| 123 | # source = bld.path.ant_glob(['server/*.cpp']), |
| 124 | # includes = "server src .", |
| 125 | # use = 'BOOST QT5CORE', |
| 126 | # ) |
| 127 | Logs.error("http_server compilation is temporary disabled") |
Alexander Afanasyev | b2fe74e | 2013-01-20 16:06:43 -0800 | [diff] [blame] | 128 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 129 | # qt = bld( |
| 130 | # target = "ChronoShare", |
| 131 | # features = "qt5 cxx cxxprogram html_resources", |
| 132 | # defines = "WAF", |
| 133 | # source = bld.path.ant_glob(['gui/*.cpp', 'gui/images.qrc']), |
| 134 | # includes = "fs-watcher gui src adhoc server . ", |
| 135 | # use = "fs_watcher chronoshare http_server QT5CORE QT5GUI QT5WIDGETS", |
Zhenkai Zhu | 369eff1 | 2013-02-05 15:43:49 -0800 | [diff] [blame] | 136 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 137 | # html_resources = bld.path.find_dir("gui/html").ant_glob([ |
| 138 | # '**/*.js', '**/*.png', '**/*.css', |
| 139 | # '**/*.html', '**/*.gif', '**/*.ico' |
| 140 | # ]), |
| 141 | # ) |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 142 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 143 | # if Utils.unversioned_sys_platform() == "darwin": |
| 144 | # app_plist = '''<?xml version="1.0" encoding="UTF-8"?> |
| 145 | # <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> |
| 146 | # <plist version="0.9"> |
| 147 | # <dict> |
| 148 | # <key>CFBundlePackageType</key> |
| 149 | # <string>APPL</string> |
| 150 | # <key>CFBundleIconFile</key> |
| 151 | # <string>chronoshare.icns</string> |
| 152 | # <key>CFBundleGetInfoString</key> |
| 153 | # <string>Created by Waf</string> |
| 154 | # <key>CFBundleIdentifier</key> |
| 155 | # <string>edu.ucla.cs.irl.Chronoshare</string> |
| 156 | # <key>CFBundleSignature</key> |
| 157 | # <string>????</string> |
| 158 | # <key>NOTE</key> |
| 159 | # <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string> |
| 160 | # <key>CFBundleExecutable</key> |
| 161 | # <string>%s</string> |
| 162 | # <key>LSUIElement</key> |
| 163 | # <string>1</string> |
| 164 | # <key>SUPublicDSAKeyFile</key> |
| 165 | # <string>dsa_pub.pem</string> |
| 166 | # <key>CFBundleIconFile</key> |
| 167 | # <string>chronoshare.icns</string> |
| 168 | # </dict> |
| 169 | # </plist>''' |
| 170 | # qt.mac_app = "ChronoShare.app" |
| 171 | # qt.mac_plist = app_plist % "ChronoShare" |
| 172 | # qt.mac_resources = 'chronoshare.icns' |
| 173 | # qt.use += " OSX_FOUNDATION OSX_COREWLAN adhoc" |
Zhenkai Zhu | a9a7e1d | 2013-02-25 18:29:07 -0800 | [diff] [blame] | 174 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 175 | # if bld.env['HAVE_SPARKLE']: |
| 176 | # qt.use += " OSX_SPARKLE" |
| 177 | # qt.source += ["osx/auto-update/sparkle-auto-update.mm"] |
| 178 | # qt.includes += " osx/auto-update" |
| 179 | # if bld.env['HAVE_LOCAL_SPARKLE']: |
| 180 | # qt.mac_frameworks = "osx/Frameworks/Sparkle.framework" |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 181 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 182 | # if Utils.unversioned_sys_platform() == "linux": |
| 183 | # bld( |
| 184 | # features = "process_in", |
| 185 | # target = "ChronoShare.desktop", |
| 186 | # source = "ChronoShare.desktop.in", |
| 187 | # install_prefix = "${DATADIR}/applications", |
| 188 | # ) |
| 189 | # bld.install_files("${DATADIR}/applications", "ChronoShare.desktop") |
| 190 | # bld.install_files("${DATADIR}/ChronoShare", "gui/images/chronoshare-big.png") |
| 191 | Logs.error("ChronoShare app compilation is temporary disabled") |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 192 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 193 | # cmdline = bld( |
| 194 | # target = "csd", |
| 195 | # features = "qt5 cxx cxxprogram", |
| 196 | # defines = "WAF", |
| 197 | # source = bld.path.ant_glob(['cmd/csd.cpp']), |
| 198 | # use = "fs_watcher chronoshare http_server QT5CORE", |
| 199 | # ) |
| 200 | Logs.error("csd app compilation is temporary disabled") |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 201 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 202 | # dump_db = bld( |
| 203 | # target = "dump-db", |
| 204 | # features = "cxx cxxprogram", |
| 205 | # source = bld.path.ant_glob(['cmd/dump-db.cpp']), |
| 206 | # use = "fs_watcher chronoshare http_server QT5CORE", |
| 207 | # ) |
| 208 | Logs.error("dump-db app compilation is temporary disabled") |
Alexander Afanasyev | 548d38d | 2013-01-26 16:36:06 -0800 | [diff] [blame] | 209 | |
Alexander Afanasyev | 4528997 | 2016-12-24 20:23:03 -0800 | [diff] [blame] | 210 | bld.recurse('tests'); |
Alexander Afanasyev | eb575e0 | 2013-01-26 17:14:51 -0800 | [diff] [blame] | 211 | |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 212 | from waflib import TaskGen |
| 213 | @TaskGen.extension('.mm') |
| 214 | def m_hook(self, node): |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 215 | """Alias .mm files to be compiled the same as .cpp files, gcc/clang will do the right thing.""" |
Alexander Afanasyev | a98e69c | 2013-02-24 15:42:45 -0800 | [diff] [blame] | 216 | return self.create_compiled_task('cxx', node) |
Zhenkai Zhu | 6b53f93 | 2013-03-02 20:46:02 -0800 | [diff] [blame] | 217 | |
Alexander Afanasyev | 0b38ad0 | 2013-03-19 13:42:22 -0700 | [diff] [blame] | 218 | @TaskGen.extension('.js', '.png', '.css', '.html', '.gif', '.ico', '.in') |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 219 | def sig_hook(self, node): |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 220 | node.sig=Utils.h_file(node.abspath()) |
Zhenkai Zhu | 6b53f93 | 2013-03-02 20:46:02 -0800 | [diff] [blame] | 221 | |
Alexander Afanasyev | 0b38ad0 | 2013-03-19 13:42:22 -0700 | [diff] [blame] | 222 | @TaskGen.feature('process_in') |
| 223 | @TaskGen.after_method('process_source') |
| 224 | def create_process_in(self): |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 225 | dst = self.bld.path.find_or_declare(self.target) |
| 226 | tsk = self.create_task('process_in', self.source, dst) |
Alexander Afanasyev | 0b38ad0 | 2013-03-19 13:42:22 -0700 | [diff] [blame] | 227 | |
| 228 | class process_in(Task.Task): |
| 229 | color='PINK' |
| 230 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 231 | def run(self): |
| 232 | self.outputs[0].write(Utils.subst_vars(self.inputs[0].read(), self.env)) |
Alexander Afanasyev | 0b38ad0 | 2013-03-19 13:42:22 -0700 | [diff] [blame] | 233 | |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 234 | @TaskGen.feature('html_resources') |
| 235 | @TaskGen.before_method('process_source') |
| 236 | def create_qrc_task(self): |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 237 | output = self.bld.path.find_or_declare("gui/html.qrc") |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 238 | tsk = self.create_task('html_resources', self.html_resources, output) |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 239 | tsk.base_path = output.parent.get_src() |
| 240 | self.create_rcc_task(output.get_src()) |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 241 | |
| 242 | class html_resources(Task.Task): |
| 243 | color='PINK' |
| 244 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 245 | def __str__(self): |
| 246 | return "%s: Generating %s\n" % (self.__class__.__name__.replace('_task',''), self.outputs[0].path_from(self.outputs[0].ctx.launch_node())) |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 247 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 248 | def run(self): |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 249 | out = self.outputs[0] |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 250 | bld_out = out.get_bld() |
| 251 | src_out = out.get_src() |
Alexander Afanasyev | 9cc6c21 | 2013-03-04 12:45:38 -0800 | [diff] [blame] | 252 | bld_out.write('<RCC>\n <qresource prefix="/">\n') |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 253 | for f in self.inputs: |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 254 | bld_out.write(' <file>%s</file>\n' % f.path_from(self.base_path), 'a') |
Alexander Afanasyev | 9cc6c21 | 2013-03-04 12:45:38 -0800 | [diff] [blame] | 255 | bld_out.write(' </qresource>\n</RCC>', 'a') |
Alexander Afanasyev | 1cb641f | 2013-03-03 17:49:02 -0800 | [diff] [blame] | 256 | |
Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 257 | src_out.write(bld_out.read(), 'w') |
Alexander Afanasyev | caf48e2 | 2013-03-02 22:47:32 -0800 | [diff] [blame] | 258 | return 0 |