windows: Add support for Zig's builtin rc compiler #14926
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.
Problems with Zig >=0.14.1
The logs report
zig rc>=0.14.1 asThis description should be sufficient, but it's unfortunate that even the new fixed version of Zig fails to identify itself as Zig.
Zig >=0.14.0 added support for the following flags:
This makes
zig rc's output more flexible. If I'm not mistaken,zig rc /:output-format coffwould qualify it asResourceCompilerType.windresinstead of the currently usedResourceCompilerType.rc. But to my (limited) knowledge, GNU windres can also output several formats.Detecting the output mode specified by the user in the cross file or elsewhere is probably not worth the effort, but I wanted to document this fact somewhere.
Choice of identifier string
The choice of identifier string is tricky. I went with the suggestion at #14372 (comment). I can change it to something else if requested.
I have compiled the outputs of
--version,--helpand/?of all known Windows Resource Compilers: https://gist.github.com/meator/d427310ec1128066ee72400522bbe0b4 This list can help with picking good identifier strings.Testing
I was able to successfully configure a builddir with Zig versions 0.13.0, 0.14.0 and 0.14.1. I tested this on my WIP android-tools fork. I wasn't able to fully compile the project for unrelated reasons1, so that could perhaps use some more testing. The PR's changes are fairly simple, it shouldn't break anything.
I haven't added any unit tests because I don't think that would be appropriate here. The test would have to depend on Zig.
closes #14372
Footnotes
android-tools depends on pthreads. Zig added support for these in 0.14.0 as documented in https://ziglang.org/download/0.14.0/release-notes.html#MinGW-w64. It also indirectly requires
windows.globalization.h, which to my knowledge isn't bundled in Zig yet. ↩