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 {...@@ -35,7 +35,7 @@ pub fn main() u8 {
35 }35 }
3636
37 var stderr_buf: [1024]u8 = undefined;37 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);
39 var diagnostics: aro.Diagnostics = switch (zig_integration) {39 var diagnostics: aro.Diagnostics = switch (zig_integration) {
40 false => .{ .output = .{ .to_writer = .{40 false => .{ .output = .{ .to_writer = .{
41 .color = .detect(stderr.file),41 .color = .detect(stderr.file),
lib/std/Build.zig+1-1
...@@ -1776,7 +1776,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {...@@ -1776,7 +1776,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
1776 while (it.next()) |ext| {1776 while (it.next()) |ext| {
1777 if (!supportedWindowsProgramExtension(ext)) continue;1777 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) {
1780 error.OutOfMemory => @panic("OOM"),1780 error.OutOfMemory => @panic("OOM"),
1781 else => continue,1781 else => continue,
1782 };1782 };
lib/std/Build/Cache.zig+1-1
...@@ -298,7 +298,7 @@ pub const Lock = struct {...@@ -298,7 +298,7 @@ pub const Lock = struct {
298 if (builtin.os.tag == .windows) {298 if (builtin.os.tag == .windows) {
299 // Windows does not guarantee that locks are immediately unlocked when299 // Windows does not guarantee that locks are immediately unlocked when
300 // the file handle is closed. See LockFileEx documentation.300 // the file handle is closed. See LockFileEx documentation.
301 lock.manifest_file.unlock();301 lock.manifest_file.unlock(io);
302 }302 }
303303
304 lock.manifest_file.close(io);304 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...@@ -201,7 +201,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib
201 try self.findNativeMsvcIncludeDir(gpa, io, sdk);201 try self.findNativeMsvcIncludeDir(gpa, io, sdk);
202 try self.findNativeMsvcLibDir(gpa, sdk);202 try self.findNativeMsvcLibDir(gpa, sdk);
203 try self.findNativeKernel32LibDir(gpa, io, args, sdk);203 try self.findNativeKernel32LibDir(gpa, io, args, sdk);
204 try self.findNativeIncludeDirWindows(gpa, io, args, sdk);204 try self.findNativeIncludeDirWindows(gpa, io, sdk);
205 try self.findNativeCrtDirWindows(gpa, io, args.target, sdk);205 try self.findNativeCrtDirWindows(gpa, io, args.target, sdk);
206 } else if (is_haiku) {206 } else if (is_haiku) {
207 try self.findNativeIncludeDirPosix(gpa, io, args);207 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...@@ -24,7 +24,7 @@ const product_version_max_length = version_major_minor_max_length + ".65535".len
24/// Find path and version of Windows 10 SDK and Windows 8.1 SDK, and find path to MSVC's `lib/` directory.24/// Find path and version of Windows 10 SDK and Windows 8.1 SDK, and find path to MSVC's `lib/` directory.
25/// Caller owns the result's fields.25/// Caller owns the result's fields.
26/// Returns memory allocated by `gpa`26/// 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 {
28 if (builtin.os.tag != .windows) return error.NotFound;28 if (builtin.os.tag != .windows) return error.NotFound;
2929
30 //note(dimenus): If this key doesn't exist, neither the Win 8 SDK nor the Win 10 SDK is installed30 //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...@@ -33,7 +33,7 @@ pub fn find(gpa: Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFo
33 };33 };
34 defer roots_key.closeKey();34 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) {
37 error.InstallationNotFound => null,37 error.InstallationNotFound => null,
38 error.PathTooLong => null,38 error.PathTooLong => null,
39 error.VersionTooLong => null,39 error.VersionTooLong => null,
...@@ -41,7 +41,7 @@ pub fn find(gpa: Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFo...@@ -41,7 +41,7 @@ pub fn find(gpa: Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFo
41 };41 };
42 errdefer if (windows10sdk) |*w| w.free(gpa);42 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) {
45 error.InstallationNotFound => null,45 error.InstallationNotFound => null,
46 error.PathTooLong => null,46 error.PathTooLong => null,
47 error.VersionTooLong => null,47 error.VersionTooLong => null,
...@@ -49,7 +49,7 @@ pub fn find(gpa: Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFo...@@ -49,7 +49,7 @@ pub fn find(gpa: Allocator, arch: std.Target.Cpu.Arch) error{ OutOfMemory, NotFo
49 };49 };
50 errdefer if (windows81sdk) |*w| w.free(gpa);50 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) {
53 error.MsvcLibDirNotFound => null,53 error.MsvcLibDirNotFound => null,
54 error.OutOfMemory => return error.OutOfMemory,54 error.OutOfMemory => return error.OutOfMemory,
55 };55 };
...@@ -80,6 +80,7 @@ pub fn free(sdk: WindowsSdk, gpa: Allocator) void {...@@ -80,6 +80,7 @@ pub fn free(sdk: WindowsSdk, gpa: Allocator) void {
80fn iterateAndFilterByVersion(80fn iterateAndFilterByVersion(
81 iterator: *Dir.Iterator,81 iterator: *Dir.Iterator,
82 gpa: Allocator,82 gpa: Allocator,
83 io: Io,
83 prefix: []const u8,84 prefix: []const u8,
84) error{OutOfMemory}![][]const u8 {85) error{OutOfMemory}![][]const u8 {
85 const Version = struct {86 const Version = struct {
...@@ -104,7 +105,7 @@ fn iterateAndFilterByVersion(...@@ -104,7 +105,7 @@ fn iterateAndFilterByVersion(
104 dirs.deinit();105 dirs.deinit();
105 }106 }
106107
107 iterate: while (iterator.next() catch null) |entry| {108 iterate: while (iterator.next(io) catch null) |entry| {
108 if (entry.kind != .directory) continue;109 if (entry.kind != .directory) continue;
109 if (!std.mem.startsWith(u8, entry.name, prefix)) continue;110 if (!std.mem.startsWith(u8, entry.name, prefix)) continue;
110111
...@@ -420,13 +421,14 @@ pub const Installation = struct {...@@ -420,13 +421,14 @@ pub const Installation = struct {
420 /// Caller owns the result's fields.421 /// Caller owns the result's fields.
421 fn find(422 fn find(
422 gpa: Allocator,423 gpa: Allocator,
424 io: Io,
423 roots_key: RegistryWtf8,425 roots_key: RegistryWtf8,
424 roots_subkey: []const u8,426 roots_subkey: []const u8,
425 prefix: []const u8,427 prefix: []const u8,
426 version_key_name: []const u8,428 version_key_name: []const u8,
427 ) error{ OutOfMemory, InstallationNotFound, PathTooLong, VersionTooLong }!Installation {429 ) error{ OutOfMemory, InstallationNotFound, PathTooLong, VersionTooLong }!Installation {
428 roots: {430 roots: {
429 const installation = findFromRoot(gpa, roots_key, roots_subkey, prefix) catch431 const installation = findFromRoot(gpa, io, roots_key, roots_subkey, prefix) catch
430 break :roots;432 break :roots;
431 if (installation.isValidVersion()) return installation;433 if (installation.isValidVersion()) return installation;
432 installation.free(gpa);434 installation.free(gpa);
...@@ -485,7 +487,7 @@ pub const Installation = struct {...@@ -485,7 +487,7 @@ pub const Installation = struct {
485 defer sdk_lib_dir.close(io);487 defer sdk_lib_dir.close(io);
486488
487 var iterator = sdk_lib_dir.iterate();489 var iterator = sdk_lib_dir.iterate();
488 const versions = try iterateAndFilterByVersion(&iterator, gpa, prefix);490 const versions = try iterateAndFilterByVersion(&iterator, gpa, io, prefix);
489 if (versions.len == 0) return error.InstallationNotFound;491 if (versions.len == 0) return error.InstallationNotFound;
490 defer {492 defer {
491 for (versions[1..]) |version| gpa.free(version);493 for (versions[1..]) |version| gpa.free(version);
...@@ -673,7 +675,7 @@ const MsvcLibDir = struct {...@@ -673,7 +675,7 @@ const MsvcLibDir = struct {
673 // First, try getting the packages cache path from the registry.675 // First, try getting the packages cache path from the registry.
674 // This only seems to exist when the path is different from the default.676 // This only seems to exist when the path is different from the default.
675 method1: {677 method1: {
676 return findInstancesDirViaSetup(gpa) catch |err| switch (err) {678 return findInstancesDirViaSetup(gpa, io) catch |err| switch (err) {
677 error.OutOfMemory => |e| return e,679 error.OutOfMemory => |e| return e,
678 error.PathNotFound => break :method1,680 error.PathNotFound => break :method1,
679 };681 };
...@@ -766,7 +768,7 @@ const MsvcLibDir = struct {...@@ -766,7 +768,7 @@ const MsvcLibDir = struct {
766768
767 var latest_version: u64 = 0;769 var latest_version: u64 = 0;
768 var instances_dir_it = instances_dir.iterateAssumeFirstIteration();770 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| {
770 if (entry.kind != .directory) continue;772 if (entry.kind != .directory) continue;
771773
772 var writer: Writer = .fixed(&state_subpath_buf);774 var writer: Writer = .fixed(&state_subpath_buf);
...@@ -828,7 +830,7 @@ const MsvcLibDir = struct {...@@ -828,7 +830,7 @@ const MsvcLibDir = struct {
828830
829 try lib_dir_buf.appendSlice("VC\\Auxiliary\\Build\\Microsoft.VCToolsVersion.default.txt");831 try lib_dir_buf.appendSlice("VC\\Auxiliary\\Build\\Microsoft.VCToolsVersion.default.txt");
830 var default_tools_version_buf: [512]u8 = undefined;832 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 {
832 return error.PathNotFound;834 return error.PathNotFound;
833 };835 };
834 var tokenizer = std.mem.tokenizeAny(u8, default_tools_version_contents, " \r\n");836 var tokenizer = std.mem.tokenizeAny(u8, default_tools_version_contents, " \r\n");
...@@ -871,7 +873,7 @@ const MsvcLibDir = struct {...@@ -871,7 +873,7 @@ const MsvcLibDir = struct {
871 defer visualstudio_folder.close(io);873 defer visualstudio_folder.close(io);
872874
873 var iterator = visualstudio_folder.iterate();875 var iterator = visualstudio_folder.iterate();
874 break :vs_versions try iterateAndFilterByVersion(&iterator, gpa, "");876 break :vs_versions try iterateAndFilterByVersion(&iterator, gpa, io, "");
875 };877 };
876 defer {878 defer {
877 for (vs_versions) |vs_version| gpa.free(vs_version);879 for (vs_versions) |vs_version| gpa.free(vs_version);
src/link/Wasm.zig+1-1
...@@ -3008,7 +3008,7 @@ pub fn createEmpty(...@@ -3008,7 +3008,7 @@ pub fn createEmpty(
3008 else3008 else
3009 .default_file3009 .default_file
3010 else3010 else
3011 0,3011 .default_file,
3012 });3012 });
3013 wasm.name = emit.sub_path;3013 wasm.name = emit.sub_path;
30143014
src/main.zig+1-1
...@@ -4513,7 +4513,7 @@ fn runOrTestHotSwap(...@@ -4513,7 +4513,7 @@ fn runOrTestHotSwap(
4513 // tmp zig-cache and use it to spawn the child process. This way we are free to update4513 // tmp zig-cache and use it to spawn the child process. This way we are free to update
4514 // the binary with each requested hot update.4514 // the binary with each requested hot update.
4515 .windows => blk: {4515 .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, .{});
4517 break :blk try fs.path.join(gpa, &.{ comp.dirs.local_cache.path orelse ".", lf.emit.sub_path });4517 break :blk try fs.path.join(gpa, &.{ comp.dirs.local_cache.path orelse ".", lf.emit.sub_path });
4518 },4518 },
45194519