zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit a7d1edae8f3d673ecbdd88b13044d7edc51b28af (tree)
parent 198f35c98c8a8216a120f146605bb729e7b8dd66
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Mon, 25 May 2026 17:20:42 -0700

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

Diffstat:
Msrc/main.zig | 23+++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/main.zig b/src/main.zig @@ -5629,7 +5629,7 @@ fn cmdBuild( break :cp .{ .{ .root_dir = dirs.local_cache, - .sub_path = try std.fmt.allocPrint(arena, "o/{s}", .{&digest}), + .sub_path = try std.fmt.allocPrint(arena, "c/{s}", .{&digest}), }, false, }; @@ -5723,7 +5723,7 @@ fn cmdBuild( const digest = config_man.final(); const final_path: Path = .{ .root_dir = dirs.local_cache, - .sub_path = try std.fmt.allocPrint(arena, "o/{s}", .{&digest}), + .sub_path = try std.fmt.allocPrint(arena, "c/{s}", .{&digest}), }; Io.Dir.rename( config_tmp_path.root_dir.handle, @@ -5731,9 +5731,24 @@ fn cmdBuild( final_path.root_dir.handle, final_path.sub_path, io, - ) catch |err| { + ) catch |err| retry: { + const e = switch (err) { + error.FileNotFound => e: { + const dir_path = final_path.dirname().?; + dir_path.root_dir.handle.createDirPath(io, dir_path.sub_path) catch |e| + fatal("failed to create directory {f}: {t}", .{ dir_path, e }); + if (Io.Dir.rename( + config_tmp_path.root_dir.handle, + config_tmp_path.sub_path, + final_path.root_dir.handle, + final_path.sub_path, + io, + )) |_| break :retry else |e| break :e e; + }, + else => |e| e, + }; fatal("failed to rename configuration file from {f} into {f}: {t}", .{ - config_tmp_path, final_path, err, + config_tmp_path, final_path, e, }); }; config_man.writeManifest() catch |err| warn("failed to write cache manifest: {t}", .{err});