Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Alexander Afanasyev | 46c7f84 | 2013-11-07 23:28:10 -0800 | [diff] [blame^] | 2 | VERSION='0.4' |
Yingdi Yu | d681e21 | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 3 | APPNAME='ChronoChat' |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 4 | |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 5 | from waflib import Configure, Utils |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 6 | |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 7 | def options(opt): |
Yingdi Yu | e35bdb8 | 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 | 46c7f84 | 2013-11-07 23:28:10 -0800 | [diff] [blame^] | 9 | opt.add_option('--log4cxx',action='store_true',default=False,dest='log4cxx',help='''Enable log4cxx''') |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 10 | |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 11 | opt.load('compiler_c compiler_cxx boost protoc qt4') |
Yingdi Yu | d04ed1a | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 12 | |
Yingdi Yu | 382bcb9 | 2013-11-07 11:44:39 -0800 | [diff] [blame] | 13 | # opt.load('tinyxml', tooldir=['waf-tools']) |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 14 | opt.load('cryptopp', tooldir=['waf-tools']) |
Yingdi Yu | a43601f | 2014-05-09 14:29:16 -0700 | [diff] [blame] | 15 | |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 16 | def configure(conf): |
Yingdi Yu | 382bcb9 | 2013-11-07 11:44:39 -0800 | [diff] [blame] | 17 | conf.load("compiler_c compiler_cxx boost protoc qt4 cryptopp") |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 18 | |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 19 | if conf.options.debug: |
| 20 | conf.define ('_DEBUG', 1) |
Alexander Afanasyev | 4a97931 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 21 | conf.env.DEBUG = 1 |
Yingdi Yu | e35bdb8 | 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 | 4390ce5 | 2013-10-10 17:27:54 -0700 | [diff] [blame] | 33 | 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 Afanasyev | 4a97931 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 35 | if conf.options.log4cxx: |
| 36 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 37 | conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], uselib_store='SYNC', mandatory=True) |
Yingdi Yu | 4390ce5 | 2013-10-10 17:27:54 -0700 | [diff] [blame] | 38 | |
Yingdi Yu | d04ed1a | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 39 | conf.check_boost(lib='system random thread filesystem') |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 40 | |
| 41 | conf.write_config_header('config.h') |
| 42 | |
| 43 | |
| 44 | def build (bld): |
| 45 | qt = bld ( |
Yingdi Yu | d681e21 | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 46 | target = "ChronoChat", |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 47 | features = "qt4 cxx cxxprogram", |
| 48 | defines = "WAF", |
Yingdi Yu | c5020b9 | 2013-11-07 17:00:35 -0800 | [diff] [blame] | 49 | source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']), |
Alexander Afanasyev | 4a97931 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 50 | includes = "src .", |
Alexander Afanasyev | 46c7f84 | 2013-11-07 23:28:10 -0800 | [diff] [blame^] | 51 | use = "QTCORE QTGUI QTWIDGETS QTSQL SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX CRYPTOPP SYNC", |
Yingdi Yu | 92e8e48 | 2013-10-17 21:13:03 -0700 | [diff] [blame] | 52 | ) |
| 53 | |
Alexander Afanasyev | 4a97931 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 54 | # 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 Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 63 | |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 64 | 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 Yu | d681e21 | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 76 | <string>edu.ucla.cs.irl.ChronoChat</string> |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 77 | <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 Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 83 | <key>SUPublicDSAKeyFile</key> |
| 84 | <string>dsa_pub.pem</string> |
| 85 | <key>CFBundleIconFile</key> |
| 86 | <string>demo.icns</string> |
| 87 | </dict> |
| 88 | </plist>''' |
| 89 | |
Alexander Afanasyev | 4a97931 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 90 | # <key>LSUIElement</key> |
| 91 | # <string>1</string> |
| 92 | |
Yingdi Yu | d681e21 | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 93 | qt.mac_app = "ChronoChat.app" |
| 94 | qt.mac_plist = app_plist % "ChronoChat" |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 95 | qt.mac_resources = 'demo.icns' |
| 96 | |
| 97 | |
| 98 | from waflib import TaskGen |
| 99 | @TaskGen.extension('.mm') |
| 100 | def 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 Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 103 | |
| 104 | @Configure.conf |
| 105 | def 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 |