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(...@@ -5629,7 +5629,7 @@ fn cmdBuild(
5629 break :cp .{5629 break :cp .{
5630 .{5630 .{
5631 .root_dir = dirs.local_cache,5631 .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}),
5633 },5633 },
5634 false,5634 false,
5635 };5635 };
...@@ -5723,7 +5723,7 @@ fn cmdBuild(...@@ -5723,7 +5723,7 @@ fn cmdBuild(
5723 const digest = config_man.final();5723 const digest = config_man.final();
5724 const final_path: Path = .{5724 const final_path: Path = .{
5725 .root_dir = dirs.local_cache,5725 .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}),
5727 };5727 };
5728 Io.Dir.rename(5728 Io.Dir.rename(
5729 config_tmp_path.root_dir.handle,5729 config_tmp_path.root_dir.handle,
...@@ -5731,9 +5731,24 @@ fn cmdBuild(...@@ -5731,9 +5731,24 @@ fn cmdBuild(
5731 final_path.root_dir.handle,5731 final_path.root_dir.handle,
5732 final_path.sub_path,5732 final_path.sub_path,
5733 io,5733 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 };
5735 fatal("failed to rename configuration file from {f} into {f}: {t}", .{5750 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,
5737 });5752 });
5738 };5753 };
5739 config_man.writeManifest() catch |err| warn("failed to write cache manifest: {t}", .{err});5754 config_man.writeManifest() catch |err| warn("failed to write cache manifest: {t}", .{err});