Trick the meson build system into thinking zig rc
is rc.exe
#23301
+3
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(would appreciate this being included in 0.14.1)
When determining the type of RC compiler, meson passes
/?
or--version
and then reads fromstdout
looking for particular string(s) anywhere in the output.So, by adding the string "Microsoft Resource Compiler" to the
/?
output, meson will recognizezig rc
as rc.exe and give it the correct options, which works fine sincezig rc
is drop-in CLI compatible with rc.exe.This allows using
zig rc
with meson for (cross-)compiling, by either:WINDRES="zig rc"
or puttingwindres = ['zig', 'rc']
in the cross-fileWINDRES="zig rc /:output-format coff"
or puttingwindres = ['zig', 'rc', '/:output-format', 'coff']
in the cross-fileExample cross file that uses
zig cc
(which can link.res
files, so/:output-format coff
is not necessary) andzig rc
:Using the test project here with the example cross file above to cross-compile from Linux:
(the
hello world
string comes from a resource)Relevant links:
zig rc
: Add COFF object file creation for CMake cross-compilation use case #22813 (getting this same sort of thing to work for CMake)/?
outputs to stderr instead of stdout squeek502/resinator#17 (upstream resinator issue about this)