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; -*- |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 2 | VERSION='0.5' |
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''') |
Yingdi Yu | fa4ce79 | 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 | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 12 | |
Alexander Afanasyev | c729176 | 2013-11-14 13:50:27 -0800 | [diff] [blame] | 13 | opt.load('compiler_c compiler_cxx qt4') |
Yingdi Yu | d04ed1a | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 14 | |
Yingdi Yu | e370a2a | 2013-11-10 17:39:36 -0800 | [diff] [blame] | 15 | if Utils.unversioned_sys_platform () != "darwin": |
| 16 | opt.load('gnu_dirs'); |
| 17 | |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 18 | opt.load('boost protoc', tooldir=['waf-tools']) |
Yingdi Yu | a43601f | 2014-05-09 14:29:16 -0700 | [diff] [blame] | 19 | |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 20 | def configure(conf): |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 21 | conf.load("compiler_c compiler_cxx boost protoc qt4") |
Alexander Afanasyev | b4b9229 | 2013-07-09 13:54:59 -0700 | [diff] [blame] | 22 | |
Yingdi Yu | e370a2a | 2013-11-10 17:39:36 -0800 | [diff] [blame] | 23 | if Utils.unversioned_sys_platform () != "darwin": |
| 24 | conf.load('gnu_dirs'); |
| 25 | |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 26 | if conf.options.debug: |
| 27 | conf.define ('_DEBUG', 1) |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 28 | conf.env['_DEBUG'] = True; |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 29 | flags = ['-O0', |
| 30 | '-Wall', |
| 31 | '-Wno-unused-variable', |
| 32 | '-g3', |
| 33 | '-Wno-unused-private-field', # only clang supports |
| 34 | '-fcolor-diagnostics', # only clang supports |
| 35 | '-Qunused-arguments', # only clang supports |
| 36 | '-Wno-deprecated-declarations', |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 37 | '-Wno-unneeded-internal-declaration', |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 38 | ] |
| 39 | |
| 40 | conf.add_supported_cxxflags (cxxflags = flags) |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 41 | else: |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 42 | flags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function', '-Wno-deprecated-declarations'] |
| 43 | conf.add_supported_cxxflags (cxxflags = flags) |
| 44 | |
| 45 | conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], uselib_store='NDN_CPP', mandatory=True) |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 46 | |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 47 | |
Alexander Afanasyev | 4a97931 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 48 | if conf.options.log4cxx: |
| 49 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 50 | conf.define ("HAVE_LOG4CXX", 1) |
| 51 | |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 52 | 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] | 53 | |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 54 | conf.check_boost(lib='system random thread filesystem unit_test_framework') |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 55 | |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 56 | if conf.options.with_tests: |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 57 | conf.env['WITH_TESTS'] = True |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 58 | conf.define('WITH_TESTS', 1) |
| 59 | |
| 60 | |
| 61 | if conf.options.with_security: |
| 62 | conf.define('WITH_SECURITY', 1) |
| 63 | |
| 64 | conf.write_config_header('src/config.h') |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 65 | |
| 66 | def build (bld): |
| 67 | qt = bld ( |
Yingdi Yu | d681e21 | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 68 | target = "ChronoChat", |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 69 | features = "qt4 cxx cxxprogram", |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 70 | # features= "qt4 cxx cxxshlib", |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 71 | defines = "WAF", |
Yingdi Yu | c5020b9 | 2013-11-07 17:00:35 -0800 | [diff] [blame] | 72 | 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] | 73 | includes = "src .", |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 74 | use = "QTCORE QTGUI QTWIDGETS QTSQL NDN_CPP BOOST LOG4CXX SYNC", |
Yingdi Yu | 92e8e48 | 2013-10-17 21:13:03 -0700 | [diff] [blame] | 75 | ) |
| 76 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 77 | # Unit tests |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 78 | # if bld.env["WITH_TESTS"]: |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 79 | # unittests = bld.program ( |
| 80 | # target="unit-tests", |
| 81 | # source = bld.path.ant_glob(['test/**/*.cc']), |
| 82 | # features=['cxx', 'cxxprogram'], |
| 83 | # use = 'BOOST ChronoChat', |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 84 | # includes = "src", |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 85 | # install_path = None, |
| 86 | # ) |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 87 | |
| 88 | # Debug tools |
| 89 | if bld.env["_DEBUG"]: |
| 90 | for app in bld.path.ant_glob('debug-tools/*.cc'): |
| 91 | bld(features=['cxx', 'cxxprogram'], |
| 92 | target = '%s' % (str(app.change_ext('','.cc'))), |
| 93 | source = app, |
| 94 | use = 'NDN_CPP', |
| 95 | install_path = None, |
| 96 | ) |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame] | 97 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 98 | # Tmp disable |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 99 | if Utils.unversioned_sys_platform () == "darwin": |
| 100 | app_plist = '''<?xml version="1.0" encoding="UTF-8"?> |
| 101 | <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> |
| 102 | <plist version="0.9"> |
| 103 | <dict> |
| 104 | <key>CFBundlePackageType</key> |
| 105 | <string>APPL</string> |
| 106 | <key>CFBundleIconFile</key> |
| 107 | <string>demo.icns</string> |
| 108 | <key>CFBundleGetInfoString</key> |
| 109 | <string>Created by Waf</string> |
| 110 | <key>CFBundleIdentifier</key> |
| 111 | <string>edu.ucla.cs.irl.ChronoChat</string> |
| 112 | <key>CFBundleSignature</key> |
| 113 | <string>????</string> |
| 114 | <key>NOTE</key> |
| 115 | <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string> |
| 116 | <key>CFBundleExecutable</key> |
| 117 | <string>%s</string> |
| 118 | <key>SUPublicDSAKeyFile</key> |
| 119 | <string>dsa_pub.pem</string> |
| 120 | <key>CFBundleIconFile</key> |
| 121 | <string>demo.icns</string> |
| 122 | </dict> |
| 123 | </plist>''' |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 124 | |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 125 | # <key>LSUIElement</key> |
| 126 | # <string>1</string> |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 127 | |
Yingdi Yu | b6fb030 | 2014-01-21 11:05:11 -0800 | [diff] [blame] | 128 | qt.mac_app = "ChronoChat.app" |
| 129 | qt.mac_plist = app_plist % "ChronoChat" |
| 130 | qt.mac_resources = 'demo.icns' |
| 131 | else: |
| 132 | bld (features = "subst", |
| 133 | source = 'linux/chronochat.desktop.in', |
| 134 | target = 'linux/chronochat.desktop', |
| 135 | BINARY = "ChronoChat", |
| 136 | install_path = "${DATAROOTDIR}/applications" |
| 137 | ) |
| 138 | bld.install_files("${DATAROOTDIR}/chronochat", |
| 139 | bld.path.ant_glob(['linux/Resources/*'])) |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 140 | |
| 141 | |
Yingdi Yu | 847aa86 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 142 | @Configure.conf |
| 143 | def add_supported_cxxflags(self, cxxflags): |
| 144 | """ |
| 145 | Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable |
| 146 | """ |
| 147 | self.start_msg('Checking allowed flags for c++ compiler') |
| 148 | |
| 149 | supportedFlags = [] |
| 150 | for flag in cxxflags: |
| 151 | if self.check_cxx (cxxflags=[flag], mandatory=False): |
| 152 | supportedFlags += [flag] |
| 153 | |
| 154 | self.end_msg (' '.join (supportedFlags)) |
| 155 | self.env.CXXFLAGS += supportedFlags |