summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 14:30:31 -0300
committerGabriel Schneider <[email protected]>2026-11-17 14:33:52 -0300
commit3e77fdcd57693b337d915873e9919de2e1ec6521 (patch)
treeee27b9006f26f0b83c17a13dd13ceaa07824c244 /build
parent4f281f275f6e9b32b2fb5f0ebfc3e9b9338c0dce (diff)
downloadpardes-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')
-rw-r--r--build/addons.zig4
-rw-r--r--build/core.zig30
-rw-r--r--build/docs.zig64
-rw-r--r--build/library.zig4
-rw-r--r--build/mupdf.zig4
-rw-r--r--build/tests.zig2
6 files changed, 55 insertions, 53 deletions
diff --git a/build/addons.zig b/build/addons.zig
index b092b82a..195255fd 100644
--- a/build/addons.zig
+++ b/build/addons.zig
@@ -13,7 +13,7 @@ pub fn gpu(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang.O
const fail = b.addFail("the GPU addons are the window's: -Dplatform=gui (sketchbook beside this checkout)");
snake_shader_step.dependOn(&fail.step);
veil_step.dependOn(&fail.step);
- } else if (b.lazyDependency("sketchbook", .{ .@"gpu-only" = true })) |sb| {
+ } else if (b.dependencyLazy("sketchbook", .{ .@"gpu-only" = true })) |sb| {
const files = b.addWriteFiles();
for ([_][]const u8{ "vert", "frag", "post.frag" }) |stage| {
const compile = b.addSystemCommand(&.{ "glslc", "-O" });
@@ -30,7 +30,7 @@ pub fn gpu(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang.O
// The frame corpus's translucent addon (test/veil.zig), into lib/ beside the snake.
const veil = b.addLibrary(.{ .name = "veil", .linkage = .dynamic, .root_module = b.createModule(.{ .root_source_file = b.path("test/veil.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "addon", .module = addon_mod }, .{ .name = "gpu_scene", .module = sb.module("gpu_scene") } } }) });
veil_step.dependOn(&b.addInstallArtifact(veil, .{}).step);
- }
+ } else |_| {}
return snake_shader_lib;
}
diff --git a/build/core.zig b/build/core.zig
index 2a434ba9..1e2801cf 100644
--- a/build/core.zig
+++ b/build/core.zig
@@ -29,7 +29,7 @@ const deps_text = blk: {
/// A file read while configuring, under a package's root. A dependency's is
/// hash-addressed and never changes under the same pin; this repo's are not
/// tracked one by one, since the configure runs again on every build anyway
-/// (findProgram and gitCommit poison its cache).
+/// (build.zig poisons its cache).
// ponytail: untracked repo reads; b.dependOnFileContents each one if the configure cache ever stays pure.
pub fn configureRead(b: *std.Build, io: std.Io, root: std.Build.Cache.Path, sub: []const u8, limit: usize) ![]u8 {
return root.root_dir.handle.readFileAlloc(io, b.pathJoin(&.{ root.subPathOrDot(), sub }), b.allocator, .limited(limit));
@@ -50,8 +50,10 @@ pub fn jjChange(b: *std.Build) ?[]const u8 {
/// files the configure cache can track, so the cache is poisoned.
pub fn command(b: *std.Build, argv: []const []const u8) ?[]const u8 {
b.graph.poisonCache();
- var code: u8 = 0;
- const out = b.runAllowFail(argv, &code, .ignore) catch return null;
+ const out = switch (b.runFallible(argv, .{ .stderr_behavior = .ignore })) {
+ .success => |stdout| stdout,
+ else => return null,
+ };
const trimmed = std.mem.trim(u8, out, " \t\r\n");
return if (trimmed.len == 0) null else trimmed;
}
@@ -102,7 +104,7 @@ fn vendoredThemes(b: *std.Build, io: std.Io) []const []const u8 {
var it = dir.iterate();
while (it.next(io) catch @panic("read vendor/themes")) |e| {
if (!std.mem.endsWith(u8, e.name, ".toml") and !std.mem.endsWith(u8, e.name, ".json")) continue;
- names.append(b.allocator, b.dupe(e.name)) catch @panic("OOM");
+ names.append(b.allocator, b.graph.dupeString(e.name)) catch @panic("OOM");
}
std.mem.sort([]const u8, names.items, {}, struct {
fn lt(_: void, a: []const u8, c: []const u8) bool {
@@ -164,7 +166,7 @@ pub fn treeSitter(b: *std.Build, io: std.Io, target: std.Build.ResolvedTarget, c
(tree_sitter_grammars == .minimal and g.tier != .full) or
(tree_sitter_grammars == .zig and g.tier == .zig))
grammar: {
- const dep = b.lazyDependency(g.dep, .{}) orelse break :grammar;
+ const dep = b.dependencyLazy(g.dep, .{}) catch break :grammar;
const upstream = configureRead(b, io, dep.builder.root, g.query, 0x100000) catch @panic("read " ++ g.name ++ " highlights");
// the patterns that colour, filtered here once and not in
// every compile, and the whole query, the filter's test's
@@ -212,17 +214,17 @@ pub fn treeSitter(b: *std.Build, io: std.Io, target: std.Build.ResolvedTarget, c
/// and vaxis share; null while it is still to be fetched.
pub fn uucodeModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) ?*std.Build.Module {
const uucode_config = b.path("uucode_config.zig");
- const uucode_tables = (b.lazyDependency("uucode", .{
+ const uucode_tables = (b.dependencyLazy("uucode", .{
.target = target,
.optimize = optimize,
.build_config_path = uucode_config,
- }) orelse return null).namedLazyPath("tables.zig");
- return (b.lazyDependency("uucode", .{
+ }) catch return null).namedLazyPath("tables.zig");
+ return (b.dependencyLazy("uucode", .{
.target = target,
.optimize = optimize,
.build_config_path = uucode_config,
.tables_path = uucode_tables,
- }) orelse return null).module("uucode");
+ }) catch return null).module("uucode");
}
/// The editor as a library (src/lib_editor.zig, docs/next-editor.md): the
@@ -419,7 +421,7 @@ pub fn assemble(b: *std.Build, c: struct {
// A dependency by path (none of these today) has no hash and is always there.
const dep = @field(zon.dependencies, name);
if (@hasField(@TypeOf(dep), "hash")) if (!std.Build.package_map.get(dep.hash).?.available) {
- _ = b.lazyDependency(name, .{});
+ _ = b.dependencyLazy(name, .{}) catch {};
};
}
const cloud9 = b.dependency("cloud9", .{ .target = target, .optimize = optimize }).module("cloud9");
@@ -446,15 +448,15 @@ pub fn assemble(b: *std.Build, c: struct {
});
// MuPDF and FreeType, lazy (build.zig's `pdf` option has why).
- const mupdf_dep = if (c.pdf) b.lazyDependency("mupdf", .{}) else null;
+ const mupdf_dep = if (c.pdf) b.dependencyLazy("mupdf", .{}) catch null else null;
// One FreeType in a binary: the gui's glyph atlas links it and MuPDF is
// built against it (see build/mupdf.zig). At c_optimize with the rest of the
// vendored C, since MuPDF rasterizes a PDF's text through it.
- const freetype_dep = if (c.pdf or c.also_gui or c.platform == .gui) b.lazyDependency("freetype", .{
+ const freetype_dep = if (c.pdf or c.also_gui or c.platform == .gui) b.dependencyLazy("freetype", .{
.target = target,
.optimize = c_optimize,
.@"enable-libpng" = false,
- }) else null;
+ }) catch null else null;
const freetype = if (freetype_dep) |d| d.artifact("freetype") else null;
// The kinds' C ABI (src/kinds/pardes_addon.h), translated once: the core's
@@ -490,7 +492,7 @@ pub fn assemble(b: *std.Build, c: struct {
var ghostty_vt_for_tests: ?*std.Build.Module = null;
const ghostty_simd = !target.result.os.tag.isDarwin() or b.graph.host.result.os.tag.isDarwin();
const ghostty_optimize: std.lang.Optimize = if (optimize == .debug) .safe else optimize;
- const ghostty_dep = b.lazyDependency("ghostty", .{ .target = target, .optimize = ghostty_optimize, .simd = ghostty_simd, .@"app-runtime" = .none, .@"emit-xcframework" = false });
+ const ghostty_dep = b.dependencyLazy("ghostty", .{ .target = target, .optimize = ghostty_optimize, .simd = ghostty_simd, .@"app-runtime" = .none, .@"emit-xcframework" = false }) catch null;
if (ghostty_dep) |dep| {
const ghostty_vt = dep.module("ghostty-vt");
ghostty_vt_for_tests = ghostty_vt;
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);
}
diff --git a/build/library.zig b/build/library.zig
index 7d924fab..049b4323 100644
--- a/build/library.zig
+++ b/build/library.zig
@@ -35,8 +35,8 @@ pub fn build(b: *std.Build) void {
// then. Of vaxis it takes the grapheme width, which uucode alone feeds.
if (!(b.option(bool, "editor", "also export `pardes-editor`, the text pane as a library (fetches uucode, mvzr and vaxis)") orelse false)) return;
const uucode = core.uucodeModule(b, target, optimize) orelse return;
- const mvzr = patches.mvzr(b, patches.tool(b), b.lazyDependency("mvzr", .{ .target = target, .optimize = optimize }) orelse return, target, optimize);
- const vaxis_dep = b.lazyDependency("vaxis", .{ .target = target, .optimize = optimize, .external_uucode = true }) orelse return;
+ const mvzr = patches.mvzr(b, patches.tool(b), b.dependencyLazy("mvzr", .{ .target = target, .optimize = optimize }) catch return, target, optimize);
+ const vaxis_dep = b.dependencyLazy("vaxis", .{ .target = target, .optimize = optimize, .external_uucode = true }) catch return;
const width = b.addWriteFiles();
_ = width.addCopyFile(vaxis_dep.path("src/gwidth.zig"), "gwidth.zig");
const vaxis = b.createModule(.{
diff --git a/build/mupdf.zig b/build/mupdf.zig
index 48dca46b..8ade36a5 100644
--- a/build/mupdf.zig
+++ b/build/mupdf.zig
@@ -242,7 +242,7 @@ pub fn addProbe(b: *std.Build, result: Result, options: struct {
.name = "pardes-mupdf-probe",
.root_module = b.createModule(.{
.target = options.target,
- .optimize = .ReleaseSafe,
+ .optimize = .safe,
.link_libc = true,
}),
});
@@ -350,7 +350,7 @@ fn makeSources(b: *std.Build, makelists: []const u8, variable: []const u8) []con
if (!std.mem.startsWith(u8, assignment, "+=")) continue;
const path = std.mem.trim(u8, assignment[2..], " \t\r");
if (!std.mem.endsWith(u8, path, ".c")) continue;
- files[file_i] = b.dupe(path);
+ files[file_i] = b.graph.dupeString(path);
file_i += 1;
}
return files;
diff --git a/build/tests.zig b/build/tests.zig
index 5417c54a..d8bce18d 100644
--- a/build/tests.zig
+++ b/build/tests.zig
@@ -191,7 +191,7 @@ pub fn add(b: *std.Build, c: struct {
_ = units.add(b, units.root(b, "src/fonts.zig", true, cloud9), null);
_ = units.add(b, units.root(b, "src/c_heap.zig", false, cloud9), null);
// Its lookup goes wrong only where the optimizer folds it.
- _ = units.add(b, b.addTest(.{ .root_module = b.createModule(.{ .target = c.target, .optimize = .ReleaseSafe, .root_source_file = b.path("src/c_heap.zig"), .link_libc = false, .imports = cloud9 }), .filters = c.test_filters }), null);
+ _ = units.add(b, b.addTest(.{ .root_module = b.createModule(.{ .target = c.target, .optimize = .safe, .root_source_file = b.path("src/c_heap.zig"), .link_libc = false, .imports = cloud9 }), .filters = c.test_filters }), null);
_ = units.add(b, units.root(b, "test/deck/replay.zig", null, &.{.{ .name = "deck", .module = b.createModule(.{ .target = c.target, .optimize = c.optimize, .root_source_file = b.path("src/gui/deck.zig") }) }}), null);