aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-12-08 17:21:52 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-12-23 22:15:08 -0800
commit4218344dd3178f2fd3d9d00e9ff6895ee344df6d (patch)
tree38a1378b45349bcd182f6bdb721dadb275c1d02e /lib/std/Build
parent950d18ef695bb7a28397e080dc3c201559ec4ee2 (diff)
downloadzig-4218344dd3178f2fd3d9d00e9ff6895ee344df6d.tar.gz
zig-4218344dd3178f2fd3d9d00e9ff6895ee344df6d.zip
std.Build.Cache: remove readSmallFile and writeSmallFile
These were to support optimizations involving detecting when to avoid calling into LLD, which are no longer implemented.
Diffstat (limited to 'lib/std/Build')
-rw-r--r--lib/std/Build/Cache.zig36
-rw-r--r--lib/std/Build/Step/ConfigHeader.zig2
-rw-r--r--lib/std/Build/Step/Run.zig2
-rw-r--r--lib/std/Build/Step/UpdateSourceFiles.zig2
-rw-r--r--lib/std/Build/Step/WriteFile.zig2
-rw-r--r--lib/std/Build/WebServer.zig2
6 files changed, 11 insertions, 35 deletions
diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig
index dab1926f53..f7c4d729bc 100644
--- a/lib/std/Build/Cache.zig
+++ b/lib/std/Build/Cache.zig
@@ -1276,30 +1276,6 @@ pub const Manifest = struct {
}
};
-/// On operating systems that support symlinks, does a readlink. On other operating systems,
-/// uses the file contents. Windows supports symlinks but only with elevated privileges, so
-/// it is treated as not supporting symlinks.
-pub fn readSmallFile(dir: Io.Dir, sub_path: []const u8, buffer: []u8) ![]u8 {
- if (builtin.os.tag == .windows) {
- return dir.readFile(sub_path, buffer);
- } else {
- return dir.readLink(sub_path, buffer);
- }
-}
-
-/// On operating systems that support symlinks, does a symlink. On other operating systems,
-/// uses the file contents. Windows supports symlinks but only with elevated privileges, so
-/// it is treated as not supporting symlinks.
-/// `data` must be a valid UTF-8 encoded file path and 255 bytes or fewer.
-pub fn writeSmallFile(dir: Io.Dir, sub_path: []const u8, data: []const u8) !void {
- assert(data.len <= 255);
- if (builtin.os.tag == .windows) {
- return dir.writeFile(.{ .sub_path = sub_path, .data = data });
- } else {
- return dir.symLink(data, sub_path, .{});
- }
-}
-
fn hashFile(io: Io, file: Io.File, bin_digest: *[Hasher.mac_length]u8) Io.File.ReadPositionalError!void {
var buffer: [2048]u8 = undefined;
var hasher = hasher_init;
@@ -1338,7 +1314,7 @@ test "cache file and then recall it" {
const temp_file = "test.txt";
const temp_manifest_dir = "temp_manifest_dir";
- try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = "Hello, world!\n" });
+ try tmp.dir.writeFile(io, .{ .sub_path = temp_file, .data = "Hello, world!\n" });
// Wait for file timestamps to tick
const initial_time = try testGetCurrentFileTimestamp(io, tmp.dir);
@@ -1404,7 +1380,7 @@ test "check that changing a file makes cache fail" {
const original_temp_file_contents = "Hello, world!\n";
const updated_temp_file_contents = "Hello, world; but updated!\n";
- try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = original_temp_file_contents });
+ try tmp.dir.writeFile(io, .{ .sub_path = temp_file, .data = original_temp_file_contents });
// Wait for file timestamps to tick
const initial_time = try testGetCurrentFileTimestamp(tmp.dir);
@@ -1441,7 +1417,7 @@ test "check that changing a file makes cache fail" {
try ch.writeManifest();
}
- try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = updated_temp_file_contents });
+ try tmp.dir.writeFile(io, .{ .sub_path = temp_file, .data = updated_temp_file_contents });
{
var ch = cache.obtain();
@@ -1521,8 +1497,8 @@ test "Manifest with files added after initial hash work" {
const temp_file2 = "cache_hash_post_file_test2.txt";
const temp_manifest_dir = "cache_hash_post_file_manifest_dir";
- try tmp.dir.writeFile(.{ .sub_path = temp_file1, .data = "Hello, world!\n" });
- try tmp.dir.writeFile(.{ .sub_path = temp_file2, .data = "Hello world the second!\n" });
+ try tmp.dir.writeFile(io, .{ .sub_path = temp_file1, .data = "Hello, world!\n" });
+ try tmp.dir.writeFile(io, .{ .sub_path = temp_file2, .data = "Hello world the second!\n" });
// Wait for file timestamps to tick
const initial_time = try testGetCurrentFileTimestamp(tmp.dir);
@@ -1573,7 +1549,7 @@ test "Manifest with files added after initial hash work" {
try testing.expect(mem.eql(u8, &digest1, &digest2));
// Modify the file added after initial hash
- try tmp.dir.writeFile(.{ .sub_path = temp_file2, .data = "Hello world the second, updated\n" });
+ try tmp.dir.writeFile(io, .{ .sub_path = temp_file2, .data = "Hello world the second, updated\n" });
// Wait for file timestamps to tick
const initial_time2 = try testGetCurrentFileTimestamp(tmp.dir);
diff --git a/lib/std/Build/Step/ConfigHeader.zig b/lib/std/Build/Step/ConfigHeader.zig
index f377959610..589110d4c4 100644
--- a/lib/std/Build/Step/ConfigHeader.zig
+++ b/lib/std/Build/Step/ConfigHeader.zig
@@ -264,7 +264,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
});
};
- b.cache_root.handle.writeFile(.{ .sub_path = sub_path, .data = output }) catch |err| {
+ b.cache_root.handle.writeFile(io, .{ .sub_path = sub_path, .data = output }) catch |err| {
return step.fail("unable to write file '{f}{s}': {s}", .{
b.cache_root, sub_path, @errorName(err),
});
diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig
index f6b29635c1..a1618beb02 100644
--- a/lib/std/Build/Step/Run.zig
+++ b/lib/std/Build/Step/Run.zig
@@ -1482,7 +1482,7 @@ fn runCommand(
.leading => mem.trimStart(u8, stream.bytes.?, &std.ascii.whitespace),
.trailing => mem.trimEnd(u8, stream.bytes.?, &std.ascii.whitespace),
};
- b.cache_root.handle.writeFile(.{ .sub_path = sub_path, .data = data }) catch |err| {
+ b.cache_root.handle.writeFile(io, .{ .sub_path = sub_path, .data = data }) catch |err| {
return step.fail("unable to write file '{f}{s}': {s}", .{
b.cache_root, sub_path, @errorName(err),
});
diff --git a/lib/std/Build/Step/UpdateSourceFiles.zig b/lib/std/Build/Step/UpdateSourceFiles.zig
index 44c6ae1ed4..eb8a6a85dd 100644
--- a/lib/std/Build/Step/UpdateSourceFiles.zig
+++ b/lib/std/Build/Step/UpdateSourceFiles.zig
@@ -84,7 +84,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
}
switch (output_source_file.contents) {
.bytes => |bytes| {
- b.build_root.handle.writeFile(.{ .sub_path = output_source_file.sub_path, .data = bytes }) catch |err| {
+ b.build_root.handle.writeFile(io, .{ .sub_path = output_source_file.sub_path, .data = bytes }) catch |err| {
return step.fail("unable to write file '{f}{s}': {t}", .{
b.build_root, output_source_file.sub_path, err,
});
diff --git a/lib/std/Build/Step/WriteFile.zig b/lib/std/Build/Step/WriteFile.zig
index 94b04b4212..3d712fa1d4 100644
--- a/lib/std/Build/Step/WriteFile.zig
+++ b/lib/std/Build/Step/WriteFile.zig
@@ -273,7 +273,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
}
switch (file.contents) {
.bytes => |bytes| {
- cache_dir.writeFile(.{ .sub_path = file.sub_path, .data = bytes }) catch |err| {
+ cache_dir.writeFile(io, .{ .sub_path = file.sub_path, .data = bytes }) catch |err| {
return step.fail("unable to write file '{f}{s}{c}{s}': {t}", .{
b.cache_root, cache_path, fs.path.sep, file.sub_path, err,
});
diff --git a/lib/std/Build/WebServer.zig b/lib/std/Build/WebServer.zig
index 162d17f070..ed07d04d57 100644
--- a/lib/std/Build/WebServer.zig
+++ b/lib/std/Build/WebServer.zig
@@ -523,7 +523,7 @@ pub fn serveTarFile(ws: *WebServer, request: *http.Server.Request, paths: []cons
if (cached_cwd_path == null) cached_cwd_path = try std.process.getCwdAlloc(gpa);
break :cwd cached_cwd_path.?;
};
- try archiver.writeFile(path.sub_path, &file_reader, @intCast(stat.mtime.toSeconds()));
+ try archiver.writeFile(io, path.sub_path, &file_reader, @intCast(stat.mtime.toSeconds()));
}
// intentionally not calling `archiver.finishPedantically`