blob: a0115e7f0d43903a708c1bc948f6aced5fa8a4b2 [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 Afanasyevc507ac22013-01-21 16:01:58 -080011 opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx logging support''')
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080012
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080013 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 Afanasyev5a95a252013-02-25 12:55:48 -080018
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080019 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 Zhua7e3da72012-12-27 13:45:00 -080028
29def configure(conf):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080030 conf.load(['compiler_c', 'compiler_cxx', 'gnu_dirs',
31 'default-compiler-flags',
32 'osx-frameworks', 'boost', 'sqlite3', 'protoc', 'tinyxml',
33 'doxygen', 'sphinx_build'])
Alexander Afanasyeva1b7bb52013-02-26 17:04:02 -080034
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080035 if 'PKG_CONFIG_PATH' not in conf.environ:
36 conf.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
Alexander Afanasyevf2890632013-01-02 13:40:02 -080037
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080038 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 Zhu3457ed42013-03-12 15:15:21 -070053 conf.check_tinyxml(path=conf.options.tinyxml_dir)
Zhenkai Zhubc2f6282013-01-08 16:40:58 -080054
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080055 conf.define("TRAY_ICON", "chronoshare-big.png")
56 if Utils.unversioned_sys_platform() == "linux":
57 conf.define("TRAY_ICON", "chronoshare-ubuntu.png")
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -080058
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080059 if conf.options.log4cxx:
60 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080061 conf.define("HAVE_LOG4CXX", 1)
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080062
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080063 USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams',
64 'regex', 'program_options', 'thread']
Alexander Afanasyev33206982013-01-09 16:29:29 -080065
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080066 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 Afanasyev33206982013-01-09 16:29:29 -080070
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080071 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 Afanasyev71b43e72012-12-27 01:03:43 -080076 return
77
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080078 # Loading "late" to prevent tests to be compiled with profiling flags
79 conf.load('coverage')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080080
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080081 conf.load('sanitizers')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080082
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080083 conf.define('SYSCONFDIR', conf.env['SYSCONFDIR'])
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080084
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080085 conf.write_config_header('core/chronoshare-config.hpp')
Zhenkai Zhue8409422013-01-28 12:52:17 -080086
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080087def 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 Afanasyev68f2a952013-01-08 14:34:16 -080098
Alexander Afanasyeve83c0562016-12-24 10:20:41 -080099 # 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 Afanasyevf2890632013-01-02 13:40:02 -0800108
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800109 # 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 Afanasyeva98e69c2013-02-24 15:42:45 -0800119
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800120 # 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 Afanasyevb2fe74e2013-01-20 16:06:43 -0800128
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800129# 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 Zhu369eff12013-02-05 15:43:49 -0800136
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800137# html_resources = bld.path.find_dir("gui/html").ant_glob([
138# '**/*.js', '**/*.png', '**/*.css',
139# '**/*.html', '**/*.gif', '**/*.ico'
140# ]),
141# )
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800142
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800143# 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 Zhua9a7e1d2013-02-25 18:29:07 -0800174
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800175# 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 Afanasyevcaf48e22013-03-02 22:47:32 -0800181
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800182# 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 Afanasyeva98e69c2013-02-24 15:42:45 -0800192
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800193# 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 Afanasyev83a53002013-01-24 11:12:01 -0800201
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800202# 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 Afanasyev548d38d2013-01-26 16:36:06 -0800209
Alexander Afanasyev45289972016-12-24 20:23:03 -0800210 bld.recurse('tests');
Alexander Afanasyeveb575e02013-01-26 17:14:51 -0800211
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800212from waflib import TaskGen
213@TaskGen.extension('.mm')
214def m_hook(self, node):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800215 """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 -0800216 return self.create_compiled_task('cxx', node)
Zhenkai Zhu6b53f932013-03-02 20:46:02 -0800217
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700218@TaskGen.extension('.js', '.png', '.css', '.html', '.gif', '.ico', '.in')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800219def sig_hook(self, node):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800220 node.sig=Utils.h_file(node.abspath())
Zhenkai Zhu6b53f932013-03-02 20:46:02 -0800221
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700222@TaskGen.feature('process_in')
223@TaskGen.after_method('process_source')
224def create_process_in(self):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800225 dst = self.bld.path.find_or_declare(self.target)
226 tsk = self.create_task('process_in', self.source, dst)
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700227
228class process_in(Task.Task):
229 color='PINK'
230
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800231 def run(self):
232 self.outputs[0].write(Utils.subst_vars(self.inputs[0].read(), self.env))
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700233
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800234@TaskGen.feature('html_resources')
235@TaskGen.before_method('process_source')
236def create_qrc_task(self):
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800237 output = self.bld.path.find_or_declare("gui/html.qrc")
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800238 tsk = self.create_task('html_resources', self.html_resources, output)
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800239 tsk.base_path = output.parent.get_src()
240 self.create_rcc_task(output.get_src())
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800241
242class html_resources(Task.Task):
243 color='PINK'
244
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800245 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 Afanasyevcaf48e22013-03-02 22:47:32 -0800247
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800248 def run(self):
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800249 out = self.outputs[0]
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800250 bld_out = out.get_bld()
251 src_out = out.get_src()
Alexander Afanasyev9cc6c212013-03-04 12:45:38 -0800252 bld_out.write('<RCC>\n <qresource prefix="/">\n')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800253 for f in self.inputs:
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800254 bld_out.write(' <file>%s</file>\n' % f.path_from(self.base_path), 'a')
Alexander Afanasyev9cc6c212013-03-04 12:45:38 -0800255 bld_out.write(' </qresource>\n</RCC>', 'a')
Alexander Afanasyev1cb641f2013-03-03 17:49:02 -0800256
Alexander Afanasyeve83c0562016-12-24 10:20:41 -0800257 src_out.write(bld_out.read(), 'w')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800258 return 0