authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 17:20:42-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 19:27:16-07:00
loga7d1edae8f3d673ecbdd88b13044d7edc51b28af
tree16cc8e9b314e868b6162c5430536faeb6b53f27e
parent198f35c98c8a8216a120f146605bb729e7b8dd66

zig build: save configurations to .zig-cache c/, not o/

keeps the cache directory hierarchy more uniform and avoids too many files in one directory

1 files changed, 19 insertions(+), 4 deletions(-)

src/main.zig+19-4
......@@ -5629,7 +5629,7 @@ fn cmdBuild(
56295629 break :cp .{
56305630 .{
56315631 .root_dir = dirs.local_cache,
5632 .sub_path = try std.fmt.allocPrint(arena, "o/{s}", .{&digest}),
5632 .sub_path = try std.fmt.allocPrint(arena, "c/{s}", .{&digest}),
56335633 },
56345634 false,
56355635 };
......@@ -5723,7 +5723,7 @@ fn cmdBuild(
57235723 const digest = config_man.final();
57245724 const final_path: Path = .{
57255725 .root_dir = dirs.local_cache,
5726 .sub_path = try std.fmt.allocPrint(arena, "o/{s}", .{&digest}),
5726 .sub_path = try std.fmt.allocPrint(arena, "c/{s}", .{&digest}),
57275727 };
57285728 Io.Dir.rename(
57295729 config_tmp_path.root_dir.handle,
......@@ -5731,9 +5731,24 @@ fn cmdBuild(
57315731 final_path.root_dir.handle,
57325732 final_path.sub_path,
57335733 io,
5734 ) catch |err| {
5734 ) catch |err| retry: {
5735 const e = switch (err) {
5736 error.FileNotFound => e: {
5737 const dir_path = final_path.dirname().?;
5738 dir_path.root_dir.handle.createDirPath(io, dir_path.sub_path) catch |e|
5739 fatal("failed to create directory {f}: {t}", .{ dir_path, e });
5740 if (Io.Dir.rename(
5741 config_tmp_path.root_dir.handle,
5742 config_tmp_path.sub_path,
5743 final_path.root_dir.handle,
5744 final_path.sub_path,
5745 io,
5746 )) |_| break :retry else |e| break :e e;
5747 },
5748 else => |e| e,
5749 };
57355750 fatal("failed to rename configuration file from {f} into {f}: {t}", .{
5736 config_tmp_path, final_path, err,
5751 config_tmp_path, final_path, e,
57375752 });
57385753 };
57395754 config_man.writeManifest() catch |err| warn("failed to write cache manifest: {t}", .{err});