Skip to content

Commit 2775135

Browse files
committed
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.
1 parent 83924d7 commit 2775135

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

build.zig

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,22 @@ pub fn build(b: *std.Build) !void {
4040
});
4141
docgen_exe.single_threaded = single_threaded;
4242

43-
const langref_out_path = try b.cache_root.join(b.allocator, &.{"langref.html"});
44-
const docgen_cmd = docgen_exe.run();
45-
docgen_cmd.addArgs(&[_][]const u8{
46-
"--zig",
47-
b.zig_exe,
48-
"doc" ++ fs.path.sep_str ++ "langref.html.in",
49-
langref_out_path,
50-
});
51-
docgen_cmd.step.dependOn(&docgen_exe.step);
43+
const docgen_cmd = b.addRunArtifact(docgen_exe);
44+
docgen_cmd.addArgs(&.{ "--zig", b.zig_exe });
45+
docgen_cmd.addFileSourceArg(.{ .path = "doc/langref.html.in" });
46+
const langref_file = docgen_cmd.addOutputFileArg("langref.html");
47+
const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "langref.html");
48+
b.getInstallStep().dependOn(&install_langref.step);
5249

5350
const docs_step = b.step("docs", "Build documentation");
5451
docs_step.dependOn(&docgen_cmd.step);
5552

53+
// This is for legacy reasons, to be removed after our CI scripts are upgraded to use
54+
// the file from the install prefix instead.
55+
const legacy_write_to_cache = b.addWriteFiles();
56+
legacy_write_to_cache.addCopyFileToSource(langref_file, "zig-cache/langref.html");
57+
docs_step.dependOn(&legacy_write_to_cache.step);
58+
5659
const check_case_exe = b.addExecutable(.{
5760
.name = "check-case",
5861
.root_source_file = .{ .path = "test/src/Cases.zig" },

0 commit comments

Comments
 (0)