| ... | ... | @@ -343,7 +343,9 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 343 | 343 | return cmdInit(gpa, arena, cmd_args); |
| 344 | 344 | } else if (mem.eql(u8, cmd, "targets")) { |
| 345 | 345 | dev.check(.targets_command); |
| 346 | | return @import("print_targets.zig").cmdTargets(arena, cmd_args); |
| 346 | const host = std.zig.resolveTargetQueryOrFatal(.{}); |
| 347 | const stdout = fs.File.stdout().deprecatedWriter(); |
| 348 | return @import("print_targets.zig").cmdTargets(arena, cmd_args, stdout, &host); |
| 347 | 349 | } else if (mem.eql(u8, cmd, "version")) { |
| 348 | 350 | dev.check(.version_command); |
| 349 | 351 | try fs.File.stdout().writeAll(build_options.version ++ "\n"); |
| ... | ... | @@ -4548,7 +4550,7 @@ fn cmdTranslateC( |
| 4548 | 4550 | error.SemanticAnalyzeFail => break :f .{ .error_bundle = errors }, |
| 4549 | 4551 | }; |
| 4550 | 4552 | defer tree.deinit(comp.gpa); |
| 4551 | | break :f .{ .success = try tree.render(arena) }; |
| 4553 | break :f .{ .success = try tree.renderAlloc(arena) }; |
| 4552 | 4554 | }, |
| 4553 | 4555 | }; |
| 4554 | 4556 | |
| ... | ... | @@ -5684,7 +5686,7 @@ const ArgIteratorResponseFile = process.ArgIteratorGeneral(.{ .comments = true, |
| 5684 | 5686 | /// Initialize the arguments from a Response File. "*.rsp" |
| 5685 | 5687 | fn initArgIteratorResponseFile(allocator: Allocator, resp_file_path: []const u8) !ArgIteratorResponseFile { |
| 5686 | 5688 | const max_bytes = 10 * 1024 * 1024; // 10 MiB of command line arguments is a reasonable limit |
| 5687 | | const cmd_line = try fs.cwd().readFileAlloc(resp_file_path, allocator, .limited(max_bytes)); |
| 5689 | const cmd_line = try fs.cwd().readFileAlloc(allocator, resp_file_path, max_bytes); |
| 5688 | 5690 | errdefer allocator.free(cmd_line); |
| 5689 | 5691 | |
| 5690 | 5692 | return ArgIteratorResponseFile.initTakeOwnership(allocator, cmd_line); |
| ... | ... | @@ -6056,7 +6058,8 @@ fn cmdAstCheck( |
| 6056 | 6058 | }; |
| 6057 | 6059 | } else fs.File.stdin(); |
| 6058 | 6060 | defer if (zig_source_path != null) f.close(); |
| 6059 | | break :s std.zig.readSourceFileToEndAlloc(arena, f, null) catch |err| { |
| 6061 | var file_reader: fs.File.Reader = f.reader(&stdio_buffer); |
| 6062 | break :s std.zig.readSourceFileToEndAlloc(arena, &file_reader) catch |err| { |
| 6060 | 6063 | fatal("unable to load file '{s}' for ast-check: {s}", .{ display_path, @errorName(err) }); |
| 6061 | 6064 | }; |
| 6062 | 6065 | }; |
| ... | ... | @@ -6413,14 +6416,16 @@ fn cmdChangelist( |
| 6413 | 6416 | var f = fs.cwd().openFile(old_source_path, .{}) catch |err| |
| 6414 | 6417 | fatal("unable to open old source file '{s}': {s}", .{ old_source_path, @errorName(err) }); |
| 6415 | 6418 | defer f.close(); |
| 6416 | | break :source std.zig.readSourceFileToEndAlloc(arena, f, std.zig.max_src_size) catch |err| |
| 6419 | var file_reader: fs.File.Reader = f.reader(&stdio_buffer); |
| 6420 | break :source std.zig.readSourceFileToEndAlloc(arena, &file_reader) catch |err| |
| 6417 | 6421 | fatal("unable to read old source file '{s}': {s}", .{ old_source_path, @errorName(err) }); |
| 6418 | 6422 | }; |
| 6419 | 6423 | const new_source = source: { |
| 6420 | 6424 | var f = fs.cwd().openFile(new_source_path, .{}) catch |err| |
| 6421 | 6425 | fatal("unable to open new source file '{s}': {s}", .{ new_source_path, @errorName(err) }); |
| 6422 | 6426 | defer f.close(); |
| 6423 | | break :source std.zig.readSourceFileToEndAlloc(arena, f, std.zig.max_src_size) catch |err| |
| 6427 | var file_reader: fs.File.Reader = f.reader(&stdio_buffer); |
| 6428 | break :source std.zig.readSourceFileToEndAlloc(arena, &file_reader) catch |err| |
| 6424 | 6429 | fatal("unable to read new source file '{s}': {s}", .{ new_source_path, @errorName(err) }); |
| 6425 | 6430 | }; |
| 6426 | 6431 | |
| ... | ... | @@ -6943,7 +6948,7 @@ fn cmdFetch( |
| 6943 | 6948 | ast.deinit(gpa); |
| 6944 | 6949 | } |
| 6945 | 6950 | |
| 6946 | | var fixups: Ast.Fixups = .{}; |
| 6951 | var fixups: Ast.Render.Fixups = .{}; |
| 6947 | 6952 | defer fixups.deinit(gpa); |
| 6948 | 6953 | |
| 6949 | 6954 | var saved_path_or_url = path_or_url; |
| ... | ... | @@ -7044,15 +7049,15 @@ fn cmdFetch( |
| 7044 | 7049 | try fixups.append_string_after_node.put(gpa, manifest.version_node, dependencies_text); |
| 7045 | 7050 | } |
| 7046 | 7051 | |
| 7047 | | var file = build_root.directory.handle.createFile(Package.Manifest.basename, .{}) catch |err| { |
| 7048 | | fatal("unable to create {s} file: {s}", .{ Package.Manifest.basename, err }); |
| 7052 | var aw: std.Io.Writer.Allocating = .init(gpa); |
| 7053 | defer aw.deinit(); |
| 7054 | try ast.render(gpa, &aw.writer, fixups); |
| 7055 | const rendered = aw.getWritten(); |
| 7056 | |
| 7057 | build_root.directory.handle.writeFile(.{ .sub_path = Package.Manifest.basename, .data = rendered }) catch |err| { |
| 7058 | fatal("unable to write {s} file: {t}", .{ Package.Manifest.basename, err }); |
| 7049 | 7059 | }; |
| 7050 | | defer file.close(); |
| 7051 | | var stdout_bw = fs.File.stdout().writer().buffered(&stdio_buffer); |
| 7052 | | ast.render(gpa, &stdout_bw, fixups) catch |err| fatal("failed to render AST to {s}: {s}", .{ |
| 7053 | | Package.Manifest.basename, err, |
| 7054 | | }); |
| 7055 | | stdout_bw.flush() catch |err| fatal("failed to flush {s}: {s}", .{ Package.Manifest.basename, err }); |
| 7060 | |
| 7056 | 7061 | return cleanExit(); |
| 7057 | 7062 | } |
| 7058 | 7063 | |
| ... | ... | @@ -7205,9 +7210,9 @@ fn loadManifest( |
| 7205 | 7210 | ) !struct { Package.Manifest, Ast } { |
| 7206 | 7211 | const manifest_bytes = while (true) { |
| 7207 | 7212 | break options.dir.readFileAllocOptions( |
| 7208 | | Package.Manifest.basename, |
| 7209 | 7213 | arena, |
| 7210 | | .limited(Package.Manifest.max_bytes), |
| 7214 | Package.Manifest.basename, |
| 7215 | Package.Manifest.max_bytes, |
| 7211 | 7216 | null, |
| 7212 | 7217 | .@"1", |
| 7213 | 7218 | 0, |
| ... | ... | @@ -7284,7 +7289,7 @@ const Templates = struct { |
| 7284 | 7289 | } |
| 7285 | 7290 | |
| 7286 | 7291 | const max_bytes = 10 * 1024 * 1024; |
| 7287 | | const contents = templates.dir.readFileAlloc(template_path, arena, .limited(max_bytes)) catch |err| { |
| 7292 | const contents = templates.dir.readFileAlloc(arena, template_path, max_bytes) catch |err| { |
| 7288 | 7293 | fatal("unable to read template file '{s}': {s}", .{ template_path, @errorName(err) }); |
| 7289 | 7294 | }; |
| 7290 | 7295 | templates.buffer.clearRetainingCapacity(); |