Skip to content

Commit c5bc6bb

Browse files
authored
fix: use flush instead of end on stdout in code generators for Windows compatibility (#10150)
This fixes the Windows build failure discussed in #10148 When building on Windows, `symbols-unigen` and `props-unigen` crash with `error.FileTooBig` because `stdout.end()` calls `setEndPos()` to truncate the output. Windows does not support `SetEndOfFile` on pipes or console handles - it returns `ERROR_INVALID_PARAMETER`, which Zig maps to `error.FileTooBig`. Using `flush()` instead of `end()` is correct here because: 1. `end()` flushes AND truncates - useful when overwriting files that might have leftover content 2. For stdout captured as a pipe, there's nothing to truncate - we're writing sequentially to a fresh pipe 3. `flush()` ensures all buffered data is sent, which is all that's needed CI before fix was failing with FileTooBig, after fix builds successfully: https://github.com/remorses/opentui/actions/runs/20671299561/job/59352503875
2 parents 09ae4c2 + e2de0bf commit c5bc6bb

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/unicode/props_uucode.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ pub fn main() !void {
8787
var buf: [4096]u8 = undefined;
8888
var stdout = std.fs.File.stdout().writer(&buf);
8989
try t.writeZig(&stdout.interface);
90-
try stdout.end();
90+
// Use flush instead of end because stdout is a pipe when captured by
91+
// the build system, and pipes cannot be truncated (Windows returns
92+
// INVALID_PARAMETER, Linux returns EINVAL).
93+
try stdout.interface.flush();
9194

9295
// Uncomment when manually debugging to see our table sizes.
9396
// std.log.warn("stage1={} stage2={} stage3={}", .{

src/unicode/symbols_uucode.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ pub fn main() !void {
3434
var buf: [4096]u8 = undefined;
3535
var stdout = std.fs.File.stdout().writer(&buf);
3636
try t.writeZig(&stdout.interface);
37-
try stdout.end();
37+
// Use flush instead of end because stdout is a pipe when captured by
38+
// the build system, and pipes cannot be truncated (Windows returns
39+
// INVALID_PARAMETER, Linux returns EINVAL).
40+
try stdout.interface.flush();
3841

3942
// Uncomment when manually debugging to see our table sizes.
4043
// std.log.warn("stage1={} stage2={} stage3={}", .{

0 commit comments

Comments
 (0)