blob: e1d56e661553e15af981bf9a050bcd838e6e7883 [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"]:
58 feature_list += ' cxxshlib'
59 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,
80 )
Yingdi Yu348f5ea2014-03-01 14:47:25 -080081
82 # Debug tools
83 if bld.env["_DEBUG"]:
84 for app in bld.path.ant_glob('debug-tools/*.cc'):
85 bld(features=['cxx', 'cxxprogram'],
86 target = '%s' % (str(app.change_ext('','.cc'))),
87 source = app,
Yingdi Yufa0b6a02014-04-30 14:26:42 -070088 use = 'NDN_CXX',
Yingdi Yu0b0a7362014-08-05 16:31:30 -070089 includes = "src .",
Yingdi Yu348f5ea2014-03-01 14:47:25 -080090 install_path = None,
91 )
Yingdi Yufa0b6a02014-04-30 14:26:42 -070092
Yingdi Yu0b0a7362014-08-05 16:31:30 -070093 if not bld.env["WITH_TESTS"]:
94 if Utils.unversioned_sys_platform () == "darwin":
95 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
Yingdi Yub6fb0302014-01-21 11:05:11 -080096<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
97<plist version="0.9">
Yingdi Yu0b0a7362014-08-05 16:31:30 -070098 <dict>
99 <key>CFBundlePackageType</key>
100 <string>APPL</string>
101 <key>CFBundleIconFile</key>
102 <string>demo.icns</string>
103 <key>CFBundleGetInfoString</key>
104 <string>Created by Waf</string>
105 <key>CFBundleIdentifier</key>
106 <string>edu.ucla.cs.irl.ChronoChat</string>
107 <key>CFBundleSignature</key>
108 <string>????</string>
109 <key>NOTE</key>
110 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
111 <key>CFBundleExecutable</key>
112 <string>%s</string>
113 <key>SUPublicDSAKeyFile</key>
114 <string>dsa_pub.pem</string>
115 <key>CFBundleIconFile</key>
116 <string>demo.icns</string>
117 </dict>
Yingdi Yub6fb0302014-01-21 11:05:11 -0800118</plist>'''
Yingdi Yu847aa862013-10-09 16:35:53 -0700119
Yingdi Yub6fb0302014-01-21 11:05:11 -0800120 # <key>LSUIElement</key>
121 # <string>1</string>
Yingdi Yue35bdb82013-11-07 11:32:40 -0800122
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700123 qt.mac_app = "ChronoChat.app"
124 qt.mac_plist = app_plist % "ChronoChat"
125 qt.mac_resources = 'demo.icns'
126 else:
127 bld(features = "subst",
128 source = 'linux/chronochat.desktop.in',
129 target = 'linux/chronochat.desktop',
130 BINARY = "ChronoChat",
131 install_path = "${DATAROOTDIR}/applications"
132 )
133 bld.install_files("${DATAROOTDIR}/chronochat",
134 bld.path.ant_glob(['linux/Resources/*']))
135
136
137# docs
138def docs(bld):
139 from waflib import Options
140 Options.commands = ['doxygen', 'sphinx'] + Options.commands
141
142def doxygen(bld):
143 version(bld)
144
145 if not bld.env.DOXYGEN:
146 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Yingdi Yub6fb0302014-01-21 11:05:11 -0800147 else:
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700148 bld(features="subst",
149 name="doxygen-conf",
150 source=["docs/doxygen.conf.in",
151 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
152 target=["docs/doxygen.conf",
153 "docs/named_data_theme/named_data_footer-with-analytics.html"],
154 VERSION=VERSION,
155 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
156 if os.getenv('GOOGLE_ANALYTICS', None) \
157 else "../docs/named_data_theme/named_data_footer.html",
158 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
Yingdi Yub6fb0302014-01-21 11:05:11 -0800159 )
Yingdi Yue35bdb82013-11-07 11:32:40 -0800160
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700161 bld(features="doxygen",
162 doxyfile='docs/doxygen.conf',
163 use="doxygen-conf")
Yingdi Yue35bdb82013-11-07 11:32:40 -0800164
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700165def sphinx(bld):
166 version(bld)
Yingdi Yu847aa862013-10-09 16:35:53 -0700167
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700168 if not bld.env.SPHINX_BUILD:
169 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
170 else:
171 bld(features="sphinx",
172 outdir="docs",
173 source=bld.path.ant_glob("docs/**/*.rst"),
174 config="docs/conf.py",
175 VERSION=VERSION)
Yingdi Yu847aa862013-10-09 16:35:53 -0700176
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700177def version(ctx):
178 if getattr(Context.g_module, 'VERSION_BASE', None):
179 return
180
181 Context.g_module.VERSION_BASE = Context.g_module.VERSION
182 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
183
184 try:
185 cmd = ['git', 'describe', '--match', 'ChronoChat-*']
186 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
187 stderr=None, stdin=None)
188 out = p.communicate()[0].strip()
189 if p.returncode == 0 and out != "":
190 Context.g_module.VERSION = out[11:]
191 except:
192 pass