2020-07-14 14:41:32 +10:00
|
|
|
project('libei', 'c',
|
2023-05-23 14:50:33 +10:00
|
|
|
version: '0.99.2',
|
2022-03-01 14:02:36 +10:00
|
|
|
license: 'MIT',
|
2020-07-14 14:41:32 +10:00
|
|
|
default_options: [ 'c_std=gnu99', 'warning_level=2' ],
|
2023-05-23 19:28:59 +10:00
|
|
|
meson_version: '>= 0.56.0')
|
2020-07-14 14:41:32 +10:00
|
|
|
|
2022-12-13 15:38:40 +10:00
|
|
|
libei_version = meson.project_version().split('.')
|
|
|
|
|
libei_version_major = libei_version[0].to_int()
|
|
|
|
|
libei_version_minor = libei_version[1].to_int()
|
|
|
|
|
if libei_version.length() > 2
|
|
|
|
|
libei_version_patchlevel = libei_version[2].to_int()
|
|
|
|
|
else
|
|
|
|
|
libei_version_patchlevel = 0
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# Our headers are in libei-1.0 until we hit 2.0 etc. libei's API is
|
|
|
|
|
# backwards-compatible until the major version bump.
|
|
|
|
|
libei_api_version = '1.0'
|
|
|
|
|
libei_api_dir = 'libei-@0@'.format(libei_api_version)
|
|
|
|
|
|
|
|
|
|
# We use the same soname across all our libraries and they track the project
|
|
|
|
|
# version. If we have ABI incompatible changes, bump the project major version.
|
|
|
|
|
if libei_version_major < 1
|
|
|
|
|
soname = '1.0.0' # Remove after the 1.0 release
|
|
|
|
|
else
|
|
|
|
|
soname = meson.project_version()
|
|
|
|
|
endif
|
|
|
|
|
|
2020-07-14 14:41:32 +10:00
|
|
|
pkgconfig = import('pkgconfig')
|
2023-03-07 11:54:10 +10:00
|
|
|
fs = import('fs')
|
2020-07-14 14:41:32 +10:00
|
|
|
|
|
|
|
|
cc = meson.get_compiler('c')
|
2022-03-01 14:04:57 +10:00
|
|
|
cflags =[
|
|
|
|
|
'-Wno-unused-parameter',
|
|
|
|
|
'-Wmissing-prototypes',
|
|
|
|
|
'-Wno-missing-field-initializers',
|
|
|
|
|
'-Wstrict-prototypes',
|
|
|
|
|
'-Wstrict-prototypes',
|
|
|
|
|
'-Wlogical-op',
|
|
|
|
|
'-Wpointer-arith',
|
|
|
|
|
'-Wuninitialized',
|
|
|
|
|
'-Winit-self',
|
|
|
|
|
'-Wstrict-prototypes',
|
|
|
|
|
'-Wimplicit-fallthrough',
|
|
|
|
|
'-Wredundant-decls',
|
|
|
|
|
'-Wincompatible-pointer-types',
|
|
|
|
|
'-Wformat=2',
|
|
|
|
|
'-Wformat-overflow=2',
|
|
|
|
|
'-Wformat-signedness',
|
|
|
|
|
'-Wformat-truncation=2',
|
|
|
|
|
'-Wmissing-declarations',
|
|
|
|
|
'-Wshift-overflow=2',
|
|
|
|
|
'-Wstrict-overflow=2',
|
|
|
|
|
'-Wswitch',
|
|
|
|
|
]
|
2022-03-01 15:09:15 +10:00
|
|
|
|
|
|
|
|
if cc.get_id() == 'clang'
|
|
|
|
|
cflags += [
|
|
|
|
|
# clang doesn't think just using _unref_ is a use of the variable
|
|
|
|
|
# _unref_(foo) *bar = something_that_gives_a_ref
|
|
|
|
|
# but we make heavy use of that in the test suite for convenience
|
|
|
|
|
# of events we know must exist but we don't care about specifically
|
|
|
|
|
'-Wno-unused-variable',
|
|
|
|
|
]
|
|
|
|
|
endif
|
|
|
|
|
|
2022-03-01 14:04:57 +10:00
|
|
|
add_project_arguments(cc.get_supported_arguments(cflags), language: 'c')
|
2020-07-14 14:41:32 +10:00
|
|
|
|
2023-02-09 11:24:02 +10:00
|
|
|
inc_builddir = include_directories('.')
|
2023-02-09 11:20:16 +10:00
|
|
|
inc_src = include_directories('src')
|
|
|
|
|
|
2020-07-28 14:19:28 +10:00
|
|
|
config_h = configuration_data()
|
|
|
|
|
config_h.set('_GNU_SOURCE', '1')
|
2022-04-07 14:35:14 +10:00
|
|
|
config_h.set_quoted('EI_VERSION', meson.project_version())
|
|
|
|
|
config_h.set_quoted('EIS_VERSION', meson.project_version())
|
2023-03-25 23:22:01 +00:00
|
|
|
if cc.has_function('memfd_create', prefix: '#define _GNU_SOURCE\n#include <sys/mman.h>')
|
|
|
|
|
config_h.set10('HAVE_MEMFD_CREATE', true)
|
|
|
|
|
endif
|
2020-07-28 14:19:28 +10:00
|
|
|
|
2023-05-17 13:21:45 +00:00
|
|
|
dep_math = cc.find_library('m', required: false)
|
2023-05-15 14:45:27 +00:00
|
|
|
dep_epoll = dependency('epoll-shim', required: false)
|
2020-08-21 16:57:41 +10:00
|
|
|
dep_libxkbcommon = dependency('xkbcommon', required: false)
|
|
|
|
|
config_h.set10('HAVE_LIBXKBCOMMON', dep_libxkbcommon.found())
|
2020-08-27 11:45:15 +10:00
|
|
|
dep_libevdev = dependency('libevdev', required: false)
|
|
|
|
|
config_h.set10('HAVE_LIBEVDEV', dep_libevdev.found())
|
2023-05-17 14:29:08 +00:00
|
|
|
|
|
|
|
|
if not get_option('liboeffis').disabled()
|
|
|
|
|
sd_bus_provider = get_option('sd-bus-provider')
|
|
|
|
|
if sd_bus_provider == 'auto'
|
|
|
|
|
message('Trying to find an sd-bus provider...')
|
|
|
|
|
providers = ['libsystemd', 'libelogind', 'basu']
|
|
|
|
|
foreach provider: providers
|
|
|
|
|
if dependency(provider, required: false).found()
|
|
|
|
|
message('Using sd-bus provider "@0@"'.format(provider))
|
|
|
|
|
sd_bus_provider = provider
|
|
|
|
|
break
|
|
|
|
|
endif
|
|
|
|
|
endforeach
|
|
|
|
|
if sd_bus_provider == 'auto'
|
|
|
|
|
error('Failed to find an sd-bus provider, tried @0@'.format(', '.join(providers)))
|
|
|
|
|
endif
|
|
|
|
|
summary({'sd-bus-provider': sd_bus_provider}, section: 'Conditional Features')
|
|
|
|
|
endif
|
|
|
|
|
dep_sdbus = dependency(sd_bus_provider, required: get_option('liboeffis'))
|
|
|
|
|
else
|
|
|
|
|
dep_sdbus = dependency('', required: false)
|
|
|
|
|
endif
|
|
|
|
|
config_h.set10('HAVE_LIBSYSTEMD', dep_sdbus.found() and dep_sdbus.name() == 'libsystemd')
|
|
|
|
|
config_h.set10('HAVE_LIBELOGIND', dep_sdbus.found() and dep_sdbus.name() == 'libelogind')
|
|
|
|
|
config_h.set10('HAVE_BASU', dep_sdbus.found() and dep_sdbus.name() == 'basu')
|
2022-12-02 12:08:40 +10:00
|
|
|
|
2023-03-07 11:08:13 +10:00
|
|
|
configure_file(output: 'config.h', configuration: config_h)
|
2022-12-02 12:08:40 +10:00
|
|
|
|
2023-03-07 10:59:42 +10:00
|
|
|
subdir('proto')
|
|
|
|
|
subdir('src')
|
|
|
|
|
subdir('tools')
|
2023-03-07 11:08:13 +10:00
|
|
|
subdir('test')
|
|
|
|
|
subdir('doc')
|
2022-12-02 12:08:40 +10:00
|
|
|
|
2023-03-02 10:45:47 +10:00
|
|
|
black = find_program('black', required: false)
|
|
|
|
|
if black.found()
|
|
|
|
|
test('python-black', black,
|
|
|
|
|
args: ['--check', meson.project_source_root(), meson.project_source_root() / 'proto' / 'ei-scanner'],
|
|
|
|
|
suite: 'python',
|
|
|
|
|
)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ruff = find_program('ruff', required: false)
|
|
|
|
|
if ruff.found()
|
|
|
|
|
test('python-ruff', ruff,
|
|
|
|
|
args: ['check', '--ignore=E741,E501', meson.project_source_root(), meson.project_source_root() / 'proto' / 'ei-scanner'],
|
|
|
|
|
suite: 'python',
|
|
|
|
|
)
|
|
|
|
|
endif
|