update docgen for std Target.Query API breaks

This commit is contained in:
Andrew Kelley 2023-12-04 23:16:42 -07:00
parent 8d5da55588
commit f5613a0e35

View File

@ -9,13 +9,12 @@ const print = std.debug.print;
const mem = std.mem; const mem = std.mem;
const testing = std.testing; const testing = std.testing;
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const getExternalExecutor = std.zig.system.getExternalExecutor;
const max_doc_file_size = 10 * 1024 * 1024; const max_doc_file_size = 10 * 1024 * 1024;
const exe_ext = @as(std.zig.CrossTarget, .{}).exeFileExt();
const obj_ext = builtin.object_format.fileExt(builtin.cpu.arch); const obj_ext = builtin.object_format.fileExt(builtin.cpu.arch);
const tmp_dir_name = "docgen_tmp"; const tmp_dir_name = "docgen_tmp";
const test_out_path = tmp_dir_name ++ fs.path.sep_str ++ "test" ++ exe_ext;
const usage = const usage =
\\Usage: docgen [--zig] [--skip-code-tests] input output" \\Usage: docgen [--zig] [--skip-code-tests] input output"
@ -1309,7 +1308,7 @@ fn genHtml(
var env_map = try process.getEnvMap(allocator); var env_map = try process.getEnvMap(allocator);
try env_map.put("YES_COLOR", "1"); try env_map.put("YES_COLOR", "1");
const host = try std.zig.system.NativeTargetInfo.detect(.{}); const host = try std.zig.system.resolveTargetQuery(.{});
const builtin_code = try getBuiltinCode(allocator, &env_map, zig_exe, opt_zig_lib_dir); const builtin_code = try getBuiltinCode(allocator, &env_map, zig_exe, opt_zig_lib_dir);
for (toc.nodes) |node| { for (toc.nodes) |node| {
@ -1424,9 +1423,7 @@ fn genHtml(
try build_args.append("-lc"); try build_args.append("-lc");
try shell_out.print("-lc ", .{}); try shell_out.print("-lc ", .{});
} }
const target = try std.zig.CrossTarget.parse(.{
.arch_os_abi = code.target_str orelse "native",
});
if (code.target_str) |triple| { if (code.target_str) |triple| {
try build_args.appendSlice(&[_][]const u8{ "-target", triple }); try build_args.appendSlice(&[_][]const u8{ "-target", triple });
try shell_out.print("-target {s} ", .{triple}); try shell_out.print("-target {s} ", .{triple});
@ -1490,9 +1487,13 @@ fn genHtml(
} }
} }
const target_query = try std.Target.Query.parse(.{
.arch_os_abi = code.target_str orelse "native",
});
const target = try std.zig.system.resolveTargetQuery(target_query);
const path_to_exe = try std.fmt.allocPrint(allocator, "./{s}{s}", .{ const path_to_exe = try std.fmt.allocPrint(allocator, "./{s}{s}", .{
code.name, code.name, target.exeFileExt(),
target.exeFileExt(),
}); });
const run_args = &[_][]const u8{path_to_exe}; const run_args = &[_][]const u8{path_to_exe};
@ -1565,13 +1566,13 @@ fn genHtml(
try test_args.appendSlice(&[_][]const u8{ "-target", triple }); try test_args.appendSlice(&[_][]const u8{ "-target", triple });
try shell_out.print("-target {s} ", .{triple}); try shell_out.print("-target {s} ", .{triple});
const cross_target = try std.zig.CrossTarget.parse(.{ const target_query = try std.Target.Query.parse(.{
.arch_os_abi = triple, .arch_os_abi = triple,
}); });
const target_info = try std.zig.system.NativeTargetInfo.detect( const target = try std.zig.system.resolveTargetQuery(
cross_target, target_query,
); );
switch (host.getExternalExecutor(&target_info, .{ switch (getExternalExecutor(host, &target, .{
.link_libc = code.link_libc, .link_libc = code.link_libc,
})) { })) {
.native => {}, .native => {},