2010-03-28 01:48:49 +03:00
#!/usr/bin/env python
2010-04-04 04:06:34 +04:00
APPNAME = 'tevent'
2021-05-31 15:58:19 +03:00
VERSION = '0.11.0'
2010-03-17 12:31:46 +03:00
2010-04-04 04:18:39 +04:00
import sys, os
# find the buildtools directory
2018-02-02 17:34:31 +03:00
top = '.'
while not os.path.exists(top+'/buildtools') and len(top.split('/')) < 5:
top = top + '/..'
sys.path.insert(0, top + '/buildtools/wafsamba')
out = 'bin'
2010-04-04 04:18:39 +04:00
2018-02-02 17:34:31 +03:00
import wafsamba
from wafsamba import samba_dist, samba_utils
2021-06-03 14:05:46 +03:00
from waflib import Options, Logs, Context, Errors
2010-04-04 05:00:42 +04:00
2021-06-03 14:05:46 +03:00
samba_dist.DIST_DIRS('''lib/tevent:. lib/replace:lib/replace
lib/talloc:lib/talloc buildtools:buildtools
third_party/cmocka:third_party/cmocka
third_party/waf:third_party/waf''')
2010-02-26 14:21:50 +03:00
2018-02-02 17:34:31 +03:00
def options(opt):
2010-03-28 08:42:28 +04:00
opt.BUILTIN_DEFAULT('replace')
2010-10-24 01:26:43 +04:00
opt.PRIVATE_EXTENSION_DEFAULT('tevent', noextension='tevent')
2010-04-04 07:16:49 +04:00
opt.RECURSE('lib/replace')
opt.RECURSE('lib/talloc')
2010-09-24 01:28:02 +04:00
2010-03-17 12:31:46 +03:00
def configure(conf):
2010-04-04 07:16:49 +04:00
conf.RECURSE('lib/replace')
conf.RECURSE('lib/talloc')
2010-03-17 12:31:46 +03:00
2021-06-03 14:05:46 +03:00
if conf.CHECK_FOR_THIRD_PARTY():
conf.RECURSE('third_party/cmocka')
else:
if not conf.CHECK_CMOCKA():
raise Errors.WafError('cmocka development package have not been found.\nIf third_party is installed, check that it is in the proper place.')
else:
conf.define('USING_SYSTEM_CMOCKA', 1)
2010-04-13 15:20:52 +04:00
conf.env.standalone_tevent = conf.IN_LAUNCH_DIR()
if not conf.env.standalone_tevent:
2011-11-12 19:36:28 +04:00
if conf.CHECK_BUNDLED_SYSTEM_PKG('tevent', minversion=VERSION,
2010-04-13 15:20:52 +04:00
onlyif='talloc', implied_deps='replace talloc'):
conf.define('USING_SYSTEM_TEVENT', 1)
2017-01-27 22:37:39 +03:00
if not conf.env.disable_python and \
conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytevent', 'tevent', minversion=VERSION):
2011-11-12 19:14:33 +04:00
conf.define('USING_SYSTEM_PYTEVENT', 1)
2010-03-28 09:38:27 +04:00
2010-03-23 01:29:51 +03:00
if conf.CHECK_FUNCS('epoll_create', headers='sys/epoll.h'):
conf.DEFINE('HAVE_EPOLL', 1)
2010-03-17 12:31:46 +03:00
2013-02-22 17:26:16 +04:00
tevent_num_signals = 64
v = conf.CHECK_VALUEOF('NSIG', headers='signal.h')
if v is not None:
tevent_num_signals = max(tevent_num_signals, v)
v = conf.CHECK_VALUEOF('_NSIG', headers='signal.h')
if v is not None:
tevent_num_signals = max(tevent_num_signals, v)
v = conf.CHECK_VALUEOF('SIGRTMAX', headers='signal.h')
if v is not None:
tevent_num_signals = max(tevent_num_signals, v)
v = conf.CHECK_VALUEOF('SIGRTMIN', headers='signal.h')
if v is not None:
tevent_num_signals = max(tevent_num_signals, v*2)
if not conf.CONFIG_SET('USING_SYSTEM_TEVENT'):
conf.DEFINE('TEVENT_NUM_SIGNALS', tevent_num_signals)
2019-02-15 06:13:48 +03:00
conf.SAMBA_CHECK_PYTHON()
conf.SAMBA_CHECK_PYTHON_HEADERS()
2010-09-24 01:28:02 +04:00
2010-03-17 12:31:46 +03:00
conf.SAMBA_CONFIG_H()
2011-11-13 21:01:09 +04:00
conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
2010-03-17 12:31:46 +03:00
def build(bld):
2010-04-04 07:16:49 +04:00
bld.RECURSE('lib/replace')
bld.RECURSE('lib/talloc')
2010-03-17 12:31:46 +03:00
2021-06-03 14:05:46 +03:00
if bld.CHECK_FOR_THIRD_PARTY():
bld.RECURSE('third_party/cmocka')
2010-03-21 05:14:24 +03:00
SRC = '''tevent.c tevent_debug.c tevent_fd.c tevent_immediate.c
2014-07-22 18:51:38 +04:00
tevent_queue.c tevent_req.c tevent_wrapper.c
2015-07-24 01:23:50 +03:00
tevent_poll.c tevent_threads.c
2010-03-17 12:31:46 +03:00
tevent_signal.c tevent_standard.c tevent_timed.c tevent_util.c tevent_wakeup.c'''
2010-03-21 05:14:24 +03:00
if bld.CONFIG_SET('HAVE_EPOLL'):
SRC += ' tevent_epoll.c'
2010-03-17 12:31:46 +03:00
2013-07-23 01:23:33 +04:00
if bld.CONFIG_SET('HAVE_SOLARIS_PORTS'):
SRC += ' tevent_port.c'
2010-10-24 22:50:47 +04:00
if bld.env.standalone_tevent:
bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
private_library = False
else:
private_library = True
2010-03-28 09:38:27 +04:00
if not bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
2016-08-08 12:26:37 +03:00
tevent_deps = 'replace talloc'
if bld.CONFIG_SET('HAVE_PTHREAD'):
tevent_deps += ' pthread'
2010-03-28 09:38:27 +04:00
bld.SAMBA_LIBRARY('tevent',
SRC,
2016-08-08 12:26:37 +03:00
deps=tevent_deps,
2010-03-28 09:38:27 +04:00
enabled= not bld.CONFIG_SET('USING_SYSTEM_TEVENT'),
2011-02-28 21:20:46 +03:00
includes='.',
2010-12-09 03:10:45 +03:00
abi_directory='ABI',
2010-04-18 06:47:13 +04:00
abi_match='tevent_* _tevent_*',
2010-12-09 13:58:20 +03:00
vnum=VERSION,
2016-01-05 02:01:26 +03:00
public_headers=('' if private_library else 'tevent.h'),
2011-03-03 09:19:33 +03:00
public_headers_install=not private_library,
2011-08-21 05:02:58 +04:00
pc_files='tevent.pc',
2010-10-24 22:50:47 +04:00
private_library=private_library)
2010-04-13 15:20:52 +04:00
2013-02-04 10:43:01 +04:00
if not bld.CONFIG_SET('USING_SYSTEM_PYTEVENT') and not bld.env.disable_python:
2019-02-15 06:37:48 +03:00
bld.SAMBA_PYTHON('_tevent',
'pytevent.c',
deps='tevent',
realname='_tevent.so',
cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
2015-05-22 12:52:39 +03:00
2019-02-15 06:37:48 +03:00
bld.INSTALL_WILDCARD('${PYTHONARCHDIR}', 'tevent.py', flat=False)
2015-05-22 12:52:39 +03:00
2011-12-07 00:18:43 +04:00
# install out various python scripts for use by make test
bld.SAMBA_SCRIPT('tevent_python',
pattern='tevent.py',
installdir='python')
2021-06-01 14:57:45 +03:00
bld.SAMBA_BINARY('test_tevent_tag',
source='tests/test_tevent_tag.c',
deps='cmocka tevent',
install=False)
2010-09-24 01:28:02 +04:00
2021-06-01 15:10:05 +03:00
bld.SAMBA_BINARY('test_tevent_trace',
source='tests/test_tevent_trace.c',
deps='cmocka tevent',
install=False)
2010-04-04 16:11:30 +04:00
def test(ctx):
'''test tevent'''
print("The tevent testsuite is part of smbtorture in samba4")
2015-11-18 05:59:37 +03:00
samba_utils.ADD_LD_LIBRARY_PATH('bin/shared')
samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
2015-05-26 14:25:12 +03:00
pyret = samba_utils.RUN_PYTHON_TESTS(['bindings.py'])
2021-06-03 14:05:46 +03:00
unit_test_ret = 0
unit_tests = [
2021-06-01 14:57:45 +03:00
'test_tevent_tag',
2021-06-01 15:10:05 +03:00
'test_tevent_trace',
2021-06-03 14:05:46 +03:00
]
for unit_test in unit_tests:
unit_test_cmd = os.path.join(Context.g_module.out, unit_test)
unit_test_ret = unit_test_ret or samba_utils.RUN_COMMAND(unit_test_cmd)
sys.exit(pyret or unit_test_ret)
2010-04-05 03:58:23 +04:00
def dist():
'''makes a tarball for distribution'''
samba_dist.dist()
2010-11-03 04:09:23 +03:00
def reconfigure(ctx):
'''reconfigure if config scripts have changed'''
samba_utils.reconfigure(ctx)