diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 14:30:31 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 14:33:52 -0300 |
| commit | 3e77fdcd57693b337d915873e9919de2e1ec6521 (patch) | |
| tree | ee27b9006f26f0b83c17a13dd13ceaa07824c244 /build/docs.zig | |
| parent | 4f281f275f6e9b32b2fb5f0ebfc3e9b9338c0dce (diff) | |
| download | pardes-3e77fdcd57693b337d915873e9919de2e1ec6521.tar.gz pardes-3e77fdcd57693b337d915873e9919de2e1ec6521.zip | |
build: typst found at make time; the deprecated build names replaced
docs.add takes typst through b.findProgramLazy: the three renders run
the program found at make time, and without typst on PATH the step that
renders fails ("program not found") where three addFail steps and the
optional renders said so before. findProgram was the configure cache's
poison; build() now poisons it itself, with the reason (the environment,
the clock and vendor/ are read untracked: REORG decision 20 keeps the
configure uncached). Line for a line: lazyDependency -> dependencyLazy
(catch for orelse), runAllowFail -> runFallible, b.dupe ->
b.graph.dupeString, .ReleaseSafe -> .safe; build.zig through zig fmt.
Left: gui.zig's three lazyDependency calls (lines 62-176, which another
change rewrites) and std.Build.package_map (no line-for-line
replacement: dependencyLazy's error would have to reach build()).
Gates: zig build -l and -h byte-identical, whole matrix and test/lib
(its configuration too); the configuration gains the find-program step
and the typst runs are named run typst (...) instead of by the path
found, nothing else changes; --print-configuration-path still a tmp/
path, twice; zig build cheatsheet writes cheatsheet.pdf, and with PATH
holding zig alone fails "program not found" while -l succeeds. Warm:
install addons, core-test shell-test unit-test process-test on tui, and
install addons on gui: 0 compiles not cached, binaries cmp-identical.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build/docs.zig')
| -rw-r--r-- | build/docs.zig | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/build/docs.zig b/build/docs.zig index e0e3f990..b698da02 100644 --- a/build/docs.zig +++ b/build/docs.zig @@ -4,39 +4,39 @@ const Platform = @import("../build.zig").Platform; /// The docs (docs/typ, docs/site): each output is one typst run, and each /// reads docs/typ/builtins-*.json; `builtins-json` refreshes this build's from the /// registry first (the tool is wired below, once the core module is). -pub fn add(b: *std.Build) [3]?*std.Build.Step.Run { - const typst_bin: ?[]const u8 = b.findProgram(.{ .names = &.{"typst"} }); - var doc_renders: [3]?*std.Build.Step.Run = @splat(null); +pub fn add(b: *std.Build) [3]*std.Build.Step.Run { + // Looked for when a render runs: without typst on PATH, that step + // fails ("program not found") and nothing else does. + const typst = b.findProgramLazy(.{ .names = &.{"typst"} }); const cheatsheet_step = b.step("cheatsheet", "render docs/typ/cheatsheet-a4.typ to <prefix>/share/doc/pardes/cheatsheet.pdf (needs typst)"); const book_step = b.step("book", "render docs/typ/book.typ to <prefix>/share/doc/pardes/pardes.pdf (needs typst)"); // The website: one Typst bundle run writes every page, the stylesheet, // the fonts and the media (docs/site/site.typ). const site_step = b.step("site", "render the docs website to <prefix>/share/doc/pardes/site (needs typst)"); - if (typst_bin) |typst| { - // They read all of docs/typ, docs/site and the tutor, so they always - // run rather than track every file. - const sheet = b.addSystemCommand(&.{ typst, "compile", "--ignore-system-fonts" }); - sheet.addFileArg(b.path("docs/typ/cheatsheet-a4.typ")); - sheet.has_side_effects = true; - cheatsheet_step.dependOn(&b.addInstallFile(sheet.addOutputFileArg("cheatsheet.pdf"), "share/doc/pardes/cheatsheet.pdf").step); - const book = b.addSystemCommand(&.{ typst, "compile", "--ignore-system-fonts", "--root", "." }); - book.setCwd(b.path(".")); - book.addFileArg(b.path("docs/typ/book.typ")); - book.has_side_effects = true; - book_step.dependOn(&b.addInstallFile(book.addOutputFileArg("pardes.pdf"), "share/doc/pardes/pardes.pdf").step); - const site = b.addSystemCommand(&.{ typst, "compile", "--format", "bundle", "--features", "bundle,html", "--root", "." }); - site.setCwd(b.path(".")); - site.addFileArg(b.path("docs/site/site.typ")); - const site_dir = site.addOutputDirectoryArg("site"); - site.has_side_effects = true; - site_step.dependOn(&b.addInstallDirectory(.{ .source_dir = site_dir, .install_dir = .prefix, .install_subdir = "share/doc/pardes/site" }).step); - doc_renders = .{ sheet, book, site }; - } else { - cheatsheet_step.dependOn(&b.addFail("zig build cheatsheet needs typst on PATH").step); - book_step.dependOn(&b.addFail("zig build book needs typst on PATH").step); - site_step.dependOn(&b.addFail("zig build site needs typst on PATH").step); - } - return doc_renders; + // They read all of docs/typ, docs/site and the tutor, so they always + // run rather than track every file. + const sheet = std.Build.Step.Run.create(b, "run typst (cheatsheet)"); + sheet.addFileArg(typst); + sheet.addArgs(&.{ "compile", "--ignore-system-fonts" }); + sheet.addFileArg(b.path("docs/typ/cheatsheet-a4.typ")); + sheet.has_side_effects = true; + cheatsheet_step.dependOn(&b.addInstallFile(sheet.addOutputFileArg("cheatsheet.pdf"), "share/doc/pardes/cheatsheet.pdf").step); + const book = std.Build.Step.Run.create(b, "run typst (book)"); + book.addFileArg(typst); + book.addArgs(&.{ "compile", "--ignore-system-fonts", "--root", "." }); + book.setCwd(b.path(".")); + book.addFileArg(b.path("docs/typ/book.typ")); + book.has_side_effects = true; + book_step.dependOn(&b.addInstallFile(book.addOutputFileArg("pardes.pdf"), "share/doc/pardes/pardes.pdf").step); + const site = std.Build.Step.Run.create(b, "run typst (site)"); + site.addFileArg(typst); + site.addArgs(&.{ "compile", "--format", "bundle", "--features", "bundle,html", "--root", "." }); + site.setCwd(b.path(".")); + site.addFileArg(b.path("docs/site/site.typ")); + const site_dir = site.addOutputDirectoryArg("site"); + site.has_side_effects = true; + site_step.dependOn(&b.addInstallDirectory(.{ .source_dir = site_dir, .install_dir = .prefix, .install_subdir = "share/doc/pardes/site" }).step); + return .{ sheet, book, site }; } /// docs/typ/builtins-<platform>.json: every builtin, from the registry and the Help @@ -44,7 +44,7 @@ pub fn add(b: *std.Build) [3]?*std.Build.Step.Run { /// `typst compile` reads it too; a unit test fails when it is stale. /// A terminal build writes builtins-tui.json and a window build /// builtins-gui.json; style.typ merges the two into one glossary. -pub fn builtinsJson(b: *std.Build, requested_platform: ?Platform, platform: Platform, target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, core_module: *std.Build.Module, doc_renders: [3]?*std.Build.Step.Run) *std.Build.Step { +pub fn builtinsJson(b: *std.Build, requested_platform: ?Platform, platform: Platform, target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, core_module: *std.Build.Module, doc_renders: [3]*std.Build.Step.Run) *std.Build.Step { const builtins_json_step = b.step("builtins-json", "rewrite docs/typ/builtins-<tui|gui>.json from the builtin registry, and with tui docs/typ/command-line.txt from pardes help --all (-Dplatform=tui or gui)"); if (requested_platform == .tui or requested_platform == .gui) { const gen = b.addExecutable(.{ .name = "pardes-gen-builtins-json", .root_module = b.createModule(.{ @@ -59,7 +59,7 @@ pub fn builtinsJson(b: *std.Build, requested_platform: ?Platform, platform: Plat const update = b.addUpdateSourceFiles(); update.addCopyFileToSource(json, b.fmt("docs/typ/builtins-{s}.json", .{@tagName(platform)})); builtins_json_step.dependOn(&update.step); - for (doc_renders) |r| if (r) |run| run.step.dependOn(&update.step); + for (doc_renders) |run| run.step.dependOn(&update.step); } else builtins_json_step.dependOn(&b.addFail("builtins-json writes one build's list: pass -Dplatform=tui or -Dplatform=gui").step); return builtins_json_step; } @@ -69,11 +69,11 @@ pub fn builtinsJson(b: *std.Build, requested_platform: ?Platform, platform: Plat /// session's), which the reference's "The pardes command" shows; /// main.zig's test fails when it is stale. The terminal's build /// writes it, the window's prints the same. -pub fn commandLine(b: *std.Build, exe: *std.Build.Step.Compile, builtins_json_step: *std.Build.Step, doc_renders: [3]?*std.Build.Step.Run) void { +pub fn commandLine(b: *std.Build, exe: *std.Build.Step.Compile, builtins_json_step: *std.Build.Step, doc_renders: [3]*std.Build.Step.Run) void { const run_help = b.addRunArtifact(exe); run_help.addArgs(&.{ "help", "--all" }); const update = b.addUpdateSourceFiles(); update.addCopyFileToSource(run_help.captureStdOut(.{}), "docs/typ/command-line.txt"); builtins_json_step.dependOn(&update.step); - for (doc_renders) |r| if (r) |run| run.step.dependOn(&update.step); + for (doc_renders) |run| run.step.dependOn(&update.step); } |
