Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Yingdi Yu | aada52d | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 2 | VERSION='1.0' |
| 3 | APPNAME='ChronoChat' |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 4 | |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 5 | from waflib import Configure, Utils |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 6 | |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 7 | def options(opt): |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 8 | opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''') |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame^] | 9 | opt.add_option('--no-log4cxx',action='store_false',default=True,dest='log4cxx',help='''Disable log4cxx''') |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 10 | |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 11 | opt.load('compiler_c compiler_cxx boost protoc qt4') |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 12 | |
Yingdi Yu | cf8a335 | 2013-11-07 11:44:39 -0800 | [diff] [blame] | 13 | # opt.load('tinyxml', tooldir=['waf-tools']) |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 14 | opt.load('cryptopp', tooldir=['waf-tools']) |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 15 | |
| 16 | def configure(conf): |
Yingdi Yu | cf8a335 | 2013-11-07 11:44:39 -0800 | [diff] [blame] | 17 | conf.load("compiler_c compiler_cxx boost protoc qt4 cryptopp") |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 18 | |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 19 | if conf.options.debug: |
| 20 | conf.define ('_DEBUG', 1) |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame^] | 21 | conf.env.DEBUG = 1 |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 22 | 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 Yu | cf8a335 | 2013-11-07 11:44:39 -0800 | [diff] [blame] | 33 | # conf.check_tinyxml(path=conf.options.tinyxml_dir) |
Yingdi Yu | ad56f1c | 2013-10-10 17:27:54 -0700 | [diff] [blame] | 34 | conf.check_cfg(package='libndn.cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX', mandatory=True) |
| 35 | conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True) |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame^] | 36 | if conf.options.log4cxx: |
| 37 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 38 | conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], uselib_store='SYNC', mandatory=True) |
Yingdi Yu | ad56f1c | 2013-10-10 17:27:54 -0700 | [diff] [blame] | 39 | |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 40 | conf.check_boost(lib='system random thread filesystem') |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 41 | |
| 42 | conf.write_config_header('config.h') |
| 43 | |
| 44 | |
| 45 | def build (bld): |
| 46 | qt = bld ( |
Yingdi Yu | aada52d | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 47 | target = "ChronoChat", |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 48 | features = "qt4 cxx cxxprogram", |
| 49 | defines = "WAF", |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 50 | source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', 'logging.cc', 'src/*.proto']), |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame^] | 51 | includes = "src .", |
Yingdi Yu | cf8a335 | 2013-11-07 11:44:39 -0800 | [diff] [blame] | 52 | use = "QTCORE QTGUI QTSQL SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX CRYPTOPP SYNC", |
Yingdi Yu | 68aced9 | 2013-10-17 21:13:03 -0700 | [diff] [blame] | 53 | ) |
| 54 | |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame^] | 55 | # if bld.env['DEBUG']: |
| 56 | # cert_publish = bld ( |
| 57 | # target = "CertPublish", |
| 58 | # features = "cxx cxxprogram", |
| 59 | # defines = "WAF", |
| 60 | # source = bld.path.ant_glob(['tmp/cert-publish.cpp']), |
| 61 | # includes = ". src", |
| 62 | # use = "SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX", |
| 63 | # ) |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 64 | |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 65 | if Utils.unversioned_sys_platform () == "darwin": |
| 66 | app_plist = '''<?xml version="1.0" encoding="UTF-8"?> |
| 67 | <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> |
| 68 | <plist version="0.9"> |
| 69 | <dict> |
| 70 | <key>CFBundlePackageType</key> |
| 71 | <string>APPL</string> |
| 72 | <key>CFBundleIconFile</key> |
| 73 | <string>demo.icns</string> |
| 74 | <key>CFBundleGetInfoString</key> |
| 75 | <string>Created by Waf</string> |
| 76 | <key>CFBundleIdentifier</key> |
Yingdi Yu | aada52d | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 77 | <string>edu.ucla.cs.irl.ChronoChat</string> |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 78 | <key>CFBundleSignature</key> |
| 79 | <string>????</string> |
| 80 | <key>NOTE</key> |
| 81 | <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string> |
| 82 | <key>CFBundleExecutable</key> |
| 83 | <string>%s</string> |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 84 | <key>SUPublicDSAKeyFile</key> |
| 85 | <string>dsa_pub.pem</string> |
| 86 | <key>CFBundleIconFile</key> |
| 87 | <string>demo.icns</string> |
| 88 | </dict> |
| 89 | </plist>''' |
| 90 | |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame^] | 91 | # <key>LSUIElement</key> |
| 92 | # <string>1</string> |
| 93 | |
Yingdi Yu | aada52d | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 94 | qt.mac_app = "ChronoChat.app" |
| 95 | qt.mac_plist = app_plist % "ChronoChat" |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 96 | qt.mac_resources = 'demo.icns' |
| 97 | |
| 98 | |
| 99 | from waflib import TaskGen |
| 100 | @TaskGen.extension('.mm') |
| 101 | def m_hook(self, node): |
| 102 | """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing.""" |
| 103 | return self.create_compiled_task('cxx', node) |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 104 | |
| 105 | @Configure.conf |
| 106 | def add_supported_cxxflags(self, cxxflags): |
| 107 | """ |
| 108 | Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable |
| 109 | """ |
| 110 | self.start_msg('Checking allowed flags for c++ compiler') |
| 111 | |
| 112 | supportedFlags = [] |
| 113 | for flag in cxxflags: |
| 114 | if self.check_cxx (cxxflags=[flag], mandatory=False): |
| 115 | supportedFlags += [flag] |
| 116 | |
| 117 | self.end_msg (' '.join (supportedFlags)) |
| 118 | self.env.CXXFLAGS += supportedFlags |