diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-05-24 08:22:47 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-05-27 20:56:48 -0700 |
| commit | f97c2f28fdc3061bc7e30ccfcafaccbee77993b6 (patch) | |
| tree | a2c4165829d84b35df23346b1808a43e0cccec41 /lib/std/Build/Step.zig | |
| parent | f6873c6b00544923d5699737651f2bc4fe29fd06 (diff) | |
| download | zig-f97c2f28fdc3061bc7e30ccfcafaccbee77993b6.tar.gz zig-f97c2f28fdc3061bc7e30ccfcafaccbee77993b6.zip | |
update the codebase for the new std.Progress API
Diffstat (limited to 'lib/std/Build/Step.zig')
| -rw-r--r-- | lib/std/Build/Step.zig | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/std/Build/Step.zig b/lib/std/Build/Step.zig index 01bea6c0ce..a965735843 100644 --- a/lib/std/Build/Step.zig +++ b/lib/std/Build/Step.zig @@ -58,7 +58,7 @@ pub const TestResults = struct { } }; -pub const MakeFn = *const fn (step: *Step, prog_node: *std.Progress.Node) anyerror!void; +pub const MakeFn = *const fn (step: *Step, prog_node: std.Progress.Node) anyerror!void; pub const State = enum { precheck_unstarted, @@ -176,7 +176,7 @@ pub fn init(options: StepOptions) Step { /// If the Step's `make` function reports `error.MakeFailed`, it indicates they /// have already reported the error. Otherwise, we add a simple error report /// here. -pub fn make(s: *Step, prog_node: *std.Progress.Node) error{ MakeFailed, MakeSkipped }!void { +pub fn make(s: *Step, prog_node: std.Progress.Node) error{ MakeFailed, MakeSkipped }!void { const arena = s.owner.allocator; s.makeFn(s, prog_node) catch |err| switch (err) { @@ -217,7 +217,7 @@ pub fn getStackTrace(s: *Step) ?std.builtin.StackTrace { }; } -fn makeNoOp(step: *Step, prog_node: *std.Progress.Node) anyerror!void { +fn makeNoOp(step: *Step, prog_node: std.Progress.Node) anyerror!void { _ = prog_node; var all_cached = true; @@ -303,7 +303,7 @@ pub fn addError(step: *Step, comptime fmt: []const u8, args: anytype) error{OutO pub fn evalZigProcess( s: *Step, argv: []const []const u8, - prog_node: *std.Progress.Node, + prog_node: std.Progress.Node, ) !?[]const u8 { assert(argv.len != 0); const b = s.owner; @@ -313,12 +313,16 @@ pub fn evalZigProcess( try handleChildProcUnsupported(s, null, argv); try handleVerbose(s.owner, null, argv); + const sub_prog_node = prog_node.start("", 0); + defer sub_prog_node.end(); + var child = std.process.Child.init(argv, arena); child.env_map = &b.graph.env_map; child.stdin_behavior = .Pipe; child.stdout_behavior = .Pipe; child.stderr_behavior = .Pipe; child.request_resource_usage_statistics = true; + child.progress_node = sub_prog_node; child.spawn() catch |err| return s.fail("unable to spawn {s}: {s}", .{ argv[0], @errorName(err), @@ -337,11 +341,6 @@ pub fn evalZigProcess( const Header = std.zig.Server.Message.Header; var result: ?[]const u8 = null; - var node_name: std.ArrayListUnmanaged(u8) = .{}; - defer node_name.deinit(gpa); - var sub_prog_node = prog_node.start("", 0); - defer sub_prog_node.end(); - const stdout = poller.fifo(.stdout); poll: while (true) { @@ -379,11 +378,6 @@ pub fn evalZigProcess( .extra = extra_array, }; }, - .progress => { - node_name.clearRetainingCapacity(); - try node_name.appendSlice(gpa, body); - sub_prog_node.setName(node_name.items); - }, .emit_bin_path => { const EbpHdr = std.zig.Server.Message.EmitBinPath; const ebp_hdr = @as(*align(1) const EbpHdr, @ptrCast(body)); |
