blob: 36442581851397a8a1646336b233ee36af01bcda [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 Afanasyev9c9c3012013-01-25 23:44:25 -080014 opt.load('compiler_cxx boost ccnx protoc 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')
Alexander Afanasyev33206982013-01-09 16:29:29 -080042
43 conf.load('qt4')
44
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080045 conf.load('boost')
46
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080047 conf.check_boost(lib='system test iostreams filesystem regex thread')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080048
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080049 boost_version = conf.env.BOOST_VERSION.split('_')
50 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
51 Logs.error ("Minumum required boost version is 1.46")
52 return
53
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080054 conf.check_ccnx (path=conf.options.ccnx_dir)
55
56 if conf.options.debug:
57 conf.define ('_DEBUG', 1)
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080058 conf.env.append_value('CXXFLAGS', ['-O0', '-Wall', '-Wno-unused-variable',
59 '-fcolor-diagnostics', '-g3', '-Qunused-arguments'])
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080060 else:
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080061 conf.env.append_value('CXXFLAGS', ['-O3', '-g', '-Qunused-arguments'])
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080062
63 if conf.options._test:
Alexander Afanasyev9e5a4702013-01-24 13:15:23 -080064 conf.define ('_TESTS', 1)
Alexander Afanasyev72ac2192013-01-03 19:33:43 -080065 conf.env.TEST = 1
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080066
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080067 conf.write_config_header('src/config.h')
68
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080069def build (bld):
Zhenkai Zhue8409422013-01-28 12:52:17 -080070 executor = bld.objects (
71 target = "executor",
72 features = ["cxx"],
73 source = bld.path.ant_glob(['executor/**/*.cc']),
74 use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS LOG4CXX',
75 includes = "executor src",
76 )
77
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080078 scheduler = bld.objects (
79 target = "scheduler",
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080080 features = ["cxx"],
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080081 source = bld.path.ant_glob(['scheduler/**/*.cc']),
Zhenkai Zhue8409422013-01-28 12:52:17 -080082 use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS LOG4CXX executor',
Zhenkai Zhu1888f742013-01-28 12:47:33 -080083 includes = "scheduler executor src",
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080084 )
85
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080086 libccnx = bld (
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080087 target="ccnx",
88 features=['cxx'],
89 source = bld.path.ant_glob(['ccnx/**/*.cc', 'ccnx/**/*.cpp']),
Zhenkai Zhue8409422013-01-28 12:52:17 -080090 use = 'BOOST BOOST_THREAD SSL CCNX LOG4CXX scheduler executor',
Zhenkai Zhu1888f742013-01-28 12:47:33 -080091 includes = "ccnx src scheduler executor",
Alexander Afanasyevf2890632013-01-02 13:40:02 -080092 )
93
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080094 chornoshare = bld (
95 target="chronoshare",
96 features=['cxx'],
97 source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.cpp', 'src/**/*.proto']),
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080098 use = "BOOST BOOST_FILESYSTEM SQLITE3 LOG4CXX scheduler ccnx",
Zhenkai Zhu1888f742013-01-28 12:47:33 -080099 includes = "ccnx scheduler src executor",
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800100 )
Alexander Afanasyevb2fe74e2013-01-20 16:06:43 -0800101
Zhenkai Zhu369eff12013-02-05 15:43:49 -0800102 fs_watcher = bld (
103 target = "fs_watcher",
104 features = "qt4 cxx",
105 defines = "WAF",
106 source = bld.path.ant_glob(['fs-watcher/*.cc']),
107 use = "SQLITE3 LOG4CXX scheduler executor QTCORE",
108 includes = "fs-watcher scheduler executor src",
109 )
110
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800111 # Unit tests
112 if bld.env['TEST']:
113 unittests = bld.program (
114 target="unit-tests",
Zhenkai Zhud1756272013-02-01 17:02:18 -0800115 features = "qt4 cxx cxxprogram",
116 defines = "WAF",
Zhenkai Zhu369eff12013-02-05 15:43:49 -0800117 source = bld.path.ant_glob(['test/*.cc']),
118 use = 'BOOST_TEST BOOST_FILESYSTEM LOG4CXX SQLITE3 QTCORE QTGUI ccnx database fs_watcher chronoshare',
119 includes = "ccnx scheduler src executor gui fs-watcher",
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800120 )
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800121
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800122 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
123<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
124<plist version="0.9">
125<dict>
126 <key>CFBundlePackageType</key>
127 <string>APPL</string>
128 <key>CFBundleGetInfoString</key>
129 <string>Created by Waf</string>
130 <key>CFBundleSignature</key>
131 <string>????</string>
132 <key>NOTE</key>
133 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
134 <key>CFBundleExecutable</key>
135 <string>%s</string>
136 <key>LSUIElement</key>
137 <string>1</string>
138</dict>
139</plist>'''
140
Jared Lindblomdc845f02013-01-18 17:29:40 -0800141 qt = bld (
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800142 target = "ChronoShare",
143 mac_app = "ChronoShare.app",
144 mac_plist = app_plist % "ChronoShare",
Jared Lindblomdc845f02013-01-18 17:29:40 -0800145 features = "qt4 cxx cxxprogram",
146 defines = "WAF",
Alexander Afanasyev9ca444e2013-01-25 16:29:35 -0800147 source = bld.path.ant_glob(['gui/*.cpp', 'gui/*.cc', 'gui/*.qrc']),
Zhenkai Zhu369eff12013-02-05 15:43:49 -0800148 includes = "ccnx scheduler executor fs-watcher gui src . ",
149 use = "BOOST BOOST_FILESYSTEM SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ccnx database chronoshare"
Jared Lindblomdc845f02013-01-18 17:29:40 -0800150 )
Alexander Afanasyev548d38d2013-01-26 16:36:06 -0800151
152 cmdline = bld (
153 target = "csd",
154 features = "qt4 cxx cxxprogram",
155 defines = "WAF",
Zhenkai Zhu369eff12013-02-05 15:43:49 -0800156 source = "cmd/csd.cc",
157 includes = "ccnx scheduler executor gui fs-watcher src . ",
158 use = "BOOST BOOST_FILESYSTEM SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ccnx database chronoshare"
Alexander Afanasyev548d38d2013-01-26 16:36:06 -0800159 )
160
Alexander Afanasyeveb575e02013-01-26 17:14:51 -0800161 dump_db = bld (
162 target = "dump-db",
163 features = "cxx cxxprogram",
164 source = "cmd/dump-db.cc",
Zhenkai Zhu369eff12013-02-05 15:43:49 -0800165 includes = "ccnx scheduler executor gui fs-watcher src . ",
166 use = "BOOST BOOST_FILESYSTEM SQLITE3 QTCORE LOG4CXX fs_watcher ccnx database chronoshare"
Alexander Afanasyeveb575e02013-01-26 17:14:51 -0800167 )
168
169
Alexander Afanasyev548d38d2013-01-26 16:36:06 -0800170
171
172
173
174
175