blob: 404959823b45b6cfd552c2ebeba8c006bd06663a [file] [log] [blame]
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyeve83c0562016-12-24 10:20:41 -08002VERSION='1.0'
3APPNAME='ChronoShare'
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08004
Alexander Afanasyeve83c0562016-12-24 10:20:41 -08005from waflib import Logs, Utils, Task, TaskGen
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08006
7def options(opt):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -08008 opt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
9 help='''Build unit tests''')
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080010 opt.add_option('--yes',action='store_true',default=False) # for autoconf/automake/make compatibility
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080011
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080012 opt.add_option('--without-sqlite-locking', action='store_false', default=True,
13 dest='with_sqlite_locking',
14 help='''Disable filesystem locking in sqlite3 database '''
15 '''(use unix-dot locking mechanism instead). '''
16 '''This option may be necessary if home directory is hosted on NFS.''')
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080017
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080018 if Utils.unversioned_sys_platform() == "darwin":
19 opt.add_option('--with-auto-update', action='store_true', default=False, dest='autoupdate',
20 help='''(OSX) Download sparkle framework and enable autoupdate feature''')
21
22 opt.load(['compiler_c', 'compiler_cxx', 'gnu_dirs', 'qt5'])
23 opt.load(['default-compiler-flags',
24 'osx-frameworks', 'boost', 'sqlite3', 'protoc', 'tinyxml',
25 'coverage', 'sanitizers',
26 'doxygen', 'sphinx_build'], tooldir=['.waf-tools'])
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080027
28def configure(conf):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080029 conf.load(['compiler_c', 'compiler_cxx', 'gnu_dirs',
30 'default-compiler-flags',
31 'osx-frameworks', 'boost', 'sqlite3', 'protoc', 'tinyxml',
32 'doxygen', 'sphinx_build'])
Alexander Afanasyeva1b7bb52013-02-26 17:04:02 -080033
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080034 if 'PKG_CONFIG_PATH' not in conf.environ:
35 conf.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
Alexander Afanasyevf2890632013-01-02 13:40:02 -080036
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080037 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
38 uselib_store='NDN_CXX')
39
40 # add homebrew path, as qt5 is no longer linked
41 conf.environ['PKG_CONFIG_PATH'] += ":/usr/local/opt/qt5/lib/pkgconfig:/opt/qt5/5.8/clang_64/lib/pkgconfig"
42 conf.environ['PATH'] += ":/usr/local/opt/qt5/bin:/opt/qt5/5.8/clang_64/bin"
43
44 conf.load('qt5')
45
46 conf.define("CHRONOSHARE_VERSION", VERSION)
47
48 conf.check_sqlite3(mandatory=True)
49 if not conf.options.with_sqlite_locking:
50 conf.define('DISABLE_SQLITE3_FS_LOCKING', 1)
51
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070052 conf.check_tinyxml(path=conf.options.tinyxml_dir)
Zhenkai Zhubc2f6282013-01-08 16:40:58 -080053
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080054 conf.define("TRAY_ICON", "chronoshare-big.png")
55 if Utils.unversioned_sys_platform() == "linux":
56 conf.define("TRAY_ICON", "chronoshare-ubuntu.png")
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -080057
Alexander Afanasyev360f41f2016-12-25 13:20:21 -080058 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080059
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080060 USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams',
61 'regex', 'program_options', 'thread']
Alexander Afanasyev33206982013-01-09 16:29:29 -080062
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080063 conf.env['WITH_TESTS'] = conf.options.with_tests
64 if conf.env['WITH_TESTS']:
65 USED_BOOST_LIBS += ['unit_test_framework']
66 conf.define('HAVE_TESTS', 1)
Alexander Afanasyev33206982013-01-09 16:29:29 -080067
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080068 conf.check_boost(lib=USED_BOOST_LIBS)
69 if conf.env.BOOST_VERSION_NUMBER < 105400:
70 Logs.error("Minimum required boost version is 1.54.0")
71 Logs.error("Please upgrade your distribution or install custom boost libraries" +
72 " (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080073 return
74
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080075 # Loading "late" to prevent tests to be compiled with profiling flags
76 conf.load('coverage')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080077
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080078 conf.load('sanitizers')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080079
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080080 conf.define('SYSCONFDIR', conf.env['SYSCONFDIR'])
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080081
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080082 conf.write_config_header('core/chronoshare-config.hpp')
Zhenkai Zhue8409422013-01-28 12:52:17 -080083
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080084def build(bld):
Alexander Afanasyev360f41f2016-12-25 13:20:21 -080085 bld(name='core-objects',
86 target='core-objects',
87 features=['cxx'],
88 source=bld.path.ant_glob('core/**/*.cpp'),
89 use='LOG4CXX BOOST',
90 includes='.',
91 export_includes='.')
92
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080093 # if Utils.unversioned_sys_platform() == 'darwin':
94 # bld(
95 # target='adhoc',
96 # mac_app = True,
97 # features=['cxx'],
98 # source='adhoc/adhoc-osx.mm'
99 # includes='. src',
100 # use='OSX_FOUNDATION OSX_COREWLAN',
101 # )
102 Logs.error("Ad hoc network creation routines are temporary disabled")
Alexander Afanasyev68f2a952013-01-08 14:34:16 -0800103
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800104 # chornoshare = bld(
105 # target="chronoshare",
106 # features=['cxx'],
107 # source=bld.path.ant_glob(['src/**/*.cpp', 'src/*.proto']),
108 # use='core adhoc BOOST LOG4CXX NDN_CXX TINYXML SQLITE3',
109 # includes="src",
110 # export_includes="src",
111 # )
112 Logs.error("Chronoshare source compilation is temporary disabled")
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800113
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800114 # fs_watcher = bld(
115 # features=['qt5', 'cxx'],
116 # target='fs-watcher',
117 # defines='WAF',
118 # source=bld.path.ant_glob('fs-watcher/*.cpp'),
119 # use='chronoshare QT5CORE',
120 # includes='fs-watcher',
121 # export_includes='fs-watcher',
122 # )
123 Logs.error("fs-watcher compilation is temporary disabled")
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800124
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800125 # http_server = bld(
126 # target = "http_server",
127 # features = "qt5 cxx",
128 # source = bld.path.ant_glob(['server/*.cpp']),
129 # includes = "server src .",
130 # use = 'BOOST QT5CORE',
131 # )
132 Logs.error("http_server compilation is temporary disabled")
Alexander Afanasyevb2fe74e2013-01-20 16:06:43 -0800133
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800134# qt = bld(
135# target = "ChronoShare",
136# features = "qt5 cxx cxxprogram html_resources",
137# defines = "WAF",
138# source = bld.path.ant_glob(['gui/*.cpp', 'gui/images.qrc']),
139# includes = "fs-watcher gui src adhoc server . ",
140# use = "fs_watcher chronoshare http_server QT5CORE QT5GUI QT5WIDGETS",
Zhenkai Zhu369eff12013-02-05 15:43:49 -0800141
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800142# html_resources = bld.path.find_dir("gui/html").ant_glob([
143# '**/*.js', '**/*.png', '**/*.css',
144# '**/*.html', '**/*.gif', '**/*.ico'
145# ]),
146# )
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800147
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800148# if Utils.unversioned_sys_platform() == "darwin":
149# app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
150# <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
151# <plist version="0.9">
152# <dict>
153# <key>CFBundlePackageType</key>
154# <string>APPL</string>
155# <key>CFBundleIconFile</key>
156# <string>chronoshare.icns</string>
157# <key>CFBundleGetInfoString</key>
158# <string>Created by Waf</string>
159# <key>CFBundleIdentifier</key>
160# <string>edu.ucla.cs.irl.Chronoshare</string>
161# <key>CFBundleSignature</key>
162# <string>????</string>
163# <key>NOTE</key>
164# <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
165# <key>CFBundleExecutable</key>
166# <string>%s</string>
167# <key>LSUIElement</key>
168# <string>1</string>
169# <key>SUPublicDSAKeyFile</key>
170# <string>dsa_pub.pem</string>
171# <key>CFBundleIconFile</key>
172# <string>chronoshare.icns</string>
173# </dict>
174# </plist>'''
175# qt.mac_app = "ChronoShare.app"
176# qt.mac_plist = app_plist % "ChronoShare"
177# qt.mac_resources = 'chronoshare.icns'
178# qt.use += " OSX_FOUNDATION OSX_COREWLAN adhoc"
Zhenkai Zhua9a7e1d2013-02-25 18:29:07 -0800179
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800180# if bld.env['HAVE_SPARKLE']:
181# qt.use += " OSX_SPARKLE"
182# qt.source += ["osx/auto-update/sparkle-auto-update.mm"]
183# qt.includes += " osx/auto-update"
184# if bld.env['HAVE_LOCAL_SPARKLE']:
185# qt.mac_frameworks = "osx/Frameworks/Sparkle.framework"
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800186
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800187# if Utils.unversioned_sys_platform() == "linux":
188# bld(
189# features = "process_in",
190# target = "ChronoShare.desktop",
191# source = "ChronoShare.desktop.in",
192# install_prefix = "${DATADIR}/applications",
193# )
194# bld.install_files("${DATADIR}/applications", "ChronoShare.desktop")
195# bld.install_files("${DATADIR}/ChronoShare", "gui/images/chronoshare-big.png")
196 Logs.error("ChronoShare app compilation is temporary disabled")
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800197
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800198# cmdline = bld(
199# target = "csd",
200# features = "qt5 cxx cxxprogram",
201# defines = "WAF",
202# source = bld.path.ant_glob(['cmd/csd.cpp']),
203# use = "fs_watcher chronoshare http_server QT5CORE",
204# )
205 Logs.error("csd app compilation is temporary disabled")
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800206
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800207# dump_db = bld(
208# target = "dump-db",
209# features = "cxx cxxprogram",
210# source = bld.path.ant_glob(['cmd/dump-db.cpp']),
211# use = "fs_watcher chronoshare http_server QT5CORE",
212# )
213 Logs.error("dump-db app compilation is temporary disabled")
Alexander Afanasyev548d38d2013-01-26 16:36:06 -0800214
Alexander Afanasyev45289972016-12-24 20:23:03 -0800215 bld.recurse('tests');
Alexander Afanasyeveb575e02013-01-26 17:14:51 -0800216
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800217from waflib import TaskGen
218@TaskGen.extension('.mm')
219def m_hook(self, node):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800220 """Alias .mm files to be compiled the same as .cpp files, gcc/clang will do the right thing."""
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800221 return self.create_compiled_task('cxx', node)
Zhenkai Zhu6b53f932013-03-02 20:46:02 -0800222
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700223@TaskGen.extension('.js', '.png', '.css', '.html', '.gif', '.ico', '.in')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800224def sig_hook(self, node):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800225 node.sig=Utils.h_file(node.abspath())
Zhenkai Zhu6b53f932013-03-02 20:46:02 -0800226
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700227@TaskGen.feature('process_in')
228@TaskGen.after_method('process_source')
229def create_process_in(self):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800230 dst = self.bld.path.find_or_declare(self.target)
231 tsk = self.create_task('process_in', self.source, dst)
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700232
233class process_in(Task.Task):
234 color='PINK'
235
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800236 def run(self):
237 self.outputs[0].write(Utils.subst_vars(self.inputs[0].read(), self.env))
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700238
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800239@TaskGen.feature('html_resources')
240@TaskGen.before_method('process_source')
241def create_qrc_task(self):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800242 output = self.bld.path.find_or_declare("gui/html.qrc")
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800243 tsk = self.create_task('html_resources', self.html_resources, output)
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800244 tsk.base_path = output.parent.get_src()
245 self.create_rcc_task(output.get_src())
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800246
247class html_resources(Task.Task):
248 color='PINK'
249
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800250 def __str__(self):
251 return "%s: Generating %s\n" % (self.__class__.__name__.replace('_task',''), self.outputs[0].path_from(self.outputs[0].ctx.launch_node()))
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800252
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800253 def run(self):
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800254 out = self.outputs[0]
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800255 bld_out = out.get_bld()
256 src_out = out.get_src()
Alexander Afanasyev9cc6c212013-03-04 12:45:38 -0800257 bld_out.write('<RCC>\n <qresource prefix="/">\n')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800258 for f in self.inputs:
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800259 bld_out.write(' <file>%s</file>\n' % f.path_from(self.base_path), 'a')
Alexander Afanasyev9cc6c212013-03-04 12:45:38 -0800260 bld_out.write(' </qresource>\n</RCC>', 'a')
Alexander Afanasyev1cb641f2013-03-03 17:49:02 -0800261
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800262 src_out.write(bld_out.read(), 'w')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800263 return 0