build: install headers with enums

Generate and install headers containing enums. See [1].

Meson requires us to generate headers in a "include/wayland-protocols"
directory, so that include paths can be properly set up when used
as a sub-project.

[1]: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/312

Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
Simon Ser 2023-05-03 16:26:00 +02:00 committed by Daniel Stone
parent e7fea17be8
commit c997223583
3 changed files with 33 additions and 3 deletions

View file

@ -0,0 +1,18 @@
header_install_dir = get_option('includedir') / 'wayland-protocols'
foreach protocol_file : protocol_files
header_name = fs.name(protocol_file).replace('.xml', '-enum.h')
custom_target(
header_name,
output: header_name,
input: '../..' / protocol_file,
command: [
prog_scanner,
'--strict',
'enum-header',
'@INPUT@',
'@OUTPUT@',
],
install: true,
install_dir: header_install_dir,
)
endforeach

View file

@ -1,6 +1,6 @@
project('wayland-protocols', project('wayland-protocols',
version: '1.37', version: '1.37',
meson_version: '>= 0.55.0', meson_version: '>= 0.58.0',
license: 'MIT/Expat', license: 'MIT/Expat',
) )
@ -8,6 +8,9 @@ wayland_protocols_version = meson.project_version()
fs = import('fs') fs = import('fs')
dep_scanner = dependency('wayland-scanner', version: '>=1.20.0', native: true, fallback: 'wayland')
prog_scanner = find_program(dep_scanner.get_variable(pkgconfig: 'wayland_scanner', internal: 'wayland_scanner'))
stable_protocols = { stable_protocols = {
'presentation-time': [''], 'presentation-time': [''],
'viewporter': [''], 'viewporter': [''],
@ -108,6 +111,12 @@ foreach protocol_file : protocol_files
) )
endforeach endforeach
include_dirs = []
if dep_scanner.version().version_compare('>=1.22.90')
subdir('include/wayland-protocols')
include_dirs = ['include']
endif
wayland_protocols_srcdir = meson.current_source_dir() wayland_protocols_srcdir = meson.current_source_dir()
pkgconfig_configuration = configuration_data() pkgconfig_configuration = configuration_data()
@ -132,6 +141,7 @@ configure_file(
) )
wayland_protocols = declare_dependency( wayland_protocols = declare_dependency(
include_directories: include_dirs,
variables: { variables: {
'pkgdatadir': wayland_protocols_srcdir, 'pkgdatadir': wayland_protocols_srcdir,
}, },
@ -142,3 +152,7 @@ meson.override_dependency('wayland-protocols', wayland_protocols)
if get_option('tests') if get_option('tests')
subdir('tests') subdir('tests')
endif endif
summary({
'Headers': include_dirs.length() > 0,
}, bool_yn: true)

View file

@ -1,6 +1,4 @@
prog_scan_sh = find_program('scan.sh') prog_scan_sh = find_program('scan.sh')
dep_scanner = dependency('wayland-scanner', version: '>=1.20.0', native: true, fallback: 'wayland')
prog_scanner = find_program(dep_scanner.get_variable(pkgconfig: 'wayland_scanner', internal: 'wayland_scanner'))
libwayland = [ libwayland = [
dependency('wayland-client'), dependency('wayland-client'),