blob: 2300f7fcf27f78c02a5c628a976a6bfb8b8c1df4 [file] [log] [blame]
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyev71b43e72012-12-27 01:03:43 -08003VERSION='0.1'
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08004APPNAME='chronoshare'
5
6from waflib import Build, Logs
7
8def options(opt):
9 opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
10 opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080011 opt.add_option('--yes',action='store_true',default=False) # for autoconf/automake/make compatibility
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080012 opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx logging support''')
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080013
Alexander Afanasyev33206982013-01-09 16:29:29 -080014 opt.load('compiler_cxx boost ccnx protoc ice_cxx qt4')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080015
16def configure(conf):
17 conf.load("compiler_cxx")
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080018
Alexander Afanasyevf2890632013-01-02 13:40:02 -080019 conf.define ("CHRONOSHARE_VERSION", VERSION)
20
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080021 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
Zhenkai Zhubc2f6282013-01-08 16:40:58 -080022 conf.check_cfg(package='libevent', args=['--cflags', '--libs'], uselib_store='LIBEVENT', mandatory=True)
23 conf.check_cfg(package='libevent_pthreads', args=['--cflags', '--libs'], uselib_store='LIBEVENT_PTHREADS', mandatory=True)
24
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080025 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080026 libcrypto = conf.check_cc(lib='crypto',
27 header_name='openssl/crypto.h',
28 define_name='HAVE_SSL',
29 uselib_store='SSL')
30 else:
31 conf.define ("HAVE_SSL", 1)
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080032 if not conf.get_define ("HAVE_SSL"):
33 conf.fatal ("Cannot find SSL libraries")
34
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080035 if conf.options.log4cxx:
36 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
37 conf.define ("HAVE_LOG4CXX", 1)
38
Zhenkai Zhu0a17aea2012-12-28 14:30:22 -080039 conf.load ('ccnx')
Alexander Afanasyev33206982013-01-09 16:29:29 -080040
41 conf.load('protoc')
42 conf.load('ice_cxx')
43
44 conf.load('qt4')
45
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080046 conf.load('boost')
47
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080048 conf.check_boost(lib='system test iostreams filesystem regex thread')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080049
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080050 boost_version = conf.env.BOOST_VERSION.split('_')
51 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
52 Logs.error ("Minumum required boost version is 1.46")
53 return
54
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080055 conf.check_ccnx (path=conf.options.ccnx_dir)
56
57 if conf.options.debug:
58 conf.define ('_DEBUG', 1)
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080059 conf.env.append_value('CXXFLAGS', ['-O0', '-Wall', '-Wno-unused-variable',
60 '-fcolor-diagnostics', '-g3', '-Qunused-arguments'])
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080061 else:
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080062 conf.env.append_value('CXXFLAGS', ['-O3', '-g', '-Qunused-arguments'])
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080063
64 if conf.options._test:
Alexander Afanasyev9e5a4702013-01-24 13:15:23 -080065 conf.define ('_TESTS', 1)
Alexander Afanasyev72ac2192013-01-03 19:33:43 -080066 conf.env.TEST = 1
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080067
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080068 conf.write_config_header('src/config.h')
69
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080070def build (bld):
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080071 scheduler = bld.objects (
72 target = "scheduler",
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080073 features = ["cxx"],
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080074 source = bld.path.ant_glob(['scheduler/**/*.cc']),
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080075 use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS LOG4CXX',
Alexander Afanasyevfc720362013-01-24 21:49:48 -080076 includes = "scheduler src",
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080077 )
78
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080079 libccnx = bld (
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080080 target="ccnx",
81 features=['cxx'],
82 source = bld.path.ant_glob(['ccnx/**/*.cc', 'ccnx/**/*.cpp']),
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080083 use = 'BOOST BOOST_THREAD SSL CCNX LOG4CXX scheduler',
84 includes = "ccnx scheduler",
Alexander Afanasyevf2890632013-01-02 13:40:02 -080085 )
86
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080087 chornoshare = bld (
88 target="chronoshare",
89 features=['cxx'],
90 source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.cpp', 'src/**/*.proto']),
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080091 use = "BOOST BOOST_FILESYSTEM SQLITE3 LOG4CXX scheduler ccnx",
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080092 includes = "ccnx scheduler src",
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080093 )
Alexander Afanasyevb2fe74e2013-01-20 16:06:43 -080094
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080095 # Unit tests
96 if bld.env['TEST']:
97 unittests = bld.program (
98 target="unit-tests",
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080099 source = bld.path.ant_glob(['test/*.cc']),
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800100 features=['cxx', 'cxxprogram'],
Alexander Afanasyevc507ac22013-01-21 16:01:58 -0800101 use = 'BOOST_TEST BOOST_FILESYSTEM LOG4CXX ccnx database chronoshare',
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -0800102 includes = "ccnx scheduler src",
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800103 )
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800104
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800105 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
106<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
107<plist version="0.9">
108<dict>
109 <key>CFBundlePackageType</key>
110 <string>APPL</string>
111 <key>CFBundleGetInfoString</key>
112 <string>Created by Waf</string>
113 <key>CFBundleSignature</key>
114 <string>????</string>
115 <key>NOTE</key>
116 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
117 <key>CFBundleExecutable</key>
118 <string>%s</string>
119 <key>LSUIElement</key>
120 <string>1</string>
121</dict>
122</plist>'''
123
Jared Lindblomdc845f02013-01-18 17:29:40 -0800124 qt = bld (
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800125 target = "ChronoShare",
126 mac_app = "ChronoShare.app",
127 mac_plist = app_plist % "ChronoShare",
Jared Lindblomdc845f02013-01-18 17:29:40 -0800128 features = "qt4 cxx cxxprogram",
129 defines = "WAF",
Alexander Afanasyev9ca444e2013-01-25 16:29:35 -0800130 source = bld.path.ant_glob(['gui/*.cpp', 'gui/*.cc', 'gui/*.qrc']),
131 includes = "ccnx scheduler src gui src . ",
Alexander Afanasyev9e5a4702013-01-24 13:15:23 -0800132 use = "QTCORE QTGUI LOG4CXX fs-watcher ccnx database chronoshare"
Jared Lindblomdc845f02013-01-18 17:29:40 -0800133 )