Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 2 | VERSION='0.5' |
Yingdi Yu | d681e21 | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 3 | APPNAME='ChronoChat' |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 4 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 5 | from waflib import Configure, Utils, Logs, Context |
| 6 | import os |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 7 | |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 8 | def options(opt): |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 9 | |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 10 | opt.load(['compiler_c', 'compiler_cxx', 'gnu_dirs']) |
Yingdi Yu | e370a2a | 2013-11-10 17:39:36 -0800 | [diff] [blame] | 11 | |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 12 | opt.load(['default-compiler-flags', 'boost', |
| 13 | 'doxygen', 'sphinx_build', 'qt5_custom', 'cryptopp'], |
| 14 | tooldir=['.waf-tools']) |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 15 | |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 16 | opt = opt.add_option_group('ChronoChat Options') |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 17 | |
| 18 | opt.add_option('--with-tests', action='store_true', default=False, dest='with_tests', |
| 19 | help='''build unit tests''') |
| 20 | |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 21 | def configure(conf): |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 22 | conf.load(['compiler_c', 'compiler_cxx', 'qt5_custom', |
| 23 | 'default-compiler-flags', 'boost', 'gnu_dirs', |
Varun Patil | 3d85090 | 2020-11-23 12:19:14 +0530 | [diff] [blame] | 24 | 'doxygen', 'sphinx_build', 'cryptopp']) |
Yingdi Yu | e370a2a | 2013-11-10 17:39:36 -0800 | [diff] [blame] | 25 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 26 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 27 | uselib_store='NDN_CXX', mandatory=True) |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 28 | |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 29 | conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.5', '--cflags', '--libs'], |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 30 | uselib_store='SYNC', mandatory=True) |
Yingdi Yu | 4390ce5 | 2013-10-10 17:27:54 -0700 | [diff] [blame] | 31 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 32 | boost_libs = 'system random thread filesystem' |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 33 | if conf.options.with_tests: |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 34 | conf.env['WITH_TESTS'] = 1 |
| 35 | conf.define('WITH_TESTS', 1); |
| 36 | boost_libs += ' unit_test_framework' |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 37 | |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 38 | 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 Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 47 | |
Varun Patil | 3d85090 | 2020-11-23 12:19:14 +0530 | [diff] [blame] | 48 | conf.check_cryptopp() |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 49 | conf.check_compiler_flags() |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 50 | conf.write_config_header('src/config.h') |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 51 | |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 52 | def build (bld): |
Varun Patil | 3d85090 | 2020-11-23 12:19:14 +0530 | [diff] [blame] | 53 | feature_list = 'qt5 cxx' |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 54 | if bld.env["WITH_TESTS"]: |
Qiuhan Ding | 56c0be5 | 2015-03-11 17:21:26 -0700 | [diff] [blame] | 55 | feature_list += ' cxxstlib' |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 56 | else: |
| 57 | feature_list += ' cxxprogram' |
| 58 | |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 59 | qt = bld ( |
Yingdi Yu | d681e21 | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 60 | target = "ChronoChat", |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 61 | features = feature_list, |
Yingdi Yu | 4212586 | 2014-08-07 17:04:28 -0700 | [diff] [blame] | 62 | defines = "WAF=1", |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 63 | source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc']), |
Alexander Afanasyev | 4a97931 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 64 | includes = "src .", |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 65 | use = "QT5CORE QT5GUI QT5WIDGETS QT5SQL NDN_CXX BOOST SYNC CRYPTOPP", |
Yingdi Yu | 92e8e48 | 2013-10-17 21:13:03 -0700 | [diff] [blame] | 66 | ) |
| 67 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 68 | # Unit tests |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 69 | 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 Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 78 | |
| 79 | # Debug tools |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 80 | if "_DEBUG" in bld.env["DEFINES"]: |
| 81 | for app in bld.path.ant_glob('debug-tools/*.cpp'): |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 82 | bld(features=['cxx', 'cxxprogram'], |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 83 | target = '%s' % (str(app.change_ext('','.cpp'))), |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 84 | source = app, |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 85 | use = 'NDN_CXX', |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 86 | includes = "src .", |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 87 | install_path = None, |
| 88 | ) |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 89 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 90 | if not bld.env["WITH_TESTS"]: |
| 91 | if Utils.unversioned_sys_platform () == "darwin": |
| 92 | app_plist = '''<?xml version="1.0" encoding="UTF-8"?> |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 93 | <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> |
| 94 | <plist version="0.9"> |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 95 | <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 Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 115 | </plist>''' |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 116 | |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 117 | # <key>LSUIElement</key> |
| 118 | # <string>1</string> |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 119 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 120 | 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 |
| 135 | def docs(bld): |
| 136 | from waflib import Options |
| 137 | Options.commands = ['doxygen', 'sphinx'] + Options.commands |
| 138 | |
| 139 | def 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 Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 144 | else: |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 145 | 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 Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 156 | ) |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 157 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 158 | bld(features="doxygen", |
| 159 | doxyfile='docs/doxygen.conf', |
| 160 | use="doxygen-conf") |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 161 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 162 | def sphinx(bld): |
| 163 | version(bld) |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 164 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 165 | 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 Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 173 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 174 | def 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 |