aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/Build')
-rw-r--r--lib/std/Build/Cache.zig8
-rw-r--r--lib/std/Build/Step.zig17
-rw-r--r--lib/std/Build/Step/CheckFile.zig4
-rw-r--r--lib/std/Build/Step/ConfigHeader.zig8
-rw-r--r--lib/std/Build/Step/Options.zig15
-rw-r--r--lib/std/Build/Step/Run.zig2
-rw-r--r--lib/std/Build/Watch.zig16
7 files changed, 38 insertions, 32 deletions
diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig
index 42459c033d..fdcb2ab714 100644
--- a/lib/std/Build/Cache.zig
+++ b/lib/std/Build/Cache.zig
@@ -508,7 +508,7 @@ pub const Manifest = struct {
// and `want_shared_lock` is set, a shared lock might be sufficient, so we'll
// open with a shared lock instead.
while (true) {
- if (self.cache.manifest_dir.createFile(&manifest_file_path, .{
+ if (self.cache.manifest_dir.createFile(io, &manifest_file_path, .{
.read = true,
.truncate = false,
.lock = .exclusive,
@@ -543,7 +543,7 @@ pub const Manifest = struct {
return error.CacheCheckFailed;
}
- if (self.cache.manifest_dir.createFile(&manifest_file_path, .{
+ if (self.cache.manifest_dir.createFile(io, &manifest_file_path, .{
.read = true,
.truncate = false,
.lock = .exclusive,
@@ -873,7 +873,7 @@ pub const Manifest = struct {
if (man.want_refresh_timestamp) {
man.want_refresh_timestamp = false;
- var file = man.cache.manifest_dir.createFile("timestamp", .{
+ var file = man.cache.manifest_dir.createFile(io, "timestamp", .{
.read = true,
.truncate = true,
}) catch |err| switch (err) {
@@ -1324,7 +1324,7 @@ fn hashFile(file: Io.File, bin_digest: *[Hasher.mac_length]u8) Io.File.PReadErro
fn testGetCurrentFileTimestamp(io: Io, dir: Io.Dir) !Io.Timestamp {
const test_out_file = "test-filetimestamp.tmp";
- var file = try dir.createFile(test_out_file, .{
+ var file = try dir.createFile(io, test_out_file, .{
.read = true,
.truncate = true,
});
diff --git a/lib/std/Build/Step.zig b/lib/std/Build/Step.zig
index 56ef32e8d8..2ec1c0ef31 100644
--- a/lib/std/Build/Step.zig
+++ b/lib/std/Build/Step.zig
@@ -401,6 +401,9 @@ pub fn evalZigProcess(
web_server: ?*Build.WebServer,
gpa: Allocator,
) !?Path {
+ const b = s.owner;
+ const io = b.graph.io;
+
// If an error occurs, it's happened in this command:
assert(s.result_failed_command == null);
s.result_failed_command = try allocPrintCmd(gpa, null, argv);
@@ -411,7 +414,7 @@ pub fn evalZigProcess(
const result = zigProcessUpdate(s, zp, watch, web_server, gpa) catch |err| switch (err) {
error.BrokenPipe => {
// Process restart required.
- const term = zp.child.wait() catch |e| {
+ const term = zp.child.wait(io) catch |e| {
return s.fail("unable to wait for {s}: {t}", .{ argv[0], e });
};
_ = term;
@@ -427,7 +430,7 @@ pub fn evalZigProcess(
if (s.result_error_msgs.items.len > 0 and result == null) {
// Crash detected.
- const term = zp.child.wait() catch |e| {
+ const term = zp.child.wait(io) catch |e| {
return s.fail("unable to wait for {s}: {t}", .{ argv[0], e });
};
s.result_peak_rss = zp.child.resource_usage_statistics.getMaxRss() orelse 0;
@@ -439,9 +442,7 @@ pub fn evalZigProcess(
return result;
}
assert(argv.len != 0);
- const b = s.owner;
const arena = b.allocator;
- const io = b.graph.io;
try handleChildProcUnsupported(s);
try handleVerbose(s.owner, null, argv);
@@ -478,7 +479,7 @@ pub fn evalZigProcess(
zp.child.stdin.?.close(io);
zp.child.stdin = null;
- const term = zp.child.wait() catch |err| {
+ const term = zp.child.wait(io) catch |err| {
return s.fail("unable to wait for {s}: {t}", .{ argv[0], err });
};
s.result_peak_rss = zp.child.resource_usage_statistics.getMaxRss() orelse 0;
@@ -519,7 +520,7 @@ pub fn installFile(s: *Step, src_lazy_path: Build.LazyPath, dest_path: []const u
pub fn installDir(s: *Step, dest_path: []const u8) !Io.Dir.MakePathStatus {
const b = s.owner;
try handleVerbose(b, null, &.{ "install", "-d", dest_path });
- return std.fs.cwd().makePathStatus(dest_path) catch |err|
+ return Io.Dir.cwd().makePathStatus(dest_path) catch |err|
return s.fail("unable to create dir '{s}': {t}", .{ dest_path, err });
}
@@ -895,7 +896,7 @@ pub fn addWatchInput(step: *Step, lazy_file: Build.LazyPath) Allocator.Error!voi
try addWatchInputFromPath(step, .{
.root_dir = .{
.path = null,
- .handle = std.fs.cwd(),
+ .handle = Io.Dir.cwd(),
},
.sub_path = std.fs.path.dirname(path_string) orelse "",
}, std.fs.path.basename(path_string));
@@ -920,7 +921,7 @@ pub fn addDirectoryWatchInput(step: *Step, lazy_directory: Build.LazyPath) Alloc
try addDirectoryWatchInputFromPath(step, .{
.root_dir = .{
.path = null,
- .handle = std.fs.cwd(),
+ .handle = Io.Dir.cwd(),
},
.sub_path = path_string,
});
diff --git a/lib/std/Build/Step/CheckFile.zig b/lib/std/Build/Step/CheckFile.zig
index efeedc8b80..560b6ad050 100644
--- a/lib/std/Build/Step/CheckFile.zig
+++ b/lib/std/Build/Step/CheckFile.zig
@@ -3,7 +3,9 @@
//! TODO: generalize the code in std.testing.expectEqualStrings and make this
//! CheckFile step produce those helpful diagnostics when there is not a match.
const CheckFile = @This();
+
const std = @import("std");
+const Io = std.Io;
const Step = std.Build.Step;
const fs = std.fs;
const mem = std.mem;
@@ -53,7 +55,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(src_path, b.allocator, .limited(check_file.max_bytes)) catch |err| {
+ const contents = Io.Dir.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/ConfigHeader.zig b/lib/std/Build/Step/ConfigHeader.zig
index df2419764d..ea7d9d99ff 100644
--- a/lib/std/Build/Step/ConfigHeader.zig
+++ b/lib/std/Build/Step/ConfigHeader.zig
@@ -1,5 +1,7 @@
-const std = @import("std");
const ConfigHeader = @This();
+
+const std = @import("std");
+const Io = std.Io;
const Step = std.Build.Step;
const Allocator = std.mem.Allocator;
const Writer = std.Io.Writer;
@@ -205,7 +207,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(src_path, arena, .limited(config_header.max_bytes)) catch |err| {
+ const contents = Io.Dir.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),
});
@@ -219,7 +221,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(src_path, arena, .limited(config_header.max_bytes)) catch |err| {
+ const contents = Io.Dir.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/Step/Options.zig b/lib/std/Build/Step/Options.zig
index 9f5665e93a..1416e0e916 100644
--- a/lib/std/Build/Step/Options.zig
+++ b/lib/std/Build/Step/Options.zig
@@ -1,12 +1,13 @@
-const std = @import("std");
+const Options = @This();
const builtin = @import("builtin");
+
+const std = @import("std");
+const Io = std.Io;
const fs = std.fs;
const Step = std.Build.Step;
const GeneratedFile = std.Build.GeneratedFile;
const LazyPath = std.Build.LazyPath;
-const Options = @This();
-
pub const base_id: Step.Id = .options;
step: Step,
@@ -542,11 +543,11 @@ test Options {
.cache = .{
.io = io,
.gpa = arena.allocator(),
- .manifest_dir = std.fs.cwd(),
+ .manifest_dir = Io.Dir.cwd(),
},
.zig_exe = "test",
.env_map = std.process.EnvMap.init(arena.allocator()),
- .global_cache_root = .{ .path = "test", .handle = std.fs.cwd() },
+ .global_cache_root = .{ .path = "test", .handle = Io.Dir.cwd() },
.host = .{
.query = .{},
.result = try std.zig.system.resolveTargetQuery(io, .{}),
@@ -557,8 +558,8 @@ test Options {
var builder = try std.Build.create(
&graph,
- .{ .path = "test", .handle = std.fs.cwd() },
- .{ .path = "test", .handle = std.fs.cwd() },
+ .{ .path = "test", .handle = Io.Dir.cwd() },
+ .{ .path = "test", .handle = Io.Dir.cwd() },
&.{},
);
diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig
index 7c54c8048e..af6bc20438 100644
--- a/lib/std/Build/Step/Run.zig
+++ b/lib/std/Build/Step/Run.zig
@@ -1023,7 +1023,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
try runCommand(run, argv_list.items, has_side_effects, tmp_dir_path, options, null);
- const dep_file_dir = std.fs.cwd();
+ const dep_file_dir = Io.Dir.cwd();
const dep_file_basename = dep_output_file.generated_file.getPath2(b, step);
if (has_side_effects)
try man.addDepFile(dep_file_dir, dep_file_basename)
diff --git a/lib/std/Build/Watch.zig b/lib/std/Build/Watch.zig
index ff06ad3ff3..f7ac47961e 100644
--- a/lib/std/Build/Watch.zig
+++ b/lib/std/Build/Watch.zig
@@ -122,7 +122,7 @@ const Os = switch (builtin.os.tag) {
}) catch return error.NameTooLong;
const stack_ptr: *std.os.linux.file_handle = @ptrCast(&file_handle_buffer);
stack_ptr.handle_bytes = file_handle_buffer.len - @sizeOf(std.os.linux.file_handle);
- try posix.name_to_handle_at(path.root_dir.handle.fd, adjusted_path, stack_ptr, mount_id, std.os.linux.AT.HANDLE_FID);
+ try posix.name_to_handle_at(path.root_dir.handle.handle, adjusted_path, stack_ptr, mount_id, std.os.linux.AT.HANDLE_FID);
const stack_lfh: FileHandle = .{ .handle = stack_ptr };
return stack_lfh.clone(gpa);
}
@@ -222,7 +222,7 @@ const Os = switch (builtin.os.tag) {
posix.fanotify_mark(fan_fd, .{
.ADD = true,
.ONLYDIR = true,
- }, fan_mask, path.root_dir.handle.fd, path.subPathOrDot()) catch |err| {
+ }, fan_mask, path.root_dir.handle.handle, path.subPathOrDot()) catch |err| {
fatal("unable to watch {f}: {s}", .{ path, @errorName(err) });
};
}
@@ -275,7 +275,7 @@ const Os = switch (builtin.os.tag) {
posix.fanotify_mark(fan_fd, .{
.REMOVE = true,
.ONLYDIR = true,
- }, fan_mask, path.root_dir.handle.fd, path.subPathOrDot()) catch |err| switch (err) {
+ }, fan_mask, path.root_dir.handle.handle, path.subPathOrDot()) catch |err| switch (err) {
error.FileNotFound => {}, // Expected, harmless.
else => |e| std.log.warn("unable to unwatch '{f}': {s}", .{ path, @errorName(e) }),
};
@@ -353,7 +353,7 @@ const Os = switch (builtin.os.tag) {
// The following code is a drawn out NtCreateFile call. (mostly adapted from Io.Dir.makeOpenDirAccessMaskW)
// It's necessary in order to get the specific flags that are required when calling ReadDirectoryChangesW.
var dir_handle: windows.HANDLE = undefined;
- const root_fd = path.root_dir.handle.fd;
+ const root_fd = path.root_dir.handle.handle;
const sub_path = path.subPathOrDot();
const sub_path_w = try windows.sliceToPrefixedFileW(root_fd, sub_path);
const path_len_bytes = std.math.cast(u16, sub_path_w.len * 2) orelse return error.NameTooLong;
@@ -681,9 +681,9 @@ const Os = switch (builtin.os.tag) {
if (!gop.found_existing) {
const skip_open_dir = path.sub_path.len == 0;
const dir_fd = if (skip_open_dir)
- path.root_dir.handle.fd
+ path.root_dir.handle.handle
else
- posix.openat(path.root_dir.handle.fd, path.sub_path, dir_open_flags, 0) catch |err| {
+ posix.openat(path.root_dir.handle.handle, path.sub_path, dir_open_flags, 0) catch |err| {
fatal("failed to open directory {f}: {s}", .{ path, @errorName(err) });
};
// Empirically the dir has to stay open or else no events are triggered.
@@ -750,7 +750,7 @@ const Os = switch (builtin.os.tag) {
// to access that data via the dir_fd field.
const path = w.dir_table.keys()[i];
const dir_fd = if (path.sub_path.len == 0)
- path.root_dir.handle.fd
+ path.root_dir.handle.handle
else
handles.items(.dir_fd)[i];
assert(dir_fd != -1);
@@ -761,7 +761,7 @@ const Os = switch (builtin.os.tag) {
const last_dir_fd = fd: {
const last_path = w.dir_table.keys()[handles.len - 1];
const last_dir_fd = if (last_path.sub_path.len == 0)
- last_path.root_dir.handle.fd
+ last_path.root_dir.handle.handle
else
handles.items(.dir_fd)[handles.len - 1];
assert(last_dir_fd != -1);