zig/lib/compiler/resinator
Ryan Liptak 9c9d3931df Trick the meson build system into thinking zig rc is rc.exe
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'
```
2025-03-21 18:07:16 -04:00
..
ani.zig
ast.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
bmp.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
cli.zig Trick the meson build system into thinking zig rc is rc.exe 2025-03-21 18:07:16 -04:00
code_pages.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
comments.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
compile.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
cvtres.zig zig rc: Add COFF object file creation for CMake cross-compilation use case 2025-02-22 21:21:30 -05:00
disjoint_code_page.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
errors.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
ico.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
lang.zig zig build fmt 2025-02-22 17:09:20 -08:00
lex.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
literals.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
main.zig Trick the meson build system into thinking zig rc is rc.exe 2025-03-21 18:07:16 -04:00
parse.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
preprocess.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
rc.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
res.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
source_mapping.zig resinator: Sync with upstream 2025-01-17 23:10:41 -08:00
utils.zig Integrate resinator errors with Zig using std.zig.Server and ErrorBundle 2024-03-11 05:06:16 -07:00
windows1252.zig