From 90c6c212f361841d57da1deadf758da684aced11 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 23 Jul 2023 21:13:58 -0700 Subject: [PATCH] std.Build.Step.Compile: getEmittedDocs API enhancements * Allow calling it multiple times. * Rename it. Sorry, this is to coincide with #16353. --- build.zig | 2 +- lib/std/Build/Step/Compile.zig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index da93831aefd6..1a129babc684 100644 --- a/build.zig +++ b/build.zig @@ -61,7 +61,7 @@ pub fn build(b: *std.Build) !void { autodoc_test.overrideZigLibDir("lib"); autodoc_test.emit_bin = .no_emit; // https://github.com/ziglang/zig/issues/16351 const install_std_docs = b.addInstallDirectory(.{ - .source_dir = autodoc_test.getOutputDocs(), + .source_dir = autodoc_test.getEmittedDocs(), .install_dir = .prefix, .install_subdir = "doc/std", }); diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig index 233afa4cc9b4..5eae4677d938 100644 --- a/lib/std/Build/Step/Compile.zig +++ b/lib/std/Build/Step/Compile.zig @@ -1004,8 +1004,8 @@ pub fn getOutputPdbSource(self: *Compile) FileSource { return .{ .generated = &self.output_pdb_path_source }; } -pub fn getOutputDocs(self: *Compile) FileSource { - assert(self.generated_docs == null); // This function may only be called once. +pub fn getEmittedDocs(self: *Compile) FileSource { + if (self.generated_docs) |g| return .{ .generated = g }; const arena = self.step.owner.allocator; const generated_file = arena.create(GeneratedFile) catch @panic("OOM"); generated_file.* = .{ .step = &self.step };