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 | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 2 | VERSION='0.5' |
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 | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 10 | opt.add_option('--with-test', action='store_true',default=False,dest='with_tests',help='''build unit tests''') |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 11 | |
Alexander Afanasyev | 30cf2bf | 2013-11-14 13:50:27 -0800 | [diff] [blame] | 12 | opt.load('compiler_c compiler_cxx qt4') |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 13 | |
Yingdi Yu | 25d8f3e | 2013-11-10 17:39:36 -0800 | [diff] [blame] | 14 | if Utils.unversioned_sys_platform () != "darwin": |
| 15 | opt.load('gnu_dirs'); |
| 16 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 17 | opt.load('boost protoc', tooldir=['waf-tools']) |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 18 | |
| 19 | def configure(conf): |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 20 | conf.load("compiler_c compiler_cxx boost protoc qt4") |
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) |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 27 | flags = ['-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 | '-Wno-deprecated-declarations', |
| 35 | ] |
| 36 | |
| 37 | conf.add_supported_cxxflags (cxxflags = flags) |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 38 | else: |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 39 | flags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function', '-Wno-deprecated-declarations'] |
| 40 | conf.add_supported_cxxflags (cxxflags = flags) |
| 41 | |
| 42 | conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], uselib_store='NDN_CPP', mandatory=True) |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 43 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 44 | |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 45 | if conf.options.log4cxx: |
| 46 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 47 | conf.define ("HAVE_LOG4CXX", 1) |
| 48 | |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 49 | 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] | 50 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 51 | conf.check_boost(lib='system random thread filesystem unit_test_framework') |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 52 | |
| 53 | conf.write_config_header('config.h') |
| 54 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 55 | if conf.options.with_tests: |
| 56 | conf.define('WITH_TESTS', 1) |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 57 | |
| 58 | def build (bld): |
| 59 | qt = bld ( |
Yingdi Yu | aada52d | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 60 | target = "ChronoChat", |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 61 | features = "qt4 cxx cxxprogram", |
| 62 | # features= "qt4 cxx cxxshlib", |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 63 | defines = "WAF", |
Yingdi Yu | 991177f | 2013-11-07 17:00:35 -0800 | [diff] [blame] | 64 | 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] | 65 | includes = "src .", |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 66 | use = "QTCORE QTGUI QTWIDGETS QTSQL SQLITE3 NDN_CPP BOOST LOG4CXX SYNC", |
Yingdi Yu | 68aced9 | 2013-10-17 21:13:03 -0700 | [diff] [blame] | 67 | ) |
| 68 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 69 | # Unit tests |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 70 | # if bld.get_define("WITH_TESTS"): |
| 71 | # unittests = bld.program ( |
| 72 | # target="unit-tests", |
| 73 | # source = bld.path.ant_glob(['test/**/*.cc']), |
| 74 | # features=['cxx', 'cxxprogram'], |
| 75 | # use = 'BOOST ChronoChat', |
| 76 | # install_path = None, |
| 77 | # ) |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 78 | # Tmp disable |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 79 | if Utils.unversioned_sys_platform () == "darwin": |
| 80 | app_plist = '''<?xml version="1.0" encoding="UTF-8"?> |
| 81 | <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> |
| 82 | <plist version="0.9"> |
| 83 | <dict> |
| 84 | <key>CFBundlePackageType</key> |
| 85 | <string>APPL</string> |
| 86 | <key>CFBundleIconFile</key> |
| 87 | <string>demo.icns</string> |
| 88 | <key>CFBundleGetInfoString</key> |
| 89 | <string>Created by Waf</string> |
| 90 | <key>CFBundleIdentifier</key> |
| 91 | <string>edu.ucla.cs.irl.ChronoChat</string> |
| 92 | <key>CFBundleSignature</key> |
| 93 | <string>????</string> |
| 94 | <key>NOTE</key> |
| 95 | <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string> |
| 96 | <key>CFBundleExecutable</key> |
| 97 | <string>%s</string> |
| 98 | <key>SUPublicDSAKeyFile</key> |
| 99 | <string>dsa_pub.pem</string> |
| 100 | <key>CFBundleIconFile</key> |
| 101 | <string>demo.icns</string> |
| 102 | </dict> |
| 103 | </plist>''' |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 104 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 105 | # <key>LSUIElement</key> |
| 106 | # <string>1</string> |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 107 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 108 | qt.mac_app = "ChronoChat.app" |
| 109 | qt.mac_plist = app_plist % "ChronoChat" |
| 110 | qt.mac_resources = 'demo.icns' |
| 111 | else: |
| 112 | bld (features = "subst", |
| 113 | source = 'linux/chronochat.desktop.in', |
| 114 | target = 'linux/chronochat.desktop', |
| 115 | BINARY = "ChronoChat", |
| 116 | install_path = "${DATAROOTDIR}/applications" |
| 117 | ) |
| 118 | bld.install_files("${DATAROOTDIR}/chronochat", |
| 119 | bld.path.ant_glob(['linux/Resources/*'])) |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 120 | |
| 121 | |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 122 | @Configure.conf |
| 123 | def add_supported_cxxflags(self, cxxflags): |
| 124 | """ |
| 125 | Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable |
| 126 | """ |
| 127 | self.start_msg('Checking allowed flags for c++ compiler') |
| 128 | |
| 129 | supportedFlags = [] |
| 130 | for flag in cxxflags: |
| 131 | if self.check_cxx (cxxflags=[flag], mandatory=False): |
| 132 | supportedFlags += [flag] |
| 133 | |
| 134 | self.end_msg (' '.join (supportedFlags)) |
| 135 | self.env.CXXFLAGS += supportedFlags |