Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/markdown/snippets/zig-rc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Added support for Zig's builtin Windows Resource Compiler

Using `zig rc` as `windres` no longer triggers the error `Could not determine
type of Windows resource compiler`.

Note: Zig 0.14.1 and later have modified their CLI for Meson compatibility, so
this change is only relevant when using `zig rc` versions earlier than 0.14.1.
11 changes: 10 additions & 1 deletion mesonbuild/modules/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def _find_resource_compiler(self, state: 'ModuleState') -> T.Tuple[ExternalProgr
raise MesonException('Could not find Windows resource compiler')

for (arg, match, rc_type) in [
# Zig >=0.14.1 is also matched by the regex below.
('/?', '^.*Microsoft.*Resource Compiler.*$', ResourceCompilerType.rc),
('/?', 'LLVM Resource Converter.*$', ResourceCompilerType.rc),
('--version', '^.*GNU windres.*$', ResourceCompilerType.windres),
Expand All @@ -98,7 +99,15 @@ def _find_resource_compiler(self, state: 'ModuleState') -> T.Tuple[ExternalProgr
self._rescomp = (rescomp, rc_type)
break
else:
raise MesonException('Could not determine type of Windows resource compiler')
# Zig <0.14.1 prints its info to stderr, so we'll handle it separately.
_, _, e = mesonlib.Popen_safe(rescomp.get_command() + ['/?'])
# The string below should be indicative of a resinator rc compiler
# (which includes zig rc).
if re.search('^Supported Win32 RC Options:$', e, re.MULTILINE):
mlog.log('Windows resource compiler: Zig <0.14.1/restinator Resource Compiler')
self._rescomp = (rescomp, ResourceCompilerType.rc)
else:
raise MesonException('Could not determine type of Windows resource compiler')

return self._rescomp

Expand Down
Loading