From 95a8def7c25a3fa6881463699a1a4c2efc10e6cc Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 1 Mar 2022 13:48:04 -0500 Subject: [PATCH] Meson: Use wayland module --- gdk/wayland/meson.build | 84 +++++++++++------------------------------ gtk/meson.build | 47 ++--------------------- meson.build | 2 - 3 files changed, 27 insertions(+), 106 deletions(-) diff --git a/gdk/wayland/meson.build b/gdk/wayland/meson.build index 00e584a105..927d82d55b 100644 --- a/gdk/wayland/meson.build +++ b/gdk/wayland/meson.build @@ -47,73 +47,35 @@ gdk_wayland_deps = [ wlegldep, ] -wayland_scanner = find_program('wayland-scanner') - -# Format: -# - protocol name -# - protocol stability ('private', 'stable' or 'unstable') -# - protocol version (if stability is 'unstable') +wlmod = import('unstable-wayland') proto_sources = [ - ['gtk-shell', 'private', ], - ['primary-selection', 'unstable', 'v1', ], - ['pointer-gestures', 'unstable', 'v1', ], - ['viewporter', 'stable', ], - ['xdg-shell', 'unstable', 'v6', ], - ['xdg-shell', 'stable', ], - ['xdg-foreign', 'unstable', 'v1', ], - ['xdg-foreign', 'unstable', 'v2', ], - ['tablet', 'unstable', 'v2', ], - ['keyboard-shortcuts-inhibit', 'unstable', 'v1', ], - ['server-decoration', 'private' ], - ['xdg-output', 'unstable', 'v1', ], - ['idle-inhibit', 'unstable', 'v1', ], - ['xdg-activation', 'staging', 'v1', ], - ['fractional-scale', 'staging', 'v1', ], - ['linux-dmabuf', 'unstable', 'v1', ], - ['presentation-time', 'stable', 'v1', ], + 'protocol/gtk-shell.xml', + 'protocol/server-decoration.xml', + wlmod.find_protocol('primary-selection', state: 'unstable', version: 1), + wlmod.find_protocol('pointer-gestures', state: 'unstable', version: 1), + wlmod.find_protocol('viewporter', state: 'stable'), + wlmod.find_protocol('xdg-shell', state: 'unstable', version: 6), + wlmod.find_protocol('xdg-shell', state: 'stable'), + wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 1), + wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 2), + wlmod.find_protocol('tablet', state: 'unstable', version: 2), + wlmod.find_protocol('keyboard-shortcuts-inhibit', state: 'unstable', version: 1), + wlmod.find_protocol('xdg-output', state: 'unstable', version: 1), + wlmod.find_protocol('idle-inhibit', state: 'unstable', version: 1), + wlmod.find_protocol('xdg-activation', state: 'staging', version: 1), + wlmod.find_protocol('fractional-scale', state: 'staging', version: 1), + wlmod.find_protocol('linux-dmabuf', state: 'unstable', version: 1), + wlmod.find_protocol('presentation-time', state: 'stable'), ] gdk_wayland_gen_headers = [] foreach p: proto_sources - proto_name = p.get(0) - proto_stability = p.get(1) - - if proto_stability == 'stable' - output_base = proto_name - input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base))) - elif proto_stability == 'staging' - proto_version = p.get(2) - output_base = '@0@-@1@'.format(proto_name, proto_version) - input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base))) - elif proto_stability == 'private' - output_base = proto_name - input = files('protocol/@0@.xml'.format(proto_name)) - else - proto_version = p.get(2) - output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability, proto_version) - input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base))) - endif - - gdk_wayland_gen_headers += custom_target('@0@ client header'.format(output_base), - input: input, - output: '@0@-client-protocol.h'.format(output_base), - command: [ - wayland_scanner, - 'client-header', - '@INPUT@', '@OUTPUT@', - ], - ) - - gdk_wayland_sources += custom_target('@0@ source'.format(output_base), - input: input, - output: '@0@-protocol.c'.format(output_base), - command: [ - wayland_scanner, - 'private-code', - '@INPUT@', '@OUTPUT@', - ], - ) + # Returns a list [.c, .h] + gen = wlmod.scan_xml(p) + assert(gen.length() == 2) + gdk_wayland_sources += gen[0] + gdk_wayland_gen_headers += gen[1] endforeach libgdk_wayland = static_library('gdk-wayland', diff --git a/gtk/meson.build b/gtk/meson.build index 1591a36c9e..4b32db4164 100644 --- a/gtk/meson.build +++ b/gtk/meson.build @@ -636,49 +636,6 @@ install_headers(gtk_print_headers, subdir: 'gtk-4.0/gtk/print') gtk_sources = gtk_public_sources + gtk_private_sources -proto_sources = [ - ['text-input', 'unstable', 'v3', ], -] - -im_wayland_sources = files('gtkimcontextwayland.c') - -foreach p: proto_sources - proto_name = p.get(0) - proto_stability = p.get(1) - - if wayland_enabled - if proto_stability == 'stable' - output_base = proto_name - input = files('@0@.xml'.format(proto_name)) - else - proto_version = p.get(2) - output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability, proto_version) - input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base))) - endif - - # wayland_scanner is defined in gdk/wayland/meson.build - im_wayland_sources += custom_target('@0@ client header'.format(output_base), - input: input, - output: '@0@-client-protocol.h'.format(output_base), - command: [ - wayland_scanner, - 'client-header', - '@INPUT@', '@OUTPUT@', - ], - ) - - im_wayland_sources += custom_target('@0@ source'.format(output_base), - input: input, - output: '@0@-protocol.c'.format(output_base), - command: [ - wayland_scanner, - 'private-code', - '@INPUT@', '@OUTPUT@', - ], - ) - endif -endforeach - if os_unix and tracker3_dep.found() gtk_sources += 'gtksearchenginetracker3.c' endif @@ -708,6 +665,10 @@ if x11_enabled endif if wayland_enabled + im_wayland_sources = files('gtkimcontextwayland.c') + xml = wlmod.find_protocol('text-input', state: 'unstable', version: 3) + im_wayland_sources += wlmod.scan_xml(xml) + gtk_sources += ['gtkapplication-wayland.c'] gtk_sources += im_wayland_sources endif diff --git a/meson.build b/meson.build index 93729e0f3d..7a75078ac3 100644 --- a/meson.build +++ b/meson.build @@ -490,8 +490,6 @@ if wayland_enabled wlprotocolsdep = dependency('wayland-protocols', version: wayland_proto_req) wlegldep = dependency('wayland-egl') - wlproto_dir = wlprotocolsdep.get_variable('pkgdatadir') - wayland_pkgs = [ 'wayland-client @0@'.format(wayland_req), 'xkbcommon @0@'.format(xkbcommon_req),