authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-12-20 21:14:25-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:11-08:00
log51a6f3a5251096f346eb28b22e1c20ed2ceb7d9e
tree747cd5e6c546bf514d2b94487b5cbc20a2978b9c
parent8968d75fb1efa89f5264c5668721c5798267a79a

Update a few more callsites for std.Io changes


7 files changed, 19 insertions(+), 17 deletions(-)

lib/compiler/translate-c/main.zig+1-1
......@@ -35,7 +35,7 @@ pub fn main() u8 {
3535 }
3636
3737 var stderr_buf: [1024]u8 = undefined;
38 var stderr = Io.File.stderr().writer(&stderr_buf);
38 var stderr = Io.File.stderr().writer(io, &stderr_buf);
3939 var diagnostics: aro.Diagnostics = switch (zig_integration) {
4040 false => .{ .output = .{ .to_writer = .{
4141 .color = .detect(stderr.file),
lib/std/Build.zig+1-1
......@@ -1776,7 +1776,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
17761776 while (it.next()) |ext| {
17771777 if (!supportedWindowsProgramExtension(ext)) continue;
17781778
1779 return fs.realpathAlloc(b.allocator, b.fmt("{s}{s}", .{ full_path, ext })) catch |err| switch (err) {
1779 return fs.realPathFileAlloc(b.graph.io, b.fmt("{s}{s}", .{ full_path, ext }), b.allocator) catch |err| switch (err) {
17801780 error.OutOfMemory => @panic("OOM"),
17811781 else => continue,
17821782 };
lib/std/Build/Cache.zig+1-1
......@@ -298,7 +298,7 @@ pub const Lock = struct {
298298 if (builtin.os.tag == .windows) {
299299 // Windows does not guarantee that locks are immediately unlocked when
300300 // the file handle is closed. See LockFileEx documentation.
301 lock.manifest_file.unlock();
301 lock.manifest_file.unlock(io);
302302 }
303303
304304 lock.manifest_file.close(io);
lib/std/zig/LibCInstallation.zig+1-1
......@@ -201,7 +201,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib
201201 try self.findNativeMsvcIncludeDir(gpa, io, sdk);
202202 try self.findNativeMsvcLibDir(gpa, sdk);
203203 try self.findNativeKernel32LibDir(gpa, io, args, sdk);
204 try self.findNativeIncludeDirWindows(gpa, io, args, sdk);
204 try self.findNativeIncludeDirWindows(gpa, io, sdk);
205205 try self.findNativeCrtDirWindows(gpa, io, args.target, sdk);
206206 } else if (is_haiku) {
207207 try self.findNativeIncludeDirPosix(gpa, io, args);
lib/std/zig/WindowsSdk.zig+13-11
......@@ -24,7 +24,7 @@ const product_version_max_length = version_major_minor_max_length + ".65535".len
2424/// Find path and version of Windows 10 SDK and Windows 8.1 SDK, and find path to MSVC's `lib/` directory.
2525/// Caller owns the result's fields.
2626/// Returns memory allocated by `gpa`
27pub fn find(gpa: Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFound, PathTooLong }!WindowsSdk {
27pub fn find(gpa: Allocator, io: Io, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFound, PathTooLong }!WindowsSdk {
2828 if (builtin.os.tag != .windows) return error.NotFound;
2929
3030 //note(dimenus): If this key doesn't exist, neither the Win 8 SDK nor the Win 10 SDK is installed
......@@ -33,7 +33,7 @@ pub fn find(gpa: Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFo
3333 };
3434 defer roots_key.closeKey();
3535
36 const windows10sdk = Installation.find(gpa, roots_key, "KitsRoot10", "", "v10.0") catch |err| switch (err) {
36 const windows10sdk = Installation.find(gpa, io, roots_key, "KitsRoot10", "", "v10.0") catch |err| switch (err) {
3737 error.InstallationNotFound => null,
3838 error.PathTooLong => null,
3939 error.VersionTooLong => null,
......@@ -41,7 +41,7 @@ pub fn find(gpa: Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFo
4141 };
4242 errdefer if (windows10sdk) |*w| w.free(gpa);
4343
44 const windows81sdk = Installation.find(gpa, roots_key, "KitsRoot81", "winver", "v8.1") catch |err| switch (err) {
44 const windows81sdk = Installation.find(gpa, io, roots_key, "KitsRoot81", "winver", "v8.1") catch |err| switch (err) {
4545 error.InstallationNotFound => null,
4646 error.PathTooLong => null,
4747 error.VersionTooLong => null,
......@@ -49,7 +49,7 @@ pub fn find(gpa: Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFo
4949 };
5050 errdefer if (windows81sdk) |*w| w.free(gpa);
5151
52 const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(gpa, arch) catch |err| switch (err) {
52 const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(gpa, io, arch) catch |err| switch (err) {
5353 error.MsvcLibDirNotFound => null,
5454 error.OutOfMemory => return error.OutOfMemory,
5555 };
......@@ -80,6 +80,7 @@ pub fn free(sdk: WindowsSdk, gpa: Allocator) void {
8080fn iterateAndFilterByVersion(
8181 iterator: *Dir.Iterator,
8282 gpa: Allocator,
83 io: Io,
8384 prefix: []const u8,
8485) error{OutOfMemory}![][]const u8 {
8586 const Version = struct {
......@@ -104,7 +105,7 @@ fn iterateAndFilterByVersion(
104105 dirs.deinit();
105106 }
106107
107 iterate: while (iterator.next() catch null) |entry| {
108 iterate: while (iterator.next(io) catch null) |entry| {
108109 if (entry.kind != .directory) continue;
109110 if (!std.mem.startsWith(u8, entry.name, prefix)) continue;
110111
......@@ -420,13 +421,14 @@ pub const Installation = struct {
420421 /// Caller owns the result's fields.
421422 fn find(
422423 gpa: Allocator,
424 io: Io,
423425 roots_key: RegistryWtf8,
424426 roots_subkey: []const u8,
425427 prefix: []const u8,
426428 version_key_name: []const u8,
427429 ) error{ OutOfMemory, InstallationNotFound, PathTooLong, VersionTooLong }!Installation {
428430 roots: {
429 const installation = findFromRoot(gpa, roots_key, roots_subkey, prefix) catch
431 const installation = findFromRoot(gpa, io, roots_key, roots_subkey, prefix) catch
430432 break :roots;
431433 if (installation.isValidVersion()) return installation;
432434 installation.free(gpa);
......@@ -485,7 +487,7 @@ pub const Installation = struct {
485487 defer sdk_lib_dir.close(io);
486488
487489 var iterator = sdk_lib_dir.iterate();
488 const versions = try iterateAndFilterByVersion(&iterator, gpa, prefix);
490 const versions = try iterateAndFilterByVersion(&iterator, gpa, io, prefix);
489491 if (versions.len == 0) return error.InstallationNotFound;
490492 defer {
491493 for (versions[1..]) |version| gpa.free(version);
......@@ -673,7 +675,7 @@ const MsvcLibDir = struct {
673675 // First, try getting the packages cache path from the registry.
674676 // This only seems to exist when the path is different from the default.
675677 method1: {
676 return findInstancesDirViaSetup(gpa) catch |err| switch (err) {
678 return findInstancesDirViaSetup(gpa, io) catch |err| switch (err) {
677679 error.OutOfMemory => |e| return e,
678680 error.PathNotFound => break :method1,
679681 };
......@@ -766,7 +768,7 @@ const MsvcLibDir = struct {
766768
767769 var latest_version: u64 = 0;
768770 var instances_dir_it = instances_dir.iterateAssumeFirstIteration();
769 while (instances_dir_it.next() catch return error.PathNotFound) |entry| {
771 while (instances_dir_it.next(io) catch return error.PathNotFound) |entry| {
770772 if (entry.kind != .directory) continue;
771773
772774 var writer: Writer = .fixed(&state_subpath_buf);
......@@ -828,7 +830,7 @@ const MsvcLibDir = struct {
828830
829831 try lib_dir_buf.appendSlice("VC\\Auxiliary\\Build\\Microsoft.VCToolsVersion.default.txt");
830832 var default_tools_version_buf: [512]u8 = undefined;
831 const default_tools_version_contents = Dir.cwd().readFile(lib_dir_buf.items, &default_tools_version_buf) catch {
833 const default_tools_version_contents = Dir.cwd().readFile(io, lib_dir_buf.items, &default_tools_version_buf) catch {
832834 return error.PathNotFound;
833835 };
834836 var tokenizer = std.mem.tokenizeAny(u8, default_tools_version_contents, " \r\n");
......@@ -871,7 +873,7 @@ const MsvcLibDir = struct {
871873 defer visualstudio_folder.close(io);
872874
873875 var iterator = visualstudio_folder.iterate();
874 break :vs_versions try iterateAndFilterByVersion(&iterator, gpa, "");
876 break :vs_versions try iterateAndFilterByVersion(&iterator, gpa, io, "");
875877 };
876878 defer {
877879 for (vs_versions) |vs_version| gpa.free(vs_version);
src/link/Wasm.zig+1-1
......@@ -3008,7 +3008,7 @@ pub fn createEmpty(
30083008 else
30093009 .default_file
30103010 else
3011 0,
3011 .default_file,
30123012 });
30133013 wasm.name = emit.sub_path;
30143014
src/main.zig+1-1
......@@ -4513,7 +4513,7 @@ fn runOrTestHotSwap(
45134513 // tmp zig-cache and use it to spawn the child process. This way we are free to update
45144514 // the binary with each requested hot update.
45154515 .windows => blk: {
4516 try lf.emit.root_dir.handle.copyFile(lf.emit.sub_path, comp.dirs.local_cache.handle, lf.emit.sub_path, .{});
4516 try lf.emit.root_dir.handle.copyFile(lf.emit.sub_path, comp.dirs.local_cache.handle, lf.emit.sub_path, io, .{});
45174517 break :blk try fs.path.join(gpa, &.{ comp.dirs.local_cache.path orelse ".", lf.emit.sub_path });
45184518 },
45194519