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; -*- |
Alexander Afanasyev | 37b9001 | 2013-11-07 23:28:10 -0800 | [diff] [blame] | 2 | VERSION='0.4' |
Yingdi Yu | aada52d | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 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 | 37b9001 | 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 | 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 | 25d8f3e | 2013-11-10 17:39:36 -0800 | [diff] [blame^] | 13 | if Utils.unversioned_sys_platform () != "darwin": |
| 14 | opt.load('gnu_dirs'); |
| 15 | |
Yingdi Yu | cf8a335 | 2013-11-07 11:44:39 -0800 | [diff] [blame] | 16 | # opt.load('tinyxml', tooldir=['waf-tools']) |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 17 | opt.load('cryptopp', tooldir=['waf-tools']) |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 18 | |
| 19 | def configure(conf): |
Yingdi Yu | cf8a335 | 2013-11-07 11:44:39 -0800 | [diff] [blame] | 20 | conf.load("compiler_c compiler_cxx boost protoc qt4 cryptopp") |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 21 | |
Yingdi Yu | 25d8f3e | 2013-11-10 17:39:36 -0800 | [diff] [blame^] | 22 | if Utils.unversioned_sys_platform () != "darwin": |
| 23 | conf.load('gnu_dirs'); |
| 24 | |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 25 | if conf.options.debug: |
| 26 | conf.define ('_DEBUG', 1) |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 27 | conf.env.DEBUG = 1 |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 28 | conf.add_supported_cxxflags (cxxflags = ['-O0', |
| 29 | '-Wall', |
| 30 | '-Wno-unused-variable', |
| 31 | '-g3', |
| 32 | '-Wno-unused-private-field', # only clang supports |
| 33 | '-fcolor-diagnostics', # only clang supports |
| 34 | '-Qunused-arguments', # only clang supports |
| 35 | ]) |
| 36 | else: |
| 37 | conf.add_supported_cxxflags (cxxflags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function']) |
| 38 | |
Yingdi Yu | ad56f1c | 2013-10-10 17:27:54 -0700 | [diff] [blame] | 39 | conf.check_cfg(package='libndn.cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX', mandatory=True) |
| 40 | 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] | 41 | if conf.options.log4cxx: |
| 42 | 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] | 43 | 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] | 44 | |
Yingdi Yu | 25d8f3e | 2013-11-10 17:39:36 -0800 | [diff] [blame^] | 45 | conf.check_cryptopp(path=conf.options.cryptopp_dir) |
| 46 | |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 47 | conf.check_boost(lib='system random thread filesystem') |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 48 | |
| 49 | conf.write_config_header('config.h') |
| 50 | |
| 51 | |
| 52 | def build (bld): |
| 53 | qt = bld ( |
Yingdi Yu | aada52d | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 54 | target = "ChronoChat", |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 55 | features = "qt4 cxx cxxprogram", |
| 56 | defines = "WAF", |
Yingdi Yu | 991177f | 2013-11-07 17:00:35 -0800 | [diff] [blame] | 57 | source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']), |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 58 | includes = "src .", |
Alexander Afanasyev | 37b9001 | 2013-11-07 23:28:10 -0800 | [diff] [blame] | 59 | use = "QTCORE QTGUI QTWIDGETS QTSQL SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX CRYPTOPP SYNC", |
Yingdi Yu | 68aced9 | 2013-10-17 21:13:03 -0700 | [diff] [blame] | 60 | ) |
| 61 | |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 62 | # if bld.env['DEBUG']: |
| 63 | # cert_publish = bld ( |
| 64 | # target = "CertPublish", |
| 65 | # features = "cxx cxxprogram", |
| 66 | # defines = "WAF", |
| 67 | # source = bld.path.ant_glob(['tmp/cert-publish.cpp']), |
| 68 | # includes = ". src", |
| 69 | # use = "SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX", |
| 70 | # ) |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 71 | |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 72 | if Utils.unversioned_sys_platform () == "darwin": |
| 73 | app_plist = '''<?xml version="1.0" encoding="UTF-8"?> |
| 74 | <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> |
| 75 | <plist version="0.9"> |
| 76 | <dict> |
| 77 | <key>CFBundlePackageType</key> |
| 78 | <string>APPL</string> |
| 79 | <key>CFBundleIconFile</key> |
| 80 | <string>demo.icns</string> |
| 81 | <key>CFBundleGetInfoString</key> |
| 82 | <string>Created by Waf</string> |
| 83 | <key>CFBundleIdentifier</key> |
Yingdi Yu | aada52d | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 84 | <string>edu.ucla.cs.irl.ChronoChat</string> |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 85 | <key>CFBundleSignature</key> |
| 86 | <string>????</string> |
| 87 | <key>NOTE</key> |
| 88 | <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string> |
| 89 | <key>CFBundleExecutable</key> |
| 90 | <string>%s</string> |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 91 | <key>SUPublicDSAKeyFile</key> |
| 92 | <string>dsa_pub.pem</string> |
| 93 | <key>CFBundleIconFile</key> |
| 94 | <string>demo.icns</string> |
| 95 | </dict> |
| 96 | </plist>''' |
| 97 | |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 98 | # <key>LSUIElement</key> |
| 99 | # <string>1</string> |
| 100 | |
Yingdi Yu | aada52d | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 101 | qt.mac_app = "ChronoChat.app" |
| 102 | qt.mac_plist = app_plist % "ChronoChat" |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 103 | qt.mac_resources = 'demo.icns' |
Yingdi Yu | 25d8f3e | 2013-11-10 17:39:36 -0800 | [diff] [blame^] | 104 | else: |
| 105 | bld (features = "subst", |
| 106 | source = 'linux/chronochat.desktop.in', |
| 107 | target = 'linux/chronochat.desktop', |
| 108 | BINARY = "ChronoChat", |
| 109 | install_path = "${DATAROOTDIR}/applications" |
| 110 | ) |
| 111 | bld.install_files("${DATAROOTDIR}/chronochat", |
| 112 | bld.path.ant_glob(['linux/Resources/*'])) |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 113 | |
| 114 | |
| 115 | from waflib import TaskGen |
| 116 | @TaskGen.extension('.mm') |
| 117 | def m_hook(self, node): |
| 118 | """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing.""" |
| 119 | return self.create_compiled_task('cxx', node) |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 120 | |
| 121 | @Configure.conf |
| 122 | def add_supported_cxxflags(self, cxxflags): |
| 123 | """ |
| 124 | Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable |
| 125 | """ |
| 126 | self.start_msg('Checking allowed flags for c++ compiler') |
| 127 | |
| 128 | supportedFlags = [] |
| 129 | for flag in cxxflags: |
| 130 | if self.check_cxx (cxxflags=[flag], mandatory=False): |
| 131 | supportedFlags += [flag] |
| 132 | |
| 133 | self.end_msg (' '.join (supportedFlags)) |
| 134 | self.env.CXXFLAGS += supportedFlags |