authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-17 20:16:56-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:35-07:00
log5fb120a3c0e1b252fb85e8259b481c28b9dba465
tree94b59480aec7f259677410603fc5d6d4b08b8881
parent9709efce98289f393ae496921ba30123ea6123f5

maker: implement cleanTmpFiles


2 files changed, 21 insertions(+), 10 deletions(-)

lib/compiler/Maker.zig+13-10
......@@ -833,7 +833,7 @@ fn makeStepNames(
833833 var pending_count: usize = 0;
834834 var total_compile_errors: usize = 0;
835835
836 var cleanup_task = io.async(cleanTmpFiles, .{ io, step_stack.keys() });
836 var cleanup_task = io.async(cleanTmpFiles, .{ maker, step_stack.keys() });
837837 defer cleanup_task.await(io);
838838
839839 for (step_stack.keys()) |step_index| {
......@@ -1677,17 +1677,20 @@ fn fatalWithHint(comptime f: []const u8, args: anytype) noreturn {
16771677 fatal(f, args);
16781678}
16791679
1680fn cleanTmpFiles(io: Io, steps: []const Configuration.Step.Index) void {
1681 std.log.err("TODO implement cleanTmpFiles", .{});
1682 if (true) return;
1680fn cleanTmpFiles(maker: *Maker, steps: []const Configuration.Step.Index) void {
1681 const graph = maker.graph;
1682 const io = graph.io;
1683 const conf = &maker.scanned_config.configuration;
16831684
16841685 for (steps) |step_index| {
1685 const wf = step_index.cast(std.Build.Step.WriteFile) orelse continue;
1686 if (wf.mode != .tmp) continue;
1687 const path = wf.generated_directory.path orelse continue;
1688 Dir.cwd().deleteTree(io, path) catch |err| {
1689 log.warn("failed to delete {s}: {t}", .{ path, err });
1690 };
1686 const conf_step = step_index.ptr(conf);
1687 const wf = conf_step.extended.cast(conf, Configuration.Step.WriteFile) orelse continue;
1688 if (wf.flags.mode != .tmp) continue;
1689 const step = maker.stepByIndex(step_index);
1690 if (step.state != .success) continue;
1691 const tmp_path = generatedPath(maker, wf.generated_directory).*;
1692 tmp_path.root_dir.handle.deleteTree(io, tmp_path.subPathOrDot()) catch |err|
1693 log.warn("failed to delete temporary path {f}: {t}", .{ tmp_path, err });
16911694 }
16921695}
16931696
lib/std/Build/Configuration.zig+8
......@@ -2513,6 +2513,14 @@ pub const Storage = enum {
25132513 return base_flags.tag;
25142514 }
25152515
2516 pub fn cast(this: @This(), c: *const Configuration, comptime S: type) ?S {
2517 const wanted_tag = @typeInfo(S.Flags).@"struct".fields[0].defaultValue().?;
2518 const base_flags: BaseFlags = @bitCast(c.extra[@intFromEnum(this)]);
2519 if (base_flags.tag != wanted_tag) return null;
2520 var i: usize = @intFromEnum(this);
2521 return data(c.extra, &i, S);
2522 }
2523
25162524 pub fn get(this: @This(), buffer: []const u32) U {
25172525 var i: usize = @intFromEnum(this);
25182526 const base_flags: BaseFlags = @bitCast(buffer[i]);