aboutsummaryrefslogtreecommitdiff
path: root/lib/compiler/resinator/main.zig
AgeCommit message (Collapse)Author
2025-10-30std.debug.lockStderrWriter: also return ttyconfMatthew Lugg
`std.Io.tty.Config.detect` may be an expensive check (e.g. involving syscalls), and doing it every time we need to print isn't really necessary; under normal usage, we can compute the value once and cache it for the whole program's execution. Since anyone outputting to stderr may reasonably want this information (in fact they are very likely to), it makes sense to cache it and return it from `lockStderrWriter`. Call sites who do not need it will experience no significant overhead, and can just ignore the TTY config with a `const w, _` destructure.
2025-10-29resinator: update for Io APIAndrew Kelley
2025-10-29resinator: update for new Io APIsAndrew Kelley
2025-10-09- Move aroDiagnosticsToErrorBundle to compiler/util.zigkcbanner
2025-10-09- Rework translate-c to integrate with the build system (by outputing error ↵kcbanner
bundles on stdout) via --zig-integration - Revive some of the removed cache integration logic in `cmdTranslateC` now that `translate-c` can return error bundles - Fixup inconsistent path separators (on Windows) when building the aro include path - Move some error bundle logic from resinator into aro.Diagnostics - Add `ErrorBundle.addRootErrorMessageWithNotes` (extracted from resinator)
2025-10-02resinator: Update for std.coff changesRyan Liptak
2025-09-24resinator: fix compile errorsAndrew Kelley
2025-09-24resinator: Update for latest aroRyan Liptak
2025-08-30update tools and other miscellaneous things to new APIsAndrew Kelley
2025-08-29std.Io: delete GenericReaderAndrew Kelley
and delete deprecated alias std.io
2025-08-28resinator: Complete the update to the new Reader/WriterRyan Liptak
2025-08-28resinator: some updates to avoid GenericWriterAndrew Kelley
These are some hastily made, untested changes to get things compiling again, since Ryan is working on a better upgrade patchset in the meantime.
2025-08-11std.ArrayList: make unmanaged the defaultAndrew Kelley
2025-08-08std.Io: remove BufferedWriterAndrew Kelley
2025-08-07resinator: a few more updates/fixesRyan Liptak
Just enough to get things working correctly again
2025-07-20Merge pull request #24488 from ziglang/moreAndrew Kelley
std.zig: finish updating to new I/O API
2025-07-19std.zig: finish updating to new I/O APIAndrew Kelley
2025-07-19resinator: fix std.json API usageAndrew Kelley
2025-07-07update standalone and incremental tests to new APIAndrew Kelley
2025-07-07std.fmt: breaking API changesAndrew Kelley
added adapter to AnyWriter and GenericWriter to help bridge the gap between old and new API make std.testing.expectFmt work at compile-time std.fmt no longer has a dependency on std.unicode. Formatted printing was never properly unicode-aware. Now it no longer pretends to be. Breakage/deprecations: * std.fs.File.reader -> std.fs.File.deprecatedReader * std.fs.File.writer -> std.fs.File.deprecatedWriter * std.io.GenericReader -> std.io.Reader * std.io.GenericWriter -> std.io.Writer * std.io.AnyReader -> std.io.Reader * std.io.AnyWriter -> std.io.Writer * std.fmt.format -> std.fmt.deprecatedFormat * std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape * std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape * std.fmt.fmtSliceHexLower -> {x} * std.fmt.fmtSliceHexUpper -> {X} * std.fmt.fmtIntSizeDec -> {B} * std.fmt.fmtIntSizeBin -> {Bi} * std.fmt.fmtDuration -> {D} * std.fmt.fmtDurationSigned -> {D} * {} -> {f} when there is a format method * format method signature - anytype -> *std.io.Writer - inferred error set -> error{WriteFailed} - options -> (deleted) * std.fmt.Formatted - now takes context type explicitly - no fmt string
2025-07-07std.io: move getStdIn, getStdOut, getStdErr functions to fs.FileAndrew Kelley
preparing to rearrange std.io namespace into an interface how to upgrade: std.io.getStdIn() -> std.fs.File.stdin() std.io.getStdOut() -> std.fs.File.stdout() std.io.getStdErr() -> std.fs.File.stderr()
2025-07-07std.io: deprecated Reader/Writer; introduce new APIAndrew Kelley
2025-06-28resinator: Fix include directory detection when cross-compiling from certain ↵Ryan Liptak
host archs Previously, resinator would use the host arch as the target arch when looking for windows-gnu include directories. However, Zig only thinks it can provide a libc for targets specified in the `std.zig.target.available_libcs` array, which only includes a few for windows-gnu. Therefore, when cross-compiling from a host architecture that doesn't have a windows-gnu target in the available_libcs list, resinator would fail to detect the MinGW include directories. Now, the custom option `/:target` is passed to `zig rc` which is intended for the COFF object file target, but can be re-used for the include directory target as well. For the include directory target, resinator will convert the MachineType to the relevant arch, or fail if there is no equivalent arch/no support for detecting the includes for the MachineType (currently 64-bit Itanium and EBC). Fixes the `windows_resources` standalone test failing when the host is, for example, `riscv64-linux`.
2025-06-28resinator: Only preprocess when the input is an .rc fileRyan Liptak
2025-06-19Target: pass and use locals by pointer instead of by valueJacob Young
This struct is larger than 256 bytes and code that copies it consistently shows up in profiles of the compiler.
2025-03-21Trick the meson build system into thinking `zig rc` is `rc.exe`Ryan Liptak
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-02-22zig rc: Add COFF object file creation for CMake cross-compilation use caseRyan Liptak
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: https://github.com/Kitware/CMake/blob/4a11fd8dde745789f66d6500412d7f56607e9218/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-10resinator: Fix some error message integrationRyan Liptak
Fixup for some of the changes in https://github.com/ziglang/zig/pull/22522
2025-01-17resinator: Sync with upstreamRyan Liptak
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-17resinator: Fix incorrect args being printed in cli diagnosticsRyan Liptak
2024-09-12Replace deprecated default initializations with decl literalsLinus Groh
2024-09-09sync Aro dependencyVeikka Tuominen
ref: adfd13c6ffb563b1379052b92f6ae4148b91cc12
2024-08-27compiler,lib,test,langref: migrate `@setCold` to `@branchHint`mlugg
2024-05-27resinator: update to new progress APIAndrew Kelley
2024-05-03Rename Dir.writeFile2 -> Dir.writeFile and update all callsitesRyan Liptak
writeFile was deprecated in favor of writeFile2 in f645022d16361865e24582d28f1e62312fbc73bb. This commit renames writeFile2 to writeFile and makes writeFile2 a compile error.
2024-03-19fix compilation failures found by CIAndrew Kelley
2024-03-11resinator: Fix auto-detected includes only being used during preprocessingRyan Liptak
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-11Fix progress when multiple zig rc child processes are building resinatorRyan Liptak
2024-03-11Report the progress of lazily building zig rcRyan Liptak
jitCmd now takes a `server` option that will emit progress/errors via std.zig.Server when enabled.
2024-03-11Integrate resinator errors with Zig using std.zig.Server and ErrorBundleRyan Liptak
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-11Lazily compile the `zig rc` subcommand and use it during `zig build-exe`Ryan Liptak
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