authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-23 14:02:58-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-23 19:16:33-07:00
log8199428beb1be2c59fc1da535372f5f7170f72b7
tree0dd67795b4b18cc6d856657e8d294cdf31589715
parentc57749f5cefd26d79d97a5a00ec07ab1a7b70505

Compilation: fix autodocs CLI

6e4fff6ba62ae3e61a948c98fa8fea7e35732cc0 regressed the direct CLI interface of -femit-docs. This commit fixes it and also hooks up to the progress bar.

1 files changed, 27 insertions(+), 10 deletions(-)

src/Compilation.zig+27-10
...@@ -2153,16 +2153,9 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2153,16 +2153,9 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2153 try comp.flush(main_progress_node);2153 try comp.flush(main_progress_node);
2154 if (comp.totalErrorCount() != 0) return;2154 if (comp.totalErrorCount() != 0) return;
21552155
2156 // TODO: do this in a separate job during performAllTheWork(). The2156 // Note the placement of this logic is relying on the call to
2157 // file copies at the end of generate() can also be extracted to2157 // `wholeCacheModeSetBinFilePath` above.
2158 // separate jobs2158 try maybeGenerateAutodocs(comp, main_progress_node);
2159 if (!build_options.only_c and !build_options.only_core_functionality) {
2160 if (comp.bin_file.options.docs_emit) |emit| {
2161 var dir = try emit.directory.handle.makeOpenPath(emit.sub_path, .{});
2162 defer dir.close();
2163 try Autodoc.generate(module, dir);
2164 }
2165 }
2166 } else {2159 } else {
2167 try comp.flush(main_progress_node);2160 try comp.flush(main_progress_node);
2168 if (comp.totalErrorCount() != 0) return;2161 if (comp.totalErrorCount() != 0) return;
...@@ -2177,6 +2170,10 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2177,6 +2170,10 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2177 comp.bin_file.lock = man.toOwnedLock();2170 comp.bin_file.lock = man.toOwnedLock();
2178 } else {2171 } else {
2179 try comp.flush(main_progress_node);2172 try comp.flush(main_progress_node);
2173
2174 if (comp.totalErrorCount() == 0) {
2175 try maybeGenerateAutodocs(comp, main_progress_node);
2176 }
2180 }2177 }
21812178
2182 // Unload all source files to save memory.2179 // Unload all source files to save memory.
...@@ -2193,6 +2190,26 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2193,6 +2190,26 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2193 }2190 }
2194}2191}
21952192
2193fn maybeGenerateAutodocs(comp: *Compilation, prog_node: *std.Progress.Node) !void {
2194 const mod = comp.bin_file.options.module orelse return;
2195 // TODO: do this in a separate job during performAllTheWork(). The
2196 // file copies at the end of generate() can also be extracted to
2197 // separate jobs
2198 if (!build_options.only_c and !build_options.only_core_functionality) {
2199 if (comp.bin_file.options.docs_emit) |emit| {
2200 var dir = try emit.directory.handle.makeOpenPath(emit.sub_path, .{});
2201 defer dir.close();
2202
2203 var sub_prog_node = prog_node.start("Generating documentation", 0);
2204 sub_prog_node.activate();
2205 sub_prog_node.context.refresh();
2206 defer sub_prog_node.end();
2207
2208 try Autodoc.generate(mod, dir);
2209 }
2210 }
2211}
2212
2196fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {2213fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {
2197 // This is needed before reading the error flags.2214 // This is needed before reading the error flags.
2198 comp.bin_file.flush(comp, prog_node) catch |err| switch (err) {2215 comp.bin_file.flush(comp, prog_node) catch |err| switch (err) {