blob: a3baf14bf1434fd59b5b5348fadf927b61cc36ff [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 Afanasyeve83c0562016-12-24 10:20:41 -080058 USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams',
Alexander Afanasyev1cf5c432017-01-13 23:22:15 -080059 'regex', 'program_options', 'thread', 'log', 'log_setup']
Alexander Afanasyev33206982013-01-09 16:29:29 -080060
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080061 conf.env['WITH_TESTS'] = conf.options.with_tests
62 if conf.env['WITH_TESTS']:
63 USED_BOOST_LIBS += ['unit_test_framework']
64 conf.define('HAVE_TESTS', 1)
Alexander Afanasyev33206982013-01-09 16:29:29 -080065
Alexander Afanasyev1cf5c432017-01-13 23:22:15 -080066 conf.check_boost(lib=USED_BOOST_LIBS, mt=True)
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080067 if conf.env.BOOST_VERSION_NUMBER < 105400:
68 Logs.error("Minimum required boost version is 1.54.0")
69 Logs.error("Please upgrade your distribution or install custom boost libraries" +
70 " (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080071 return
72
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080073 # Loading "late" to prevent tests to be compiled with profiling flags
74 conf.load('coverage')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080075
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080076 conf.load('sanitizers')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080077
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080078 conf.define('SYSCONFDIR', conf.env['SYSCONFDIR'])
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080079
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080080 conf.write_config_header('core/chronoshare-config.hpp')
Zhenkai Zhue8409422013-01-28 12:52:17 -080081
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080082def build(bld):
Alexander Afanasyev360f41f2016-12-25 13:20:21 -080083 bld(name='core-objects',
84 target='core-objects',
85 features=['cxx'],
86 source=bld.path.ant_glob('core/**/*.cpp'),
Alexander Afanasyev1cf5c432017-01-13 23:22:15 -080087 use='NDN_CXX BOOST',
Alexander Afanasyev360f41f2016-12-25 13:20:21 -080088 includes='.',
89 export_includes='.')
90
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080091 # if Utils.unversioned_sys_platform() == 'darwin':
92 # bld(
93 # target='adhoc',
94 # mac_app = True,
95 # features=['cxx'],
96 # source='adhoc/adhoc-osx.mm'
97 # includes='. src',
98 # use='OSX_FOUNDATION OSX_COREWLAN',
99 # )
100 Logs.error("Ad hoc network creation routines are temporary disabled")
Alexander Afanasyev68f2a952013-01-08 14:34:16 -0800101
Lijing Wange84adea2015-05-31 16:25:16 -0700102 chornoshare = bld(
103 target="chronoshare",
104 features=['cxx'],
105 source=bld.path.ant_glob(['src/*.proto',
106 'src/db-helper.cpp',
107 'src/sync-*.cpp',
Lijing Wang51837ad2016-12-25 14:43:53 -0800108 'src/file-state.cpp',
109 'src/action-log.cpp',
Lijing Wang9f77a8c2016-12-25 14:44:04 -0800110 'src/object-*.cpp',
Lijing Wanga697cf22016-12-25 14:44:22 -0800111 'src/fetch*.cpp',
Lijing Wang8e56d082016-12-25 14:45:23 -0800112 'src/content-server.cpp',
Lijing Wangb95c6a52016-12-25 14:45:17 -0800113 'src/dispatcher.cpp',
114 'src/state-server.cpp'
Lijing Wange84adea2015-05-31 16:25:16 -0700115 ]),
Yukai Tu09e02fd2016-10-24 13:48:01 -0700116 use='core-objects adhoc NDN_CXX BOOST TINYXML SQLITE3',
Lijing Wange84adea2015-05-31 16:25:16 -0700117 includes="src",
118 export_includes="src",
119 )
120 Logs.error("Most of Chronoshare source compilation is temporary disabled")
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800121
Lijing Wange0dd63e2015-05-31 16:25:16 -0700122 fs_watcher = bld(
123 features=['qt5', 'cxx'],
124 target='fs-watcher',
125 defines='WAF',
126 moc = "fs-watcher/fs-watcher.hpp",
127 source=bld.path.ant_glob('fs-watcher/*.cpp'),
128 use='chronoshare QT5CORE',
129 includes='fs-watcher',
130 export_includes='fs-watcher',
131 )
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800132
Alexander Afanasyevcaf61b12016-12-25 14:18:52 -0800133 http_server = bld(
Lijing Wang152449c2015-05-31 16:25:16 -0700134 target = "http_server",
135 features = "qt5 cxx",
136 source = bld.path.ant_glob(['server/*.cpp']),
137 includes = "server src .",
138 use = 'BOOST QT5CORE',
139 )
Alexander Afanasyevb2fe74e2013-01-20 16:06:43 -0800140
Lijing Wang152449c2015-05-31 16:25:16 -0700141 qt = bld(
142 target = "ChronoShare",
143 features = "qt5 cxx cxxprogram html_resources",
144 defines = "WAF",
145 source = bld.path.ant_glob(['gui/*.cpp', 'gui/images.qrc']),
146 includes = "fs-watcher gui src adhoc server . ",
147 use = "fs-watcher chronoshare http_server QT5CORE QT5GUI QT5WIDGETS",
148 moc = "gui/chronosharegui.hpp",
149 html_resources = bld.path.find_dir("gui/html").ant_glob([
150 '**/*.js', '**/*.png', '**/*.css',
151 '**/*.html', '**/*.gif', '**/*.ico'
152 ]),
153 )
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800154
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800155# if Utils.unversioned_sys_platform() == "darwin":
156# app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
157# <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
158# <plist version="0.9">
159# <dict>
160# <key>CFBundlePackageType</key>
161# <string>APPL</string>
162# <key>CFBundleIconFile</key>
163# <string>chronoshare.icns</string>
164# <key>CFBundleGetInfoString</key>
165# <string>Created by Waf</string>
166# <key>CFBundleIdentifier</key>
167# <string>edu.ucla.cs.irl.Chronoshare</string>
168# <key>CFBundleSignature</key>
169# <string>????</string>
170# <key>NOTE</key>
171# <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
172# <key>CFBundleExecutable</key>
173# <string>%s</string>
174# <key>LSUIElement</key>
175# <string>1</string>
176# <key>SUPublicDSAKeyFile</key>
177# <string>dsa_pub.pem</string>
178# <key>CFBundleIconFile</key>
179# <string>chronoshare.icns</string>
180# </dict>
181# </plist>'''
182# qt.mac_app = "ChronoShare.app"
183# qt.mac_plist = app_plist % "ChronoShare"
184# qt.mac_resources = 'chronoshare.icns'
185# qt.use += " OSX_FOUNDATION OSX_COREWLAN adhoc"
Zhenkai Zhua9a7e1d2013-02-25 18:29:07 -0800186
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800187# if bld.env['HAVE_SPARKLE']:
188# qt.use += " OSX_SPARKLE"
189# qt.source += ["osx/auto-update/sparkle-auto-update.mm"]
190# qt.includes += " osx/auto-update"
191# if bld.env['HAVE_LOCAL_SPARKLE']:
192# qt.mac_frameworks = "osx/Frameworks/Sparkle.framework"
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800193
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800194# if Utils.unversioned_sys_platform() == "linux":
195# bld(
196# features = "process_in",
197# target = "ChronoShare.desktop",
198# source = "ChronoShare.desktop.in",
199# install_prefix = "${DATADIR}/applications",
200# )
201# bld.install_files("${DATADIR}/applications", "ChronoShare.desktop")
202# bld.install_files("${DATADIR}/ChronoShare", "gui/images/chronoshare-big.png")
203 Logs.error("ChronoShare app compilation is temporary disabled")
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800204
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800205# cmdline = bld(
206# target = "csd",
207# features = "qt5 cxx cxxprogram",
208# defines = "WAF",
209# source = bld.path.ant_glob(['cmd/csd.cpp']),
210# use = "fs_watcher chronoshare http_server QT5CORE",
211# )
212 Logs.error("csd app compilation is temporary disabled")
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800213
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800214# dump_db = bld(
215# target = "dump-db",
216# features = "cxx cxxprogram",
217# source = bld.path.ant_glob(['cmd/dump-db.cpp']),
218# use = "fs_watcher chronoshare http_server QT5CORE",
219# )
220 Logs.error("dump-db app compilation is temporary disabled")
Alexander Afanasyev548d38d2013-01-26 16:36:06 -0800221
Alexander Afanasyev45289972016-12-24 20:23:03 -0800222 bld.recurse('tests');
Alexander Afanasyeveb575e02013-01-26 17:14:51 -0800223
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800224from waflib import TaskGen
225@TaskGen.extension('.mm')
226def m_hook(self, node):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800227 """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 -0800228 return self.create_compiled_task('cxx', node)
Zhenkai Zhu6b53f932013-03-02 20:46:02 -0800229
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700230@TaskGen.extension('.js', '.png', '.css', '.html', '.gif', '.ico', '.in')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800231def sig_hook(self, node):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800232 node.sig=Utils.h_file(node.abspath())
Zhenkai Zhu6b53f932013-03-02 20:46:02 -0800233
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700234@TaskGen.feature('process_in')
235@TaskGen.after_method('process_source')
236def create_process_in(self):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800237 dst = self.bld.path.find_or_declare(self.target)
238 tsk = self.create_task('process_in', self.source, dst)
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700239
240class process_in(Task.Task):
241 color='PINK'
242
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800243 def run(self):
244 self.outputs[0].write(Utils.subst_vars(self.inputs[0].read(), self.env))
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700245
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800246@TaskGen.feature('html_resources')
247@TaskGen.before_method('process_source')
248def create_qrc_task(self):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800249 output = self.bld.path.find_or_declare("gui/html.qrc")
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800250 tsk = self.create_task('html_resources', self.html_resources, output)
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800251 tsk.base_path = output.parent.get_src()
252 self.create_rcc_task(output.get_src())
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800253
254class html_resources(Task.Task):
255 color='PINK'
256
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800257 def __str__(self):
258 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 -0800259
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800260 def run(self):
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800261 out = self.outputs[0]
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800262 bld_out = out.get_bld()
263 src_out = out.get_src()
Alexander Afanasyev9cc6c212013-03-04 12:45:38 -0800264 bld_out.write('<RCC>\n <qresource prefix="/">\n')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800265 for f in self.inputs:
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800266 bld_out.write(' <file>%s</file>\n' % f.path_from(self.base_path), 'a')
Alexander Afanasyev9cc6c212013-03-04 12:45:38 -0800267 bld_out.write(' </qresource>\n</RCC>', 'a')
Alexander Afanasyev1cb641f2013-03-03 17:49:02 -0800268
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800269 src_out.write(bld_out.read(), 'w')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800270 return 0