modules/wayland: Support --include-core-only

wayland-scanner can generate header files that only include
wayland-client-core.h using a flag.

Add a core_only option to scan_xml to support this use case.
pull/10786/head
Mark Bolhuis 2 years ago committed by Xavier Claessens
parent a4d5442207
commit 25f838fd33
  1. 3
      docs/markdown/Wayland-module.md
  2. 5
      docs/markdown/snippets/wayland_scan_xml_core_only_arg.md
  3. 8
      mesonbuild/modules/wayland.py
  4. 9
      test cases/wayland/2 core only/core.c
  5. 14
      test cases/wayland/2 core only/meson.build

@ -50,6 +50,7 @@ generated = wl_mod.scan_xml(
client : true,
server : true,
public : false,
core_only : false,
)
```
This function accepts one or more arguments of either string or file type.
@ -61,6 +62,8 @@ It takes the following keyword arguments:
generated. The default is true.
- `server` Optional arg that specifies if server side header file is
generated. The default is false.
- `core_only` Optional arg that specifies that generated headers only include
wayland-client-core.h instead of wayland-client.h. Since *0.64.0*
**Returns**: a list of [[@custom_tgt]] in the order source, client side header,
server side header. Generated header files have the name

@ -0,0 +1,5 @@
## Added core_only arg to wayland.scan_xml.
The `scan_xml` function from the wayland module now has an optional bool
argument `core_only`, so that headers generated by wayland-scanner now
only include `wayland-client-core.h` instead of `wayland-client.h`.

@ -37,6 +37,7 @@ if T.TYPE_CHECKING:
public: bool
client: bool
server: bool
core_only: bool
class FindProtocol(TypedDict):
@ -65,6 +66,7 @@ class WaylandModule(ExtensionModule):
KwargInfo('public', bool, default=False),
KwargInfo('client', bool, default=True),
KwargInfo('server', bool, default=False),
KwargInfo('core_only', bool, default=False, since='0.64.0'),
)
def scan_xml(self, state: ModuleState, args: T.Tuple[T.List[FileOrString]], kwargs: ScanXML) -> ModuleReturnValue:
if self.scanner_bin is None:
@ -98,12 +100,16 @@ class WaylandModule(ExtensionModule):
targets.append(code)
for side in sides:
command = [self.scanner_bin, f'{side}-header', '@INPUT@', '@OUTPUT@']
if kwargs['core_only']:
command.append('--include-core-only')
header = CustomTarget(
f'{name}-{side}-protocol',
state.subdir,
state.subproject,
state.environment,
[self.scanner_bin, f'{side}-header', '@INPUT@', '@OUTPUT@'],
command,
[xml_file],
[f'{name}-{side}-protocol.h'],
backend=state.backend,

@ -0,0 +1,9 @@
#include <xdg-shell-client-protocol.h>
int main() {
#if defined(XDG_SHELL_CLIENT_PROTOCOL_H) && !defined(WAYLAND_CLIENT_H) && !defined(WAYLAND_CLIENT_PROTOCOL_H)
return 0;
#else
return 1;
#endif
}

@ -0,0 +1,14 @@
project('wayland-test-core-only', 'c')
wl_protocols_dep = dependency('wayland-protocols', required : false)
if not wl_protocols_dep.found()
error('MESON_SKIP_TEST: wayland-protocols not installed')
endif
wl_mod = import('unstable-wayland')
wl_client_dep = dependency('wayland-client')
xdg_shell_xml = wl_mod.find_protocol('xdg-shell')
xdg_shell = wl_mod.scan_xml(xdg_shell_xml, core_only : true)
exe = executable('core', 'core.c', xdg_shell, dependencies : wl_client_dep)
test('core', exe)
Loading…
Cancel
Save