summaryrefslogtreecommitdiff
path: root/build/tools.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 13:35:31 -0300
committerGabriel Schneider <[email protected]>2026-11-17 13:45:32 -0300
commit7a1c66f1a15911763db42d890e9e8172fe404170 (patch)
tree2604fc13399b96b091af1350bc6b78d6e0a9f89a /build/tools.zig
parente5c57a863004914136c4e6b0fa13ed805b3b383d (diff)
downloadpardes-7a1c66f1a15911763db42d890e9e8172fe404170.tar.gz
pardes-7a1c66f1a15911763db42d890e9e8172fe404170.zip
build: the core named once (core.module), the window's pieces made once
build/core.zig's module() makes every core: the shell, the core, the core without the terminal (core-test), pardes-isolate, the static, the bare build's window, the syntax module's (syntax-test) and the 9P test roots; each import and library a core takes is written there once, in the order the fold over core_mods and wireCore gave them, so every compile keeps its inputs. Parts holds what a core is made of, Core the few ways the products differ. Tracy's client and BSD libutil stay where they were (Tracy: the shell and the core; libutil: the shell), now said by a field. Gone: the core_mods fold and its buffers, wireCore and its eleven optional fields, the 9P roots' copies of core_module's import table and link objects. The editor library's and pardes-syntax's import lists are written out in full (editorModule, library.zig); TreeSitter.wire adds the grammars; ShellConfig has defaults, so the library's two literals are one. build/gui.zig's make() builds SDL, gui_c, sketchbook's renderer, HarfBuzz and the renderer's and atlas's tests once, and Window.wire links them into each window shell. One pardes-lspmock (tests and process-test shared it twice from one root); tools.program() makes the eleven uniform runner programs in a line each. The pdf benches (tools.pdfBenches) are made once the core is. Gates: zig build -l and -h byte-identical to the base over the matrix (bare, tui, gui, macos, ReleaseFast, -Dpdf=false, -Dtree-sitter=minimal, musl, -Dtracy), test/lib's configuration byte-identical. Warm rebuild of install addons and core-test shell-test unit-test process-test on the base's cache: tui every compile cached (0 rebuilt), 2339/2486 tests passed with the base's 4 known failures, the same counts as the base; gui one change: SDL3 had -DSDL_DISABLE_STB=1 added once per window shell (twice with -Dplatform=gui), now once, so libSDL3.a's cache path moves and pardes-gui and the shell-test root relink (their argv differ in that one path, nothing else); tests 2398/2545, as the base. Installed bin/pardes, image.so and pdf.so cmp-identical on tui; image.so and pdf.so identical on gui, pardes-gui differs by the relinked SDL3 (size 398,737,210 -> 398,733,114). zig build syntax-test, which did not compile on main, now compiles and passes (40/40). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build/tools.zig')
-rw-r--r--build/tools.zig170
1 files changed, 46 insertions, 124 deletions
diff --git a/build/tools.zig b/build/tools.zig
index 0819401c..4393e088 100644
--- a/build/tools.zig
+++ b/build/tools.zig
@@ -6,6 +6,12 @@ const TreeSitterGrammars = @import("../build.zig").TreeSitterGrammars;
const core = @import("core.zig");
const testMatch = @import("tests.zig").testMatch;
+/// A program of this build's, from `root`, with libc and `imports`: the
+/// harnesses, benches and runners below and in tests.zig.
+pub fn program(b: *std.Build, name: []const u8, root: []const u8, target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, imports: []const std.Build.Module.Import) *std.Build.Step.Compile {
+ return b.addExecutable(.{ .name = name, .root_module = b.createModule(.{ .target = target, .optimize = optimize, .root_source_file = b.path(root), .link_libc = true, .imports = imports }) });
+}
+
/// What unit-test runs of what these make.
pub const Tools = struct {
perf_gate_step: *std.Build.Step,
@@ -17,7 +23,6 @@ pub const Tools = struct {
/// The harnesses, the helix comparisons, the benches and the perf gate, the
/// syntax snapshots and their tests, the library's package test and history.
pub fn add(b: *std.Build, c: struct {
- c_heap_mod: *std.Build.Module,
c_optimize: std.lang.Optimize,
core_module: *std.Build.Module,
enable_jpx: bool,
@@ -26,36 +31,22 @@ pub fn add(b: *std.Build, c: struct {
ghostty_simd: bool,
ghostty_vt_for_tests: ?*std.Build.Module,
image_addon: *std.Build.Step.Compile,
- mvzr_mod: *std.Build.Module,
+ /// core-test's core: the syntax module's tests run on it.
+ lean: core.Core,
no_pdf: ?*std.Build.Step,
optimize: std.lang.Optimize,
- opts: *std.Build.Step.Options,
+ parts: core.Parts,
pdf_addon: ?*std.Build.Step.Compile,
platform: Platform,
prebuilt_shaders: bool,
shell_cfg: core.ShellConfig,
target: std.Build.ResolvedTarget,
- term_mod: *std.Build.Module,
test_filters: []const []const u8,
- themes_mod: *std.Build.Module,
tracy: ?[]const u8,
tree_sitter_grammars: TreeSitterGrammars,
- ts_libs: std.ArrayList(*std.Build.Step.Compile),
- ts_mod: ?*std.Build.Module,
- ts_queries_opts: ?*std.Build.Step.Options,
unit_profile: *std.Build.Step.Compile,
- uucode_mod: *std.Build.Module,
- vaxis_mod: *std.Build.Module,
}) Tools {
- const image_harness = b.addExecutable(.{
- .name = "pardes-image-harness",
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/image_harness.zig"),
- .link_libc = true,
- }),
- });
+ const image_harness = program(b, "pardes-image-harness", "test/image_harness.zig", c.target, c.optimize, &.{});
if (c.ghostty_vt_for_tests) |vt| image_harness.root_module.addImport("ghostty-vt", vt);
switch (c.target.result.os.tag) {
.freebsd, .netbsd, .openbsd => image_harness.root_module.linkSystemLibrary("util", .{}),
@@ -72,24 +63,8 @@ pub fn add(b: *std.Build, c: struct {
// the pane's bash (and kitten icat, chafa when installed), a kitty
// terminal outside (tui) or the GPU capture (gui). test/kitty.zig
// is the same protocol at the core.
- const kitty_client = b.addExecutable(.{
- .name = "pardes-kitty-client",
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/kitty_client.zig"),
- .link_libc = true,
- }),
- });
- const kitty_harness = b.addExecutable(.{
- .name = "pardes-kitty-harness",
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/kitty_harness.zig"),
- .link_libc = true,
- }),
- });
+ const kitty_client = program(b, "pardes-kitty-client", "test/kitty_client.zig", c.target, c.optimize, &.{});
+ const kitty_harness = program(b, "pardes-kitty-harness", "test/kitty_harness.zig", c.target, c.optimize, &.{});
if (c.ghostty_vt_for_tests) |vt| kitty_harness.root_module.addImport("ghostty-vt", vt);
switch (c.target.result.os.tag) {
.freebsd, .netbsd, .openbsd => kitty_harness.root_module.linkSystemLibrary("util", .{}),
@@ -114,16 +89,7 @@ pub fn add(b: *std.Build, c: struct {
pdf_harness_step.dependOn(&run_pdf_harness.step);
}
- const hxdiff = b.addExecutable(.{
- .name = "pardes-hxdiff",
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/hxdiff.zig"),
- .link_libc = true,
- }),
- });
- hxdiff.root_module.addImport("pardes", c.core_module);
+ const hxdiff = program(b, "pardes-hxdiff", "test/hxdiff.zig", c.target, c.optimize, &.{.{ .name = "pardes", .module = c.core_module }});
const run_hxdiff = b.addRunArtifact(hxdiff);
run_hxdiff.has_side_effects = true;
// Bare, it runs the checked-in suite (test/hxdiff.zig); `-- --parity`
@@ -145,24 +111,8 @@ pub fn add(b: *std.Build, c: struct {
// types them into an editor value and prints its results, which
// hxdiff holds against helix's goldens, or with `-- --parity`
// against the file pane, so the library cannot drift from either.
- const hxlib = b.addExecutable(.{
- .name = "pardes-hxlib",
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/hxlib.zig"),
- .link_libc = true,
- }),
- });
- hxlib.root_module.addImport("pardes-editor", core.editorModule(b, null, c.target, c.optimize, c.shell_cfg, .{
- .themes = c.themes_mod,
- .tree_sitter = c.ts_mod,
- .ts_libs = c.ts_libs.items,
- .ts_queries = c.ts_queries_opts,
- .uucode = c.uucode_mod,
- .mvzr = c.mvzr_mod,
- .vaxis = c.vaxis_mod,
- }));
+ const hxlib = program(b, "pardes-hxlib", "test/hxlib.zig", c.target, c.optimize, &.{});
+ hxlib.root_module.addImport("pardes-editor", core.editorModule(b, null, c.target, c.optimize, c.shell_cfg, .{ .themes = c.parts.themes, .ts = c.parts.ts, .uucode = c.parts.uucode, .mvzr = c.parts.mvzr, .vaxis = c.parts.vaxis }));
const run_hxlib = b.addRunArtifact(hxlib);
run_hxlib.addArgs(&.{ "test/hxcases/cases.jsonl", "test/hxcases/parity.jsonl" });
run_hxlib.setCwd(b.path("."));
@@ -199,16 +149,7 @@ pub fn add(b: *std.Build, c: struct {
run_hxgolf.setCwd(b.path("."));
b.step("hxgolf", "compare the helix-golf examples against their Helix results").dependOn(&run_hxgolf.step);
- const lspbench = b.addExecutable(.{
- .name = "pardes-lspbench",
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = .fast,
- .root_source_file = b.path("test/lspbench.zig"),
- .link_libc = true,
- }),
- });
- lspbench.root_module.addImport("pardes", c.core_module);
+ const lspbench = program(b, "pardes-lspbench", "test/lspbench.zig", c.target, .fast, &.{.{ .name = "pardes", .module = c.core_module }});
const run_lspbench = b.addRunArtifact(lspbench);
run_lspbench.addPassthruArgs();
run_lspbench.setCwd(b.path("."));
@@ -216,21 +157,12 @@ pub fn add(b: *std.Build, c: struct {
const lspbench_step = b.step("lspbench", "language-backend latency + feature matrix (-- [--json] [--check] [repo-root]), or one query (-- probe <kind> <file> <line>:<col> [arg] [--reps N])");
lspbench_step.dependOn(&run_lspbench.step);
- const rollback_bench = b.addExecutable(.{
- .name = "pardes-rollback-bench",
- .root_module = b.createModule(.{ .target = c.target, .optimize = c.optimize, .root_source_file = b.path("test/rollback_bench.zig"), .link_libc = true }),
- });
- rollback_bench.root_module.addImport("pardes", c.core_module);
+ const rollback_bench = program(b, "pardes-rollback-bench", "test/rollback_bench.zig", c.target, c.optimize, &.{.{ .name = "pardes", .module = c.core_module }});
const run_rollback_bench = b.addRunArtifact(rollback_bench);
run_rollback_bench.has_side_effects = true;
b.step("rollback-bench", "a replica's rollback copy (walked state, pinned blobs, walk time) for a typical and a big session, and a fork of the big one (-Doptimize=ReleaseFast)").dependOn(&run_rollback_bench.step);
- const replicas = b.addExecutable(.{
- .name = "pardes-replicas",
- .root_module = b.createModule(.{ .target = c.target, .optimize = c.optimize, .root_source_file = b.path("test/replicas.zig"), .link_libc = true }),
- });
- replicas.root_module.addImport("pardes", c.core_module);
- replicas.root_module.addImport("term", c.term_mod);
+ const replicas = program(b, "pardes-replicas", "test/replicas.zig", c.target, c.optimize, &.{ .{ .name = "pardes", .module = c.core_module }, .{ .name = "term", .module = c.parts.term } });
const run_replicas = b.addRunArtifact(replicas);
run_replicas.addPassthruArgs();
run_replicas.has_side_effects = true;
@@ -275,16 +207,7 @@ pub fn add(b: *std.Build, c: struct {
perf_options.addOptionPath("image_addon", c.image_addon.getEmittedBin());
perf_options.addOption(bool, "has_pdf_addon", c.pdf_addon != null);
if (c.pdf_addon) |l| perf_options.addOptionPath("pdf_addon", l.getEmittedBin());
- const perf = b.addExecutable(.{
- .name = "pardes-perf",
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = perf_optimize,
- .root_source_file = b.path("test/perf.zig"),
- .link_libc = true,
- }),
- });
- perf.root_module.addImport("pardes", c.core_module);
+ const perf = program(b, "pardes-perf", "test/perf.zig", c.target, perf_optimize, &.{.{ .name = "pardes", .module = c.core_module }});
// --live drives the real binary through a pty (test/e2e_harness.zig).
if (c.ghostty_vt_for_tests) |vt| perf.root_module.addImport("ghostty-vt", vt);
perf.root_module.addOptions("perf_options", perf_options);
@@ -317,16 +240,7 @@ pub fn add(b: *std.Build, c: struct {
});
perf_tests.root_module.addOptions("perf_options", perf_options);
- const fs_bench = b.addExecutable(.{
- .name = "pardes-fs-bench",
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = .fast,
- .root_source_file = b.path("test/fs_bench.zig"),
- .link_libc = true,
- }),
- });
- fs_bench.root_module.addImport("pardes", c.core_module);
+ const fs_bench = program(b, "pardes-fs-bench", "test/fs_bench.zig", c.target, .fast, &.{.{ .name = "pardes", .module = c.core_module }});
const run_fs_bench = b.addRunArtifact(fs_bench);
run_fs_bench.has_side_effects = true;
run_fs_bench.addPassthruArgs();
@@ -342,24 +256,12 @@ pub fn add(b: *std.Build, c: struct {
.filters = c.test_filters,
});
- const syntax_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("src/syntax.zig"),
- .link_libc = true,
- });
- syntax_module.addOptions("pardes_config", c.opts);
- core.wireCore(syntax_module, .{ .tree_sitter = c.ts_mod, .ts_libs = c.ts_libs.items, .ts_queries = c.ts_queries_opts, .c_heap = c.c_heap_mod });
- const syntax_runner = b.addExecutable(.{
- .name = "pardes-syntax",
- .root_module = b.createModule(.{
- .target = c.target,
- .optimize = c.optimize,
- .root_source_file = b.path("test/syntax.zig"),
- .link_libc = true,
- }),
- });
- syntax_runner.root_module.addImport("syntax", syntax_module);
+ // The syntax module's own tests and snapshots, on the core without
+ // a terminal: its tests reach the editor's modes (modal.zig).
+ var syntax_cfg = c.lean;
+ syntax_cfg.root = "src/syntax.zig";
+ const syntax_module = core.module(b, c.parts, syntax_cfg);
+ const syntax_runner = program(b, "pardes-syntax", "test/syntax.zig", c.target, c.optimize, &.{.{ .name = "syntax", .module = syntax_module }});
const run_syntax = b.addRunArtifact(syntax_runner);
run_syntax.addPassthruArgs();
run_syntax.has_side_effects = true;
@@ -397,3 +299,23 @@ pub fn add(b: *std.Build, c: struct {
b.step("history", "compare command output and test/build runtime across jj revisions").dependOn(&run_history.step);
return .{ .perf_gate_step = perf_gate_step, .perf_tests = perf_tests, .fs_bench_test = fs_bench_test, .lib_test_step = lib_test_step };
}
+
+/// The PDF benches: the core over the pdf addon, a pane of it.
+pub fn pdfBenches(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, core_module: *std.Build.Module, lib: *std.Build.Step.Compile, pointer_step: *std.Build.Step, scroll_step: *std.Build.Step) void {
+ const config = b.addOptions();
+ config.addOption(bool, "release_fast_core", optimize == .fast);
+ config.addOption([]const u8, "core_optimize", @tagName(optimize));
+ config.addOptionPath("pdf_addon", lib.getEmittedBin());
+ for ([_]struct { step: *std.Build.Step, exe: []const u8, file: []const u8, optimize: std.lang.Optimize }{
+ .{ .step = pointer_step, .exe = "pardes-pdf-pointer-bench", .file = "test/pdf_pointer_bench.zig", .optimize = .fast },
+ .{ .step = scroll_step, .exe = "pardes-pdf-scroll-bench", .file = "test/pdf_scroll_bench.zig", .optimize = optimize },
+ }) |bench| {
+ const exe = b.addExecutable(.{ .name = bench.exe, .root_module = b.createModule(.{ .target = target, .optimize = bench.optimize, .root_source_file = b.path(bench.file), .link_libc = true }) });
+ exe.root_module.addImport("pardes", core_module);
+ exe.root_module.addOptions("pdf_bench_config", config);
+ const run = b.addRunArtifact(exe);
+ run.addPassthruArgs();
+ run.setCwd(b.path("."));
+ bench.step.dependOn(&run.step);
+ }
+}