aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-08-29 20:19:23 -0700
committerAndrew Kelley <andrew@ziglang.org>2025-08-30 00:48:50 -0700
commit9a0970a12bdcae105b6f3f65c0a72d95a209bd35 (patch)
treeab0de8f2447b5e52c2bb5c92a976a52fb4b613ee /lib/std/Build
parent79f267f6b9e7f80a6fed3b1019f9de942841c3be (diff)
downloadzig-9a0970a12bdcae105b6f3f65c0a72d95a209bd35.tar.gz
zig-9a0970a12bdcae105b6f3f65c0a72d95a209bd35.zip
rework std.Io.Writer.Allocating to support runtime-known alignment
Also, breaking API changes to: * std.fs.Dir.readFileAlloc * std.fs.Dir.readFileAllocOptions
Diffstat (limited to 'lib/std/Build')
-rw-r--r--lib/std/Build/Cache.zig2
-rw-r--r--lib/std/Build/Step/CheckFile.zig2
-rw-r--r--lib/std/Build/Step/CheckObject.zig9
-rw-r--r--lib/std/Build/Step/ConfigHeader.zig4
-rw-r--r--lib/std/Build/WebServer.zig2
5 files changed, 9 insertions, 10 deletions
diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig
index 9552675be8..80170e1752 100644
--- a/lib/std/Build/Cache.zig
+++ b/lib/std/Build/Cache.zig
@@ -1056,7 +1056,7 @@ pub const Manifest = struct {
fn addDepFileMaybePost(self: *Manifest, dir: fs.Dir, dep_file_basename: []const u8) !void {
const gpa = self.cache.gpa;
- const dep_file_contents = try dir.readFileAlloc(gpa, dep_file_basename, manifest_file_size_max);
+ const dep_file_contents = try dir.readFileAlloc(dep_file_basename, gpa, .limited(manifest_file_size_max));
defer gpa.free(dep_file_contents);
var error_buf: std.ArrayListUnmanaged(u8) = .empty;
diff --git a/lib/std/Build/Step/CheckFile.zig b/lib/std/Build/Step/CheckFile.zig
index 699e6d2e9d..5e664b3bc3 100644
--- a/lib/std/Build/Step/CheckFile.zig
+++ b/lib/std/Build/Step/CheckFile.zig
@@ -53,7 +53,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
try step.singleUnchangingWatchInput(check_file.source);
const src_path = check_file.source.getPath2(b, step);
- const contents = fs.cwd().readFileAlloc(b.allocator, src_path, check_file.max_bytes) catch |err| {
+ const contents = fs.cwd().readFileAlloc(src_path, b.allocator, .limited(check_file.max_bytes)) catch |err| {
return step.fail("unable to read '{s}': {s}", .{
src_path, @errorName(err),
});
diff --git a/lib/std/Build/Step/CheckObject.zig b/lib/std/Build/Step/CheckObject.zig
index 5fa039b772..2f7afa8dba 100644
--- a/lib/std/Build/Step/CheckObject.zig
+++ b/lib/std/Build/Step/CheckObject.zig
@@ -553,14 +553,13 @@ fn make(step: *Step, make_options: Step.MakeOptions) !void {
const src_path = check_object.source.getPath3(b, step);
const contents = src_path.root_dir.handle.readFileAllocOptions(
- gpa,
src_path.sub_path,
- check_object.max_bytes,
- null,
+ gpa,
+ .limited(check_object.max_bytes),
.of(u64),
null,
- ) catch |err| return step.fail("unable to read '{f}': {s}", .{
- std.fmt.alt(src_path, .formatEscapeChar), @errorName(err),
+ ) catch |err| return step.fail("unable to read '{f}': {t}", .{
+ std.fmt.alt(src_path, .formatEscapeChar), err,
});
var vars: std.StringHashMap(u64) = .init(gpa);
diff --git a/lib/std/Build/Step/ConfigHeader.zig b/lib/std/Build/Step/ConfigHeader.zig
index 3c7f9a70c2..3f89bf8ec9 100644
--- a/lib/std/Build/Step/ConfigHeader.zig
+++ b/lib/std/Build/Step/ConfigHeader.zig
@@ -208,7 +208,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
.autoconf_undef, .autoconf_at => |file_source| {
try bw.writeAll(c_generated_line);
const src_path = file_source.getPath2(b, step);
- const contents = std.fs.cwd().readFileAlloc(arena, src_path, config_header.max_bytes) catch |err| {
+ const contents = std.fs.cwd().readFileAlloc(src_path, arena, .limited(config_header.max_bytes)) catch |err| {
return step.fail("unable to read autoconf input file '{s}': {s}", .{
src_path, @errorName(err),
});
@@ -222,7 +222,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
.cmake => |file_source| {
try bw.writeAll(c_generated_line);
const src_path = file_source.getPath2(b, step);
- const contents = std.fs.cwd().readFileAlloc(arena, src_path, config_header.max_bytes) catch |err| {
+ const contents = std.fs.cwd().readFileAlloc(src_path, arena, .limited(config_header.max_bytes)) catch |err| {
return step.fail("unable to read cmake input file '{s}': {s}", .{
src_path, @errorName(err),
});
diff --git a/lib/std/Build/WebServer.zig b/lib/std/Build/WebServer.zig
index b456aa16ca..1b3e3bfe82 100644
--- a/lib/std/Build/WebServer.zig
+++ b/lib/std/Build/WebServer.zig
@@ -446,7 +446,7 @@ pub fn serveFile(
// The desired API is actually sendfile, which will require enhancing http.Server.
// We load the file with every request so that the user can make changes to the file
// and refresh the HTML page without restarting this server.
- const file_contents = path.root_dir.handle.readFileAlloc(gpa, path.sub_path, 10 * 1024 * 1024) catch |err| {
+ const file_contents = path.root_dir.handle.readFileAlloc(path.sub_path, gpa, .limited(10 * 1024 * 1024)) catch |err| {
log.err("failed to read '{f}': {s}", .{ path, @errorName(err) });
return error.AlreadyReported;
};