| ... | ... | @@ -319,7 +319,7 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 319 | 319 | .root_src_path = "objcopy.zig", |
| 320 | 320 | }); |
| 321 | 321 | } else if (mem.eql(u8, cmd, "fetch")) { |
| 322 | | return cmdFetch(gpa, arena, cmd_args); |
| 322 | return cmdFetch(gpa, arena, io, cmd_args); |
| 323 | 323 | } else if (mem.eql(u8, cmd, "libc")) { |
| 324 | 324 | return jitCmd(gpa, arena, io, cmd_args, .{ |
| 325 | 325 | .cmd_name = "libc", |
| ... | ... | @@ -348,12 +348,14 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 348 | 348 | return; |
| 349 | 349 | } else if (mem.eql(u8, cmd, "env")) { |
| 350 | 350 | dev.check(.env_command); |
| 351 | const host = std.zig.resolveTargetQueryOrFatal(io, .{}); |
| 351 | 352 | var stdout_writer = fs.File.stdout().writer(&stdout_buffer); |
| 352 | 353 | try @import("print_env.zig").cmdEnv( |
| 353 | 354 | arena, |
| 354 | 355 | &stdout_writer.interface, |
| 355 | 356 | args, |
| 356 | 357 | if (native_os == .wasi) wasi_preopens, |
| 358 | &host, |
| 357 | 359 | ); |
| 358 | 360 | return stdout_writer.interface.flush(); |
| 359 | 361 | } else if (mem.eql(u8, cmd, "reduce")) { |
| ... | ... | @@ -368,11 +370,11 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 368 | 370 | dev.check(.help_command); |
| 369 | 371 | return fs.File.stdout().writeAll(usage); |
| 370 | 372 | } else if (mem.eql(u8, cmd, "ast-check")) { |
| 371 | | return cmdAstCheck(arena, cmd_args); |
| 373 | return cmdAstCheck(arena, io, cmd_args); |
| 372 | 374 | } else if (mem.eql(u8, cmd, "detect-cpu")) { |
| 373 | 375 | return cmdDetectCpu(io, cmd_args); |
| 374 | 376 | } else if (build_options.enable_debug_extensions and mem.eql(u8, cmd, "changelist")) { |
| 375 | | return cmdChangelist(arena, cmd_args); |
| 377 | return cmdChangelist(arena, io, cmd_args); |
| 376 | 378 | } else if (build_options.enable_debug_extensions and mem.eql(u8, cmd, "dump-zir")) { |
| 377 | 379 | return cmdDumpZir(arena, cmd_args); |
| 378 | 380 | } else if (build_options.enable_debug_extensions and mem.eql(u8, cmd, "llvm-ints")) { |
| ... | ... | @@ -741,7 +743,7 @@ const ArgMode = union(enum) { |
| 741 | 743 | const Listen = union(enum) { |
| 742 | 744 | none, |
| 743 | 745 | stdio: if (dev.env.supports(.stdio_listen)) void else noreturn, |
| 744 | | ip4: if (dev.env.supports(.network_listen)) std.net.Ip4Address else noreturn, |
| 746 | ip4: if (dev.env.supports(.network_listen)) Io.net.Ip4Address else noreturn, |
| 745 | 747 | }; |
| 746 | 748 | |
| 747 | 749 | const ArgsIterator = struct { |
| ... | ... | @@ -1335,7 +1337,7 @@ fn buildOutputType( |
| 1335 | 1337 | const host, const port_text = mem.cutScalar(u8, next_arg, ':') orelse .{ next_arg, "14735" }; |
| 1336 | 1338 | const port = std.fmt.parseInt(u16, port_text, 10) catch |err| |
| 1337 | 1339 | fatal("invalid port number: '{s}': {s}", .{ port_text, @errorName(err) }); |
| 1338 | | listen = .{ .ip4 = std.net.Ip4Address.parse(host, port) catch |err| |
| 1340 | listen = .{ .ip4 = Io.net.Ip4Address.parse(host, port) catch |err| |
| 1339 | 1341 | fatal("invalid host: '{s}': {s}", .{ host, @errorName(err) }) }; |
| 1340 | 1342 | } |
| 1341 | 1343 | } else if (mem.eql(u8, arg, "--listen=-")) { |
| ... | ... | @@ -3318,7 +3320,7 @@ fn buildOutputType( |
| 3318 | 3320 | var file_writer = f.writer(&.{}); |
| 3319 | 3321 | var buffer: [1000]u8 = undefined; |
| 3320 | 3322 | var hasher = file_writer.interface.hashed(Cache.Hasher.init("0123456789abcdef"), &buffer); |
| 3321 | | var stdin_reader = fs.File.stdin().readerStreaming(&.{}); |
| 3323 | var stdin_reader = fs.File.stdin().readerStreaming(io, &.{}); |
| 3322 | 3324 | _ = hasher.writer.sendFileAll(&stdin_reader, .unlimited) catch |err| switch (err) { |
| 3323 | 3325 | error.WriteFailed => fatal("failed to write {s}: {t}", .{ dump_path, file_writer.err.? }), |
| 3324 | 3326 | else => fatal("failed to pipe stdin to {s}: {t}", .{ dump_path, err }), |
| ... | ... | @@ -3549,7 +3551,7 @@ fn buildOutputType( |
| 3549 | 3551 | switch (listen) { |
| 3550 | 3552 | .none => {}, |
| 3551 | 3553 | .stdio => { |
| 3552 | | var stdin_reader = fs.File.stdin().reader(&stdin_buffer); |
| 3554 | var stdin_reader = fs.File.stdin().reader(io, &stdin_buffer); |
| 3553 | 3555 | var stdout_writer = fs.File.stdout().writer(&stdout_buffer); |
| 3554 | 3556 | try serve( |
| 3555 | 3557 | io, |
| ... | ... | @@ -3565,23 +3567,23 @@ fn buildOutputType( |
| 3565 | 3567 | return cleanExit(); |
| 3566 | 3568 | }, |
| 3567 | 3569 | .ip4 => |ip4_addr| { |
| 3568 | | const addr: std.net.Address = .{ .in = ip4_addr }; |
| 3570 | const addr: Io.net.IpAddress = .{ .ip4 = ip4_addr }; |
| 3569 | 3571 | |
| 3570 | | var server = try addr.listen(.{ |
| 3572 | var server = try addr.listen(io, .{ |
| 3571 | 3573 | .reuse_address = true, |
| 3572 | 3574 | }); |
| 3573 | | defer server.deinit(); |
| 3575 | defer server.deinit(io); |
| 3574 | 3576 | |
| 3575 | | const conn = try server.accept(); |
| 3576 | | defer conn.stream.close(); |
| 3577 | var stream = try server.accept(io); |
| 3578 | defer stream.close(io); |
| 3577 | 3579 | |
| 3578 | | var input = conn.stream.reader(&stdin_buffer); |
| 3579 | | var output = conn.stream.writer(&stdout_buffer); |
| 3580 | var input = stream.reader(io, &stdin_buffer); |
| 3581 | var output = stream.writer(io, &stdout_buffer); |
| 3580 | 3582 | |
| 3581 | 3583 | try serve( |
| 3582 | 3584 | io, |
| 3583 | 3585 | comp, |
| 3584 | | input.interface(), |
| 3586 | &input.interface, |
| 3585 | 3587 | &output.interface, |
| 3586 | 3588 | test_exec_args.items, |
| 3587 | 3589 | self_exe_path, |
| ... | ... | @@ -5062,7 +5064,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) |
| 5062 | 5064 | var http_client: if (dev.env.supports(.fetch_command)) std.http.Client else struct { |
| 5063 | 5065 | allocator: Allocator, |
| 5064 | 5066 | fn deinit(_: @This()) void {} |
| 5065 | | } = .{ .allocator = gpa }; |
| 5067 | } = .{ .allocator = gpa, .io = io }; |
| 5066 | 5068 | defer http_client.deinit(); |
| 5067 | 5069 | |
| 5068 | 5070 | var unlazy_set: Package.Fetch.JobQueue.UnlazySet = .{}; |
| ... | ... | @@ -5600,7 +5602,7 @@ fn jitCmd( |
| 5600 | 5602 | try child.spawn(); |
| 5601 | 5603 | |
| 5602 | 5604 | if (options.capture) |ptr| { |
| 5603 | | var stdout_reader = child.stdout.?.readerStreaming(&.{}); |
| 5605 | var stdout_reader = child.stdout.?.readerStreaming(io, &.{}); |
| 5604 | 5606 | ptr.* = try stdout_reader.interface.allocRemaining(arena, .limited(std.math.maxInt(u32))); |
| 5605 | 5607 | } |
| 5606 | 5608 | |
| ... | ... | @@ -6055,10 +6057,7 @@ const usage_ast_check = |
| 6055 | 6057 | \\ |
| 6056 | 6058 | ; |
| 6057 | 6059 | |
| 6058 | | fn cmdAstCheck( |
| 6059 | | arena: Allocator, |
| 6060 | | args: []const []const u8, |
| 6061 | | ) !void { |
| 6060 | fn cmdAstCheck(arena: Allocator, io: Io, args: []const []const u8) !void { |
| 6062 | 6061 | dev.check(.ast_check_command); |
| 6063 | 6062 | |
| 6064 | 6063 | const Zir = std.zig.Zir; |
| ... | ... | @@ -6106,7 +6105,7 @@ fn cmdAstCheck( |
| 6106 | 6105 | }; |
| 6107 | 6106 | } else fs.File.stdin(); |
| 6108 | 6107 | defer if (zig_source_path != null) f.close(); |
| 6109 | | var file_reader: fs.File.Reader = f.reader(&stdin_buffer); |
| 6108 | var file_reader: fs.File.Reader = f.reader(io, &stdin_buffer); |
| 6110 | 6109 | break :s std.zig.readSourceFileToEndAlloc(arena, &file_reader) catch |err| { |
| 6111 | 6110 | fatal("unable to load file '{s}' for ast-check: {s}", .{ display_path, @errorName(err) }); |
| 6112 | 6111 | }; |
| ... | ... | @@ -6448,10 +6447,7 @@ fn cmdDumpZir( |
| 6448 | 6447 | } |
| 6449 | 6448 | |
| 6450 | 6449 | /// This is only enabled for debug builds. |
| 6451 | | fn cmdChangelist( |
| 6452 | | arena: Allocator, |
| 6453 | | args: []const []const u8, |
| 6454 | | ) !void { |
| 6450 | fn cmdChangelist(arena: Allocator, io: Io, args: []const []const u8) !void { |
| 6455 | 6451 | dev.check(.changelist_command); |
| 6456 | 6452 | |
| 6457 | 6453 | const color: Color = .auto; |
| ... | ... | @@ -6464,7 +6460,7 @@ fn cmdChangelist( |
| 6464 | 6460 | var f = fs.cwd().openFile(old_source_path, .{}) catch |err| |
| 6465 | 6461 | fatal("unable to open old source file '{s}': {s}", .{ old_source_path, @errorName(err) }); |
| 6466 | 6462 | defer f.close(); |
| 6467 | | var file_reader: fs.File.Reader = f.reader(&stdin_buffer); |
| 6463 | var file_reader: fs.File.Reader = f.reader(io, &stdin_buffer); |
| 6468 | 6464 | break :source std.zig.readSourceFileToEndAlloc(arena, &file_reader) catch |err| |
| 6469 | 6465 | fatal("unable to read old source file '{s}': {s}", .{ old_source_path, @errorName(err) }); |
| 6470 | 6466 | }; |
| ... | ... | @@ -6472,7 +6468,7 @@ fn cmdChangelist( |
| 6472 | 6468 | var f = fs.cwd().openFile(new_source_path, .{}) catch |err| |
| 6473 | 6469 | fatal("unable to open new source file '{s}': {s}", .{ new_source_path, @errorName(err) }); |
| 6474 | 6470 | defer f.close(); |
| 6475 | | var file_reader: fs.File.Reader = f.reader(&stdin_buffer); |
| 6471 | var file_reader: fs.File.Reader = f.reader(io, &stdin_buffer); |
| 6476 | 6472 | break :source std.zig.readSourceFileToEndAlloc(arena, &file_reader) catch |err| |
| 6477 | 6473 | fatal("unable to read new source file '{s}': {s}", .{ new_source_path, @errorName(err) }); |
| 6478 | 6474 | }; |
| ... | ... | @@ -6829,6 +6825,7 @@ const usage_fetch = |
| 6829 | 6825 | fn cmdFetch( |
| 6830 | 6826 | gpa: Allocator, |
| 6831 | 6827 | arena: Allocator, |
| 6828 | io: Io, |
| 6832 | 6829 | args: []const []const u8, |
| 6833 | 6830 | ) !void { |
| 6834 | 6831 | dev.check(.fetch_command); |
| ... | ... | @@ -6884,7 +6881,7 @@ fn cmdFetch( |
| 6884 | 6881 | try thread_pool.init(.{ .allocator = gpa }); |
| 6885 | 6882 | defer thread_pool.deinit(); |
| 6886 | 6883 | |
| 6887 | | var http_client: std.http.Client = .{ .allocator = gpa }; |
| 6884 | var http_client: std.http.Client = .{ .allocator = gpa, .io = io }; |
| 6888 | 6885 | defer http_client.deinit(); |
| 6889 | 6886 | |
| 6890 | 6887 | try http_client.initDefaultProxies(arena); |