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 | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 10 | opt.add_option('--test', action='store_true',default=False,dest='_test',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 | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 17 | opt.load('boost protoc cryptopp ndn_cpp', tooldir=['waf-tools']) |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 18 | |
| 19 | def configure(conf): |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 20 | conf.load("compiler_c compiler_cxx boost protoc qt4 cryptopp ndn_cpp") |
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 | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 39 | conf.check_ndncpp (path=conf.options.ndn_cpp_dir) |
| 40 | conf.check_cfg(package='libndn-cpp-et', args=['--cflags', '--libs'], uselib_store='NDN-CPP-ET', mandatory=True) |
| 41 | |
Yingdi Yu | ad56f1c | 2013-10-10 17:27:54 -0700 | [diff] [blame] | 42 | 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] | 43 | if conf.options.log4cxx: |
| 44 | 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] | 45 | 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] | 46 | |
Yingdi Yu | 25d8f3e | 2013-11-10 17:39:36 -0800 | [diff] [blame] | 47 | conf.check_cryptopp(path=conf.options.cryptopp_dir) |
| 48 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 49 | conf.check_boost(lib='system random thread filesystem test') |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 50 | |
| 51 | conf.write_config_header('config.h') |
| 52 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 53 | if conf.options._test: |
| 54 | conf.define('_TEST', 1) |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 55 | |
| 56 | def build (bld): |
| 57 | qt = bld ( |
Yingdi Yu | aada52d | 2013-11-07 11:36:50 -0800 | [diff] [blame] | 58 | target = "ChronoChat", |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 59 | # features = "qt4 cxx cxxprogram", |
| 60 | features= "qt4 cxx cxxshlib", |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 61 | defines = "WAF", |
Yingdi Yu | 991177f | 2013-11-07 17:00:35 -0800 | [diff] [blame] | 62 | 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] | 63 | includes = "src .", |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 64 | use = "QTCORE QTGUI QTWIDGETS QTSQL SQLITE3 NDNCPP NDN-CPP-ET BOOST BOOST_FILESYSTEM LOG4CXX CRYPTOPP SYNC", |
Yingdi Yu | 68aced9 | 2013-10-17 21:13:03 -0700 | [diff] [blame] | 65 | ) |
| 66 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 67 | # Unit tests |
| 68 | if bld.get_define("_TEST"): |
| 69 | unittests = bld.program ( |
| 70 | target="unit-tests", |
| 71 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 72 | features=['cxx', 'cxxprogram'], |
| 73 | use = 'BOOST_TEST ChronoChat', |
| 74 | includes = ['src'], |
| 75 | ) |
| 76 | # Tmp disable |
| 77 | # if Utils.unversioned_sys_platform () == "darwin": |
| 78 | # app_plist = '''<?xml version="1.0" encoding="UTF-8"?> |
| 79 | # <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> |
| 80 | # <plist version="0.9"> |
| 81 | # <dict> |
| 82 | # <key>CFBundlePackageType</key> |
| 83 | # <string>APPL</string> |
| 84 | # <key>CFBundleIconFile</key> |
| 85 | # <string>demo.icns</string> |
| 86 | # <key>CFBundleGetInfoString</key> |
| 87 | # <string>Created by Waf</string> |
| 88 | # <key>CFBundleIdentifier</key> |
| 89 | # <string>edu.ucla.cs.irl.ChronoChat</string> |
| 90 | # <key>CFBundleSignature</key> |
| 91 | # <string>????</string> |
| 92 | # <key>NOTE</key> |
| 93 | # <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string> |
| 94 | # <key>CFBundleExecutable</key> |
| 95 | # <string>%s</string> |
| 96 | # <key>SUPublicDSAKeyFile</key> |
| 97 | # <string>dsa_pub.pem</string> |
| 98 | # <key>CFBundleIconFile</key> |
| 99 | # <string>demo.icns</string> |
| 100 | # </dict> |
| 101 | # </plist>''' |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 102 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 103 | # # <key>LSUIElement</key> |
| 104 | # # <string>1</string> |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 105 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 106 | # qt.mac_app = "ChronoChat.app" |
| 107 | # qt.mac_plist = app_plist % "ChronoChat" |
| 108 | # qt.mac_resources = 'demo.icns' |
| 109 | # else: |
| 110 | # bld (features = "subst", |
| 111 | # source = 'linux/chronochat.desktop.in', |
| 112 | # target = 'linux/chronochat.desktop', |
| 113 | # BINARY = "ChronoChat", |
| 114 | # install_path = "${DATAROOTDIR}/applications" |
| 115 | # ) |
| 116 | # bld.install_files("${DATAROOTDIR}/chronochat", |
| 117 | # bld.path.ant_glob(['linux/Resources/*'])) |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 118 | |
| 119 | |
| 120 | from waflib import TaskGen |
| 121 | @TaskGen.extension('.mm') |
| 122 | def m_hook(self, node): |
| 123 | """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing.""" |
| 124 | return self.create_compiled_task('cxx', node) |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 125 | |
| 126 | @Configure.conf |
| 127 | def add_supported_cxxflags(self, cxxflags): |
| 128 | """ |
| 129 | Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable |
| 130 | """ |
| 131 | self.start_msg('Checking allowed flags for c++ compiler') |
| 132 | |
| 133 | supportedFlags = [] |
| 134 | for flag in cxxflags: |
| 135 | if self.check_cxx (cxxflags=[flag], mandatory=False): |
| 136 | supportedFlags += [flag] |
| 137 | |
| 138 | self.end_msg (' '.join (supportedFlags)) |
| 139 | self.env.CXXFLAGS += supportedFlags |