authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-04 23:16:42-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:18-07:00
logf5613a0e3589fcca51411ce379f3c90eace99fa6
tree32300af5524638edd0534d6755551bc3956f3c26
parent8d5da5558827d9152dc8453c87c41ac6519f8a05

update docgen for std Target.Query API breaks


1 files changed, 13 insertions(+), 12 deletions(-)

tools/docgen.zig+13-12
...@@ -9,13 +9,12 @@ const print = std.debug.print;...@@ -9,13 +9,12 @@ const print = std.debug.print;
9const mem = std.mem;9const mem = std.mem;
10const testing = std.testing;10const testing = std.testing;
11const Allocator = std.mem.Allocator;11const Allocator = std.mem.Allocator;
12const getExternalExecutor = std.zig.system.getExternalExecutor;
1213
13const max_doc_file_size = 10 * 1024 * 1024;14const max_doc_file_size = 10 * 1024 * 1024;
1415
15const exe_ext = @as(std.zig.CrossTarget, .{}).exeFileExt();
16const obj_ext = builtin.object_format.fileExt(builtin.cpu.arch);16const obj_ext = builtin.object_format.fileExt(builtin.cpu.arch);
17const tmp_dir_name = "docgen_tmp";17const tmp_dir_name = "docgen_tmp";
18const test_out_path = tmp_dir_name ++ fs.path.sep_str ++ "test" ++ exe_ext;
1918
20const usage =19const usage =
21 \\Usage: docgen [--zig] [--skip-code-tests] input output"20 \\Usage: docgen [--zig] [--skip-code-tests] input output"
...@@ -1309,7 +1308,7 @@ fn genHtml(...@@ -1309,7 +1308,7 @@ fn genHtml(
1309 var env_map = try process.getEnvMap(allocator);1308 var env_map = try process.getEnvMap(allocator);
1310 try env_map.put("YES_COLOR", "1");1309 try env_map.put("YES_COLOR", "1");
13111310
1312 const host = try std.zig.system.NativeTargetInfo.detect(.{});1311 const host = try std.zig.system.resolveTargetQuery(.{});
1313 const builtin_code = try getBuiltinCode(allocator, &env_map, zig_exe, opt_zig_lib_dir);1312 const builtin_code = try getBuiltinCode(allocator, &env_map, zig_exe, opt_zig_lib_dir);
13141313
1315 for (toc.nodes) |node| {1314 for (toc.nodes) |node| {
...@@ -1424,9 +1423,7 @@ fn genHtml(...@@ -1424,9 +1423,7 @@ fn genHtml(
1424 try build_args.append("-lc");1423 try build_args.append("-lc");
1425 try shell_out.print("-lc ", .{});1424 try shell_out.print("-lc ", .{});
1426 }1425 }
1427 const target = try std.zig.CrossTarget.parse(.{1426
1428 .arch_os_abi = code.target_str orelse "native",
1429 });
1430 if (code.target_str) |triple| {1427 if (code.target_str) |triple| {
1431 try build_args.appendSlice(&[_][]const u8{ "-target", triple });1428 try build_args.appendSlice(&[_][]const u8{ "-target", triple });
1432 try shell_out.print("-target {s} ", .{triple});1429 try shell_out.print("-target {s} ", .{triple});
...@@ -1490,9 +1487,13 @@ fn genHtml(...@@ -1490,9 +1487,13 @@ fn genHtml(
1490 }1487 }
1491 }1488 }
14921489
1490 const target_query = try std.Target.Query.parse(.{
1491 .arch_os_abi = code.target_str orelse "native",
1492 });
1493 const target = try std.zig.system.resolveTargetQuery(target_query);
1494
1493 const path_to_exe = try std.fmt.allocPrint(allocator, "./{s}{s}", .{1495 const path_to_exe = try std.fmt.allocPrint(allocator, "./{s}{s}", .{
1494 code.name,1496 code.name, target.exeFileExt(),
1495 target.exeFileExt(),
1496 });1497 });
1497 const run_args = &[_][]const u8{path_to_exe};1498 const run_args = &[_][]const u8{path_to_exe};
14981499
...@@ -1565,13 +1566,13 @@ fn genHtml(...@@ -1565,13 +1566,13 @@ fn genHtml(
1565 try test_args.appendSlice(&[_][]const u8{ "-target", triple });1566 try test_args.appendSlice(&[_][]const u8{ "-target", triple });
1566 try shell_out.print("-target {s} ", .{triple});1567 try shell_out.print("-target {s} ", .{triple});
15671568
1568 const cross_target = try std.zig.CrossTarget.parse(.{1569 const target_query = try std.Target.Query.parse(.{
1569 .arch_os_abi = triple,1570 .arch_os_abi = triple,
1570 });1571 });
1571 const target_info = try std.zig.system.NativeTargetInfo.detect(1572 const target = try std.zig.system.resolveTargetQuery(
1572 cross_target,1573 target_query,
1573 );1574 );
1574 switch (host.getExternalExecutor(&target_info, .{1575 switch (getExternalExecutor(host, &target, .{
1575 .link_libc = code.link_libc,1576 .link_libc = code.link_libc,
1576 })) {1577 })) {
1577 .native => {},1578 .native => {},