mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-20 03:20:06 +01:00
Add support for the meson build system
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
223909ed0b
commit
6c88d8c1cf
3 changed files with 293 additions and 1 deletions
|
|
@ -8,4 +8,4 @@ SUBDIRS = doc libevdev tools test
|
|||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libevdev.pc
|
||||
|
||||
EXTRA_DIST = libevdev.pc.in
|
||||
EXTRA_DIST = libevdev.pc.in meson.build meson_options.txt
|
||||
|
|
|
|||
280
meson.build
Normal file
280
meson.build
Normal file
|
|
@ -0,0 +1,280 @@
|
|||
project('libevdev', 'c',
|
||||
version: '1.8.0',
|
||||
license: 'MIT/Expat',
|
||||
default_options: [ 'c_std=gnu99', 'warning_level=2' ],
|
||||
meson_version: '>= 0.47.0')
|
||||
|
||||
libevdev_version = meson.project_version().split('.')
|
||||
|
||||
dir_src = join_paths(meson.source_root(), 'libevdev')
|
||||
dir_src_test = join_paths(meson.source_root(), 'test')
|
||||
dir_man1 = join_paths(get_option('prefix'), get_option('mandir'), 'man1')
|
||||
|
||||
# Include directories
|
||||
includes_include = include_directories('include')
|
||||
|
||||
# We use libtool-version numbers because it's easier to understand.
|
||||
# Before making a release, the libinput_so_*
|
||||
# numbers should be modified. The components are of the form C:R:A.
|
||||
# a) If binary compatibility has been broken (eg removed or changed interfaces)
|
||||
# change to C+1:0:0.
|
||||
# b) If interfaces have been changed or added, but binary compatibility has
|
||||
# been preserved, change to C+1:0:A+1
|
||||
# c) If the interface is the same as the previous version, change to C:R+1:A
|
||||
libevdev_lt_c=5
|
||||
libevdev_lt_r=0
|
||||
libevdev_lt_a=3
|
||||
|
||||
# convert to soname
|
||||
libevdev_so_version = '@0@.@1@.@2@'.format((libevdev_lt_c - libevdev_lt_a),
|
||||
libevdev_lt_a, libevdev_lt_r)
|
||||
|
||||
|
||||
# Compiler setup
|
||||
cc = meson.get_compiler('c')
|
||||
cppflags = ['-Wno-unused-parameter', '-fvisibility=hidden']
|
||||
cflags = cppflags + ['-Wmissing-prototypes', '-Wstrict-prototypes']
|
||||
add_project_arguments(cflags, language : 'c')
|
||||
add_project_arguments(cppflags, language : 'cpp')
|
||||
|
||||
# config.h
|
||||
config_h = configuration_data()
|
||||
config_h.set('_GNU_SOURCE', '1')
|
||||
|
||||
# Dependencies
|
||||
pkgconfig = import('pkgconfig')
|
||||
dep_lm = cc.find_library('m')
|
||||
|
||||
# event-names.h
|
||||
input_h = join_paths(meson.source_root(), 'include', 'linux', 'input.h')
|
||||
input_event_codes_h = join_paths(meson.source_root(), 'include', 'linux', 'input-event-codes.h')
|
||||
|
||||
make_event_names = find_program('libevdev/make-event-names.py')
|
||||
event_names_h = configure_file(input: 'libevdev/libevdev.h',
|
||||
output: 'event-names.h',
|
||||
command: [make_event_names, input_h, input_event_codes_h],
|
||||
capture: true)
|
||||
|
||||
|
||||
# libevdev.so
|
||||
install_headers('libevdev/libevdev.h',
|
||||
'libevdev/libevdev-uinput.h',
|
||||
subdir: 'libevdev-1.0/libevdev')
|
||||
src_libevdev = [
|
||||
event_names_h,
|
||||
'libevdev/libevdev.h',
|
||||
'libevdev/libevdev-int.h',
|
||||
'libevdev/libevdev-util.h',
|
||||
'libevdev/libevdev-uinput.c',
|
||||
'libevdev/libevdev-uinput.h',
|
||||
'libevdev/libevdev-uinput-int.h',
|
||||
'libevdev/libevdev.c',
|
||||
'libevdev/libevdev-names.c',
|
||||
'include/linux/input-event-codes.h',
|
||||
'include/linux/input.h',
|
||||
'include/linux/uinput.h'
|
||||
]
|
||||
|
||||
mapfile = join_paths(dir_src, 'libevdev.sym')
|
||||
version_flag = '-Wl,--version-script,@0@'.format(mapfile)
|
||||
lib_libevdev = shared_library('evdev',
|
||||
src_libevdev,
|
||||
include_directories: [includes_include],
|
||||
dependencies: [],
|
||||
version: libevdev_so_version,
|
||||
link_args: version_flag,
|
||||
link_depends: mapfile,
|
||||
install: true
|
||||
)
|
||||
|
||||
dep_libevdev = declare_dependency(link_with: lib_libevdev)
|
||||
|
||||
pkgconfig.generate(
|
||||
filebase: 'libevdev',
|
||||
name: 'libevdev',
|
||||
description: 'Handler library for evdev events',
|
||||
version: meson.project_version(),
|
||||
libraries: lib_libevdev,
|
||||
subdirs: 'libevdev-1.0',
|
||||
)
|
||||
|
||||
man_config = configuration_data()
|
||||
man_config.set('PACKAGE_VERSION', meson.project_version())
|
||||
manpage = configure_file(input: 'doc/libevdev.man.in',
|
||||
output: 'libevdev.3',
|
||||
configuration: man_config)
|
||||
install_man(manpage)
|
||||
|
||||
|
||||
# tools
|
||||
executable('libevdev-events',
|
||||
sources: ['tools/libevdev-events.c'],
|
||||
dependencies: dep_libevdev,
|
||||
install: false)
|
||||
executable('touchpad-edge-detector',
|
||||
sources: ['tools/touchpad-edge-detector.c'],
|
||||
dependencies: [dep_libevdev, dep_lm],
|
||||
install: true)
|
||||
executable('mouse-dpi-tool',
|
||||
sources: ['tools/mouse-dpi-tool.c'],
|
||||
dependencies: dep_libevdev,
|
||||
install: true)
|
||||
executable('libevdev-tweak-device',
|
||||
sources: ['tools/libevdev-tweak-device.c'],
|
||||
dependencies: dep_libevdev,
|
||||
install: true)
|
||||
|
||||
|
||||
# tests
|
||||
dep_check = dependency('check', version: '>= 0.9.9',
|
||||
required: get_option('tests'))
|
||||
if dep_check.found()
|
||||
executable('test-link',
|
||||
sources: ['test/test-link.c'],
|
||||
dependencies: dep_libevdev,
|
||||
install: false)
|
||||
executable('test-compile-pedantic',
|
||||
sources: ['test/test-compile-pedantic.c'],
|
||||
c_args: ['-pedantic', '-Werror', '-std=c89'],
|
||||
dependencies: dep_libevdev,
|
||||
install: false)
|
||||
|
||||
src_common = [
|
||||
'test/test-common-uinput.c',
|
||||
'test/test-common-uinput.h',
|
||||
'test/test-common.c',
|
||||
'test/test-common.h',
|
||||
'test/test-main.c',
|
||||
]
|
||||
test_event_codes = executable('test-event-codes',
|
||||
sources: src_common + [
|
||||
'test/test-event-codes.c',
|
||||
'test/test-event-names.c',
|
||||
'test/test-context.c',
|
||||
],
|
||||
dependencies: [dep_libevdev, dep_check],
|
||||
install: false)
|
||||
test('test-event-codes', test_event_codes)
|
||||
|
||||
test_internals = executable('test-internals',
|
||||
sources: src_common + [
|
||||
'test/test-int-queue.c',
|
||||
],
|
||||
dependencies: [dep_libevdev, dep_check],
|
||||
install: false)
|
||||
test('test-internals', test_internals)
|
||||
|
||||
test_uinput = executable('test-uinput',
|
||||
sources: src_common + [
|
||||
'test/test-uinput.c',
|
||||
],
|
||||
dependencies: [dep_libevdev, dep_check],
|
||||
install: false)
|
||||
test('test-uinput', test_uinput)
|
||||
|
||||
test_libevdev = executable('test-libevdev',
|
||||
sources: src_common + [
|
||||
'test/test-libevdev-init.c',
|
||||
'test/test-libevdev-has-event.c',
|
||||
'test/test-libevdev-events.c',
|
||||
],
|
||||
dependencies: [dep_libevdev, dep_check],
|
||||
install: false)
|
||||
test('test-libevdev', test_libevdev)
|
||||
|
||||
test_kernel = executable('test-kernel',
|
||||
sources: src_common + [
|
||||
'test/test-kernel.c',
|
||||
],
|
||||
dependencies: [dep_libevdev, dep_check],
|
||||
install: false)
|
||||
test('test-kernel', test_kernel)
|
||||
|
||||
|
||||
valgrind = find_program('valgrind', required : false)
|
||||
if valgrind.found()
|
||||
valgrind_env = environment()
|
||||
valgrind_suppressions_file = join_paths(dir_src_test, 'valgrind.suppressions')
|
||||
add_test_setup('valgrind',
|
||||
exe_wrapper : [ valgrind,
|
||||
'--leak-check=full',
|
||||
'--gen-suppressions=all',
|
||||
'--error-exitcode=3',
|
||||
'--suppressions=' + valgrind_suppressions_file ],
|
||||
env : valgrind_env,
|
||||
timeout_multiplier : 100)
|
||||
else
|
||||
message('valgrind not found, disabling valgrind test suite')
|
||||
endif
|
||||
|
||||
# FIXME: static link test
|
||||
endif
|
||||
|
||||
doxygen = find_program('doxygen', required: get_option('documentation'))
|
||||
if doxygen.found()
|
||||
doxygen = find_program('doxygen')
|
||||
|
||||
src_doxygen = files(
|
||||
# source files
|
||||
join_paths(dir_src, 'libevdev.h'),
|
||||
join_paths(dir_src, 'libevdev-uinput.h'),
|
||||
# style files
|
||||
'doc/style/bootstrap.css',
|
||||
'doc/style/customdoxygen.css',
|
||||
'doc/style/doxy-boot.js',
|
||||
'doc/style/dynsections.js',
|
||||
'doc/style/footer.html',
|
||||
'doc/style/header.html',
|
||||
'doc/style/layout.xml',
|
||||
'doc/style/libevdevdoxygen.css',
|
||||
'doc/style/LICENSE',
|
||||
'doc/style/README.md',
|
||||
'doc/style/style.css',
|
||||
)
|
||||
doxyfiles = []
|
||||
foreach f: src_doxygen
|
||||
df = configure_file(input: f,
|
||||
output: '@PLAINNAME@',
|
||||
copy: true)
|
||||
doxyfiles += [df]
|
||||
endforeach
|
||||
|
||||
doc_config = configuration_data()
|
||||
doc_config.set('PACKAGE_NAME', meson.project_name())
|
||||
doc_config.set('PACKAGE_VERSION', meson.project_version())
|
||||
doc_config.set('builddir', meson.current_build_dir())
|
||||
doc_config.set('top_srcdir', meson.source_root())
|
||||
doc_config.set('srcdir', join_paths(meson.source_root(), 'doc'))
|
||||
|
||||
doxyfile = configure_file(input: 'doc/libevdev.doxygen.in',
|
||||
output: 'libevdev.doxygen',
|
||||
configuration: doc_config)
|
||||
custom_target('doxygen',
|
||||
input: [doxyfiles, doxyfile] + src_doxygen,
|
||||
output: ['.'],
|
||||
command: [doxygen, doxyfile],
|
||||
install: false,
|
||||
build_by_default: true)
|
||||
endif
|
||||
|
||||
# Coverity breaks because it doesn't define _Float128 correctly, you'll end
|
||||
# up with a bunch of messages in the form:
|
||||
# "/usr/include/stdlib.h", line 133: error #20: identifier "_Float128" is
|
||||
# undefined
|
||||
# extern _Float128 strtof128 (const char *__restrict __nptr,
|
||||
# ^
|
||||
# We don't use float128 ourselves, it gets pulled in from math.h or
|
||||
# something, so let's just define it as uint128 and move on.
|
||||
# Unfortunately we can't detect the coverity build at meson configure
|
||||
# time, we only know it fails at runtime. So make this an option instead, to
|
||||
# be removed when coverity fixes this again.
|
||||
if get_option('coverity')
|
||||
config_h.set('_Float128', '__uint128_t')
|
||||
config_h.set('_Float32', 'int')
|
||||
config_h.set('_Float32x', 'int')
|
||||
config_h.set('_Float64', 'long')
|
||||
config_h.set('_Float64x', 'long')
|
||||
endif
|
||||
|
||||
############ output files ############
|
||||
configure_file(output : 'config.h', configuration : config_h)
|
||||
12
meson_options.txt
Normal file
12
meson_options.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
option('tests',
|
||||
type: 'feature',
|
||||
value: 'enabled',
|
||||
description: 'Build the tests')
|
||||
option('documentation',
|
||||
type: 'feature',
|
||||
value: 'enabled',
|
||||
description: 'Build the documentation')
|
||||
option('coverity',
|
||||
type: 'boolean',
|
||||
value: 'false',
|
||||
description: 'Enable coverity build fixes, see meson.build for details')
|
||||
Loading…
Add table
Reference in a new issue