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:
61
build.zig
61
build.zig
@ -15,6 +15,7 @@ const LibtoolStep = @import("src/build/LibtoolStep.zig");
|
|||||||
const LipoStep = @import("src/build/LipoStep.zig");
|
const LipoStep = @import("src/build/LipoStep.zig");
|
||||||
const XCFrameworkStep = @import("src/build/XCFrameworkStep.zig");
|
const XCFrameworkStep = @import("src/build/XCFrameworkStep.zig");
|
||||||
const Version = @import("src/build/Version.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
|
// 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,
|
// 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(
|
const emit_docs = b.option(
|
||||||
bool,
|
bool,
|
||||||
"emit-docs",
|
"emit-docs",
|
||||||
"Build and install auto-generated documentation",
|
"Build and install auto-generated documentation (requires pandoc)",
|
||||||
) orelse true;
|
) 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(
|
const emit_test_exe = b.option(
|
||||||
bool,
|
bool,
|
||||||
@ -1178,16 +1185,14 @@ fn buildDocumentation(
|
|||||||
},
|
},
|
||||||
.target = b.host,
|
.target = b.host,
|
||||||
});
|
});
|
||||||
|
addHelp(b, generate_markdown);
|
||||||
const generate_markdown_step = b.addRunArtifact(generate_markdown);
|
|
||||||
|
|
||||||
const markdown_output = generate_markdown_step.captureStdOut();
|
|
||||||
|
|
||||||
const generate_markdown_options = b.addOptions();
|
const generate_markdown_options = b.addOptions();
|
||||||
generate_markdown_options.addOption(std.SemanticVersion, "version", version);
|
generate_markdown_options.addOption(std.SemanticVersion, "version", version);
|
||||||
generate_markdown.root_module.addOptions("build_options", generate_markdown_options);
|
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(
|
b.getInstallStep().dependOn(&b.addInstallFile(
|
||||||
markdown_output,
|
markdown_output,
|
||||||
@ -1195,42 +1200,32 @@ fn buildDocumentation(
|
|||||||
).step);
|
).step);
|
||||||
|
|
||||||
const generate_html = b.addSystemCommand(&.{"pandoc"});
|
const generate_html = b.addSystemCommand(&.{"pandoc"});
|
||||||
generate_html.step.dependOn(&generate_markdown_step.step);
|
generate_html.addArgs(&.{
|
||||||
generate_html.addArgs(
|
"--standalone",
|
||||||
&.{
|
"--from",
|
||||||
"--standalone",
|
"markdown",
|
||||||
"--from",
|
"--to",
|
||||||
"markdown",
|
"html",
|
||||||
"--to",
|
});
|
||||||
"html",
|
|
||||||
},
|
|
||||||
);
|
|
||||||
generate_html.addFileArg(markdown_output);
|
generate_html.addFileArg(markdown_output);
|
||||||
|
|
||||||
const html_output = generate_html.captureStdOut();
|
|
||||||
|
|
||||||
b.getInstallStep().dependOn(&b.addInstallFile(
|
b.getInstallStep().dependOn(&b.addInstallFile(
|
||||||
html_output,
|
generate_html.captureStdOut(),
|
||||||
"share/ghostty/doc/" ++ manpage.name ++ "." ++ manpage.section ++ ".html",
|
"share/ghostty/doc/" ++ manpage.name ++ "." ++ manpage.section ++ ".html",
|
||||||
).step);
|
).step);
|
||||||
|
|
||||||
const generate_manpage = b.addSystemCommand(&.{"pandoc"});
|
const generate_manpage = b.addSystemCommand(&.{"pandoc"});
|
||||||
generate_manpage.step.dependOn(&generate_markdown_step.step);
|
generate_manpage.addArgs(&.{
|
||||||
generate_manpage.addArgs(
|
"--standalone",
|
||||||
&.{
|
"--from",
|
||||||
"--standalone",
|
"markdown",
|
||||||
"--from",
|
"--to",
|
||||||
"markdown",
|
"man",
|
||||||
"--to",
|
});
|
||||||
"man",
|
|
||||||
},
|
|
||||||
);
|
|
||||||
generate_manpage.addFileArg(markdown_output);
|
generate_manpage.addFileArg(markdown_output);
|
||||||
|
|
||||||
const manpage_output = generate_manpage.captureStdOut();
|
|
||||||
|
|
||||||
b.getInstallStep().dependOn(&b.addInstallFile(
|
b.getInstallStep().dependOn(&b.addInstallFile(
|
||||||
manpage_output,
|
generate_manpage.captureStdOut(),
|
||||||
"share/man/man" ++ manpage.section ++ "/" ++ manpage.name ++ "." ++ manpage.section,
|
"share/man/man" ++ manpage.section ++ "/" ++ manpage.name ++ "." ++ manpage.section,
|
||||||
).step);
|
).step);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user