blob: 3dcfe07a7cc2876a7cb5bda3f747925b9e4934d4 [file] [log] [blame]
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyev46c7f842013-11-07 23:28:10 -08002VERSION='0.4'
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''')
Alexander Afanasyev46c7f842013-11-07 23:28:10 -08009 opt.add_option('--log4cxx',action='store_true',default=False,dest='log4cxx',help='''Enable log4cxx''')
Yingdi Yue35bdb82013-11-07 11:32:40 -080010
Alexander Afanasyevc7291762013-11-14 13:50:27 -080011 opt.load('compiler_c compiler_cxx qt4')
Yingdi Yud04ed1a2013-10-14 14:07:03 -070012
Yingdi Yue370a2a2013-11-10 17:39:36 -080013 if Utils.unversioned_sys_platform () != "darwin":
14 opt.load('gnu_dirs');
15
Alexander Afanasyevc7291762013-11-14 13:50:27 -080016 opt.load('boost protoc cryptopp', tooldir=['waf-tools'])
Yingdi Yua43601f2014-05-09 14:29:16 -070017
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070018def configure(conf):
Yingdi Yu382bcb92013-11-07 11:44:39 -080019 conf.load("compiler_c compiler_cxx boost protoc qt4 cryptopp")
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070020
Yingdi Yue370a2a2013-11-10 17:39:36 -080021 if Utils.unversioned_sys_platform () != "darwin":
22 conf.load('gnu_dirs');
23
Yingdi Yue35bdb82013-11-07 11:32:40 -080024 if conf.options.debug:
25 conf.define ('_DEBUG', 1)
Alexander Afanasyev4a979312013-11-07 15:30:05 -080026 conf.env.DEBUG = 1
Yingdi Yue35bdb82013-11-07 11:32:40 -080027 conf.add_supported_cxxflags (cxxflags = ['-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 ])
35 else:
36 conf.add_supported_cxxflags (cxxflags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function'])
37
Yingdi Yu4390ce52013-10-10 17:27:54 -070038 conf.check_cfg(package='libndn.cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX', mandatory=True)
39 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
Alexander Afanasyev4a979312013-11-07 15:30:05 -080040 if conf.options.log4cxx:
41 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
Yingdi Yub2e747d2013-11-05 23:06:43 -080042 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], uselib_store='SYNC', mandatory=True)
Yingdi Yu4390ce52013-10-10 17:27:54 -070043
Yingdi Yue370a2a2013-11-10 17:39:36 -080044 conf.check_cryptopp(path=conf.options.cryptopp_dir)
45
Yingdi Yud04ed1a2013-10-14 14:07:03 -070046 conf.check_boost(lib='system random thread filesystem')
Yingdi Yu847aa862013-10-09 16:35:53 -070047
48 conf.write_config_header('config.h')
49
50
51def build (bld):
52 qt = bld (
Yingdi Yud681e212013-11-07 11:36:50 -080053 target = "ChronoChat",
Yingdi Yu847aa862013-10-09 16:35:53 -070054 features = "qt4 cxx cxxprogram",
55 defines = "WAF",
Yingdi Yuc5020b92013-11-07 17:00:35 -080056 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']),
Alexander Afanasyev4a979312013-11-07 15:30:05 -080057 includes = "src .",
Alexander Afanasyev46c7f842013-11-07 23:28:10 -080058 use = "QTCORE QTGUI QTWIDGETS QTSQL SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX CRYPTOPP SYNC",
Yingdi Yu92e8e482013-10-17 21:13:03 -070059 )
60
Alexander Afanasyev4a979312013-11-07 15:30:05 -080061 # if bld.env['DEBUG']:
62 # cert_publish = bld (
63 # target = "CertPublish",
64 # features = "cxx cxxprogram",
65 # defines = "WAF",
66 # source = bld.path.ant_glob(['tmp/cert-publish.cpp']),
67 # includes = ". src",
68 # use = "SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX",
69 # )
Yingdi Yu847aa862013-10-09 16:35:53 -070070
Yingdi Yue35bdb82013-11-07 11:32:40 -080071 if Utils.unversioned_sys_platform () == "darwin":
72 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
73<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
74<plist version="0.9">
75<dict>
76 <key>CFBundlePackageType</key>
77 <string>APPL</string>
78 <key>CFBundleIconFile</key>
79 <string>demo.icns</string>
80 <key>CFBundleGetInfoString</key>
81 <string>Created by Waf</string>
82 <key>CFBundleIdentifier</key>
Yingdi Yud681e212013-11-07 11:36:50 -080083 <string>edu.ucla.cs.irl.ChronoChat</string>
Yingdi Yue35bdb82013-11-07 11:32:40 -080084 <key>CFBundleSignature</key>
85 <string>????</string>
86 <key>NOTE</key>
87 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
88 <key>CFBundleExecutable</key>
89 <string>%s</string>
Yingdi Yue35bdb82013-11-07 11:32:40 -080090 <key>SUPublicDSAKeyFile</key>
91 <string>dsa_pub.pem</string>
92 <key>CFBundleIconFile</key>
93 <string>demo.icns</string>
94</dict>
95</plist>'''
96
Alexander Afanasyev4a979312013-11-07 15:30:05 -080097 # <key>LSUIElement</key>
98 # <string>1</string>
99
Yingdi Yud681e212013-11-07 11:36:50 -0800100 qt.mac_app = "ChronoChat.app"
101 qt.mac_plist = app_plist % "ChronoChat"
Yingdi Yue35bdb82013-11-07 11:32:40 -0800102 qt.mac_resources = 'demo.icns'
Yingdi Yue370a2a2013-11-10 17:39:36 -0800103 else:
104 bld (features = "subst",
105 source = 'linux/chronochat.desktop.in',
106 target = 'linux/chronochat.desktop',
107 BINARY = "ChronoChat",
108 install_path = "${DATAROOTDIR}/applications"
109 )
110 bld.install_files("${DATAROOTDIR}/chronochat",
111 bld.path.ant_glob(['linux/Resources/*']))
Yingdi Yue35bdb82013-11-07 11:32:40 -0800112
113
114from waflib import TaskGen
115@TaskGen.extension('.mm')
116def m_hook(self, node):
117 """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
118 return self.create_compiled_task('cxx', node)
Yingdi Yu847aa862013-10-09 16:35:53 -0700119
120@Configure.conf
121def add_supported_cxxflags(self, cxxflags):
122 """
123 Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
124 """
125 self.start_msg('Checking allowed flags for c++ compiler')
126
127 supportedFlags = []
128 for flag in cxxflags:
129 if self.check_cxx (cxxflags=[flag], mandatory=False):
130 supportedFlags += [flag]
131
132 self.end_msg (' '.join (supportedFlags))
133 self.env.CXXFLAGS += supportedFlags