blob: e147a74c7f339f371e0969ce4acd7fbf11827bc0 [file] [log] [blame]
Yingdi Yu767d2ac2013-10-09 15:16:11 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyev37b90012013-11-07 23:28:10 -08002VERSION='0.4'
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''')
Alexander Afanasyev37b90012013-11-07 23:28:10 -08009 opt.add_option('--log4cxx',action='store_true',default=False,dest='log4cxx',help='''Enable log4cxx''')
Yingdi Yu64206112013-12-24 11:16:32 +080010 opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
Yingdi Yub35b8652013-11-07 11:32:40 -080011
Alexander Afanasyev30cf2bf2013-11-14 13:50:27 -080012 opt.load('compiler_c compiler_cxx qt4')
Yingdi Yuede8eaf2013-10-14 14:07:03 -070013
Yingdi Yu25d8f3e2013-11-10 17:39:36 -080014 if Utils.unversioned_sys_platform () != "darwin":
15 opt.load('gnu_dirs');
16
Yingdi Yu64206112013-12-24 11:16:32 +080017 opt.load('boost protoc cryptopp ndn_cpp', tooldir=['waf-tools'])
Yingdi Yu767d2ac2013-10-09 15:16:11 -070018
19def configure(conf):
Yingdi Yu64206112013-12-24 11:16:32 +080020 conf.load("compiler_c compiler_cxx boost protoc qt4 cryptopp ndn_cpp")
Yingdi Yu767d2ac2013-10-09 15:16:11 -070021
Yingdi Yu25d8f3e2013-11-10 17:39:36 -080022 if Utils.unversioned_sys_platform () != "darwin":
23 conf.load('gnu_dirs');
24
Yingdi Yub35b8652013-11-07 11:32:40 -080025 if conf.options.debug:
26 conf.define ('_DEBUG', 1)
Alexander Afanasyev4f04c552013-11-07 15:30:05 -080027 conf.env.DEBUG = 1
Yingdi Yub35b8652013-11-07 11:32:40 -080028 conf.add_supported_cxxflags (cxxflags = ['-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 ])
36 else:
37 conf.add_supported_cxxflags (cxxflags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function'])
38
Yingdi Yu64206112013-12-24 11:16:32 +080039 conf.check_ndncpp (path=conf.options.ndn_cpp_dir)
40 conf.check_cfg(package='libndn-cpp-et', args=['--cflags', '--libs'], uselib_store='NDN-CPP-ET', mandatory=True)
41
Yingdi Yuad56f1c2013-10-10 17:27:54 -070042 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
Alexander Afanasyev4f04c552013-11-07 15:30:05 -080043 if conf.options.log4cxx:
44 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
Yingdi Yu8dacdf22013-11-05 23:06:43 -080045 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], uselib_store='SYNC', mandatory=True)
Yingdi Yuad56f1c2013-10-10 17:27:54 -070046
Yingdi Yu25d8f3e2013-11-10 17:39:36 -080047 conf.check_cryptopp(path=conf.options.cryptopp_dir)
48
Yingdi Yu64206112013-12-24 11:16:32 +080049 conf.check_boost(lib='system random thread filesystem test')
Yingdi Yu614db142013-10-09 16:35:53 -070050
51 conf.write_config_header('config.h')
52
Yingdi Yu64206112013-12-24 11:16:32 +080053 if conf.options._test:
54 conf.define('_TEST', 1)
Yingdi Yu614db142013-10-09 16:35:53 -070055
56def build (bld):
57 qt = bld (
Yingdi Yuaada52d2013-11-07 11:36:50 -080058 target = "ChronoChat",
Yingdi Yu64206112013-12-24 11:16:32 +080059 # features = "qt4 cxx cxxprogram",
60 features= "qt4 cxx cxxshlib",
Yingdi Yu614db142013-10-09 16:35:53 -070061 defines = "WAF",
Yingdi Yu991177f2013-11-07 17:00:35 -080062 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']),
Alexander Afanasyev4f04c552013-11-07 15:30:05 -080063 includes = "src .",
Yingdi Yu64206112013-12-24 11:16:32 +080064 use = "QTCORE QTGUI QTWIDGETS QTSQL SQLITE3 NDNCPP NDN-CPP-ET BOOST BOOST_FILESYSTEM LOG4CXX CRYPTOPP SYNC",
Yingdi Yu68aced92013-10-17 21:13:03 -070065 )
66
Yingdi Yu64206112013-12-24 11:16:32 +080067 # Unit tests
68 if bld.get_define("_TEST"):
69 unittests = bld.program (
70 target="unit-tests",
71 source = bld.path.ant_glob(['test/**/*.cc']),
72 features=['cxx', 'cxxprogram'],
73 use = 'BOOST_TEST ChronoChat',
74 includes = ['src'],
75 )
76 # Tmp disable
77# if Utils.unversioned_sys_platform () == "darwin":
78# app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
79# <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
80# <plist version="0.9">
81# <dict>
82# <key>CFBundlePackageType</key>
83# <string>APPL</string>
84# <key>CFBundleIconFile</key>
85# <string>demo.icns</string>
86# <key>CFBundleGetInfoString</key>
87# <string>Created by Waf</string>
88# <key>CFBundleIdentifier</key>
89# <string>edu.ucla.cs.irl.ChronoChat</string>
90# <key>CFBundleSignature</key>
91# <string>????</string>
92# <key>NOTE</key>
93# <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
94# <key>CFBundleExecutable</key>
95# <string>%s</string>
96# <key>SUPublicDSAKeyFile</key>
97# <string>dsa_pub.pem</string>
98# <key>CFBundleIconFile</key>
99# <string>demo.icns</string>
100# </dict>
101# </plist>'''
Yingdi Yu614db142013-10-09 16:35:53 -0700102
Yingdi Yu64206112013-12-24 11:16:32 +0800103# # <key>LSUIElement</key>
104# # <string>1</string>
Yingdi Yub35b8652013-11-07 11:32:40 -0800105
Yingdi Yu64206112013-12-24 11:16:32 +0800106# qt.mac_app = "ChronoChat.app"
107# qt.mac_plist = app_plist % "ChronoChat"
108# qt.mac_resources = 'demo.icns'
109# else:
110# bld (features = "subst",
111# source = 'linux/chronochat.desktop.in',
112# target = 'linux/chronochat.desktop',
113# BINARY = "ChronoChat",
114# install_path = "${DATAROOTDIR}/applications"
115# )
116# bld.install_files("${DATAROOTDIR}/chronochat",
117# bld.path.ant_glob(['linux/Resources/*']))
Yingdi Yub35b8652013-11-07 11:32:40 -0800118
119
120from waflib import TaskGen
121@TaskGen.extension('.mm')
122def m_hook(self, node):
123 """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
124 return self.create_compiled_task('cxx', node)
Yingdi Yu614db142013-10-09 16:35:53 -0700125
126@Configure.conf
127def add_supported_cxxflags(self, cxxflags):
128 """
129 Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
130 """
131 self.start_msg('Checking allowed flags for c++ compiler')
132
133 supportedFlags = []
134 for flag in cxxflags:
135 if self.check_cxx (cxxflags=[flag], mandatory=False):
136 supportedFlags += [flag]
137
138 self.end_msg (' '.join (supportedFlags))
139 self.env.CXXFLAGS += supportedFlags