blob: ca889e9a842e5bb79023f18451de085fd6f50587 [file] [log] [blame]
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Yingdi Yub6fb0302014-01-21 11:05:11 -08002VERSION='0.5'
Yingdi Yud681e212013-11-07 11:36:50 -08003APPNAME='ChronoChat'
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07004
Yingdi Yu0b0a7362014-08-05 16:31:30 -07005from waflib import Configure, Utils, Logs, Context
6import os
Yingdi Yu847aa862013-10-09 16:35:53 -07007
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07008def options(opt):
Yingdi Yufa0b6a02014-04-30 14:26:42 -07009
Varun Patila24bd3e2020-11-24 10:08:33 +053010 opt.load(['compiler_c', 'compiler_cxx', 'gnu_dirs'])
Yingdi Yue370a2a2013-11-10 17:39:36 -080011
Varun Patila24bd3e2020-11-24 10:08:33 +053012 opt.load(['default-compiler-flags', 'boost',
13 'doxygen', 'sphinx_build', 'qt5_custom', 'cryptopp'],
14 tooldir=['.waf-tools'])
Yingdi Yu0b0a7362014-08-05 16:31:30 -070015
Varun Patila24bd3e2020-11-24 10:08:33 +053016 opt = opt.add_option_group('ChronoChat Options')
Yingdi Yu0b0a7362014-08-05 16:31:30 -070017
18 opt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
19 help='''build unit tests''')
20
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070021def configure(conf):
Varun Patila24bd3e2020-11-24 10:08:33 +053022 conf.load(['compiler_c', 'compiler_cxx', 'qt5_custom',
23 'default-compiler-flags', 'boost', 'gnu_dirs',
Varun Patil3d850902020-11-23 12:19:14 +053024 'doxygen', 'sphinx_build', 'cryptopp'])
Yingdi Yue370a2a2013-11-10 17:39:36 -080025
Yingdi Yu0b0a7362014-08-05 16:31:30 -070026 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
27 uselib_store='NDN_CXX', mandatory=True)
Yingdi Yufa0b6a02014-04-30 14:26:42 -070028
Varun Patila24bd3e2020-11-24 10:08:33 +053029 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.5', '--cflags', '--libs'],
Yingdi Yu0b0a7362014-08-05 16:31:30 -070030 uselib_store='SYNC', mandatory=True)
Yingdi Yu4390ce52013-10-10 17:27:54 -070031
Yingdi Yu0b0a7362014-08-05 16:31:30 -070032 boost_libs = 'system random thread filesystem'
Yingdi Yub6fb0302014-01-21 11:05:11 -080033 if conf.options.with_tests:
Yingdi Yu0b0a7362014-08-05 16:31:30 -070034 conf.env['WITH_TESTS'] = 1
35 conf.define('WITH_TESTS', 1);
36 boost_libs += ' unit_test_framework'
Yingdi Yufa4ce792014-02-06 18:09:22 -080037
Varun Patila24bd3e2020-11-24 10:08:33 +053038 conf.check_boost(lib=boost_libs, mt=True)
39 if conf.env.BOOST_VERSION_NUMBER < 105800:
40 conf.fatal('The minimum supported version of Boost is 1.65.1.\n'
41 'Please upgrade your distribution or manually install a newer version of Boost.\n'
42 'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')
43 elif conf.env.BOOST_VERSION_NUMBER < 106501:
44 Logs.warn('WARNING: Using a version of Boost older than 1.65.1 is not officially supported and may not work.\n'
45 'If you encounter any problems, please upgrade your distribution or manually install a newer version of Boost.\n'
46 'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')
Yingdi Yufa4ce792014-02-06 18:09:22 -080047
Varun Patil3d850902020-11-23 12:19:14 +053048 conf.check_cryptopp()
Varun Patila24bd3e2020-11-24 10:08:33 +053049 conf.check_compiler_flags()
Yingdi Yufa4ce792014-02-06 18:09:22 -080050 conf.write_config_header('src/config.h')
Yingdi Yufa0b6a02014-04-30 14:26:42 -070051
Yingdi Yu847aa862013-10-09 16:35:53 -070052def build (bld):
Varun Patil3d850902020-11-23 12:19:14 +053053 feature_list = 'qt5 cxx'
Yingdi Yu0b0a7362014-08-05 16:31:30 -070054 if bld.env["WITH_TESTS"]:
Qiuhan Ding56c0be52015-03-11 17:21:26 -070055 feature_list += ' cxxstlib'
Yingdi Yu0b0a7362014-08-05 16:31:30 -070056 else:
57 feature_list += ' cxxprogram'
58
Yingdi Yu847aa862013-10-09 16:35:53 -070059 qt = bld (
Yingdi Yud681e212013-11-07 11:36:50 -080060 target = "ChronoChat",
Yingdi Yu0b0a7362014-08-05 16:31:30 -070061 features = feature_list,
Yingdi Yu42125862014-08-07 17:04:28 -070062 defines = "WAF=1",
Varun Patila24bd3e2020-11-24 10:08:33 +053063 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc']),
Alexander Afanasyev4a979312013-11-07 15:30:05 -080064 includes = "src .",
Varun Patila24bd3e2020-11-24 10:08:33 +053065 use = "QT5CORE QT5GUI QT5WIDGETS QT5SQL NDN_CXX BOOST SYNC CRYPTOPP",
Yingdi Yu92e8e482013-10-17 21:13:03 -070066 )
67
Yingdi Yu76dd8002013-12-24 11:16:32 +080068 # Unit tests
Yingdi Yu0b0a7362014-08-05 16:31:30 -070069 if bld.env["WITH_TESTS"]:
70 unittests = bld.program (
71 target="unit-tests",
72 source = bld.path.ant_glob(['test/**/*.cpp']),
73 features=['cxx', 'cxxprogram'],
74 use = 'BOOST ChronoChat',
75 includes = "src .",
76 install_path = None,
77 )
Yingdi Yu348f5ea2014-03-01 14:47:25 -080078
79 # Debug tools
Varun Patila24bd3e2020-11-24 10:08:33 +053080 if "_DEBUG" in bld.env["DEFINES"]:
81 for app in bld.path.ant_glob('debug-tools/*.cpp'):
Yingdi Yu348f5ea2014-03-01 14:47:25 -080082 bld(features=['cxx', 'cxxprogram'],
Varun Patila24bd3e2020-11-24 10:08:33 +053083 target = '%s' % (str(app.change_ext('','.cpp'))),
Yingdi Yu348f5ea2014-03-01 14:47:25 -080084 source = app,
Yingdi Yufa0b6a02014-04-30 14:26:42 -070085 use = 'NDN_CXX',
Yingdi Yu0b0a7362014-08-05 16:31:30 -070086 includes = "src .",
Yingdi Yu348f5ea2014-03-01 14:47:25 -080087 install_path = None,
88 )
Yingdi Yufa0b6a02014-04-30 14:26:42 -070089
Yingdi Yu0b0a7362014-08-05 16:31:30 -070090 if not bld.env["WITH_TESTS"]:
91 if Utils.unversioned_sys_platform () == "darwin":
92 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
Yingdi Yub6fb0302014-01-21 11:05:11 -080093<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
94<plist version="0.9">
Yingdi Yu0b0a7362014-08-05 16:31:30 -070095 <dict>
96 <key>CFBundlePackageType</key>
97 <string>APPL</string>
98 <key>CFBundleIconFile</key>
99 <string>demo.icns</string>
100 <key>CFBundleGetInfoString</key>
101 <string>Created by Waf</string>
102 <key>CFBundleIdentifier</key>
103 <string>edu.ucla.cs.irl.ChronoChat</string>
104 <key>CFBundleSignature</key>
105 <string>????</string>
106 <key>NOTE</key>
107 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
108 <key>CFBundleExecutable</key>
109 <string>%s</string>
110 <key>SUPublicDSAKeyFile</key>
111 <string>dsa_pub.pem</string>
112 <key>CFBundleIconFile</key>
113 <string>demo.icns</string>
114 </dict>
Yingdi Yub6fb0302014-01-21 11:05:11 -0800115</plist>'''
Yingdi Yu847aa862013-10-09 16:35:53 -0700116
Yingdi Yub6fb0302014-01-21 11:05:11 -0800117 # <key>LSUIElement</key>
118 # <string>1</string>
Yingdi Yue35bdb82013-11-07 11:32:40 -0800119
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700120 qt.mac_app = "ChronoChat.app"
121 qt.mac_plist = app_plist % "ChronoChat"
122 qt.mac_resources = 'demo.icns'
123 else:
124 bld(features = "subst",
125 source = 'linux/chronochat.desktop.in',
126 target = 'linux/chronochat.desktop',
127 BINARY = "ChronoChat",
128 install_path = "${DATAROOTDIR}/applications"
129 )
130 bld.install_files("${DATAROOTDIR}/chronochat",
131 bld.path.ant_glob(['linux/Resources/*']))
132
133
134# docs
135def docs(bld):
136 from waflib import Options
137 Options.commands = ['doxygen', 'sphinx'] + Options.commands
138
139def doxygen(bld):
140 version(bld)
141
142 if not bld.env.DOXYGEN:
143 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Yingdi Yub6fb0302014-01-21 11:05:11 -0800144 else:
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700145 bld(features="subst",
146 name="doxygen-conf",
147 source=["docs/doxygen.conf.in",
148 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
149 target=["docs/doxygen.conf",
150 "docs/named_data_theme/named_data_footer-with-analytics.html"],
151 VERSION=VERSION,
152 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
153 if os.getenv('GOOGLE_ANALYTICS', None) \
154 else "../docs/named_data_theme/named_data_footer.html",
155 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
Yingdi Yub6fb0302014-01-21 11:05:11 -0800156 )
Yingdi Yue35bdb82013-11-07 11:32:40 -0800157
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700158 bld(features="doxygen",
159 doxyfile='docs/doxygen.conf',
160 use="doxygen-conf")
Yingdi Yue35bdb82013-11-07 11:32:40 -0800161
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700162def sphinx(bld):
163 version(bld)
Yingdi Yu847aa862013-10-09 16:35:53 -0700164
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700165 if not bld.env.SPHINX_BUILD:
166 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
167 else:
168 bld(features="sphinx",
169 outdir="docs",
170 source=bld.path.ant_glob("docs/**/*.rst"),
171 config="docs/conf.py",
172 VERSION=VERSION)
Yingdi Yu847aa862013-10-09 16:35:53 -0700173
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700174def version(ctx):
175 if getattr(Context.g_module, 'VERSION_BASE', None):
176 return
177
178 Context.g_module.VERSION_BASE = Context.g_module.VERSION
179 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
180
181 try:
182 cmd = ['git', 'describe', '--match', 'ChronoChat-*']
183 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
184 stderr=None, stdin=None)
185 out = p.communicate()[0].strip()
186 if p.returncode == 0 and out != "":
187 Context.g_module.VERSION = out[11:]
188 except:
189 pass