blob: acf100c4a2907d6662f7b49c79446f73a0eb5d80 [file] [log] [blame]
Yingdi Yu767d2ac2013-10-09 15:16:11 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Yingdi Yu6df61252014-01-21 11:05:11 -08002VERSION='0.5'
Yingdi Yuaada52d2013-11-07 11:36:50 -08003APPNAME='ChronoChat'
Yingdi Yu767d2ac2013-10-09 15:16:11 -07004
Yingdi Yub35b8652013-11-07 11:32:40 -08005from waflib import Configure, Utils
Yingdi Yu614db142013-10-09 16:35:53 -07006
Yingdi Yu767d2ac2013-10-09 15:16:11 -07007def options(opt):
Yingdi Yub35b8652013-11-07 11:32:40 -08008 opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
Yingdi Yua1a688f2014-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 Yub35b8652013-11-07 11:32:40 -080012
Alexander Afanasyev30cf2bf2013-11-14 13:50:27 -080013 opt.load('compiler_c compiler_cxx qt4')
Yingdi Yuede8eaf2013-10-14 14:07:03 -070014
Yingdi Yu25d8f3e2013-11-10 17:39:36 -080015 if Utils.unversioned_sys_platform () != "darwin":
16 opt.load('gnu_dirs');
17
Yingdi Yu6df61252014-01-21 11:05:11 -080018 opt.load('boost protoc', tooldir=['waf-tools'])
Yingdi Yu767d2ac2013-10-09 15:16:11 -070019
20def configure(conf):
Yingdi Yu6df61252014-01-21 11:05:11 -080021 conf.load("compiler_c compiler_cxx boost protoc qt4")
Yingdi Yu767d2ac2013-10-09 15:16:11 -070022
Yingdi Yu25d8f3e2013-11-10 17:39:36 -080023 if Utils.unversioned_sys_platform () != "darwin":
24 conf.load('gnu_dirs');
25
Yingdi Yub35b8652013-11-07 11:32:40 -080026 if conf.options.debug:
27 conf.define ('_DEBUG', 1)
Yingdi Yu6df61252014-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 Yua1a688f2014-02-06 18:09:22 -080036 '-Wno-unneeded-internal-declaration',
Yingdi Yu6df61252014-01-21 11:05:11 -080037 ]
38
39 conf.add_supported_cxxflags (cxxflags = flags)
Yingdi Yub35b8652013-11-07 11:32:40 -080040 else:
Yingdi Yu6df61252014-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 Yu64206112013-12-24 11:16:32 +080045
Yingdi Yu6df61252014-01-21 11:05:11 -080046
Alexander Afanasyev4f04c552013-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 Yu6df61252014-01-21 11:05:11 -080049 conf.define ("HAVE_LOG4CXX", 1)
50
Yingdi Yu8dacdf22013-11-05 23:06:43 -080051 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], uselib_store='SYNC', mandatory=True)
Yingdi Yuad56f1c2013-10-10 17:27:54 -070052
Yingdi Yu6df61252014-01-21 11:05:11 -080053 conf.check_boost(lib='system random thread filesystem unit_test_framework')
Yingdi Yu614db142013-10-09 16:35:53 -070054
Yingdi Yu6df61252014-01-21 11:05:11 -080055 if conf.options.with_tests:
Yingdi Yua1a688f2014-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 Yu614db142013-10-09 16:35:53 -070063
64def build (bld):
65 qt = bld (
Yingdi Yuaada52d2013-11-07 11:36:50 -080066 target = "ChronoChat",
Yingdi Yu6df61252014-01-21 11:05:11 -080067 features = "qt4 cxx cxxprogram",
Yingdi Yua1a688f2014-02-06 18:09:22 -080068 # features= "qt4 cxx cxxshlib",
Yingdi Yu614db142013-10-09 16:35:53 -070069 defines = "WAF",
Yingdi Yu991177f2013-11-07 17:00:35 -080070 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']),
Alexander Afanasyev4f04c552013-11-07 15:30:05 -080071 includes = "src .",
Yingdi Yua1a688f2014-02-06 18:09:22 -080072 use = "QTCORE QTGUI QTWIDGETS QTSQL NDN_CPP BOOST LOG4CXX SYNC",
Yingdi Yu68aced92013-10-17 21:13:03 -070073 )
74
Yingdi Yu64206112013-12-24 11:16:32 +080075 # Unit tests
Yingdi Yu6df61252014-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 Yua1a688f2014-02-06 18:09:22 -080082 # includes = "src",
Yingdi Yu6df61252014-01-21 11:05:11 -080083 # install_path = None,
84 # )
Yingdi Yua1a688f2014-02-06 18:09:22 -080085
Yingdi Yu64206112013-12-24 11:16:32 +080086 # Tmp disable
Yingdi Yu6df61252014-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 Yu614db142013-10-09 16:35:53 -0700112
Yingdi Yu6df61252014-01-21 11:05:11 -0800113 # <key>LSUIElement</key>
114 # <string>1</string>
Yingdi Yub35b8652013-11-07 11:32:40 -0800115
Yingdi Yu6df61252014-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 Yub35b8652013-11-07 11:32:40 -0800128
129
Yingdi Yu614db142013-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