mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
build: only default emit-docs to true if pandoc is on PATH
This commit is contained in:
41
build.zig
41
build.zig
@ -15,6 +15,7 @@ const LibtoolStep = @import("src/build/LibtoolStep.zig");
|
||||
const LipoStep = @import("src/build/LipoStep.zig");
|
||||
const XCFrameworkStep = @import("src/build/XCFrameworkStep.zig");
|
||||
const Version = @import("src/build/Version.zig");
|
||||
const Command = @import("src/Command.zig");
|
||||
|
||||
// Do a comptime Zig version requirement. The required Zig version is
|
||||
// somewhat arbitrary: it is meant to be a version that we feel works well,
|
||||
@ -105,8 +106,14 @@ pub fn build(b: *std.Build) !void {
|
||||
const emit_docs = b.option(
|
||||
bool,
|
||||
"emit-docs",
|
||||
"Build and install auto-generated documentation",
|
||||
) orelse true;
|
||||
"Build and install auto-generated documentation (requires pandoc)",
|
||||
) orelse emit_docs: {
|
||||
// We only default to true if we can find pandoc.
|
||||
const path = Command.expandPath(b.allocator, "pandoc") catch
|
||||
break :emit_docs false;
|
||||
defer if (path) |p| b.allocator.free(p);
|
||||
break :emit_docs path != null;
|
||||
};
|
||||
|
||||
const emit_test_exe = b.option(
|
||||
bool,
|
||||
@ -1178,16 +1185,14 @@ fn buildDocumentation(
|
||||
},
|
||||
.target = b.host,
|
||||
});
|
||||
|
||||
const generate_markdown_step = b.addRunArtifact(generate_markdown);
|
||||
|
||||
const markdown_output = generate_markdown_step.captureStdOut();
|
||||
addHelp(b, generate_markdown);
|
||||
|
||||
const generate_markdown_options = b.addOptions();
|
||||
generate_markdown_options.addOption(std.SemanticVersion, "version", version);
|
||||
generate_markdown.root_module.addOptions("build_options", generate_markdown_options);
|
||||
|
||||
addHelp(b, generate_markdown);
|
||||
const generate_markdown_step = b.addRunArtifact(generate_markdown);
|
||||
const markdown_output = generate_markdown_step.captureStdOut();
|
||||
|
||||
b.getInstallStep().dependOn(&b.addInstallFile(
|
||||
markdown_output,
|
||||
@ -1195,42 +1200,32 @@ fn buildDocumentation(
|
||||
).step);
|
||||
|
||||
const generate_html = b.addSystemCommand(&.{"pandoc"});
|
||||
generate_html.step.dependOn(&generate_markdown_step.step);
|
||||
generate_html.addArgs(
|
||||
&.{
|
||||
generate_html.addArgs(&.{
|
||||
"--standalone",
|
||||
"--from",
|
||||
"markdown",
|
||||
"--to",
|
||||
"html",
|
||||
},
|
||||
);
|
||||
});
|
||||
generate_html.addFileArg(markdown_output);
|
||||
|
||||
const html_output = generate_html.captureStdOut();
|
||||
|
||||
b.getInstallStep().dependOn(&b.addInstallFile(
|
||||
html_output,
|
||||
generate_html.captureStdOut(),
|
||||
"share/ghostty/doc/" ++ manpage.name ++ "." ++ manpage.section ++ ".html",
|
||||
).step);
|
||||
|
||||
const generate_manpage = b.addSystemCommand(&.{"pandoc"});
|
||||
generate_manpage.step.dependOn(&generate_markdown_step.step);
|
||||
generate_manpage.addArgs(
|
||||
&.{
|
||||
generate_manpage.addArgs(&.{
|
||||
"--standalone",
|
||||
"--from",
|
||||
"markdown",
|
||||
"--to",
|
||||
"man",
|
||||
},
|
||||
);
|
||||
});
|
||||
generate_manpage.addFileArg(markdown_output);
|
||||
|
||||
const manpage_output = generate_manpage.captureStdOut();
|
||||
|
||||
b.getInstallStep().dependOn(&b.addInstallFile(
|
||||
manpage_output,
|
||||
generate_manpage.captureStdOut(),
|
||||
"share/man/man" ++ manpage.section ++ "/" ++ manpage.name ++ "." ++ manpage.section,
|
||||
).step);
|
||||
}
|
||||
|
Reference in New Issue
Block a user