blob: ab4a0c89cb40ab51dd21226ffa3f2eeec4ab94f0 [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
Yingdi Yu52892592014-09-04 14:30:23 -070010 opt.load(['compiler_c', 'compiler_cxx', 'qt4', 'gnu_dirs'])
Yingdi Yue370a2a2013-11-10 17:39:36 -080011
Yingdi Yu0b0a7362014-08-05 16:31:30 -070012 opt.load(['default-compiler-flags', 'boost', 'protoc',
13 'doxygen', 'sphinx_build'],
14 tooldir=['waf-tools'])
15
16 opt = opt.add_option_group('ChronotChat Options')
17
18 opt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
19 help='''build unit tests''')
20
21 opt.add_option('--with-log4cxx', action='store_true', default=False, dest='log4cxx',
22 help='''Enable log4cxx''')
Yingdi Yufa0b6a02014-04-30 14:26:42 -070023
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070024def configure(conf):
Yingdi Yu0b0a7362014-08-05 16:31:30 -070025 conf.load(['compiler_c', 'compiler_cxx', 'qt4',
Yingdi Yu52892592014-09-04 14:30:23 -070026 'default-compiler-flags', 'boost', 'protoc', 'gnu_dirs',
Yingdi Yu0b0a7362014-08-05 16:31:30 -070027 'doxygen', 'sphinx_build'])
Yingdi Yue370a2a2013-11-10 17:39:36 -080028
Yingdi Yu0b0a7362014-08-05 16:31:30 -070029 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
30 uselib_store='NDN_CXX', mandatory=True)
Yingdi Yufa0b6a02014-04-30 14:26:42 -070031
Alexander Afanasyev4a979312013-11-07 15:30:05 -080032 if conf.options.log4cxx:
Yingdi Yu0b0a7362014-08-05 16:31:30 -070033 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'],
34 uselib_store='LOG4CXX', mandatory=True)
35 conf.define("HAVE_LOG4CXX", 1)
Yingdi Yufa0b6a02014-04-30 14:26:42 -070036
Yingdi Yu0b0a7362014-08-05 16:31:30 -070037 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'],
38 uselib_store='SYNC', mandatory=True)
Yingdi Yu4390ce52013-10-10 17:27:54 -070039
Yingdi Yu0b0a7362014-08-05 16:31:30 -070040 boost_libs = 'system random thread filesystem'
Yingdi Yub6fb0302014-01-21 11:05:11 -080041 if conf.options.with_tests:
Yingdi Yu0b0a7362014-08-05 16:31:30 -070042 conf.env['WITH_TESTS'] = 1
43 conf.define('WITH_TESTS', 1);
44 boost_libs += ' unit_test_framework'
Yingdi Yufa4ce792014-02-06 18:09:22 -080045
Yingdi Yu0b0a7362014-08-05 16:31:30 -070046 conf.check_boost(lib=boost_libs)
47 if conf.env.BOOST_VERSION_NUMBER < 104800:
48 Logs.error("Minimum required boost version is 1.48.0")
49 Logs.error("Please upgrade your distribution or install custom boost libraries" +
50 " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
51 return
Yingdi Yufa4ce792014-02-06 18:09:22 -080052
53 conf.write_config_header('src/config.h')
Yingdi Yufa0b6a02014-04-30 14:26:42 -070054
Yingdi Yu847aa862013-10-09 16:35:53 -070055def build (bld):
Yingdi Yu0b0a7362014-08-05 16:31:30 -070056 feature_list = 'qt4 cxx'
57 if bld.env["WITH_TESTS"]:
Qiuhan Ding56c0be52015-03-11 17:21:26 -070058 feature_list += ' cxxstlib'
Yingdi Yu0b0a7362014-08-05 16:31:30 -070059 else:
60 feature_list += ' cxxprogram'
61
Yingdi Yu847aa862013-10-09 16:35:53 -070062 qt = bld (
Yingdi Yud681e212013-11-07 11:36:50 -080063 target = "ChronoChat",
Yingdi Yu0b0a7362014-08-05 16:31:30 -070064 features = feature_list,
Yingdi Yu42125862014-08-07 17:04:28 -070065 defines = "WAF=1",
Yingdi Yuc5020b92013-11-07 17:00:35 -080066 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']),
Alexander Afanasyev4a979312013-11-07 15:30:05 -080067 includes = "src .",
Yingdi Yufa0b6a02014-04-30 14:26:42 -070068 use = "QTCORE QTGUI QTWIDGETS QTSQL NDN_CXX BOOST LOG4CXX SYNC",
Yingdi Yu92e8e482013-10-17 21:13:03 -070069 )
70
Yingdi Yu76dd8002013-12-24 11:16:32 +080071 # Unit tests
Yingdi Yu0b0a7362014-08-05 16:31:30 -070072 if bld.env["WITH_TESTS"]:
73 unittests = bld.program (
74 target="unit-tests",
75 source = bld.path.ant_glob(['test/**/*.cpp']),
76 features=['cxx', 'cxxprogram'],
77 use = 'BOOST ChronoChat',
78 includes = "src .",
79 install_path = None,
Qiuhan Ding52f13832015-03-06 14:05:59 -080080 defines = 'TEST_CERT_PATH=\"%s/cert-test\"' %(bld.bldnode),
Yingdi Yu0b0a7362014-08-05 16:31:30 -070081 )
Yingdi Yu348f5ea2014-03-01 14:47:25 -080082
83 # Debug tools
84 if bld.env["_DEBUG"]:
85 for app in bld.path.ant_glob('debug-tools/*.cc'):
86 bld(features=['cxx', 'cxxprogram'],
87 target = '%s' % (str(app.change_ext('','.cc'))),
88 source = app,
Yingdi Yufa0b6a02014-04-30 14:26:42 -070089 use = 'NDN_CXX',
Yingdi Yu0b0a7362014-08-05 16:31:30 -070090 includes = "src .",
Yingdi Yu348f5ea2014-03-01 14:47:25 -080091 install_path = None,
92 )
Yingdi Yufa0b6a02014-04-30 14:26:42 -070093
Yingdi Yu0b0a7362014-08-05 16:31:30 -070094 if not bld.env["WITH_TESTS"]:
95 if Utils.unversioned_sys_platform () == "darwin":
96 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
Yingdi Yub6fb0302014-01-21 11:05:11 -080097<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
98<plist version="0.9">
Yingdi Yu0b0a7362014-08-05 16:31:30 -070099 <dict>
100 <key>CFBundlePackageType</key>
101 <string>APPL</string>
102 <key>CFBundleIconFile</key>
103 <string>demo.icns</string>
104 <key>CFBundleGetInfoString</key>
105 <string>Created by Waf</string>
106 <key>CFBundleIdentifier</key>
107 <string>edu.ucla.cs.irl.ChronoChat</string>
108 <key>CFBundleSignature</key>
109 <string>????</string>
110 <key>NOTE</key>
111 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
112 <key>CFBundleExecutable</key>
113 <string>%s</string>
114 <key>SUPublicDSAKeyFile</key>
115 <string>dsa_pub.pem</string>
116 <key>CFBundleIconFile</key>
117 <string>demo.icns</string>
118 </dict>
Yingdi Yub6fb0302014-01-21 11:05:11 -0800119</plist>'''
Yingdi Yu847aa862013-10-09 16:35:53 -0700120
Yingdi Yub6fb0302014-01-21 11:05:11 -0800121 # <key>LSUIElement</key>
122 # <string>1</string>
Yingdi Yue35bdb82013-11-07 11:32:40 -0800123
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700124 qt.mac_app = "ChronoChat.app"
125 qt.mac_plist = app_plist % "ChronoChat"
126 qt.mac_resources = 'demo.icns'
127 else:
128 bld(features = "subst",
129 source = 'linux/chronochat.desktop.in',
130 target = 'linux/chronochat.desktop',
131 BINARY = "ChronoChat",
132 install_path = "${DATAROOTDIR}/applications"
133 )
134 bld.install_files("${DATAROOTDIR}/chronochat",
135 bld.path.ant_glob(['linux/Resources/*']))
136
137
138# docs
139def docs(bld):
140 from waflib import Options
141 Options.commands = ['doxygen', 'sphinx'] + Options.commands
142
143def doxygen(bld):
144 version(bld)
145
146 if not bld.env.DOXYGEN:
147 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Yingdi Yub6fb0302014-01-21 11:05:11 -0800148 else:
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700149 bld(features="subst",
150 name="doxygen-conf",
151 source=["docs/doxygen.conf.in",
152 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
153 target=["docs/doxygen.conf",
154 "docs/named_data_theme/named_data_footer-with-analytics.html"],
155 VERSION=VERSION,
156 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
157 if os.getenv('GOOGLE_ANALYTICS', None) \
158 else "../docs/named_data_theme/named_data_footer.html",
159 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
Yingdi Yub6fb0302014-01-21 11:05:11 -0800160 )
Yingdi Yue35bdb82013-11-07 11:32:40 -0800161
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700162 bld(features="doxygen",
163 doxyfile='docs/doxygen.conf',
164 use="doxygen-conf")
Yingdi Yue35bdb82013-11-07 11:32:40 -0800165
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700166def sphinx(bld):
167 version(bld)
Yingdi Yu847aa862013-10-09 16:35:53 -0700168
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700169 if not bld.env.SPHINX_BUILD:
170 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
171 else:
172 bld(features="sphinx",
173 outdir="docs",
174 source=bld.path.ant_glob("docs/**/*.rst"),
175 config="docs/conf.py",
176 VERSION=VERSION)
Yingdi Yu847aa862013-10-09 16:35:53 -0700177
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700178def version(ctx):
179 if getattr(Context.g_module, 'VERSION_BASE', None):
180 return
181
182 Context.g_module.VERSION_BASE = Context.g_module.VERSION
183 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
184
185 try:
186 cmd = ['git', 'describe', '--match', 'ChronoChat-*']
187 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
188 stderr=None, stdin=None)
189 out = p.communicate()[0].strip()
190 if p.returncode == 0 and out != "":
191 Context.g_module.VERSION = out[11:]
192 except:
193 pass