blob: a2f88e4f38c2e6241cd00336efa0f7aaf3d531f4 [file] [log] [blame]
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07002
Davide Pesavento7676b562020-12-14 00:41:26 -05003from waflib import Context, Logs, Utils
Yingdi Yu0b0a7362014-08-05 16:31:30 -07004import os
Yingdi Yu847aa862013-10-09 16:35:53 -07005
Davide Pesavento7676b562020-12-14 00:41:26 -05006VERSION = '0.5'
7APPNAME = 'ChronoChat'
8
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07009def options(opt):
Davide Pesavento7676b562020-12-14 00:41:26 -050010 opt.load(['compiler_cxx', 'gnu_dirs'])
11 opt.load(['default-compiler-flags',
12 'boost', 'qt5_custom',
13 'doxygen', 'sphinx_build'],
14 tooldir=['.waf-tools'])
Yingdi Yufa0b6a02014-04-30 14:26:42 -070015
Davide Pesavento7676b562020-12-14 00:41:26 -050016 optgrp = opt.add_option_group('ChronoChat Options')
17 optgrp.add_option('--with-tests', action='store_true', default=False,
18 help='Build unit tests')
Yingdi Yu0b0a7362014-08-05 16:31:30 -070019
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070020def configure(conf):
Davide Pesavento7676b562020-12-14 00:41:26 -050021 conf.load(['compiler_cxx', 'gnu_dirs',
22 'default-compiler-flags', 'boost', 'qt5_custom',
23 'doxygen', 'sphinx_build'])
Yingdi Yue370a2a2013-11-10 17:39:36 -080024
Davide Pesavento7676b562020-12-14 00:41:26 -050025 conf.env.WITH_TESTS = conf.options.with_tests
Yingdi Yufa0b6a02014-04-30 14:26:42 -070026
Davide Pesavento7676b562020-12-14 00:41:26 -050027 pkg_config_path = os.environ.get('PKG_CONFIG_PATH', '%s/pkgconfig' % conf.env.LIBDIR)
28 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDN_CXX',
29 pkg_config_path=pkg_config_path)
30 conf.check_cfg(package='ChronoSync', args=['--cflags', '--libs'], uselib_store='SYNC',
31 pkg_config_path=pkg_config_path)
Yingdi Yu4390ce52013-10-10 17:27:54 -070032
Davide Pesavento7676b562020-12-14 00:41:26 -050033 boost_libs = ['system', 'random', 'thread', 'filesystem']
34 if conf.env.WITH_TESTS:
35 boost_libs.append('unit_test_framework')
36 conf.define('WITH_TESTS', 1)
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 Patila24bd3e2020-11-24 10:08:33 +053048 conf.check_compiler_flags()
Yingdi Yufa4ce792014-02-06 18:09:22 -080049 conf.write_config_header('src/config.h')
Yingdi Yufa0b6a02014-04-30 14:26:42 -070050
Yingdi Yu847aa862013-10-09 16:35:53 -070051def build (bld):
Varun Patil3d850902020-11-23 12:19:14 +053052 feature_list = 'qt5 cxx'
Davide Pesavento7676b562020-12-14 00:41:26 -050053 if bld.env.WITH_TESTS:
Qiuhan Ding56c0be52015-03-11 17:21:26 -070054 feature_list += ' cxxstlib'
Yingdi Yu0b0a7362014-08-05 16:31:30 -070055 else:
56 feature_list += ' cxxprogram'
57
Davide Pesavento7676b562020-12-14 00:41:26 -050058 qt = bld(
Yingdi Yud681e212013-11-07 11:36:50 -080059 target = "ChronoChat",
Yingdi Yu0b0a7362014-08-05 16:31:30 -070060 features = feature_list,
Yingdi Yu42125862014-08-07 17:04:28 -070061 defines = "WAF=1",
Varun Patila24bd3e2020-11-24 10:08:33 +053062 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc']),
Alexander Afanasyev4a979312013-11-07 15:30:05 -080063 includes = "src .",
Davide Pesavento7676b562020-12-14 00:41:26 -050064 use = "QT5CORE QT5GUI QT5WIDGETS QT5SQL NDN_CXX BOOST SYNC",
Yingdi Yu92e8e482013-10-17 21:13:03 -070065 )
66
Yingdi Yu76dd8002013-12-24 11:16:32 +080067 # Unit tests
Davide Pesavento7676b562020-12-14 00:41:26 -050068 if bld.env.WITH_TESTS:
69 unittests = bld.program(
Yingdi Yu0b0a7362014-08-05 16:31:30 -070070 target="unit-tests",
71 source = bld.path.ant_glob(['test/**/*.cpp']),
72 features=['cxx', 'cxxprogram'],
73 use = 'BOOST ChronoChat',
74 includes = "src .",
75 install_path = None,
76 )
Yingdi Yu348f5ea2014-03-01 14:47:25 -080077
78 # Debug tools
Varun Patila24bd3e2020-11-24 10:08:33 +053079 if "_DEBUG" in bld.env["DEFINES"]:
80 for app in bld.path.ant_glob('debug-tools/*.cpp'):
Yingdi Yu348f5ea2014-03-01 14:47:25 -080081 bld(features=['cxx', 'cxxprogram'],
Varun Patila24bd3e2020-11-24 10:08:33 +053082 target = '%s' % (str(app.change_ext('','.cpp'))),
Yingdi Yu348f5ea2014-03-01 14:47:25 -080083 source = app,
Yingdi Yufa0b6a02014-04-30 14:26:42 -070084 use = 'NDN_CXX',
Yingdi Yu0b0a7362014-08-05 16:31:30 -070085 includes = "src .",
Yingdi Yu348f5ea2014-03-01 14:47:25 -080086 install_path = None,
87 )
Yingdi Yufa0b6a02014-04-30 14:26:42 -070088
Davide Pesavento7676b562020-12-14 00:41:26 -050089 if not bld.env.WITH_TESTS:
Yingdi Yu0b0a7362014-08-05 16:31:30 -070090 if Utils.unversioned_sys_platform () == "darwin":
91 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
Yingdi Yub6fb0302014-01-21 11:05:11 -080092<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
93<plist version="0.9">
Yingdi Yu0b0a7362014-08-05 16:31:30 -070094 <dict>
95 <key>CFBundlePackageType</key>
96 <string>APPL</string>
97 <key>CFBundleIconFile</key>
98 <string>demo.icns</string>
99 <key>CFBundleGetInfoString</key>
100 <string>Created by Waf</string>
101 <key>CFBundleIdentifier</key>
102 <string>edu.ucla.cs.irl.ChronoChat</string>
103 <key>CFBundleSignature</key>
104 <string>????</string>
105 <key>NOTE</key>
106 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
107 <key>CFBundleExecutable</key>
108 <string>%s</string>
109 <key>SUPublicDSAKeyFile</key>
110 <string>dsa_pub.pem</string>
111 <key>CFBundleIconFile</key>
112 <string>demo.icns</string>
113 </dict>
Yingdi Yub6fb0302014-01-21 11:05:11 -0800114</plist>'''
Yingdi Yu847aa862013-10-09 16:35:53 -0700115
Yingdi Yub6fb0302014-01-21 11:05:11 -0800116 # <key>LSUIElement</key>
117 # <string>1</string>
Yingdi Yue35bdb82013-11-07 11:32:40 -0800118
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700119 qt.mac_app = "ChronoChat.app"
120 qt.mac_plist = app_plist % "ChronoChat"
121 qt.mac_resources = 'demo.icns'
122 else:
123 bld(features = "subst",
124 source = 'linux/chronochat.desktop.in',
125 target = 'linux/chronochat.desktop',
126 BINARY = "ChronoChat",
127 install_path = "${DATAROOTDIR}/applications"
128 )
129 bld.install_files("${DATAROOTDIR}/chronochat",
130 bld.path.ant_glob(['linux/Resources/*']))
131
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700132def docs(bld):
133 from waflib import Options
134 Options.commands = ['doxygen', 'sphinx'] + Options.commands
135
136def doxygen(bld):
137 version(bld)
138
139 if not bld.env.DOXYGEN:
140 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Yingdi Yub6fb0302014-01-21 11:05:11 -0800141 else:
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700142 bld(features="subst",
143 name="doxygen-conf",
144 source=["docs/doxygen.conf.in",
145 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
146 target=["docs/doxygen.conf",
147 "docs/named_data_theme/named_data_footer-with-analytics.html"],
148 VERSION=VERSION,
149 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
150 if os.getenv('GOOGLE_ANALYTICS', None) \
151 else "../docs/named_data_theme/named_data_footer.html",
152 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
Yingdi Yub6fb0302014-01-21 11:05:11 -0800153 )
Yingdi Yue35bdb82013-11-07 11:32:40 -0800154
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700155 bld(features="doxygen",
156 doxyfile='docs/doxygen.conf',
157 use="doxygen-conf")
Yingdi Yue35bdb82013-11-07 11:32:40 -0800158
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700159def sphinx(bld):
160 version(bld)
Yingdi Yu847aa862013-10-09 16:35:53 -0700161
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700162 if not bld.env.SPHINX_BUILD:
163 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
164 else:
165 bld(features="sphinx",
166 outdir="docs",
167 source=bld.path.ant_glob("docs/**/*.rst"),
168 config="docs/conf.py",
169 VERSION=VERSION)
Yingdi Yu847aa862013-10-09 16:35:53 -0700170
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700171def version(ctx):
172 if getattr(Context.g_module, 'VERSION_BASE', None):
173 return
174
175 Context.g_module.VERSION_BASE = Context.g_module.VERSION
176 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
177
178 try:
179 cmd = ['git', 'describe', '--match', 'ChronoChat-*']
180 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
181 stderr=None, stdin=None)
182 out = p.communicate()[0].strip()
183 if p.returncode == 0 and out != "":
184 Context.g_module.VERSION = out[11:]
185 except:
186 pass