blob: f7bdf1cf811cd5d70261c6738c8785722696600c [file] [log] [blame]
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Yingdi Yua43601f2014-05-09 14:29:16 -07002VERSION='0.1'
3APPNAME='QT-Test'
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07004
Yingdi Yue35bdb82013-11-07 11:32:40 -08005from waflib import Configure, Utils
Yingdi Yu847aa862013-10-09 16:35:53 -07006
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07007def options(opt):
Yingdi Yue35bdb82013-11-07 11:32:40 -08008 opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
9
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070010 opt.load('compiler_c compiler_cxx boost protoc qt4')
Yingdi Yud04ed1a2013-10-14 14:07:03 -070011
12 opt.load('tinyxml', tooldir=['waf-tools'])
Yingdi Yub2e747d2013-11-05 23:06:43 -080013 opt.load('cryptopp', tooldir=['waf-tools'])
Yingdi Yua43601f2014-05-09 14:29:16 -070014
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070015def configure(conf):
Yingdi Yub2e747d2013-11-05 23:06:43 -080016 conf.load("compiler_c compiler_cxx boost protoc qt4 tinyxml cryptopp")
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070017
Yingdi Yue35bdb82013-11-07 11:32:40 -080018 if conf.options.debug:
19 conf.define ('_DEBUG', 1)
20 conf.add_supported_cxxflags (cxxflags = ['-O0',
21 '-Wall',
22 '-Wno-unused-variable',
23 '-g3',
24 '-Wno-unused-private-field', # only clang supports
25 '-fcolor-diagnostics', # only clang supports
26 '-Qunused-arguments', # only clang supports
27 ])
28 else:
29 conf.add_supported_cxxflags (cxxflags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function'])
30
Yingdi Yud04ed1a2013-10-14 14:07:03 -070031 conf.check_tinyxml(path=conf.options.tinyxml_dir)
Yingdi Yu4390ce52013-10-10 17:27:54 -070032 conf.check_cfg(package='libndn.cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX', mandatory=True)
33 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
Yingdi Yu3b318c12013-10-15 17:54:00 -070034 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
Yingdi Yub2e747d2013-11-05 23:06:43 -080035 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], uselib_store='SYNC', mandatory=True)
Yingdi Yu3b318c12013-10-15 17:54:00 -070036 conf.define ("HAVE_LOG4CXX", 1)
Yingdi Yu4390ce52013-10-10 17:27:54 -070037
Yingdi Yud04ed1a2013-10-14 14:07:03 -070038 conf.check_boost(lib='system random thread filesystem')
Yingdi Yu847aa862013-10-09 16:35:53 -070039
40 conf.write_config_header('config.h')
41
42
43def build (bld):
44 qt = bld (
Yingdi Yu40eca752013-10-10 15:00:58 -070045 target = "Contacts",
Yingdi Yu847aa862013-10-09 16:35:53 -070046 features = "qt4 cxx cxxprogram",
47 defines = "WAF",
Yingdi Yub2e747d2013-11-05 23:06:43 -080048 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', 'logging.cc', 'src/*.proto']),
Yingdi Yu847aa862013-10-09 16:35:53 -070049 includes = ".",
Yingdi Yub2e747d2013-11-05 23:06:43 -080050 use = "QTCORE QTGUI QTSQL SQLITE3 NDNCXX TINYXML BOOST BOOST_FILESYSTEM LOG4CXX CRYPTOPP SYNC",
Yingdi Yu92e8e482013-10-17 21:13:03 -070051 )
52
53 cert_publish = bld (
54 target = "CertPublish",
55 features = "cxx cxxprogram",
56 defines = "WAF",
57 source = bld.path.ant_glob(['tmp/cert-publish.cpp']),
58 includes = ".",
59 use = "SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX",
60 )
Yingdi Yu847aa862013-10-09 16:35:53 -070061
Yingdi Yue35bdb82013-11-07 11:32:40 -080062 if Utils.unversioned_sys_platform () == "darwin":
63 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
64<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
65<plist version="0.9">
66<dict>
67 <key>CFBundlePackageType</key>
68 <string>APPL</string>
69 <key>CFBundleIconFile</key>
70 <string>demo.icns</string>
71 <key>CFBundleGetInfoString</key>
72 <string>Created by Waf</string>
73 <key>CFBundleIdentifier</key>
74 <string>edu.ucla.cs.irl.Contacts</string>
75 <key>CFBundleSignature</key>
76 <string>????</string>
77 <key>NOTE</key>
78 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
79 <key>CFBundleExecutable</key>
80 <string>%s</string>
81 <key>LSUIElement</key>
82 <string>1</string>
83 <key>SUPublicDSAKeyFile</key>
84 <string>dsa_pub.pem</string>
85 <key>CFBundleIconFile</key>
86 <string>demo.icns</string>
87</dict>
88</plist>'''
89
90 qt.mac_app = "Contacts.app"
91 qt.mac_plist = app_plist % "Contacts"
92 qt.mac_resources = 'demo.icns'
93
94
95from waflib import TaskGen
96@TaskGen.extension('.mm')
97def m_hook(self, node):
98 """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
99 return self.create_compiled_task('cxx', node)
Yingdi Yu847aa862013-10-09 16:35:53 -0700100
101@Configure.conf
102def add_supported_cxxflags(self, cxxflags):
103 """
104 Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
105 """
106 self.start_msg('Checking allowed flags for c++ compiler')
107
108 supportedFlags = []
109 for flag in cxxflags:
110 if self.check_cxx (cxxflags=[flag], mandatory=False):
111 supportedFlags += [flag]
112
113 self.end_msg (' '.join (supportedFlags))
114 self.env.CXXFLAGS += supportedFlags
115
116from waflib.TaskGen import feature, before_method, after_method
117@feature('cxx')
118@after_method('process_source')
119@before_method('apply_incpaths')
120def add_includes_paths(self):
121 incs = set(self.to_list(getattr(self, 'includes', '')))
122 for x in self.compiled_tasks:
123 incs.add(x.inputs[0].parent.path_from(self.path))
124 self.includes = list(incs)