Meson: port dub configurations to Meson options
This commit is contained in:
parent
76cf12fc22
commit
17ade7f9ca
107
meson.build
107
meson.build
|
@ -1,6 +1,6 @@
|
||||||
project('eventcore', 'd',
|
project('eventcore', 'd',
|
||||||
meson_version: '>=0.50',
|
meson_version: '>=0.53',
|
||||||
version: '0.9.13'
|
version: '0.9.13',
|
||||||
)
|
)
|
||||||
|
|
||||||
project_soversion = '0'
|
project_soversion = '0'
|
||||||
|
@ -10,11 +10,110 @@ project_version_full = project_version + project_version_suffix
|
||||||
|
|
||||||
taggedalgebraic_dep = dependency('taggedalgebraic', version: ['>=0.10.12', '<0.12'])
|
taggedalgebraic_dep = dependency('taggedalgebraic', version: ['>=0.10.12', '<0.12'])
|
||||||
|
|
||||||
|
eventcore_build_versions = []
|
||||||
|
eventcore_extra_deps = []
|
||||||
|
|
||||||
|
default_driver = 'select'
|
||||||
|
host_system = host_machine.system()
|
||||||
|
|
||||||
|
host_is_posix = false
|
||||||
|
host_is_osx = false
|
||||||
|
host_is_windows = false
|
||||||
|
host_is_bsd = false
|
||||||
|
host_is_linux = false
|
||||||
|
|
||||||
|
# Determine the default driver if 'driver' was not explicitly set
|
||||||
|
if host_system == 'linux'
|
||||||
|
host_is_linux = true
|
||||||
|
host_is_posix = true
|
||||||
|
elif host_system == 'windows'
|
||||||
|
host_is_windows = true
|
||||||
|
elif host_system == 'dragonfly' or host_system == 'freebsd' or host_system == 'netbsd' or host_system == 'openbsd'
|
||||||
|
host_is_bsd = true
|
||||||
|
host_is_posix = true
|
||||||
|
else
|
||||||
|
# What are we running on?
|
||||||
|
default_driver = 'generic'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if host_is_linux
|
||||||
|
default_driver = 'epoll'
|
||||||
|
elif host_is_osx
|
||||||
|
default_driver = 'cfrunloop'
|
||||||
|
elif host_is_windows
|
||||||
|
default_driver = 'winapi'
|
||||||
|
elif host_is_bsd
|
||||||
|
default_driver = 'kqueue'
|
||||||
|
elif host_is_posix
|
||||||
|
default_driver = 'select'
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Optional dependencies
|
||||||
|
libasync_dep = dependency('libasync', version: '~>0.8.2', required: false)
|
||||||
|
gaia_dep = dependency('anl', required: get_option('use_gaia'))
|
||||||
|
|
||||||
|
# Driver logic
|
||||||
|
driver_opt = get_option('driver')
|
||||||
|
if driver_opt == 'auto'
|
||||||
|
driver_opt = default_driver
|
||||||
|
endif
|
||||||
|
|
||||||
|
if driver_opt == 'epoll'
|
||||||
|
if not host_is_linux
|
||||||
|
error('epoll driver is only supported on Linux')
|
||||||
|
endif
|
||||||
|
eventcore_build_versions += ['EventcoreEpollDriver']
|
||||||
|
if gaia_dep.found()
|
||||||
|
eventcore_extra_deps += [gaia_dep]
|
||||||
|
eventcore_build_versions += ['EventcoreUseGAIA']
|
||||||
|
endif
|
||||||
|
elif driver_opt == 'cfrunloop'
|
||||||
|
if not host_is_osx
|
||||||
|
error('cfrunloop driver is only supported on OSX')
|
||||||
|
endif
|
||||||
|
eventcore_build_versions += ['EventcoreCFRunLoopDriver']
|
||||||
|
elif driver_opt == 'kqueue'
|
||||||
|
if not host_is_bsd
|
||||||
|
error('kqueue driver is only supported on BSD variants (including OSX)')
|
||||||
|
endif
|
||||||
|
eventcore_build_versions += ['EventcoreKqueueDriver']
|
||||||
|
elif driver_opt == 'winapi'
|
||||||
|
if not host_is_windows
|
||||||
|
error('winapi driver is only supported on Windows')
|
||||||
|
endif
|
||||||
|
eventcore_build_versions += ['EventcoreWinAPIDriver']
|
||||||
|
elif driver_opt == 'select'
|
||||||
|
if not (host_is_posix or host_is_windows)
|
||||||
|
error('select driver is only supported on POSIX-like systems and Windows')
|
||||||
|
endif
|
||||||
|
eventcore_build_versions += ['EventcoreSelectDriver']
|
||||||
|
elif driver_opt == 'libasync'
|
||||||
|
if not libasync_dep.found()
|
||||||
|
error('libasync could not be found, but is required for the libasync driver')
|
||||||
|
endif
|
||||||
|
eventcore_build_versions += ['EventcoreLibasyncDriver']
|
||||||
|
eventcore_extra_deps += [libasync_dep]
|
||||||
|
elif driver_opt == 'generic'
|
||||||
|
# Defines eventDriver as the generic EventDriver interface. Setup must be done manually.
|
||||||
|
else
|
||||||
|
error('No combination of driver and compatible host machine OS specified')
|
||||||
|
endif
|
||||||
|
|
||||||
|
summary(
|
||||||
|
{
|
||||||
|
'Chosen driver': driver_opt,
|
||||||
|
'Default driver': default_driver,
|
||||||
|
'Using GAIA': gaia_dep.found()
|
||||||
|
},
|
||||||
|
bool_yn: true
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
source_root = meson.source_root()
|
source_root = meson.source_root()
|
||||||
build_root = meson.build_root()
|
build_root = meson.build_root()
|
||||||
subdir('source/eventcore')
|
subdir('source/eventcore')
|
||||||
|
|
||||||
eventcore_dep = declare_dependency(
|
eventcore_dep = declare_dependency(
|
||||||
include_directories: include_directories('source'),
|
include_directories: include_directories('source'),
|
||||||
link_with: eventcore_lib
|
link_with: eventcore_lib
|
||||||
)
|
)
|
||||||
|
|
8
meson_options.txt
Normal file
8
meson_options.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
option('driver',
|
||||||
|
type: 'combo',
|
||||||
|
choices: ['epoll', 'cfrunloop', 'kqueue', 'winapi', 'select', 'libasync', 'generic', 'auto'],
|
||||||
|
value: 'auto',
|
||||||
|
description: 'Which async backend driver to use',
|
||||||
|
yield: true
|
||||||
|
)
|
||||||
|
option('use_gaia', type: 'feature', value: 'auto')
|
|
@ -2,6 +2,7 @@ eventcore_src = [
|
||||||
'core.d',
|
'core.d',
|
||||||
'driver.d',
|
'driver.d',
|
||||||
'drivers/libasync.d',
|
'drivers/libasync.d',
|
||||||
|
'drivers/posix/cfrunloop.d',
|
||||||
'drivers/posix/dns.d',
|
'drivers/posix/dns.d',
|
||||||
'drivers/posix/driver.d',
|
'drivers/posix/driver.d',
|
||||||
'drivers/posix/epoll.d',
|
'drivers/posix/epoll.d',
|
||||||
|
@ -26,11 +27,12 @@ eventcore_src = [
|
||||||
'drivers/winapi/sockets.d',
|
'drivers/winapi/sockets.d',
|
||||||
'drivers/winapi/watchers.d',
|
'drivers/winapi/watchers.d',
|
||||||
'internal/consumablequeue.d',
|
'internal/consumablequeue.d',
|
||||||
|
'internal/corefoundation.d',
|
||||||
'internal/dlist.d',
|
'internal/dlist.d',
|
||||||
|
'internal/ioworker.d',
|
||||||
'internal/utils.d',
|
'internal/utils.d',
|
||||||
'internal/win32.d',
|
'internal/win32.d',
|
||||||
'socket.d',
|
'socket.d',
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
eventcore_lib = library(
|
eventcore_lib = library(
|
||||||
|
@ -39,7 +41,8 @@ eventcore_lib = library(
|
||||||
version: project_version,
|
version: project_version,
|
||||||
install: true,
|
install: true,
|
||||||
include_directories: include_directories('../'),
|
include_directories: include_directories('../'),
|
||||||
dependencies: taggedalgebraic_dep,
|
dependencies: [taggedalgebraic_dep, eventcore_extra_deps],
|
||||||
|
d_module_versions: eventcore_build_versions
|
||||||
)
|
)
|
||||||
|
|
||||||
pkgc = import('pkgconfig')
|
pkgc = import('pkgconfig')
|
||||||
|
@ -47,11 +50,33 @@ pkgc = import('pkgconfig')
|
||||||
pkgc.generate(
|
pkgc.generate(
|
||||||
eventcore_lib,
|
eventcore_lib,
|
||||||
subdirs: 'd/eventcore',
|
subdirs: 'd/eventcore',
|
||||||
|
d_module_versions: eventcore_build_versions
|
||||||
)
|
)
|
||||||
|
|
||||||
install_headers(
|
# This is using install_subdir instead of install_headers, since
|
||||||
eventcore_src,
|
# install_headers flattens the headers directory, it turns
|
||||||
subdir: 'd/eventcore/eventcore',
|
# ├ ...
|
||||||
|
# ├ driver.d
|
||||||
|
# ├ drivers
|
||||||
|
# │ ├ libasync.d
|
||||||
|
# │ ├ ...
|
||||||
|
# │ └ winapi
|
||||||
|
# │ └ ...
|
||||||
|
# ├ ...
|
||||||
|
# └ socket.d
|
||||||
|
#
|
||||||
|
# into
|
||||||
|
#
|
||||||
|
# ├ ...
|
||||||
|
# ├ drivers.d
|
||||||
|
# ├ libasync.d
|
||||||
|
# ├ ...
|
||||||
|
# └ socket.d
|
||||||
|
#
|
||||||
|
|
||||||
|
install_subdir(
|
||||||
|
'../',
|
||||||
|
install_dir: 'include/d/eventcore/eventcore',
|
||||||
)
|
)
|
||||||
|
|
||||||
test_exe = executable(
|
test_exe = executable(
|
||||||
|
@ -59,7 +84,8 @@ test_exe = executable(
|
||||||
eventcore_src,
|
eventcore_src,
|
||||||
include_directories: include_directories('../'),
|
include_directories: include_directories('../'),
|
||||||
d_unittest: true,
|
d_unittest: true,
|
||||||
d_args: '-main',
|
d_args: meson.get_compiler('d').unittest_args(),
|
||||||
|
link_args: '-main',
|
||||||
dependencies: taggedalgebraic_dep,
|
dependencies: taggedalgebraic_dep,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue