render/gles2: skip glslang check when shaders are unchanged

Currently, the glslang check is run every time ninja is invoked,
even with an up-to-date build directory when GLSL shaders haven't
been modified. This is due to glslang not creating any output
file: the _check file never exists so ninja keeps trying to
generate it by running the command.

Unfortunately Meson doesn't support running commands with no
outputs [1]. Create an empty output file to fix this by setting
`capture: true`.

This doesn't work out-of-the-box, because glslang prints messages
to stdout, and provides no way to change this [2]. As a result,
shader errors are not surfaced back to the user - they end up in
the _check file. Workaround this with a thin wrapper which
redirects stdout to stderr when invoking glslang.

[1]: https://github.com/mesonbuild/meson/issues/11506
[2]: https://github.com/KhronosGroup/glslang/pull/4138
This commit is contained in:
Simon Ser 2026-01-03 19:35:17 +01:00 committed by Simon Zeni
parent 2c64b30a67
commit 89c9ef6692
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,4 @@
#!/bin/sh -eu
# glslang prints log messages to stdout, remap to stderr
exec "$@" >&2

View file

@ -1,3 +1,4 @@
check = find_program('./check.sh', native: true)
embed = find_program('./embed.sh', native: true)
shaders = [
@ -13,7 +14,8 @@ foreach name : shaders
'gles2-' + name,
input: name,
output: name + '_check',
command: [glslang, '@INPUT@'],
command: [check, glslang, '@INPUT@'],
capture: true,
build_by_default: true,
)