Skip to content

Commit 3b77f1e

Browse files
committed
rename zig-cache to .zig-cache
closes #20077
1 parent bdb3b38 commit 3b77f1e

File tree

8 files changed

+33
-33
lines changed

8 files changed

+33
-33
lines changed

lib/std/debug.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ test printLineFromFileAnyOs {
15261526
var test_dir = std.testing.tmpDir(.{});
15271527
defer test_dir.cleanup();
15281528
// Relies on testing.tmpDir internals which is not ideal, but LineInfo requires paths.
1529-
const test_dir_path = try join(allocator, &.{ "zig-cache", "tmp", test_dir.sub_path[0..] });
1529+
const test_dir_path = try join(allocator, &.{ ".zig-cache", "tmp", test_dir.sub_path[0..] });
15301530
defer allocator.free(test_dir_path);
15311531

15321532
// Cases

lib/std/fs/test.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ test "accessAbsolute" {
325325
const allocator = arena.allocator();
326326

327327
const base_path = blk: {
328-
const relative_path = try fs.path.join(allocator, &.{ "zig-cache", "tmp", tmp.sub_path[0..] });
328+
const relative_path = try fs.path.join(allocator, &.{ ".zig-cache", "tmp", tmp.sub_path[0..] });
329329
break :blk try fs.realpathAlloc(allocator, relative_path);
330330
};
331331

@@ -344,7 +344,7 @@ test "openDirAbsolute" {
344344
const allocator = arena.allocator();
345345

346346
const base_path = blk: {
347-
const relative_path = try fs.path.join(allocator, &.{ "zig-cache", "tmp", tmp.sub_path[0..], "subdir" });
347+
const relative_path = try fs.path.join(allocator, &.{ ".zig-cache", "tmp", tmp.sub_path[0..], "subdir" });
348348
break :blk try fs.realpathAlloc(allocator, relative_path);
349349
};
350350

@@ -407,7 +407,7 @@ test "readLinkAbsolute" {
407407
const allocator = arena.allocator();
408408

409409
const base_path = blk: {
410-
const relative_path = try fs.path.join(allocator, &.{ "zig-cache", "tmp", tmp.sub_path[0..] });
410+
const relative_path = try fs.path.join(allocator, &.{ ".zig-cache", "tmp", tmp.sub_path[0..] });
411411
break :blk try fs.realpathAlloc(allocator, relative_path);
412412
};
413413

@@ -990,7 +990,7 @@ test "renameAbsolute" {
990990
const allocator = arena.allocator();
991991

992992
const base_path = blk: {
993-
const relative_path = try fs.path.join(allocator, &.{ "zig-cache", "tmp", tmp_dir.sub_path[0..] });
993+
const relative_path = try fs.path.join(allocator, &.{ ".zig-cache", "tmp", tmp_dir.sub_path[0..] });
994994
break :blk try fs.realpathAlloc(allocator, relative_path);
995995
};
996996

@@ -1772,7 +1772,7 @@ test "'.' and '..' in absolute functions" {
17721772
const allocator = arena.allocator();
17731773

17741774
const base_path = blk: {
1775-
const relative_path = try fs.path.join(allocator, &.{ "zig-cache", "tmp", tmp.sub_path[0..] });
1775+
const relative_path = try fs.path.join(allocator, &.{ ".zig-cache", "tmp", tmp.sub_path[0..] });
17761776
break :blk try fs.realpathAlloc(allocator, relative_path);
17771777
};
17781778

lib/std/posix/test.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ test "open smoke test" {
101101
const allocator = arena.allocator();
102102

103103
const base_path = blk: {
104-
const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
104+
const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
105105
break :blk try fs.realpathAlloc(allocator, relative_path);
106106
};
107107

@@ -1022,7 +1022,7 @@ test "rename smoke test" {
10221022
const allocator = arena.allocator();
10231023

10241024
const base_path = blk: {
1025-
const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
1025+
const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
10261026
break :blk try fs.realpathAlloc(allocator, relative_path);
10271027
};
10281028

@@ -1079,7 +1079,7 @@ test "access smoke test" {
10791079
const allocator = arena.allocator();
10801080

10811081
const base_path = blk: {
1082-
const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
1082+
const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
10831083
break :blk try fs.realpathAlloc(allocator, relative_path);
10841084
};
10851085

@@ -1153,7 +1153,7 @@ test "read with empty buffer" {
11531153

11541154
// Get base abs path
11551155
const base_path = blk: {
1156-
const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
1156+
const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
11571157
break :blk try fs.realpathAlloc(allocator, relative_path);
11581158
};
11591159

@@ -1178,7 +1178,7 @@ test "pread with empty buffer" {
11781178

11791179
// Get base abs path
11801180
const base_path = blk: {
1181-
const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
1181+
const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
11821182
break :blk try fs.realpathAlloc(allocator, relative_path);
11831183
};
11841184

@@ -1203,7 +1203,7 @@ test "write with empty buffer" {
12031203

12041204
// Get base abs path
12051205
const base_path = blk: {
1206-
const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
1206+
const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
12071207
break :blk try fs.realpathAlloc(allocator, relative_path);
12081208
};
12091209

@@ -1228,7 +1228,7 @@ test "pwrite with empty buffer" {
12281228

12291229
// Get base abs path
12301230
const base_path = blk: {
1231-
const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
1231+
const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
12321232
break :blk try fs.realpathAlloc(allocator, relative_path);
12331233
};
12341234

lib/std/testing.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,11 @@ pub fn tmpDir(opts: std.fs.Dir.OpenDirOptions) TmpDir {
563563
_ = std.fs.base64_encoder.encode(&sub_path, &random_bytes);
564564

565565
const cwd = std.fs.cwd();
566-
var cache_dir = cwd.makeOpenPath("zig-cache", .{}) catch
567-
@panic("unable to make tmp dir for testing: unable to make and open zig-cache dir");
566+
var cache_dir = cwd.makeOpenPath(".zig-cache", .{}) catch
567+
@panic("unable to make tmp dir for testing: unable to make and open .zig-cache dir");
568568
defer cache_dir.close();
569569
const parent_dir = cache_dir.makeOpenPath("tmp", .{}) catch
570-
@panic("unable to make tmp dir for testing: unable to make and open zig-cache/tmp dir");
570+
@panic("unable to make tmp dir for testing: unable to make and open .zig-cache/tmp dir");
571571
const dir = parent_dir.makeOpenPath(&sub_path, opts) catch
572572
@panic("unable to make tmp dir for testing: unable to make and open the tmp dir");
573573

src/Package/Fetch.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,7 @@ test "zip" {
20002000
try bw.flush();
20012001
}
20022002

2003-
const zip_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/test.zip", .{tmp.sub_path});
2003+
const zip_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/test.zip", .{tmp.sub_path});
20042004
defer gpa.free(zip_path);
20052005

20062006
var fb: TestFetchBuilder = undefined;
@@ -2033,7 +2033,7 @@ test "zip with one root folder" {
20332033
try bw.flush();
20342034
}
20352035

2036-
const zip_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/test.zip", .{tmp.sub_path});
2036+
const zip_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/test.zip", .{tmp.sub_path});
20372037
defer gpa.free(zip_path);
20382038

20392039
var fb: TestFetchBuilder = undefined;
@@ -2069,7 +2069,7 @@ test "tarball with duplicate paths" {
20692069

20702070
const tarball_name = "duplicate_paths.tar.gz";
20712071
try saveEmbedFile(tarball_name, tmp.dir);
2072-
const tarball_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
2072+
const tarball_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
20732073
defer gpa.free(tarball_path);
20742074

20752075
// Run tarball fetch, expect to fail
@@ -2101,7 +2101,7 @@ test "tarball with excluded duplicate paths" {
21012101

21022102
const tarball_name = "duplicate_paths_excluded.tar.gz";
21032103
try saveEmbedFile(tarball_name, tmp.dir);
2104-
const tarball_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
2104+
const tarball_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
21052105
defer gpa.free(tarball_path);
21062106

21072107
// Run tarball fetch, should succeed
@@ -2145,7 +2145,7 @@ test "tarball without root folder" {
21452145

21462146
const tarball_name = "no_root.tar.gz";
21472147
try saveEmbedFile(tarball_name, tmp.dir);
2148-
const tarball_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
2148+
const tarball_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
21492149
defer gpa.free(tarball_path);
21502150

21512151
// Run tarball fetch, should succeed
@@ -2176,7 +2176,7 @@ test "set executable bit based on file content" {
21762176

21772177
const tarball_name = "executables.tar.gz";
21782178
try saveEmbedFile(tarball_name, tmp.dir);
2179-
const tarball_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
2179+
const tarball_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
21802180
defer gpa.free(tarball_path);
21812181

21822182
// $ tar -tvf executables.tar.gz

src/main.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ const debug_usage = normal_usage ++
123123
;
124124

125125
const usage = if (build_options.enable_debug_extensions) debug_usage else normal_usage;
126+
const default_local_zig_cache_basename = ".zig-cache";
126127

127128
var log_scopes: std.ArrayListUnmanaged([]const u8) = .{};
128129

@@ -3107,14 +3108,13 @@ fn buildOutputType(
31073108

31083109
// search upwards from cwd until we find directory with build.zig
31093110
const cwd_path = try process.getCwdAlloc(arena);
3110-
const zig_cache = "zig-cache";
31113111
var dirname: []const u8 = cwd_path;
31123112
while (true) {
31133113
const joined_path = try fs.path.join(arena, &.{
31143114
dirname, Package.build_zig_basename,
31153115
});
31163116
if (fs.cwd().access(joined_path, .{})) |_| {
3117-
const cache_dir_path = try fs.path.join(arena, &.{ dirname, zig_cache });
3117+
const cache_dir_path = try fs.path.join(arena, &.{ dirname, default_local_zig_cache_basename });
31183118
const dir = try fs.cwd().makeOpenPath(cache_dir_path, .{});
31193119
cleanup_local_cache_dir = dir;
31203120
break :l .{ .handle = dir, .path = cache_dir_path };
@@ -4869,9 +4869,9 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
48694869
.path = local_cache_dir_path,
48704870
};
48714871
}
4872-
const cache_dir_path = try build_root.directory.join(arena, &[_][]const u8{"zig-cache"});
4872+
const cache_dir_path = try build_root.directory.join(arena, &.{default_local_zig_cache_basename});
48734873
break :l .{
4874-
.handle = try build_root.directory.handle.makeOpenPath("zig-cache", .{}),
4874+
.handle = try build_root.directory.handle.makeOpenPath(default_local_zig_cache_basename, .{}),
48754875
.path = cache_dir_path,
48764876
};
48774877
};

test/src/Cases.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,14 +1449,14 @@ fn runCases(self: *Cases, zig_exe_path: []const u8) !void {
14491449
var global_tmp = std.testing.tmpDir(.{});
14501450
defer global_tmp.cleanup();
14511451

1452-
var cache_dir = try global_tmp.dir.makeOpenPath("zig-cache", .{});
1452+
var cache_dir = try global_tmp.dir.makeOpenPath(".zig-cache", .{});
14531453
defer cache_dir.close();
1454-
const tmp_dir_path = try std.fs.path.join(self.gpa, &[_][]const u8{ ".", "zig-cache", "tmp", &global_tmp.sub_path });
1454+
const tmp_dir_path = try std.fs.path.join(self.gpa, &[_][]const u8{ ".", ".zig-cache", "tmp", &global_tmp.sub_path });
14551455
defer self.gpa.free(tmp_dir_path);
14561456

14571457
const global_cache_directory: Compilation.Directory = .{
14581458
.handle = cache_dir,
1459-
.path = try std.fs.path.join(self.gpa, &[_][]const u8{ tmp_dir_path, "zig-cache" }),
1459+
.path = try std.fs.path.join(self.gpa, &[_][]const u8{ tmp_dir_path, ".zig-cache" }),
14601460
};
14611461
defer self.gpa.free(global_cache_directory.path.?);
14621462

@@ -1529,16 +1529,16 @@ fn runOneCase(
15291529
var tmp = std.testing.tmpDir(.{});
15301530
defer tmp.cleanup();
15311531

1532-
var cache_dir = try tmp.dir.makeOpenPath("zig-cache", .{});
1532+
var cache_dir = try tmp.dir.makeOpenPath(".zig-cache", .{});
15331533
defer cache_dir.close();
15341534

15351535
const tmp_dir_path = try std.fs.path.join(
15361536
arena,
1537-
&[_][]const u8{ ".", "zig-cache", "tmp", &tmp.sub_path },
1537+
&[_][]const u8{ ".", ".zig-cache", "tmp", &tmp.sub_path },
15381538
);
15391539
const local_cache_path = try std.fs.path.join(
15401540
arena,
1541-
&[_][]const u8{ tmp_dir_path, "zig-cache" },
1541+
&[_][]const u8{ tmp_dir_path, ".zig-cache" },
15421542
);
15431543

15441544
const zig_cache_directory: Compilation.Directory = .{

tools/doctest.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const usage =
2222
\\ -o output Where to write output HTML docs to
2323
\\ --zig zig Path to the zig compiler
2424
\\ --zig-lib-dir dir Override the zig compiler library path
25-
\\ --cache-root dir Path to local zig-cache/
25+
\\ --cache-root dir Path to local .zig-cache/
2626
\\
2727
;
2828

0 commit comments

Comments
 (0)