blob: 04433814de77d8df548283677c8680135bb71f02 [file] [log] [blame]
Alexander Afanasyevb4b92292013-07-09 13:54:59 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyev46c7f842013-11-07 23:28:10 -08002VERSION='0.4'
Yingdi Yud681e212013-11-07 11:36:50 -08003APPNAME='ChronoChat'
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''')
Alexander Afanasyev46c7f842013-11-07 23:28:10 -08009 opt.add_option('--log4cxx',action='store_true',default=False,dest='log4cxx',help='''Enable log4cxx''')
Yingdi Yue35bdb82013-11-07 11:32:40 -080010
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070011 opt.load('compiler_c compiler_cxx boost protoc qt4')
Yingdi Yud04ed1a2013-10-14 14:07:03 -070012
Yingdi Yu382bcb92013-11-07 11:44:39 -080013 # opt.load('tinyxml', tooldir=['waf-tools'])
Yingdi Yub2e747d2013-11-05 23:06:43 -080014 opt.load('cryptopp', tooldir=['waf-tools'])
Yingdi Yua43601f2014-05-09 14:29:16 -070015
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070016def configure(conf):
Yingdi Yu382bcb92013-11-07 11:44:39 -080017 conf.load("compiler_c compiler_cxx boost protoc qt4 cryptopp")
Alexander Afanasyevb4b92292013-07-09 13:54:59 -070018
Yingdi Yue35bdb82013-11-07 11:32:40 -080019 if conf.options.debug:
20 conf.define ('_DEBUG', 1)
Alexander Afanasyev4a979312013-11-07 15:30:05 -080021 conf.env.DEBUG = 1
Yingdi Yue35bdb82013-11-07 11:32:40 -080022 conf.add_supported_cxxflags (cxxflags = ['-O0',
23 '-Wall',
24 '-Wno-unused-variable',
25 '-g3',
26 '-Wno-unused-private-field', # only clang supports
27 '-fcolor-diagnostics', # only clang supports
28 '-Qunused-arguments', # only clang supports
29 ])
30 else:
31 conf.add_supported_cxxflags (cxxflags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function'])
32
Yingdi Yu4390ce52013-10-10 17:27:54 -070033 conf.check_cfg(package='libndn.cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX', mandatory=True)
34 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
Alexander Afanasyev4a979312013-11-07 15:30:05 -080035 if conf.options.log4cxx:
36 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
Yingdi Yub2e747d2013-11-05 23:06:43 -080037 conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], uselib_store='SYNC', mandatory=True)
Yingdi Yu4390ce52013-10-10 17:27:54 -070038
Yingdi Yud04ed1a2013-10-14 14:07:03 -070039 conf.check_boost(lib='system random thread filesystem')
Yingdi Yu847aa862013-10-09 16:35:53 -070040
41 conf.write_config_header('config.h')
42
43
44def build (bld):
45 qt = bld (
Yingdi Yud681e212013-11-07 11:36:50 -080046 target = "ChronoChat",
Yingdi Yu847aa862013-10-09 16:35:53 -070047 features = "qt4 cxx cxxprogram",
48 defines = "WAF",
Yingdi Yuc5020b92013-11-07 17:00:35 -080049 source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']),
Alexander Afanasyev4a979312013-11-07 15:30:05 -080050 includes = "src .",
Alexander Afanasyev46c7f842013-11-07 23:28:10 -080051 use = "QTCORE QTGUI QTWIDGETS QTSQL SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX CRYPTOPP SYNC",
Yingdi Yu92e8e482013-10-17 21:13:03 -070052 )
53
Alexander Afanasyev4a979312013-11-07 15:30:05 -080054 # if bld.env['DEBUG']:
55 # cert_publish = bld (
56 # target = "CertPublish",
57 # features = "cxx cxxprogram",
58 # defines = "WAF",
59 # source = bld.path.ant_glob(['tmp/cert-publish.cpp']),
60 # includes = ". src",
61 # use = "SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX",
62 # )
Yingdi Yu847aa862013-10-09 16:35:53 -070063
Yingdi Yue35bdb82013-11-07 11:32:40 -080064 if Utils.unversioned_sys_platform () == "darwin":
65 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
66<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
67<plist version="0.9">
68<dict>
69 <key>CFBundlePackageType</key>
70 <string>APPL</string>
71 <key>CFBundleIconFile</key>
72 <string>demo.icns</string>
73 <key>CFBundleGetInfoString</key>
74 <string>Created by Waf</string>
75 <key>CFBundleIdentifier</key>
Yingdi Yud681e212013-11-07 11:36:50 -080076 <string>edu.ucla.cs.irl.ChronoChat</string>
Yingdi Yue35bdb82013-11-07 11:32:40 -080077 <key>CFBundleSignature</key>
78 <string>????</string>
79 <key>NOTE</key>
80 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
81 <key>CFBundleExecutable</key>
82 <string>%s</string>
Yingdi Yue35bdb82013-11-07 11:32:40 -080083 <key>SUPublicDSAKeyFile</key>
84 <string>dsa_pub.pem</string>
85 <key>CFBundleIconFile</key>
86 <string>demo.icns</string>
87</dict>
88</plist>'''
89
Alexander Afanasyev4a979312013-11-07 15:30:05 -080090 # <key>LSUIElement</key>
91 # <string>1</string>
92
Yingdi Yud681e212013-11-07 11:36:50 -080093 qt.mac_app = "ChronoChat.app"
94 qt.mac_plist = app_plist % "ChronoChat"
Yingdi Yue35bdb82013-11-07 11:32:40 -080095 qt.mac_resources = 'demo.icns'
96
97
98from waflib import TaskGen
99@TaskGen.extension('.mm')
100def m_hook(self, node):
101 """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
102 return self.create_compiled_task('cxx', node)
Yingdi Yu847aa862013-10-09 16:35:53 -0700103
104@Configure.conf
105def add_supported_cxxflags(self, cxxflags):
106 """
107 Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
108 """
109 self.start_msg('Checking allowed flags for c++ compiler')
110
111 supportedFlags = []
112 for flag in cxxflags:
113 if self.check_cxx (cxxflags=[flag], mandatory=False):
114 supportedFlags += [flag]
115
116 self.end_msg (' '.join (supportedFlags))
117 self.env.CXXFLAGS += supportedFlags