Commit 3b77f1ed7e

Andrew Kelley <andrew@ziglang.org>
2024-05-29 19:20:15
rename zig-cache to .zig-cache
closes #20077
1 parent bdb3b38
Changed files (8)
lib/std/fs/test.zig
@@ -325,7 +325,7 @@ test "accessAbsolute" {
     const allocator = arena.allocator();
 
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &.{ "zig-cache", "tmp", tmp.sub_path[0..] });
+        const relative_path = try fs.path.join(allocator, &.{ ".zig-cache", "tmp", tmp.sub_path[0..] });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
@@ -344,7 +344,7 @@ test "openDirAbsolute" {
     const allocator = arena.allocator();
 
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &.{ "zig-cache", "tmp", tmp.sub_path[0..], "subdir" });
+        const relative_path = try fs.path.join(allocator, &.{ ".zig-cache", "tmp", tmp.sub_path[0..], "subdir" });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
@@ -407,7 +407,7 @@ test "readLinkAbsolute" {
     const allocator = arena.allocator();
 
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &.{ "zig-cache", "tmp", tmp.sub_path[0..] });
+        const relative_path = try fs.path.join(allocator, &.{ ".zig-cache", "tmp", tmp.sub_path[0..] });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
@@ -990,7 +990,7 @@ test "renameAbsolute" {
     const allocator = arena.allocator();
 
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &.{ "zig-cache", "tmp", tmp_dir.sub_path[0..] });
+        const relative_path = try fs.path.join(allocator, &.{ ".zig-cache", "tmp", tmp_dir.sub_path[0..] });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
@@ -1772,7 +1772,7 @@ test "'.' and '..' in absolute functions" {
     const allocator = arena.allocator();
 
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &.{ "zig-cache", "tmp", tmp.sub_path[0..] });
+        const relative_path = try fs.path.join(allocator, &.{ ".zig-cache", "tmp", tmp.sub_path[0..] });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
lib/std/posix/test.zig
@@ -101,7 +101,7 @@ test "open smoke test" {
     const allocator = arena.allocator();
 
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
+        const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
@@ -1022,7 +1022,7 @@ test "rename smoke test" {
     const allocator = arena.allocator();
 
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
+        const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
@@ -1079,7 +1079,7 @@ test "access smoke test" {
     const allocator = arena.allocator();
 
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
+        const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
@@ -1153,7 +1153,7 @@ test "read with empty buffer" {
 
     // Get base abs path
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
+        const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
@@ -1178,7 +1178,7 @@ test "pread with empty buffer" {
 
     // Get base abs path
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
+        const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
@@ -1203,7 +1203,7 @@ test "write with empty buffer" {
 
     // Get base abs path
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
+        const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
@@ -1228,7 +1228,7 @@ test "pwrite with empty buffer" {
 
     // Get base abs path
     const base_path = blk: {
-        const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
+        const relative_path = try fs.path.join(allocator, &[_][]const u8{ ".zig-cache", "tmp", tmp.sub_path[0..] });
         break :blk try fs.realpathAlloc(allocator, relative_path);
     };
 
lib/std/debug.zig
@@ -1526,7 +1526,7 @@ test printLineFromFileAnyOs {
     var test_dir = std.testing.tmpDir(.{});
     defer test_dir.cleanup();
     // Relies on testing.tmpDir internals which is not ideal, but LineInfo requires paths.
-    const test_dir_path = try join(allocator, &.{ "zig-cache", "tmp", test_dir.sub_path[0..] });
+    const test_dir_path = try join(allocator, &.{ ".zig-cache", "tmp", test_dir.sub_path[0..] });
     defer allocator.free(test_dir_path);
 
     // Cases
lib/std/testing.zig
@@ -563,11 +563,11 @@ pub fn tmpDir(opts: std.fs.Dir.OpenDirOptions) TmpDir {
     _ = std.fs.base64_encoder.encode(&sub_path, &random_bytes);
 
     const cwd = std.fs.cwd();
-    var cache_dir = cwd.makeOpenPath("zig-cache", .{}) catch
-        @panic("unable to make tmp dir for testing: unable to make and open zig-cache dir");
+    var cache_dir = cwd.makeOpenPath(".zig-cache", .{}) catch
+        @panic("unable to make tmp dir for testing: unable to make and open .zig-cache dir");
     defer cache_dir.close();
     const parent_dir = cache_dir.makeOpenPath("tmp", .{}) catch
-        @panic("unable to make tmp dir for testing: unable to make and open zig-cache/tmp dir");
+        @panic("unable to make tmp dir for testing: unable to make and open .zig-cache/tmp dir");
     const dir = parent_dir.makeOpenPath(&sub_path, opts) catch
         @panic("unable to make tmp dir for testing: unable to make and open the tmp dir");
 
src/Package/Fetch.zig
@@ -2000,7 +2000,7 @@ test "zip" {
         try bw.flush();
     }
 
-    const zip_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/test.zip", .{tmp.sub_path});
+    const zip_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/test.zip", .{tmp.sub_path});
     defer gpa.free(zip_path);
 
     var fb: TestFetchBuilder = undefined;
@@ -2033,7 +2033,7 @@ test "zip with one root folder" {
         try bw.flush();
     }
 
-    const zip_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/test.zip", .{tmp.sub_path});
+    const zip_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/test.zip", .{tmp.sub_path});
     defer gpa.free(zip_path);
 
     var fb: TestFetchBuilder = undefined;
@@ -2069,7 +2069,7 @@ test "tarball with duplicate paths" {
 
     const tarball_name = "duplicate_paths.tar.gz";
     try saveEmbedFile(tarball_name, tmp.dir);
-    const tarball_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
+    const tarball_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
     defer gpa.free(tarball_path);
 
     // Run tarball fetch, expect to fail
@@ -2101,7 +2101,7 @@ test "tarball with excluded duplicate paths" {
 
     const tarball_name = "duplicate_paths_excluded.tar.gz";
     try saveEmbedFile(tarball_name, tmp.dir);
-    const tarball_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
+    const tarball_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
     defer gpa.free(tarball_path);
 
     // Run tarball fetch, should succeed
@@ -2145,7 +2145,7 @@ test "tarball without root folder" {
 
     const tarball_name = "no_root.tar.gz";
     try saveEmbedFile(tarball_name, tmp.dir);
-    const tarball_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
+    const tarball_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
     defer gpa.free(tarball_path);
 
     // Run tarball fetch, should succeed
@@ -2176,7 +2176,7 @@ test "set executable bit based on file content" {
 
     const tarball_name = "executables.tar.gz";
     try saveEmbedFile(tarball_name, tmp.dir);
-    const tarball_path = try std.fmt.allocPrint(gpa, "zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
+    const tarball_path = try std.fmt.allocPrint(gpa, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, tarball_name });
     defer gpa.free(tarball_path);
 
     // $ tar -tvf executables.tar.gz
src/main.zig
@@ -123,6 +123,7 @@ const debug_usage = normal_usage ++
 ;
 
 const usage = if (build_options.enable_debug_extensions) debug_usage else normal_usage;
+const default_local_zig_cache_basename = ".zig-cache";
 
 var log_scopes: std.ArrayListUnmanaged([]const u8) = .{};
 
@@ -3107,14 +3108,13 @@ fn buildOutputType(
 
         // search upwards from cwd until we find directory with build.zig
         const cwd_path = try process.getCwdAlloc(arena);
-        const zig_cache = "zig-cache";
         var dirname: []const u8 = cwd_path;
         while (true) {
             const joined_path = try fs.path.join(arena, &.{
                 dirname, Package.build_zig_basename,
             });
             if (fs.cwd().access(joined_path, .{})) |_| {
-                const cache_dir_path = try fs.path.join(arena, &.{ dirname, zig_cache });
+                const cache_dir_path = try fs.path.join(arena, &.{ dirname, default_local_zig_cache_basename });
                 const dir = try fs.cwd().makeOpenPath(cache_dir_path, .{});
                 cleanup_local_cache_dir = dir;
                 break :l .{ .handle = dir, .path = cache_dir_path };
@@ -4869,9 +4869,9 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
                 .path = local_cache_dir_path,
             };
         }
-        const cache_dir_path = try build_root.directory.join(arena, &[_][]const u8{"zig-cache"});
+        const cache_dir_path = try build_root.directory.join(arena, &.{default_local_zig_cache_basename});
         break :l .{
-            .handle = try build_root.directory.handle.makeOpenPath("zig-cache", .{}),
+            .handle = try build_root.directory.handle.makeOpenPath(default_local_zig_cache_basename, .{}),
             .path = cache_dir_path,
         };
     };
test/src/Cases.zig
@@ -1449,14 +1449,14 @@ fn runCases(self: *Cases, zig_exe_path: []const u8) !void {
     var global_tmp = std.testing.tmpDir(.{});
     defer global_tmp.cleanup();
 
-    var cache_dir = try global_tmp.dir.makeOpenPath("zig-cache", .{});
+    var cache_dir = try global_tmp.dir.makeOpenPath(".zig-cache", .{});
     defer cache_dir.close();
-    const tmp_dir_path = try std.fs.path.join(self.gpa, &[_][]const u8{ ".", "zig-cache", "tmp", &global_tmp.sub_path });
+    const tmp_dir_path = try std.fs.path.join(self.gpa, &[_][]const u8{ ".", ".zig-cache", "tmp", &global_tmp.sub_path });
     defer self.gpa.free(tmp_dir_path);
 
     const global_cache_directory: Compilation.Directory = .{
         .handle = cache_dir,
-        .path = try std.fs.path.join(self.gpa, &[_][]const u8{ tmp_dir_path, "zig-cache" }),
+        .path = try std.fs.path.join(self.gpa, &[_][]const u8{ tmp_dir_path, ".zig-cache" }),
     };
     defer self.gpa.free(global_cache_directory.path.?);
 
@@ -1529,16 +1529,16 @@ fn runOneCase(
     var tmp = std.testing.tmpDir(.{});
     defer tmp.cleanup();
 
-    var cache_dir = try tmp.dir.makeOpenPath("zig-cache", .{});
+    var cache_dir = try tmp.dir.makeOpenPath(".zig-cache", .{});
     defer cache_dir.close();
 
     const tmp_dir_path = try std.fs.path.join(
         arena,
-        &[_][]const u8{ ".", "zig-cache", "tmp", &tmp.sub_path },
+        &[_][]const u8{ ".", ".zig-cache", "tmp", &tmp.sub_path },
     );
     const local_cache_path = try std.fs.path.join(
         arena,
-        &[_][]const u8{ tmp_dir_path, "zig-cache" },
+        &[_][]const u8{ tmp_dir_path, ".zig-cache" },
     );
 
     const zig_cache_directory: Compilation.Directory = .{
tools/doctest.zig
@@ -22,7 +22,7 @@ const usage =
     \\   -o output              Where to write output HTML docs to
     \\   --zig zig              Path to the zig compiler
     \\   --zig-lib-dir dir      Override the zig compiler library path
-    \\   --cache-root dir       Path to local zig-cache/
+    \\   --cache-root dir       Path to local .zig-cache/
     \\
 ;