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