| author | |
| committer | |
| log | 59bdd7722939219c8d4267d301cdf063d9c26421 |
| tree | e30837a5dc096d6709bdc7609feedbfb7a2377b3 |
| parent | bfc554b542175bf21179804a269e3f65aff7fe18 |
When determining the type of RC compiler, meson passes `/?` or `--version` and then reads from `stdout` looking for particular string(s) anywhere in the output.
So, by adding the string "Microsoft Resource Compiler" to the `/?` output, meson will recognize `zig rc` as rc.exe and give it the correct options, which works fine since `zig rc` is drop-in CLI compatible with rc.exe.
This allows using `zig rc` with meson for (cross-)compiling, by either:
- Setting WINDRES="zig rc" or putting windres = ['zig', 'rc'] in the cross-file
+ This will work like rc.exe, so it will output .res files. This will only link successfully if you are using a linker that can do .res -> .obj conversion (so something like zig cc, MSVC, lld)
- Setting WINDRES="zig rc /:output-format coff" or putting windres = ['zig', 'rc', '/:output-format', 'coff'] in the cross-file
+ This will make meson pass flags as if it were rc.exe, but it will cause the resulting .res file to actually be a COFF object file, meaning it will work with any linker that handles COFF object files
Example cross file that uses `zig cc` (which can link `.res` files, so `/:output-format coff` is not necessary) and `zig rc`:
```
[binaries]
c = ['zig', 'cc', '--target=x86_64-windows-gnu']
windres = ['zig', 'rc']
[target_machine]
system = 'windows'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
```2 files changed, 3 insertions(+), 1 deletions(-)
lib/compiler/resinator/cli.zig+1| ... | @@ -17,6 +17,7 @@ pub const usage_string_after_command_name = | ... | @@ -17,6 +17,7 @@ pub const usage_string_after_command_name = |
| 17 | \\This is necessary when the input path begins with a forward slash. | 17 | \\This is necessary when the input path begins with a forward slash. |
| 18 | \\ | 18 | \\ |
| 19 | \\Supported option prefixes are /, -, and --, so e.g. /h, -h, and --h all work. | 19 | \\Supported option prefixes are /, -, and --, so e.g. /h, -h, and --h all work. |
| 20 | \\Drop-in compatible with the Microsoft Resource Compiler. | ||
| 20 | \\ | 21 | \\ |
| 21 | \\Supported Win32 RC Options: | 22 | \\Supported Win32 RC Options: |
| 22 | \\ /?, /h Print this help and exit. | 23 | \\ /?, /h Print this help and exit. |
lib/compiler/resinator/main.zig+2-1| ... | @@ -81,7 +81,8 @@ pub fn main() !void { | ... | @@ -81,7 +81,8 @@ pub fn main() !void { |
| 81 | defer options.deinit(); | 81 | defer options.deinit(); |
| 82 | 82 | ||
| 83 | if (options.print_help_and_exit) { | 83 | if (options.print_help_and_exit) { |
| 84 | try cli.writeUsage(stderr.writer(), "zig rc"); | 84 | const stdout = std.io.getStdOut(); |
| 85 | try cli.writeUsage(stdout.writer(), "zig rc"); | ||
| 85 | return; | 86 | return; |
| 86 | } | 87 | } |
| 87 | 88 |