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 <contact@emersion.fr>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22682>
This commit is contained in:
Simon Ser
2022-08-26 11:01:29 +02:00
committed by Marge Bot
parent 0b251d4362
commit 47cd010931
4 changed files with 23 additions and 26 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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