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; -*- |
| 2 | VERSION='0.1' |
| 3 | APPNAME='QT-Test' |
| 4 | |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 5 | from waflib import Configure |
| 6 | |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 7 | def options(opt): |
| 8 | opt.load('compiler_c compiler_cxx boost protoc qt4') |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 9 | |
| 10 | opt.load('tinyxml', tooldir=['waf-tools']) |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 11 | |
| 12 | def configure(conf): |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 13 | conf.load("compiler_c compiler_cxx boost protoc qt4 tinyxml") |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 14 | |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 15 | conf.add_supported_cxxflags (cxxflags = ['-O3', '-g']) |
Yingdi Yu | 767d2ac | 2013-10-09 15:16:11 -0700 | [diff] [blame] | 16 | |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 17 | conf.check_tinyxml(path=conf.options.tinyxml_dir) |
Yingdi Yu | ad56f1c | 2013-10-10 17:27:54 -0700 | [diff] [blame] | 18 | conf.check_cfg(package='libndn.cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX', mandatory=True) |
| 19 | conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True) |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame^] | 20 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
| 21 | conf.define ("HAVE_LOG4CXX", 1) |
Yingdi Yu | ad56f1c | 2013-10-10 17:27:54 -0700 | [diff] [blame] | 22 | |
Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 23 | conf.check_boost(lib='system random thread filesystem') |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 24 | |
| 25 | conf.write_config_header('config.h') |
| 26 | |
| 27 | |
| 28 | def build (bld): |
| 29 | qt = bld ( |
Yingdi Yu | 01a942b | 2013-10-10 15:00:58 -0700 | [diff] [blame] | 30 | target = "Contacts", |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 31 | features = "qt4 cxx cxxprogram", |
| 32 | defines = "WAF", |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame^] | 33 | source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', 'logging.cc']), |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 34 | includes = ".", |
Yingdi Yu | 0a6b6c5 | 2013-10-15 17:54:00 -0700 | [diff] [blame^] | 35 | use = "QTCORE QTGUI QTSQL SQLITE3 NDNCXX TINYXML BOOST BOOST_FILESYSTEM LOG4CXX", |
Yingdi Yu | 614db14 | 2013-10-09 16:35:53 -0700 | [diff] [blame] | 36 | ) |
| 37 | |
| 38 | |
| 39 | @Configure.conf |
| 40 | def add_supported_cxxflags(self, cxxflags): |
| 41 | """ |
| 42 | Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable |
| 43 | """ |
| 44 | self.start_msg('Checking allowed flags for c++ compiler') |
| 45 | |
| 46 | supportedFlags = [] |
| 47 | for flag in cxxflags: |
| 48 | if self.check_cxx (cxxflags=[flag], mandatory=False): |
| 49 | supportedFlags += [flag] |
| 50 | |
| 51 | self.end_msg (' '.join (supportedFlags)) |
| 52 | self.env.CXXFLAGS += supportedFlags |
Yingdi Yu | ffb3263 | 2013-10-09 18:11:41 -0700 | [diff] [blame] | 53 | |
| 54 | from waflib.TaskGen import feature, before_method, after_method |
| 55 | @feature('cxx') |
| 56 | @after_method('process_source') |
| 57 | @before_method('apply_incpaths') |
| 58 | def add_includes_paths(self): |
| 59 | incs = set(self.to_list(getattr(self, 'includes', ''))) |
| 60 | for x in self.compiled_tasks: |
| 61 | incs.add(x.inputs[0].parent.path_from(self.path)) |
| 62 | self.includes = list(incs) |