blob: ba54b618fc88fda1e0410bba88b2aceb714a39b4 [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 Yue35bdb82013-11-07 11:32:40 -08005from waflib import Configure, Utils
Yingdi Yu847aa862013-10-09 16:35:53 -07006
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07007def options(opt):
Yingdi Yue35bdb82013-11-07 11:32:40 -08008 opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
Yingdi Yufa4ce792014-02-06 18:09:22 -08009 opt.add_option('--with-log4cxx',action='store_true',default=False,dest='log4cxx',help='''Enable log4cxx''')
10 opt.add_option('--with-tests', action='store_true',default=False,dest='with_tests',help='''build unit tests''')
11 opt.add_option('--without-security', action='store_false',default=True,dest='with_security',help='''Enable security''')
Yingdi Yue35bdb82013-11-07 11:32:40 -080012
Alexander Afanasyevc7291762013-11-14 13:50:27 -080013 opt.load('compiler_c compiler_cxx qt4')
Yingdi Yud04ed1a2013-10-14 14:07:03 -070014
Yingdi Yue370a2a2013-11-10 17:39:36 -080015 if Utils.unversioned_sys_platform () != "darwin":
16 opt.load('gnu_dirs');
17
Yingdi Yub6fb0302014-01-21 11:05:11 -080018 opt.load('boost protoc', tooldir=['waf-tools'])
Yingdi Yua43601f2014-05-09 14:29:16 -070019
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070020def configure(conf):
Yingdi Yub6fb0302014-01-21 11:05:11 -080021 conf.load("compiler_c compiler_cxx boost protoc qt4")
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070022
Yingdi Yue370a2a2013-11-10 17:39:36 -080023 if Utils.unversioned_sys_platform () != "darwin":
24 conf.load('gnu_dirs');
25
Yingdi Yue35bdb82013-11-07 11:32:40 -080026 if conf.options.debug:
27 conf.define ('_DEBUG', 1)
Yingdi Yu348f5ea2014-03-01 14:47:25 -080028 conf.env['_DEBUG'] = True;
Yingdi Yub6fb0302014-01-21 11:05:11 -080029 flags = ['-O0',
30 '-Wall',
31 '-Wno-unused-variable',
32 '-g3',
33 '-Wno-unused-private-field', # only clang supports
34 '-fcolor-diagnostics', # only clang supports
35 '-Qunused-arguments', # only clang supports
36 '-Wno-deprecated-declarations',
Yingdi Yufa4ce792014-02-06 18:09:22 -080037 '-Wno-unneeded-internal-declaration',
Yingdi Yub6fb0302014-01-21 11:05:11 -080038 ]
39
40 conf.add_supported_cxxflags (cxxflags = flags)
Yingdi Yue35bdb82013-11-07 11:32:40 -080041 else:
Yingdi Yub6fb0302014-01-21 11:05:11 -080042 flags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function', '-Wno-deprecated-declarations']
43 conf.add_supported_cxxflags (cxxflags = flags)
44
45 conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], uselib_store='NDN_CPP', mandatory=True)
Yingdi Yu76dd8002013-12-24 11:16:32 +080046
Yingdi Yub6fb0302014-01-21 11:05:11 -080047
Alexander Afanasyev4a979312013-11-07 15:30:05 -080048 if conf.options.log4cxx:
49 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
Yingdi Yub6fb0302014-01-21 11:05:11 -080050 conf.define ("HAVE_LOG4CXX", 1)
51
Yingdi Yub2e747d2013-11-05 23:06:43 -080052 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], uselib_store='SYNC', mandatory=True)
Yingdi Yu4390ce52013-10-10 17:27:54 -070053
Yingdi Yub6fb0302014-01-21 11:05:11 -080054 conf.check_boost(lib='system random thread filesystem unit_test_framework')
Yingdi Yu847aa862013-10-09 16:35:53 -070055
Yingdi Yub6fb0302014-01-21 11:05:11 -080056 if conf.options.with_tests:
Yingdi Yu348f5ea2014-03-01 14:47:25 -080057 conf.env['WITH_TESTS'] = True
Yingdi Yufa4ce792014-02-06 18:09:22 -080058 conf.define('WITH_TESTS', 1)
59
60
61 if conf.options.with_security:
62 conf.define('WITH_SECURITY', 1)
63
64 conf.write_config_header('src/config.h')
Yingdi Yu847aa862013-10-09 16:35:53 -070065
66def build (bld):
67 qt = bld (
Yingdi Yud681e212013-11-07 11:36:50 -080068 target = "ChronoChat",
Yingdi Yub6fb0302014-01-21 11:05:11 -080069 features = "qt4 cxx cxxprogram",
Yingdi Yufa4ce792014-02-06 18:09:22 -080070 # features= "qt4 cxx cxxshlib",
Yingdi Yu847aa862013-10-09 16:35:53 -070071 defines = "WAF",
Yingdi Yuc5020b92013-11-07 17:00:35 -080072 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']),
Alexander Afanasyev4a979312013-11-07 15:30:05 -080073 includes = "src .",
Yingdi Yufa4ce792014-02-06 18:09:22 -080074 use = "QTCORE QTGUI QTWIDGETS QTSQL NDN_CPP BOOST LOG4CXX SYNC",
Yingdi Yu92e8e482013-10-17 21:13:03 -070075 )
76
Yingdi Yu76dd8002013-12-24 11:16:32 +080077 # Unit tests
Yingdi Yu348f5ea2014-03-01 14:47:25 -080078 # if bld.env["WITH_TESTS"]:
Yingdi Yub6fb0302014-01-21 11:05:11 -080079 # unittests = bld.program (
80 # target="unit-tests",
81 # source = bld.path.ant_glob(['test/**/*.cc']),
82 # features=['cxx', 'cxxprogram'],
83 # use = 'BOOST ChronoChat',
Yingdi Yufa4ce792014-02-06 18:09:22 -080084 # includes = "src",
Yingdi Yub6fb0302014-01-21 11:05:11 -080085 # install_path = None,
86 # )
Yingdi Yu348f5ea2014-03-01 14:47:25 -080087
88 # Debug tools
89 if bld.env["_DEBUG"]:
90 for app in bld.path.ant_glob('debug-tools/*.cc'):
91 bld(features=['cxx', 'cxxprogram'],
92 target = '%s' % (str(app.change_ext('','.cc'))),
93 source = app,
94 use = 'NDN_CPP',
95 install_path = None,
96 )
Yingdi Yufa4ce792014-02-06 18:09:22 -080097
Yingdi Yu76dd8002013-12-24 11:16:32 +080098 # Tmp disable
Yingdi Yub6fb0302014-01-21 11:05:11 -080099 if Utils.unversioned_sys_platform () == "darwin":
100 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
101<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
102<plist version="0.9">
103<dict>
104 <key>CFBundlePackageType</key>
105 <string>APPL</string>
106 <key>CFBundleIconFile</key>
107 <string>demo.icns</string>
108 <key>CFBundleGetInfoString</key>
109 <string>Created by Waf</string>
110 <key>CFBundleIdentifier</key>
111 <string>edu.ucla.cs.irl.ChronoChat</string>
112 <key>CFBundleSignature</key>
113 <string>????</string>
114 <key>NOTE</key>
115 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
116 <key>CFBundleExecutable</key>
117 <string>%s</string>
118 <key>SUPublicDSAKeyFile</key>
119 <string>dsa_pub.pem</string>
120 <key>CFBundleIconFile</key>
121 <string>demo.icns</string>
122</dict>
123</plist>'''
Yingdi Yu847aa862013-10-09 16:35:53 -0700124
Yingdi Yub6fb0302014-01-21 11:05:11 -0800125 # <key>LSUIElement</key>
126 # <string>1</string>
Yingdi Yue35bdb82013-11-07 11:32:40 -0800127
Yingdi Yub6fb0302014-01-21 11:05:11 -0800128 qt.mac_app = "ChronoChat.app"
129 qt.mac_plist = app_plist % "ChronoChat"
130 qt.mac_resources = 'demo.icns'
131 else:
132 bld (features = "subst",
133 source = 'linux/chronochat.desktop.in',
134 target = 'linux/chronochat.desktop',
135 BINARY = "ChronoChat",
136 install_path = "${DATAROOTDIR}/applications"
137 )
138 bld.install_files("${DATAROOTDIR}/chronochat",
139 bld.path.ant_glob(['linux/Resources/*']))
Yingdi Yue35bdb82013-11-07 11:32:40 -0800140
141
Yingdi Yu847aa862013-10-09 16:35:53 -0700142@Configure.conf
143def add_supported_cxxflags(self, cxxflags):
144 """
145 Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
146 """
147 self.start_msg('Checking allowed flags for c++ compiler')
148
149 supportedFlags = []
150 for flag in cxxflags:
151 if self.check_cxx (cxxflags=[flag], mandatory=False):
152 supportedFlags += [flag]
153
154 self.end_msg (' '.join (supportedFlags))
155 self.env.CXXFLAGS += supportedFlags