blob: 7bf7d90f76ecf021682358281b9e23cdb31dccd7 [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 Yu0b0a7362014-08-05 16:31:30 -070010 opt.load(['compiler_c', 'compiler_cxx', 'qt4'])
Yingdi Yue370a2a2013-11-10 17:39:36 -080011 if Utils.unversioned_sys_platform () != "darwin":
12 opt.load('gnu_dirs');
13
Yingdi Yu0b0a7362014-08-05 16:31:30 -070014 opt.load(['default-compiler-flags', 'boost', 'protoc',
15 'doxygen', 'sphinx_build'],
16 tooldir=['waf-tools'])
17
18 opt = opt.add_option_group('ChronotChat Options')
19
20 opt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
21 help='''build unit tests''')
22
23 opt.add_option('--with-log4cxx', action='store_true', default=False, dest='log4cxx',
24 help='''Enable log4cxx''')
Yingdi Yufa0b6a02014-04-30 14:26:42 -070025
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070026def configure(conf):
Yingdi Yu0b0a7362014-08-05 16:31:30 -070027 conf.load(['compiler_c', 'compiler_cxx', 'qt4',
28 'default-compiler-flags', 'boost', 'protoc',
29 'doxygen', 'sphinx_build'])
Yingdi Yue370a2a2013-11-10 17:39:36 -080030 if Utils.unversioned_sys_platform () != "darwin":
Yingdi Yu0b0a7362014-08-05 16:31:30 -070031 opt.load('gnu_dirs');
Yingdi Yue370a2a2013-11-10 17:39:36 -080032
Yingdi Yu0b0a7362014-08-05 16:31:30 -070033 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
34 uselib_store='NDN_CXX', mandatory=True)
Yingdi Yufa0b6a02014-04-30 14:26:42 -070035
Alexander Afanasyev4a979312013-11-07 15:30:05 -080036 if conf.options.log4cxx:
Yingdi Yu0b0a7362014-08-05 16:31:30 -070037 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'],
38 uselib_store='LOG4CXX', mandatory=True)
39 conf.define("HAVE_LOG4CXX", 1)
Yingdi Yufa0b6a02014-04-30 14:26:42 -070040
Yingdi Yu0b0a7362014-08-05 16:31:30 -070041 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'],
42 uselib_store='SYNC', mandatory=True)
Yingdi Yu4390ce52013-10-10 17:27:54 -070043
Yingdi Yu0b0a7362014-08-05 16:31:30 -070044 boost_libs = 'system random thread filesystem'
Yingdi Yub6fb0302014-01-21 11:05:11 -080045 if conf.options.with_tests:
Yingdi Yu0b0a7362014-08-05 16:31:30 -070046 conf.env['WITH_TESTS'] = 1
47 conf.define('WITH_TESTS', 1);
48 boost_libs += ' unit_test_framework'
Yingdi Yufa4ce792014-02-06 18:09:22 -080049
Yingdi Yu0b0a7362014-08-05 16:31:30 -070050 conf.check_boost(lib=boost_libs)
51 if conf.env.BOOST_VERSION_NUMBER < 104800:
52 Logs.error("Minimum required boost version is 1.48.0")
53 Logs.error("Please upgrade your distribution or install custom boost libraries" +
54 " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
55 return
Yingdi Yufa4ce792014-02-06 18:09:22 -080056
57 conf.write_config_header('src/config.h')
Yingdi Yufa0b6a02014-04-30 14:26:42 -070058
Yingdi Yu847aa862013-10-09 16:35:53 -070059def build (bld):
Yingdi Yu0b0a7362014-08-05 16:31:30 -070060 feature_list = 'qt4 cxx'
61 if bld.env["WITH_TESTS"]:
62 feature_list += ' cxxshlib'
63 else:
64 feature_list += ' cxxprogram'
65
Yingdi Yu847aa862013-10-09 16:35:53 -070066 qt = bld (
Yingdi Yud681e212013-11-07 11:36:50 -080067 target = "ChronoChat",
Yingdi Yu0b0a7362014-08-05 16:31:30 -070068 features = feature_list,
Yingdi Yu42125862014-08-07 17:04:28 -070069 defines = "WAF=1",
Yingdi Yuc5020b92013-11-07 17:00:35 -080070 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']),
Alexander Afanasyev4a979312013-11-07 15:30:05 -080071 includes = "src .",
Yingdi Yufa0b6a02014-04-30 14:26:42 -070072 use = "QTCORE QTGUI QTWIDGETS QTSQL NDN_CXX BOOST LOG4CXX SYNC",
Yingdi Yu92e8e482013-10-17 21:13:03 -070073 )
74
Yingdi Yu76dd8002013-12-24 11:16:32 +080075 # Unit tests
Yingdi Yu0b0a7362014-08-05 16:31:30 -070076 if bld.env["WITH_TESTS"]:
77 unittests = bld.program (
78 target="unit-tests",
79 source = bld.path.ant_glob(['test/**/*.cpp']),
80 features=['cxx', 'cxxprogram'],
81 use = 'BOOST ChronoChat',
82 includes = "src .",
83 install_path = None,
84 )
Yingdi Yu348f5ea2014-03-01 14:47:25 -080085
86 # Debug tools
87 if bld.env["_DEBUG"]:
88 for app in bld.path.ant_glob('debug-tools/*.cc'):
89 bld(features=['cxx', 'cxxprogram'],
90 target = '%s' % (str(app.change_ext('','.cc'))),
91 source = app,
Yingdi Yufa0b6a02014-04-30 14:26:42 -070092 use = 'NDN_CXX',
Yingdi Yu0b0a7362014-08-05 16:31:30 -070093 includes = "src .",
Yingdi Yu348f5ea2014-03-01 14:47:25 -080094 install_path = None,
95 )
Yingdi Yufa0b6a02014-04-30 14:26:42 -070096
Yingdi Yu0b0a7362014-08-05 16:31:30 -070097 if not bld.env["WITH_TESTS"]:
98 if Utils.unversioned_sys_platform () == "darwin":
99 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
Yingdi Yub6fb0302014-01-21 11:05:11 -0800100<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
101<plist version="0.9">
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700102 <dict>
103 <key>CFBundlePackageType</key>
104 <string>APPL</string>
105 <key>CFBundleIconFile</key>
106 <string>demo.icns</string>
107 <key>CFBundleGetInfoString</key>
108 <string>Created by Waf</string>
109 <key>CFBundleIdentifier</key>
110 <string>edu.ucla.cs.irl.ChronoChat</string>
111 <key>CFBundleSignature</key>
112 <string>????</string>
113 <key>NOTE</key>
114 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
115 <key>CFBundleExecutable</key>
116 <string>%s</string>
117 <key>SUPublicDSAKeyFile</key>
118 <string>dsa_pub.pem</string>
119 <key>CFBundleIconFile</key>
120 <string>demo.icns</string>
121 </dict>
Yingdi Yub6fb0302014-01-21 11:05:11 -0800122</plist>'''
Yingdi Yu847aa862013-10-09 16:35:53 -0700123
Yingdi Yub6fb0302014-01-21 11:05:11 -0800124 # <key>LSUIElement</key>
125 # <string>1</string>
Yingdi Yue35bdb82013-11-07 11:32:40 -0800126
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700127 qt.mac_app = "ChronoChat.app"
128 qt.mac_plist = app_plist % "ChronoChat"
129 qt.mac_resources = 'demo.icns'
130 else:
131 bld(features = "subst",
132 source = 'linux/chronochat.desktop.in',
133 target = 'linux/chronochat.desktop',
134 BINARY = "ChronoChat",
135 install_path = "${DATAROOTDIR}/applications"
136 )
137 bld.install_files("${DATAROOTDIR}/chronochat",
138 bld.path.ant_glob(['linux/Resources/*']))
139
140
141# docs
142def docs(bld):
143 from waflib import Options
144 Options.commands = ['doxygen', 'sphinx'] + Options.commands
145
146def doxygen(bld):
147 version(bld)
148
149 if not bld.env.DOXYGEN:
150 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Yingdi Yub6fb0302014-01-21 11:05:11 -0800151 else:
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700152 bld(features="subst",
153 name="doxygen-conf",
154 source=["docs/doxygen.conf.in",
155 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
156 target=["docs/doxygen.conf",
157 "docs/named_data_theme/named_data_footer-with-analytics.html"],
158 VERSION=VERSION,
159 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
160 if os.getenv('GOOGLE_ANALYTICS', None) \
161 else "../docs/named_data_theme/named_data_footer.html",
162 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
Yingdi Yub6fb0302014-01-21 11:05:11 -0800163 )
Yingdi Yue35bdb82013-11-07 11:32:40 -0800164
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700165 bld(features="doxygen",
166 doxyfile='docs/doxygen.conf',
167 use="doxygen-conf")
Yingdi Yue35bdb82013-11-07 11:32:40 -0800168
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700169def sphinx(bld):
170 version(bld)
Yingdi Yu847aa862013-10-09 16:35:53 -0700171
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700172 if not bld.env.SPHINX_BUILD:
173 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
174 else:
175 bld(features="sphinx",
176 outdir="docs",
177 source=bld.path.ant_glob("docs/**/*.rst"),
178 config="docs/conf.py",
179 VERSION=VERSION)
Yingdi Yu847aa862013-10-09 16:35:53 -0700180
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700181def version(ctx):
182 if getattr(Context.g_module, 'VERSION_BASE', None):
183 return
184
185 Context.g_module.VERSION_BASE = Context.g_module.VERSION
186 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
187
188 try:
189 cmd = ['git', 'describe', '--match', 'ChronoChat-*']
190 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
191 stderr=None, stdin=None)
192 out = p.communicate()[0].strip()
193 if p.returncode == 0 and out != "":
194 Context.g_module.VERSION = out[11:]
195 except:
196 pass