From 47cd010931a48fcdf259ffcd455ca065f180adc3 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 26 Aug 2022 11:01:29 +0200 Subject: [PATCH] wayland: generalize wayland-protocols code generation Make it easy to add a new protocol to the list without duplicating logic. Signed-off-by: Simon Ser Reviewed-by: Eric Engestrom Reviewed-by: Daniel Stone Part-of: --- meson.build | 4 --- src/egl/meson.build | 7 ++---- src/egl/wayland/wayland-drm/meson.build | 33 +++++++++++++++---------- src/vulkan/wsi/meson.build | 5 +--- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/meson.build b/meson.build index 37c323200a8..3351d4e4d37 100644 --- a/meson.build +++ b/meson.build @@ -1913,10 +1913,6 @@ if with_platform_wayland dep_wayland_egl = dependency('wayland-egl-backend', version : '>= 3') dep_wayland_egl_headers = dep_wayland_egl.partial_dependency(compile_args : true) endif - wayland_dmabuf_xml = join_paths( - dep_wl_protocols.get_variable(pkgconfig : 'pkgdatadir'), 'unstable', - 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml' - ) pre_args += '-DWL_HIDE_DEPRECATED' endif diff --git a/src/egl/meson.build b/src/egl/meson.build index ac9a48e0990..013a93367d6 100644 --- a/src/egl/meson.build +++ b/src/egl/meson.build @@ -129,11 +129,8 @@ if with_dri2 deps_for_egl += [dep_wayland_client, dep_wayland_server, dep_wayland_egl_headers] link_for_egl += libwayland_drm files_egl += files('drivers/dri2/platform_wayland.c') - files_egl += [ - linux_dmabuf_unstable_v1_protocol_c, - linux_dmabuf_unstable_v1_client_protocol_h, - wayland_drm_client_protocol_h, - ] + files_egl += wp_files['linux-dmabuf-unstable-v1'] + files_egl += [wayland_drm_client_protocol_h] incs_for_egl += include_directories('wayland/wayland-drm') endif if with_platform_android diff --git a/src/egl/wayland/wayland-drm/meson.build b/src/egl/wayland/wayland-drm/meson.build index b4782a013c9..7bb9237e06e 100644 --- a/src/egl/wayland/wayland-drm/meson.build +++ b/src/egl/wayland/wayland-drm/meson.build @@ -57,16 +57,23 @@ libwayland_drm = static_library( # # Moving these to a src/wsi/ was suggested but shot down, so put these # here for now as the maybe-least-bad solution. -linux_dmabuf_unstable_v1_protocol_c = custom_target( - 'linux-dmabuf-unstable-v1-protocol.c', - input : wayland_dmabuf_xml, - output : 'linux-dmabuf-unstable-v1-protocol.c', - command : [prog_wl_scanner, wl_scanner_arg, '@INPUT@', '@OUTPUT@'], -) - -linux_dmabuf_unstable_v1_client_protocol_h = custom_target( - 'linux-dmabuf-unstable-v1-client-protocol.h', - input : wayland_dmabuf_xml, - output : 'linux-dmabuf-unstable-v1-client-protocol.h', - command : [prog_wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'], -) +wp_dir = dep_wl_protocols.get_variable(pkgconfig : 'pkgdatadir') +wp_protos = { + 'linux-dmabuf-unstable-v1': 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml', +} +wp_files = {} +foreach name, xml : wp_protos + code = custom_target( + name + '-protocol.c', + input : join_paths(wp_dir, xml), + output : name + '-protocol.c', + command : [prog_wl_scanner, wl_scanner_arg, '@INPUT@', '@OUTPUT@'], + ) + header = custom_target( + name + '-client-protocol.h', + input : join_paths(wp_dir, xml), + output : name + '-client-protocol.h', + command : [prog_wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'], + ) + wp_files += { name: [code, header] } +endforeach diff --git a/src/vulkan/wsi/meson.build b/src/vulkan/wsi/meson.build index 0a9ac8ef572..08414a386da 100644 --- a/src/vulkan/wsi/meson.build +++ b/src/vulkan/wsi/meson.build @@ -31,10 +31,7 @@ endif if with_platform_wayland files_vulkan_wsi += files('wsi_common_wayland.c') - files_vulkan_wsi += [ - linux_dmabuf_unstable_v1_client_protocol_h, - linux_dmabuf_unstable_v1_protocol_c, - ] + files_vulkan_wsi += wp_files['linux-dmabuf-unstable-v1'] endif if with_platform_windows