From c9972235833b3586c05a6e6c4145aef6df3f4281 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 3 May 2023 16:26:00 +0200 Subject: [PATCH] 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 --- include/wayland-protocols/meson.build | 18 ++++++++++++++++++ meson.build | 16 +++++++++++++++- tests/meson.build | 2 -- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 include/wayland-protocols/meson.build diff --git a/include/wayland-protocols/meson.build b/include/wayland-protocols/meson.build new file mode 100644 index 0000000..95af9de --- /dev/null +++ b/include/wayland-protocols/meson.build @@ -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 diff --git a/meson.build b/meson.build index c096772..6b663a7 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('wayland-protocols', version: '1.37', - meson_version: '>= 0.55.0', + meson_version: '>= 0.58.0', license: 'MIT/Expat', ) @@ -8,6 +8,9 @@ wayland_protocols_version = meson.project_version() 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 = { 'presentation-time': [''], 'viewporter': [''], @@ -108,6 +111,12 @@ foreach protocol_file : protocol_files ) 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() pkgconfig_configuration = configuration_data() @@ -132,6 +141,7 @@ configure_file( ) wayland_protocols = declare_dependency( + include_directories: include_dirs, variables: { 'pkgdatadir': wayland_protocols_srcdir, }, @@ -142,3 +152,7 @@ meson.override_dependency('wayland-protocols', wayland_protocols) if get_option('tests') subdir('tests') endif + +summary({ + 'Headers': include_dirs.length() > 0, +}, bool_yn: true) diff --git a/tests/meson.build b/tests/meson.build index 4f7cdf8..aa216ec 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,6 +1,4 @@ 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 = [ dependency('wayland-client'),