blob: 9f659881846ebf76ddee2d4a87c4acad2aa825fb [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''')
Alexander Afanasyev37b90012013-11-07 23:28:10 -08009 opt.add_option('--log4cxx',action='store_true',default=False,dest='log4cxx',help='''Enable log4cxx''')
Yingdi Yu6df61252014-01-21 11:05:11 -080010 opt.add_option('--with-test', action='store_true',default=False,dest='with_tests',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 Yu6df61252014-01-21 11:05:11 -080017 opt.load('boost protoc', tooldir=['waf-tools'])
Yingdi Yu767d2ac2013-10-09 15:16:11 -070018
19def configure(conf):
Yingdi Yu6df61252014-01-21 11:05:11 -080020 conf.load("compiler_c compiler_cxx boost protoc qt4")
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)
Yingdi Yu6df61252014-01-21 11:05:11 -080027 flags = ['-O0',
28 '-Wall',
29 '-Wno-unused-variable',
30 '-g3',
31 '-Wno-unused-private-field', # only clang supports
32 '-fcolor-diagnostics', # only clang supports
33 '-Qunused-arguments', # only clang supports
34 '-Wno-deprecated-declarations',
35 ]
36
37 conf.add_supported_cxxflags (cxxflags = flags)
Yingdi Yub35b8652013-11-07 11:32:40 -080038 else:
Yingdi Yu6df61252014-01-21 11:05:11 -080039 flags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function', '-Wno-deprecated-declarations']
40 conf.add_supported_cxxflags (cxxflags = flags)
41
42 conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], uselib_store='NDN_CPP', mandatory=True)
Yingdi Yu64206112013-12-24 11:16:32 +080043
Yingdi Yu6df61252014-01-21 11:05:11 -080044
Alexander Afanasyev4f04c552013-11-07 15:30:05 -080045 if conf.options.log4cxx:
46 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
Yingdi Yu6df61252014-01-21 11:05:11 -080047 conf.define ("HAVE_LOG4CXX", 1)
48
Yingdi Yu8dacdf22013-11-05 23:06:43 -080049 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], uselib_store='SYNC', mandatory=True)
Yingdi Yuad56f1c2013-10-10 17:27:54 -070050
Yingdi Yu6df61252014-01-21 11:05:11 -080051 conf.check_boost(lib='system random thread filesystem unit_test_framework')
Yingdi Yu614db142013-10-09 16:35:53 -070052
53 conf.write_config_header('config.h')
54
Yingdi Yu6df61252014-01-21 11:05:11 -080055 if conf.options.with_tests:
56 conf.define('WITH_TESTS', 1)
Yingdi Yu614db142013-10-09 16:35:53 -070057
58def build (bld):
59 qt = bld (
Yingdi Yuaada52d2013-11-07 11:36:50 -080060 target = "ChronoChat",
Yingdi Yu6df61252014-01-21 11:05:11 -080061 features = "qt4 cxx cxxprogram",
62 # features= "qt4 cxx cxxshlib",
Yingdi Yu614db142013-10-09 16:35:53 -070063 defines = "WAF",
Yingdi Yu991177f2013-11-07 17:00:35 -080064 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']),
Alexander Afanasyev4f04c552013-11-07 15:30:05 -080065 includes = "src .",
Yingdi Yu6df61252014-01-21 11:05:11 -080066 use = "QTCORE QTGUI QTWIDGETS QTSQL SQLITE3 NDN_CPP BOOST LOG4CXX SYNC",
Yingdi Yu68aced92013-10-17 21:13:03 -070067 )
68
Yingdi Yu64206112013-12-24 11:16:32 +080069 # Unit tests
Yingdi Yu6df61252014-01-21 11:05:11 -080070 # if bld.get_define("WITH_TESTS"):
71 # unittests = bld.program (
72 # target="unit-tests",
73 # source = bld.path.ant_glob(['test/**/*.cc']),
74 # features=['cxx', 'cxxprogram'],
75 # use = 'BOOST ChronoChat',
76 # install_path = None,
77 # )
Yingdi Yu64206112013-12-24 11:16:32 +080078 # Tmp disable
Yingdi Yu6df61252014-01-21 11:05:11 -080079 if Utils.unversioned_sys_platform () == "darwin":
80 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
81<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
82<plist version="0.9">
83<dict>
84 <key>CFBundlePackageType</key>
85 <string>APPL</string>
86 <key>CFBundleIconFile</key>
87 <string>demo.icns</string>
88 <key>CFBundleGetInfoString</key>
89 <string>Created by Waf</string>
90 <key>CFBundleIdentifier</key>
91 <string>edu.ucla.cs.irl.ChronoChat</string>
92 <key>CFBundleSignature</key>
93 <string>????</string>
94 <key>NOTE</key>
95 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
96 <key>CFBundleExecutable</key>
97 <string>%s</string>
98 <key>SUPublicDSAKeyFile</key>
99 <string>dsa_pub.pem</string>
100 <key>CFBundleIconFile</key>
101 <string>demo.icns</string>
102</dict>
103</plist>'''
Yingdi Yu614db142013-10-09 16:35:53 -0700104
Yingdi Yu6df61252014-01-21 11:05:11 -0800105 # <key>LSUIElement</key>
106 # <string>1</string>
Yingdi Yub35b8652013-11-07 11:32:40 -0800107
Yingdi Yu6df61252014-01-21 11:05:11 -0800108 qt.mac_app = "ChronoChat.app"
109 qt.mac_plist = app_plist % "ChronoChat"
110 qt.mac_resources = 'demo.icns'
111 else:
112 bld (features = "subst",
113 source = 'linux/chronochat.desktop.in',
114 target = 'linux/chronochat.desktop',
115 BINARY = "ChronoChat",
116 install_path = "${DATAROOTDIR}/applications"
117 )
118 bld.install_files("${DATAROOTDIR}/chronochat",
119 bld.path.ant_glob(['linux/Resources/*']))
Yingdi Yub35b8652013-11-07 11:32:40 -0800120
121
Yingdi Yu614db142013-10-09 16:35:53 -0700122@Configure.conf
123def add_supported_cxxflags(self, cxxflags):
124 """
125 Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
126 """
127 self.start_msg('Checking allowed flags for c++ compiler')
128
129 supportedFlags = []
130 for flag in cxxflags:
131 if self.check_cxx (cxxflags=[flag], mandatory=False):
132 supportedFlags += [flag]
133
134 self.end_msg (' '.join (supportedFlags))
135 self.env.CXXFLAGS += supportedFlags