blob: 04433814de77d8df548283677c8680135bb71f02 [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 Yub35b8652013-11-07 11:32:40 -080010
Yingdi Yu767d2ac2013-10-09 15:16:11 -070011 opt.load('compiler_c compiler_cxx boost protoc qt4')
Yingdi Yuede8eaf2013-10-14 14:07:03 -070012
Yingdi Yucf8a3352013-11-07 11:44:39 -080013 # opt.load('tinyxml', tooldir=['waf-tools'])
Yingdi Yu8dacdf22013-11-05 23:06:43 -080014 opt.load('cryptopp', tooldir=['waf-tools'])
Yingdi Yu767d2ac2013-10-09 15:16:11 -070015
16def configure(conf):
Yingdi Yucf8a3352013-11-07 11:44:39 -080017 conf.load("compiler_c compiler_cxx boost protoc qt4 cryptopp")
Yingdi Yu767d2ac2013-10-09 15:16:11 -070018
Yingdi Yub35b8652013-11-07 11:32:40 -080019 if conf.options.debug:
20 conf.define ('_DEBUG', 1)
Alexander Afanasyev4f04c552013-11-07 15:30:05 -080021 conf.env.DEBUG = 1
Yingdi Yub35b8652013-11-07 11:32:40 -080022 conf.add_supported_cxxflags (cxxflags = ['-O0',
23 '-Wall',
24 '-Wno-unused-variable',
25 '-g3',
26 '-Wno-unused-private-field', # only clang supports
27 '-fcolor-diagnostics', # only clang supports
28 '-Qunused-arguments', # only clang supports
29 ])
30 else:
31 conf.add_supported_cxxflags (cxxflags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function'])
32
Yingdi Yuad56f1c2013-10-10 17:27:54 -070033 conf.check_cfg(package='libndn.cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX', mandatory=True)
34 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
Alexander Afanasyev4f04c552013-11-07 15:30:05 -080035 if conf.options.log4cxx:
36 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
Yingdi Yu8dacdf22013-11-05 23:06:43 -080037 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], uselib_store='SYNC', mandatory=True)
Yingdi Yuad56f1c2013-10-10 17:27:54 -070038
Yingdi Yuede8eaf2013-10-14 14:07:03 -070039 conf.check_boost(lib='system random thread filesystem')
Yingdi Yu614db142013-10-09 16:35:53 -070040
41 conf.write_config_header('config.h')
42
43
44def build (bld):
45 qt = bld (
Yingdi Yuaada52d2013-11-07 11:36:50 -080046 target = "ChronoChat",
Yingdi Yu614db142013-10-09 16:35:53 -070047 features = "qt4 cxx cxxprogram",
48 defines = "WAF",
Yingdi Yu991177f2013-11-07 17:00:35 -080049 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']),
Alexander Afanasyev4f04c552013-11-07 15:30:05 -080050 includes = "src .",
Alexander Afanasyev37b90012013-11-07 23:28:10 -080051 use = "QTCORE QTGUI QTWIDGETS QTSQL SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX CRYPTOPP SYNC",
Yingdi Yu68aced92013-10-17 21:13:03 -070052 )
53
Alexander Afanasyev4f04c552013-11-07 15:30:05 -080054 # if bld.env['DEBUG']:
55 # cert_publish = bld (
56 # target = "CertPublish",
57 # features = "cxx cxxprogram",
58 # defines = "WAF",
59 # source = bld.path.ant_glob(['tmp/cert-publish.cpp']),
60 # includes = ". src",
61 # use = "SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX",
62 # )
Yingdi Yu614db142013-10-09 16:35:53 -070063
Yingdi Yub35b8652013-11-07 11:32:40 -080064 if Utils.unversioned_sys_platform () == "darwin":
65 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
66<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
67<plist version="0.9">
68<dict>
69 <key>CFBundlePackageType</key>
70 <string>APPL</string>
71 <key>CFBundleIconFile</key>
72 <string>demo.icns</string>
73 <key>CFBundleGetInfoString</key>
74 <string>Created by Waf</string>
75 <key>CFBundleIdentifier</key>
Yingdi Yuaada52d2013-11-07 11:36:50 -080076 <string>edu.ucla.cs.irl.ChronoChat</string>
Yingdi Yub35b8652013-11-07 11:32:40 -080077 <key>CFBundleSignature</key>
78 <string>????</string>
79 <key>NOTE</key>
80 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
81 <key>CFBundleExecutable</key>
82 <string>%s</string>
Yingdi Yub35b8652013-11-07 11:32:40 -080083 <key>SUPublicDSAKeyFile</key>
84 <string>dsa_pub.pem</string>
85 <key>CFBundleIconFile</key>
86 <string>demo.icns</string>
87</dict>
88</plist>'''
89
Alexander Afanasyev4f04c552013-11-07 15:30:05 -080090 # <key>LSUIElement</key>
91 # <string>1</string>
92
Yingdi Yuaada52d2013-11-07 11:36:50 -080093 qt.mac_app = "ChronoChat.app"
94 qt.mac_plist = app_plist % "ChronoChat"
Yingdi Yub35b8652013-11-07 11:32:40 -080095 qt.mac_resources = 'demo.icns'
96
97
98from waflib import TaskGen
99@TaskGen.extension('.mm')
100def m_hook(self, node):
101 """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
102 return self.create_compiled_task('cxx', node)
Yingdi Yu614db142013-10-09 16:35:53 -0700103
104@Configure.conf
105def add_supported_cxxflags(self, cxxflags):
106 """
107 Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
108 """
109 self.start_msg('Checking allowed flags for c++ compiler')
110
111 supportedFlags = []
112 for flag in cxxflags:
113 if self.check_cxx (cxxflags=[flag], mandatory=False):
114 supportedFlags += [flag]
115
116 self.end_msg (' '.join (supportedFlags))
117 self.env.CXXFLAGS += supportedFlags