build.zig: update docgen to modern build system API

it still writes the output to zig-cache/langref.html but now it does
that explicitly as a legacy step with the intention of having that
removed in the future. It also outputs the langref to the install
prefix.
This commit is contained in:
Andrew Kelley 2023-03-09 22:04:09 -07:00
parent f829f848dd
commit 857296a9f4

View File

@ -40,19 +40,22 @@ pub fn build(b: *std.Build) !void {
}); });
docgen_exe.single_threaded = single_threaded; docgen_exe.single_threaded = single_threaded;
const langref_out_path = try b.cache_root.join(b.allocator, &.{"langref.html"}); const docgen_cmd = b.addRunArtifact(docgen_exe);
const docgen_cmd = docgen_exe.run(); docgen_cmd.addArgs(&.{ "--zig", b.zig_exe });
docgen_cmd.addArgs(&[_][]const u8{ docgen_cmd.addFileSourceArg(.{ .path = "doc/langref.html.in" });
"--zig", const langref_file = docgen_cmd.addOutputFileArg("langref.html");
b.zig_exe, const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "langref.html");
"doc" ++ fs.path.sep_str ++ "langref.html.in", b.getInstallStep().dependOn(&install_langref.step);
langref_out_path,
});
docgen_cmd.step.dependOn(&docgen_exe.step);
const docs_step = b.step("docs", "Build documentation"); const docs_step = b.step("docs", "Build documentation");
docs_step.dependOn(&docgen_cmd.step); docs_step.dependOn(&docgen_cmd.step);
// This is for legacy reasons, to be removed after our CI scripts are upgraded to use
// the file from the install prefix instead.
const legacy_write_to_cache = b.addWriteFiles();
legacy_write_to_cache.addCopyFileToSource(langref_file, "zig-cache/langref.html");
docs_step.dependOn(&legacy_write_to_cache.step);
const check_case_exe = b.addExecutable(.{ const check_case_exe = b.addExecutable(.{
.name = "check-case", .name = "check-case",
.root_source_file = .{ .path = "test/src/Cases.zig" }, .root_source_file = .{ .path = "test/src/Cases.zig" },