authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-24 17:25:12-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-29 23:50:20-07:00
log09f61b13b359eec02d12567b3bd2c967c5448e81
tree1ab29fb852fb83e6bf170552c121b4b088fda4e1
parent46bdb35420efc111a38bba19f9bd714ad41a759f

std.zig.buildExeSubprocess: remove log, return more info


3 files changed, 22 insertions(+), 7 deletions(-)

lib/compiler/Maker.zig+1-1
......@@ -965,7 +965,7 @@ pub fn main(init: process.Init.Minimal) !void {
965965 .cache_manifest = &config_man,
966966 .arch_os_abi = target_arch_os_abi,
967967 .progress_node = compile_prog_node,
968 })) |p| p else |err| switch (err) {
968 })) |r| r.path else |err| switch (err) {
969969 error.AlreadyReported => process.exit(1),
970970 // If the file system inputs are populated, we can
971971 // still watch for changes and try again.
lib/compiler/Maker/WebServer.zig+3-1
......@@ -625,7 +625,7 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim
625625 const compile_prog_node = ws.root_prog_node.start("Compile WebAssembly Component", 0);
626626 defer compile_prog_node.end();
627627
628 return std.zig.buildExeSubprocess(gpa, io, .{
628 const result = try std.zig.buildExeSubprocess(gpa, io, .{
629629 .argv = argv.items,
630630 .cache_root = graph.global_cache_root,
631631 .root_name = root_name,
......@@ -633,6 +633,8 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim
633633 .cpu_features = cpu_features,
634634 .progress_node = compile_prog_node,
635635 });
636 if (!result.cache_hit) log.info("source changes detected; rebuilt wasm component", .{});
637 return result.path;
636638}
637639
638640pub fn updateTimeReportCompile(ws: *WebServer, opts: struct {
lib/std/zig.zig+18-5
......@@ -1644,10 +1644,20 @@ pub const BuildExeSubprocessError = error{
16441644 FailedButCacheIntact,
16451645} || Io.Cancelable || Allocator.Error;
16461646
1647pub const BuildExeSubprocessResult = struct {
1648 received_fs_inputs: bool,
1649 cache_hit: bool,
1650 path: Cache.Path,
1651};
1652
16471653/// Assumes `argv` has `--listen=-` in it and the child process is `zig build-exe`.
16481654///
16491655/// Result path is allocated via gpa.
1650pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOptions) BuildExeSubprocessError!Cache.Path {
1656pub fn buildExeSubprocess(
1657 gpa: Allocator,
1658 io: Io,
1659 options: BuildExeSubprocessOptions,
1660) BuildExeSubprocessError!BuildExeSubprocessResult {
16511661 const cmd: SubprocessCommand = .{ .argv = options.argv };
16521662
16531663 var child = std.process.spawn(io, .{
......@@ -1699,6 +1709,7 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt
16991709 defer body_buffer.deinit(gpa);
17001710
17011711 var received_fs_inputs = false;
1712 var cache_hit = false;
17021713
17031714 while (true) {
17041715 const header = stdout.takeStruct(Header, .little) catch |err| switch (err) {
......@@ -1739,9 +1750,7 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt
17391750 .emit_digest => {
17401751 const EmitDigest = Server.Message.EmitDigest;
17411752 const ebp_hdr: *align(1) const EmitDigest = @ptrCast(body);
1742 if (!ebp_hdr.flags.cache_hit) {
1743 log.info("source changes detected; rebuilt {s}", .{options.root_name});
1744 }
1753 cache_hit = ebp_hdr.flags.cache_hit;
17451754 const digest = body[@sizeOf(EmitDigest)..][0..Cache.bin_digest_len];
17461755 if (result) |r| gpa.free(r.sub_path);
17471756 result = .{
......@@ -1831,7 +1840,11 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt
18311840 .output_mode = .Exe,
18321841 });
18331842 defer gpa.free(bin_name);
1834 return base_path.join(gpa, bin_name);
1843 return .{
1844 .received_fs_inputs = received_fs_inputs,
1845 .cache_hit = cache_hit,
1846 .path = try base_path.join(gpa, bin_name),
1847 };
18351848}
18361849
18371850fn readStreamAlloc(gpa: Allocator, io: Io, file: Io.File, limit: Io.Limit) ![]u8 {