aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-07-20 12:49:14 -0700
committerAndrew Kelley <andrew@ziglang.org>2025-07-21 12:32:37 -0700
commitf2a3ac7c0534a74ee544fdf6ef9d2176a8d62389 (patch)
tree548115489df6c29b38049d8727b5be74806b488f /lib/std/Build
parent5df52ca0a28d204da0557e88c6c9fe1818bcd6af (diff)
downloadzig-f2a3ac7c0534a74ee544fdf6ef9d2176a8d62389.tar.gz
zig-f2a3ac7c0534a74ee544fdf6ef9d2176a8d62389.zip
std.fs.File: delete writeFileAll and friends
please use File.Writer for these use cases also breaking API changes to std.fs.AtomicFile
Diffstat (limited to 'lib/std/Build')
-rw-r--r--lib/std/Build/Step/Run.zig19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig
index e35b602e06..414f7ccff2 100644
--- a/lib/std/Build/Step/Run.zig
+++ b/lib/std/Build/Step/Run.zig
@@ -169,7 +169,7 @@ pub const Output = struct {
pub fn create(owner: *std.Build, name: []const u8) *Run {
const run = owner.allocator.create(Run) catch @panic("OOM");
run.* = .{
- .step = Step.init(.{
+ .step = .init(.{
.id = base_id,
.name = name,
.owner = owner,
@@ -1769,13 +1769,22 @@ fn evalGeneric(run: *Run, child: *std.process.Child) !StdIoResult {
child.stdin = null;
},
.lazy_path => |lazy_path| {
- const path = lazy_path.getPath2(b, &run.step);
- const file = b.build_root.handle.openFile(path, .{}) catch |err| {
+ const path = lazy_path.getPath3(b, &run.step);
+ const file = path.root_dir.handle.openFile(path.subPathOrDot(), .{}) catch |err| {
return run.step.fail("unable to open stdin file: {s}", .{@errorName(err)});
};
defer file.close();
- child.stdin.?.writeFileAll(file, .{}) catch |err| {
- return run.step.fail("unable to write file to stdin: {s}", .{@errorName(err)});
+ // TODO https://github.com/ziglang/zig/issues/23955
+ var buffer: [1024]u8 = undefined;
+ var file_reader = file.reader(&buffer);
+ var stdin_writer = child.stdin.?.writer(&.{});
+ _ = stdin_writer.interface.sendFileAll(&file_reader, .unlimited) catch |err| switch (err) {
+ error.ReadFailed => return run.step.fail("failed to read from {f}: {t}", .{
+ path, file_reader.err.?,
+ }),
+ error.WriteFailed => return run.step.fail("failed to write to stdin: {t}", .{
+ stdin_writer.err.?,
+ }),
};
child.stdin.?.close();
child.stdin = null;