Skip to content

Commit

Permalink
wayland-protocols: fix tests on older versions of wayland-scanner
Browse files Browse the repository at this point in the history
wayland-protocols 1.38 adds a `deprecated-since` attribute to some
protocols. This attribute is only supported in wayland-scanner 1.23.

The current version of wayland-scanner on CI is older than 1.23, so
the tests fail to build. To fix this, this commit disables
wayland-scanner's strict mode for the affected protocols if its version
is older than 1.23.
  • Loading branch information
MonterraByte committed Oct 15, 2024
1 parent 1b533fe commit 8b8e4e5
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 0 deletions.
158 changes: 158 additions & 0 deletions subprojects/packagefiles/wayland-protocols/tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
prog_scan_sh = find_program('scan.sh')

libwayland = [
dependency('wayland-client'),
dependency('wayland-server'),
]

dep_scanner_version_parts = dep_scanner.version().split('.')
dep_scanner_version_major = dep_scanner_version_parts[0].to_int()
dep_scanner_version_minor = dep_scanner_version_parts[1].to_int()

supports_deprecated_since = true
if dep_scanner_version_major == 1 and dep_scanner_version_minor < 23
supports_deprecated_since = false
endif

# Check that each protocol passes through the scanner
foreach protocol_file : protocol_files
if not supports_deprecated_since and fs.name(protocol_file).split('.')[0] in ['linux-dmabuf-v1', 'xdg-output-unstable-v1']:
continue
endif

protocol_path = join_paths(wayland_protocols_srcdir, protocol_file)
test_name = 'scan-@0@'.format(protocol_file.underscorify())
test(test_name, prog_scan_sh,
args: protocol_path,
env: [
'SCANNER=@0@'.format(prog_scanner.full_path()),
]
)
endforeach

# Check buildability

add_languages('c', 'cpp', native: false)
replace = find_program('replace.py')

extra_linker_flags = meson.get_compiler('c').get_supported_link_arguments([
'-Wl,--unresolved-symbols=ignore-all',
])

foreach protocol_file : protocol_files
xml_file = fs.name(protocol_file)
xml_components = xml_file.split('.')
protocol_base_file_name = xml_components[0]

strict = true
if not supports_deprecated_since and protocol_base_file_name in ['linux-dmabuf-v1', 'xdg-output-unstable-v1']
strict = false
endif

protocol_path = files(join_paths(wayland_protocols_srcdir, protocol_file))
client_header_path = '@[email protected]'.format(protocol_base_file_name)
server_header_path = '@[email protected]'.format(protocol_base_file_name)
code_path = '@[email protected]'.format(protocol_base_file_name)
client_header = custom_target(
client_header_path,
output: client_header_path,
input: protocol_path,
command: [
prog_scanner,
'client-header',
'@INPUT@',
'@OUTPUT@',
] + (strict ? ['--strict'] : []),
install: false,
)
server_header = custom_target(
server_header_path,
output: server_header_path,
input: protocol_path,
command: [
prog_scanner,
'server-header',
'@INPUT@',
'@OUTPUT@',
] + (strict ? ['--strict'] : []),
install: false,
)
code = custom_target(
code_path,
output: code_path,
input: protocol_path,
command: [
prog_scanner,
'private-code',
'@INPUT@',
'@OUTPUT@',
] + (strict ? ['--strict'] : []),
install: false,
)

replace_command = [
replace,
'@INPUT@',
'@OUTPUT@',
'PROTOCOL_CLIENT_INCLUDE_FILE',
client_header.full_path(),
'PROTOCOL_SERVER_INCLUDE_FILE',
server_header.full_path(),
]

# Check that header can be included by a pedantic C99 compiler
test_name = 'test-build-pedantic-@0@'.format(protocol_file.underscorify())
test_name_source = '@[email protected]'.format(test_name)
test_source = custom_target(
test_name_source,
input: 'build-pedantic.c.in',
output: test_name_source,
command: replace_command,
)
pedantic_test_executable = executable(
test_name,
[
test_source,
client_header,
server_header,
code
],
link_args: extra_linker_flags,
dependencies: libwayland,
c_args: [
'-std=c99',
'-pedantic',
'-Wall',
'-Werror' ],
install: false,
)
test(test_name, pedantic_test_executable)

# Check that the header
if not protocol_file.contains('xdg-foreign-unstable-v1')
test_name = 'test-build-cxx-@0@'.format(protocol_file.underscorify())
test_name_source = '@[email protected]'.format(test_name)
test_source = custom_target(
test_name_source,
input: 'build-cxx.cc.in',
output: test_name_source,
command: replace_command,
)
cxx_test_executable = executable(
test_name,
[
test_source,
client_header,
server_header,
],
link_args: extra_linker_flags,
dependencies: libwayland,
cpp_args: [
'-Wall',
'-Werror',
],
install: false,
)
test(test_name, cxx_test_executable)
endif
endforeach
1 change: 1 addition & 0 deletions subprojects/wayland-protocols.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ directory = wayland-protocols-1.38
source_url = https://gitlab.freedesktop.org/wayland/wayland-protocols/-/releases/1.38/downloads/wayland-protocols-1.38.tar.xz
source_filename = wayland-protocols-1.38.tar.xz
source_hash = ff17292c05159d2b20ce6cacfe42d7e31a28198fa1429a769b03af7c38581dbe
patch_directory = wayland-protocols

[provide]
wayland-protocols = wayland_protocols

0 comments on commit 8b8e4e5

Please sign in to comment.