blob: acf100c4a2907d6662f7b49c79446f73a0eb5d80 [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 Yub6fb0302014-01-21 11:05:11 -080028 flags = ['-O0',
29 '-Wall',
30 '-Wno-unused-variable',
31 '-g3',
32 '-Wno-unused-private-field', # only clang supports
33 '-fcolor-diagnostics', # only clang supports
34 '-Qunused-arguments', # only clang supports
35 '-Wno-deprecated-declarations',
Yingdi Yufa4ce792014-02-06 18:09:22 -080036 '-Wno-unneeded-internal-declaration',
Yingdi Yub6fb0302014-01-21 11:05:11 -080037 ]
38
39 conf.add_supported_cxxflags (cxxflags = flags)
Yingdi Yue35bdb82013-11-07 11:32:40 -080040 else:
Yingdi Yub6fb0302014-01-21 11:05:11 -080041 flags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function', '-Wno-deprecated-declarations']
42 conf.add_supported_cxxflags (cxxflags = flags)
43
44 conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], uselib_store='NDN_CPP', mandatory=True)
Yingdi Yu76dd8002013-12-24 11:16:32 +080045
Yingdi Yub6fb0302014-01-21 11:05:11 -080046
Alexander Afanasyev4a979312013-11-07 15:30:05 -080047 if conf.options.log4cxx:
48 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
Yingdi Yub6fb0302014-01-21 11:05:11 -080049 conf.define ("HAVE_LOG4CXX", 1)
50
Yingdi Yub2e747d2013-11-05 23:06:43 -080051 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], uselib_store='SYNC', mandatory=True)
Yingdi Yu4390ce52013-10-10 17:27:54 -070052
Yingdi Yub6fb0302014-01-21 11:05:11 -080053 conf.check_boost(lib='system random thread filesystem unit_test_framework')
Yingdi Yu847aa862013-10-09 16:35:53 -070054
Yingdi Yub6fb0302014-01-21 11:05:11 -080055 if conf.options.with_tests:
Yingdi Yufa4ce792014-02-06 18:09:22 -080056 conf.define('WITH_TESTS', 1)
57
58
59 if conf.options.with_security:
60 conf.define('WITH_SECURITY', 1)
61
62 conf.write_config_header('src/config.h')
Yingdi Yu847aa862013-10-09 16:35:53 -070063
64def build (bld):
65 qt = bld (
Yingdi Yud681e212013-11-07 11:36:50 -080066 target = "ChronoChat",
Yingdi Yub6fb0302014-01-21 11:05:11 -080067 features = "qt4 cxx cxxprogram",
Yingdi Yufa4ce792014-02-06 18:09:22 -080068 # features= "qt4 cxx cxxshlib",
Yingdi Yu847aa862013-10-09 16:35:53 -070069 defines = "WAF",
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 Yufa4ce792014-02-06 18:09:22 -080072 use = "QTCORE QTGUI QTWIDGETS QTSQL NDN_CPP BOOST LOG4CXX SYNC",
Yingdi Yu92e8e482013-10-17 21:13:03 -070073 )
74
Yingdi Yu76dd8002013-12-24 11:16:32 +080075 # Unit tests
Yingdi Yub6fb0302014-01-21 11:05:11 -080076 # if bld.get_define("WITH_TESTS"):
77 # unittests = bld.program (
78 # target="unit-tests",
79 # source = bld.path.ant_glob(['test/**/*.cc']),
80 # features=['cxx', 'cxxprogram'],
81 # use = 'BOOST ChronoChat',
Yingdi Yufa4ce792014-02-06 18:09:22 -080082 # includes = "src",
Yingdi Yub6fb0302014-01-21 11:05:11 -080083 # install_path = None,
84 # )
Yingdi Yufa4ce792014-02-06 18:09:22 -080085
Yingdi Yu76dd8002013-12-24 11:16:32 +080086 # Tmp disable
Yingdi Yub6fb0302014-01-21 11:05:11 -080087 if Utils.unversioned_sys_platform () == "darwin":
88 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
89<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
90<plist version="0.9">
91<dict>
92 <key>CFBundlePackageType</key>
93 <string>APPL</string>
94 <key>CFBundleIconFile</key>
95 <string>demo.icns</string>
96 <key>CFBundleGetInfoString</key>
97 <string>Created by Waf</string>
98 <key>CFBundleIdentifier</key>
99 <string>edu.ucla.cs.irl.ChronoChat</string>
100 <key>CFBundleSignature</key>
101 <string>????</string>
102 <key>NOTE</key>
103 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
104 <key>CFBundleExecutable</key>
105 <string>%s</string>
106 <key>SUPublicDSAKeyFile</key>
107 <string>dsa_pub.pem</string>
108 <key>CFBundleIconFile</key>
109 <string>demo.icns</string>
110</dict>
111</plist>'''
Yingdi Yu847aa862013-10-09 16:35:53 -0700112
Yingdi Yub6fb0302014-01-21 11:05:11 -0800113 # <key>LSUIElement</key>
114 # <string>1</string>
Yingdi Yue35bdb82013-11-07 11:32:40 -0800115
Yingdi Yub6fb0302014-01-21 11:05:11 -0800116 qt.mac_app = "ChronoChat.app"
117 qt.mac_plist = app_plist % "ChronoChat"
118 qt.mac_resources = 'demo.icns'
119 else:
120 bld (features = "subst",
121 source = 'linux/chronochat.desktop.in',
122 target = 'linux/chronochat.desktop',
123 BINARY = "ChronoChat",
124 install_path = "${DATAROOTDIR}/applications"
125 )
126 bld.install_files("${DATAROOTDIR}/chronochat",
127 bld.path.ant_glob(['linux/Resources/*']))
Yingdi Yue35bdb82013-11-07 11:32:40 -0800128
129
Yingdi Yu847aa862013-10-09 16:35:53 -0700130@Configure.conf
131def add_supported_cxxflags(self, cxxflags):
132 """
133 Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
134 """
135 self.start_msg('Checking allowed flags for c++ compiler')
136
137 supportedFlags = []
138 for flag in cxxflags:
139 if self.check_cxx (cxxflags=[flag], mandatory=False):
140 supportedFlags += [flag]
141
142 self.end_msg (' '.join (supportedFlags))
143 self.env.CXXFLAGS += supportedFlags