Skip to content

Commit

Permalink
update docgen for std Target.Query API breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Dec 5, 2023
1 parent a3c93e1 commit 11f86d4
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tools/docgen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ const print = std.debug.print;
const mem = std.mem;
const testing = std.testing;
const Allocator = std.mem.Allocator;
const getExternalExecutor = std.zig.system.getExternalExecutor;

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 tmp_dir_name = "docgen_tmp";
const test_out_path = tmp_dir_name ++ fs.path.sep_str ++ "test" ++ exe_ext;

const usage =
\\Usage: docgen [--zig] [--skip-code-tests] input output"
Expand Down Expand Up @@ -1309,7 +1308,7 @@ fn genHtml(
var env_map = try process.getEnvMap(allocator);
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);

for (toc.nodes) |node| {
Expand Down Expand Up @@ -1424,9 +1423,7 @@ fn genHtml(
try build_args.append("-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| {
try build_args.appendSlice(&[_][]const u8{ "-target", triple });
try shell_out.print("-target {s} ", .{triple});
Expand Down Expand Up @@ -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}", .{
code.name,
target.exeFileExt(),
code.name, target.exeFileExt(),
});
const run_args = &[_][]const u8{path_to_exe};

Expand Down Expand Up @@ -1565,13 +1566,13 @@ fn genHtml(
try test_args.appendSlice(&[_][]const u8{ "-target", 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,
});
const target_info = try std.zig.system.NativeTargetInfo.detect(
cross_target,
const target = try std.zig.system.resolveTargetQuery(
target_query,
);
switch (host.getExternalExecutor(&target_info, .{
switch (getExternalExecutor(host, &target, .{
.link_libc = code.link_libc,
})) {
.native => {},
Expand Down

0 comments on commit 11f86d4

Please sign in to comment.