Commit graph

15 commits

Author SHA1 Message Date
Ryan Liptak
a502301b5e zig rc: Add COFF object file creation for CMake cross-compilation use case
In #22522 I said:

> RC="zig rc" will now work in combination with zig cc and CMake. Here's an example of cross-compiling a simple Windows GUI CMake project
>
>    $ RC="zig rc" CC="zig cc --target=x86_64-windows-gnu" cmake .. -DCMAKE_SYSTEM_NAME=Windows -G Ninja

However, I didn't realize that the time that this only works because of the `-G Ninja` part. When not using Ninja as the build tool, CMake adds a workaround for 'very long lists of object files' where it takes all object files and runs them through `ar` to combine them into one archive:

4a11fd8dde/Modules/Platform/Windows-GNU.cmake (L141-L158)

This is a problem for the Windows resource use-case, because `ar` doesn't know how to deal with `.res` files and so this object combining step fails with:

    unknown file type: foo.rc.res

Only the linker knows what to do with .res files (since it has its own `.res` -> `.obj` ('cvtres') conversion mechanism). So, when using Ninja, this object file combining step is skipped and the .res file gets passed to the linker and everyone is happy.

Note: When CMake thinks that its using `windres` as the Windows resource compiler, it will pass `-O coff` to windres which causes it to output a COFF object file instead of a `.res` file, which means that the `ar` step can succeed because it's only working on actual object files.

---

This commit gives `zig rc` the ability to output COFF object files directly when `/:output-format coff` is provided as an argument. This effectively matches what happens when CMake uses `windres` for resource compilation, but requires the argument to be provided explicitly.

So, after this change, the following CMake cross-compilation use case will work, even when not using Ninja as the generator:

    RC="zig rc /:output-format coff" CC="zig cc --target=x86_64-windows-gnu" cmake .. -DCMAKE_SYSTEM_NAME=Windows
2025-02-22 21:21:30 -05:00
Ryan Liptak
00316bfbf0 resinator: Fix some error message integration
Fixup for some of the changes in https://github.com/ziglang/zig/pull/22522
2025-02-10 01:37:04 -08:00
Ryan Liptak
289e9c3507 resinator: Sync with upstream
Note: This mostly matches resinator v0.1.0 rather than the latest master version, since the latest master version focuses on adding support for .res -> .obj conversion which is not necessary for the future planned relationship of zig and resinator (resinator will likely be moved out of the compiler and into the build system, a la translate-c).

So, ultimately the changes here consist mostly of bug fixes for obscure edge cases.
2025-01-17 23:10:41 -08:00
Ryan Liptak
4baa448335 resinator: Fix incorrect args being printed in cli diagnostics 2025-01-17 23:04:26 -08:00
Linus Groh
8588964972 Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
Veikka Tuominen
de8cece6e7 sync Aro dependency
ref: adfd13c6ffb563b1379052b92f6ae4148b91cc12
2024-09-09 12:35:49 +03:00
mlugg
6808ce27bd
compiler,lib,test,langref: migrate @setCold to @branchHint 2024-08-27 00:44:35 +01:00
Andrew Kelley
0937992a14 resinator: update to new progress API 2024-05-27 20:56:49 -07:00
Ryan Liptak
b86c4bde64 Rename Dir.writeFile2 -> Dir.writeFile and update all callsites
writeFile was deprecated in favor of writeFile2 in f645022d16. This commit renames writeFile2 to writeFile and makes writeFile2 a compile error.
2024-05-03 13:29:22 -07:00
Andrew Kelley
8c94950c24 fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
Ryan Liptak
3f92cbef89 resinator: Fix auto-detected includes only being used during preprocessing
Also need to pass them to the .res compilation step, since files (cursors, icons, etc) can be found in the system include directories.
2024-03-11 05:06:17 -07:00
Ryan Liptak
c32e0d3000 Fix progress when multiple zig rc child processes are building resinator 2024-03-11 05:06:17 -07:00
Ryan Liptak
8799f7466d Report the progress of lazily building zig rc
jitCmd now takes a `server` option that will emit progress/errors via std.zig.Server when enabled.
2024-03-11 05:06:17 -07:00
Ryan Liptak
7c05330287 Integrate resinator errors with Zig using std.zig.Server and ErrorBundle
This takes the code that was previously in src/Compilation.zig to turn resinator diagnostics into Zig error bundles and puts it in resinator/main.zig, and then makes resinator emit the resulting error bundles via std.zig.Server (which is used by the build runner, etc). Also adds support for turning Aro diagnostics into ErrorBundles.
2024-03-11 05:06:16 -07:00
Ryan Liptak
52de2802c4 Lazily compile the zig rc subcommand and use it during zig build-exe
This moves .rc/.manifest compilation out of the main Zig binary, contributing towards #19063

Also:
- Make resinator use Aro as its preprocessor instead of clang
- Sync resinator with upstream
2024-03-11 05:06:16 -07:00