From c48e96fd76643dcef460a3d84f4692ee6c18aef1 Mon Sep 17 00:00:00 2001 From: Slava Andrejev Date: Thu, 2 Nov 2023 18:41:15 -0700 Subject: [PATCH] meson: prevent sandbox violation if GStreamer and wayland-protocols are subprojects Suppose you have a project where GStreamer and wayland-protocols are pulled in as dependencies via .wrap files. In that case, Meson's setup step will fail for gst-plugins-bad with the message "Sandbox violation: Tried to grab file viewporter.xml outside current (sub)project." To avoid this exception, one should use Meson's `files` and `join_paths` functions. The suggested solution is identical to how GTK 4 processes Wayland files. Part-of: --- .../gst-libs/gst/wayland/meson.build | 54 ++++++++++++------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/wayland/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/wayland/meson.build index f96da60e1c..7dcc56d1f5 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/wayland/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/wayland/meson.build @@ -7,7 +7,7 @@ wl_scanner = find_program('wayland-scanner', required: get_option('wayland')) use_wayland = wl_protocol_dep.found() and wl_client_dep.found() and wl_scanner.found() and libdrm_dep.found() if use_wayland - wl_sources = [ + wl_sources = files([ 'gstwlbuffer.c', 'gstwlcontext.c', 'gstwldisplay.c', @@ -16,9 +16,9 @@ if use_wayland 'gstwlvideobufferpool.c', 'gstwlvideoformat.c', 'gstwlwindow.c', - ] + ]) - wl_headers = [ + wl_headers = files([ 'gstwl_fwd.h', 'gstwlbuffer.h', 'gstwlcontext.h', @@ -30,32 +30,48 @@ if use_wayland 'gstwlwindow.h', 'wayland.h', 'wayland-prelude.h', - ] + ]) protocols_datadir = wl_protocol_dep.get_variable('pkgdatadir') protocol_defs = [ - ['/stable/viewporter/viewporter.xml', 'viewporter-protocol.c', 'viewporter-client-protocol.h'], - ['/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml', - 'linux-dmabuf-unstable-v1-protocol.c', 'linux-dmabuf-unstable-v1-client-protocol.h'], - ['/unstable/fullscreen-shell/fullscreen-shell-unstable-v1.xml', - 'fullscreen-shell-unstable-v1-protocol.c', 'fullscreen-shell-unstable-v1-client-protocol.h'], - ['/stable/xdg-shell/xdg-shell.xml', 'xdg-shell-protocol.c', 'xdg-shell-client-protocol.h'], + ['viewporter', 'stable', ], + ['linux-dmabuf', 'unstable', 'v1', ], + ['fullscreen-shell', 'unstable', 'v1', ], + ['xdg-shell', 'stable', ] ] protocols_files = [] foreach protodef: protocol_defs - xmlfile = protocols_datadir + protodef.get(0) + proto_name = protodef.get(0) + proto_stability = protodef.get(1) + if proto_stability == 'stable' + output_base = proto_name + else + proto_version = protodef.get(2) + output_base = f'@proto_name@-@proto_stability@-@proto_version@' + endif + input = protocols_datadir / proto_stability / proto_name / f'@output_base@.xml' - protocols_files += [custom_target(protodef.get(1), - output : protodef.get(1), - input : xmlfile, - command : [wl_scanner, 'code', '@INPUT@', '@OUTPUT@'])] + protocols_files += [custom_target(f'@output_base@ client header', + input: input, + output: f'@output_base@-client-protocol.h', + command: [ + wl_scanner, + 'client-header', + '@INPUT@', '@OUTPUT@', + ], + )] - protocols_files += [custom_target(protodef.get(2), - output : protodef.get(2), - input : xmlfile, - command : [wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'])] + protocols_files += [custom_target(f'@output_base@ source', + input: input, + output: f'@output_base@-protocol.c', + command: [ + wl_scanner, + 'code', + '@INPUT@', '@OUTPUT@', + ], + )] endforeach extra_c_args = [