summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 03:44:57 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commita22b579ad2df8d1811f0e194fa1bbc06e2282cf8 (patch)
tree9dcaaa6d17c6c67048b58456dcd9dbdb74b9fc9a /build.zig
parenta3509e4df5efc94b0deee3b06dd72f85b0d96647 (diff)
downloadpardes-a22b579ad2df8d1811f0e194fa1bbc06e2282cf8.tar.gz
pardes-a22b579ad2df8d1811f0e194fa1bbc06e2282cf8.zip
term: the terminal a module of its own (docs/next-terminal.md, Phase 1): src/term/term.zig roots it, importing std, ghostty-vt, wuffs, zstbi and plain, never the core, and gives the core one table, `ops` (plain.term.Ops: about 60 entries, the records they take and give and the opaque handles State, Encoder, Track and Replica, in src/plain/term.zig), its own functions put in it through a cast refused at compile time unless each parameter and result matches the table's but for the handles and every error is one the table names; src/Term.zig, the core's side, takes `ops` from the term module when the build's term_options say the core has one (every core module but core-test's), null otherwise, and Term.State is a handle with the walk's hooks, so a dump keeps a terminal as it did (its Parts by name through walk.save, then ghostty's snapshot) and the digest is the emulator's; echo.zig comes back to the core (src/echo.zig: predicted echo is the replica's presentation, its five reads of the emulator through Term.grid, modes, prompt and Term.echoCell); screen_state's Peer is a plain record both sides name (its noteSent a function of screen_state's), its Encoder, Track and Replica handles made and freed through the table (replica.Screens makes its encoder at the first encode); a prompt's cut is told in columns and measured in its row's text by the core (Term.promptPrefix, File.rawAtDisplay); TerminalImages' decode bound moves from memory.limits to the decoder it bounds; build.zig: core_lean, the core module without the terminal, is core-test's, and wireCore no longer gives any core module ghostty-vt, wuffs or zstbi (the term module has them), so core-test's compile names none of ghostty, wuffs, zstbi, simdutf, highway or -lc++ (from --verbose); term-test runs the module's own tests (the pager's, screen_state's, the luminance table's); the tests of a terminal through a core move as they were to test/terminal.zig, in pane-test, which imports both (`of` reads the emulator behind a handle; the dump round trip frees through State.dumpFree), and tests elsewhere that read the emulator do it through Term.emulatorOf, a test in core-test skipping first; core-test skips a test whose terminal Term.open refuses; Authority.init releases its tape when the core it boots fails (it leaked); tests: core-test (no terminal) 409 of 941, 532 skipped, shell-test (the same tests with the terminal) 984 of 984, pane-test 180 of 181 (1 skipped, as before), term-test 15 of 15, kitty-test 45 of 45, replicas checked/wrong 0, hxdiff 658 cases 0 mismatches, behaviour-test 268 of 272 (the base's four addon ABI tests), lib-test
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig52
1 files changed, 39 insertions, 13 deletions
diff --git a/build.zig b/build.zig
index f59d1928..5104d0a2 100644
--- a/build.zig
+++ b/build.zig
@@ -197,6 +197,15 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("src/pardes.zig"),
.link_libc = true,
});
+ // The core without the terminal module (docs/next-terminal.md, Phase 1):
+ // what core-test is compiled from. No ghostty-vt, wuffs, zstbi or C++;
+ // its terminal tests skip (Term.open), and run where the core has one.
+ const core_lean = b.createModule(.{
+ .target = target,
+ .optimize = optimize,
+ .root_source_file = b.path("src/pardes.zig"),
+ .link_libc = true,
+ });
const isolated_mod: ?*std.Build.Module = if (platform == .tui) b.createModule(.{
.target = target,
@@ -225,8 +234,8 @@ pub fn build(b: *std.Build) void {
}) else null;
const CoreMod = struct { mod: ?*std.Build.Module, shell: Platform };
- var core_mods_buf: [5]*std.Build.Module = undefined;
- var core_shells_buf: [5]Platform = undefined;
+ var core_mods_buf: [6]*std.Build.Module = undefined;
+ var core_shells_buf: [6]Platform = undefined;
var core_mods_len: usize = 0;
// root_mod FIRST: the module map below is folded out of its import table.
for ([_]CoreMod{
@@ -234,6 +243,7 @@ pub fn build(b: *std.Build) void {
// hxdiff's headless core and pardes-isolate are the primary shell's
// configuration compiled two more ways, not two more frontends.
.{ .mod = core_module, .shell = platform },
+ .{ .mod = core_lean, .shell = platform },
.{ .mod = isolated_mod, .shell = platform },
.{ .mod = static_mod, .shell = platform },
.{ .mod = gui_mod, .shell = .gui },
@@ -838,6 +848,23 @@ pub fn build(b: *std.Build) void {
for (builtin_mods) |m| m.addImport("image_addon", image_mod);
// The records the core and the terminal both name (src/plain/plain.zig).
const plain_mod = b.createModule(.{ .root_source_file = b.path("src/plain/plain.zig"), .target = target, .optimize = optimize });
+ // The terminal, a module of its own (src/term/term.zig): the emulator and
+ // what it brings are its, and every core but core-test's is given it.
+ const term_mod = b.createModule(.{ .root_source_file = b.path("src/term/term.zig"), .target = target, .optimize = optimize, .link_libc = true });
+ term_mod.addImport("plain", plain_mod);
+ if (ghostty_core_vt) |x| term_mod.addImport("ghostty-vt", x);
+ if (wuffs_mod) |x| term_mod.addImport("wuffs", x);
+ term_mod.addImport("zstbi", zstbi_mod);
+ const term_on = b.addOptions();
+ term_on.addOption(bool, "terminal", true);
+ const term_off = b.addOptions();
+ term_off.addOption(bool, "terminal", false);
+ for (core_mods) |m| if (m == core_lean) {
+ m.addOptions("term_options", term_off);
+ } else {
+ m.addImport("term", term_mod);
+ m.addOptions("term_options", term_on);
+ };
for (core_mods) |m| wireCore(m, .{
.plain = plain_mod,
.kind = kind_mod,
@@ -845,13 +872,10 @@ pub fn build(b: *std.Build) void {
.tree_sitter = ts_mod,
.ts_libs = ts_libs.items,
.ts_queries = ts_queries_opts,
- .zstbi = zstbi_mod,
.mvzr = mvzr_mod,
.c_heap = c_heap_mod,
- .ghostty_vt = ghostty_core_vt,
.vaxis = vaxis_mod,
.uucode = uucode_mod,
- .wuffs = wuffs_mod,
.xitdb = xitdb_mod,
});
@@ -1398,6 +1422,7 @@ pub fn build(b: *std.Build) void {
.root_module = b.createModule(.{ .target = target, .optimize = optimize, .root_source_file = b.path("test/replicas.zig"), .link_libc = true }),
});
replicas.root_module.addImport("pardes", core_module);
+ replicas.root_module.addImport("term", term_mod);
const run_replicas = b.addRunArtifact(replicas);
run_replicas.addPassthruArgs();
run_replicas.has_side_effects = true;
@@ -1591,12 +1616,15 @@ pub fn build(b: *std.Build) void {
// The perf and fs bench programs' own tests: they compile no editor.
_ = units.add(b, perf_tests, null);
_ = units.add(b, fs_bench_test, null);
- const core_test = b.addTest(.{ .root_module = core_module, .filters = test_filters });
+ const core_test = b.addTest(.{ .root_module = core_lean, .filters = test_filters });
const run_core_test = b.addRunArtifact(core_test);
run_core_test.has_side_effects = true;
- const core_test_step = b.step("core-test", "run core tests without native shell tests");
+ const core_test_step = b.step("core-test", "run core tests without native shell tests, on the core without a terminal (its terminal tests skip)");
core_test_step.dependOn(&run_core_test.step);
if (testMatch(b, unit_profile, test_filters, core_test_step)) |check| check.addArtifactArg(core_test);
+ // The terminal module's own tests (src/term/): the emulator without a core.
+ const run_term_test = units.add(b, b.addTest(.{ .root_module = term_mod, .filters = test_filters }), null);
+ b.step("term-test", "run the terminal module's own tests (src/term/)").dependOn(&run_term_test.step);
const pane_module = b.createModule(.{
.target = target,
.optimize = optimize,
@@ -1604,6 +1632,10 @@ pub fn build(b: *std.Build) void {
.link_libc = true,
});
pane_module.addImport("pardes", core_module);
+ // test/terminal.zig reads the emulator behind a core's terminal.
+ pane_module.addImport("term", term_mod);
+ pane_module.addImport("plain", plain_mod);
+ if (ghostty_vt_for_tests) |x| pane_module.addImport("ghostty-vt", x);
pane_module.addImport("pardes_config", core_module.import_table.get("pardes_config").?);
const test_addons = b.addOptions();
test_addons.addOptionPath("image", image_addon.getEmittedBin());
@@ -2197,13 +2229,10 @@ fn wireCore(m: *std.Build.Module, d: struct {
tree_sitter: ?*std.Build.Module = null,
ts_libs: []const *std.Build.Step.Compile = &.{},
ts_queries: ?*std.Build.Step.Options = null,
- zstbi: ?*std.Build.Module = null,
mvzr: ?*std.Build.Module = null,
c_heap: ?*std.Build.Module = null,
- ghostty_vt: ?*std.Build.Module = null,
vaxis: ?*std.Build.Module = null,
uucode: ?*std.Build.Module = null,
- wuffs: ?*std.Build.Module = null,
xitdb: ?*std.Build.Module = null,
}) void {
if (d.plain) |x| m.addImport("plain", x);
@@ -2212,12 +2241,9 @@ fn wireCore(m: *std.Build.Module, d: struct {
if (d.tree_sitter) |x| m.addImport("tree-sitter", x);
for (d.ts_libs) |lib| m.linkLibrary(lib);
if (d.ts_queries) |x| m.addOptions("ts_queries", x);
- if (d.zstbi) |x| m.addImport("zstbi", x);
if (d.mvzr) |x| m.addImport("mvzr", x);
if (d.c_heap) |x| m.addImport("c_heap", x);
- if (d.ghostty_vt) |x| m.addImport("ghostty-vt", x);
if (d.vaxis) |x| m.addImport("vaxis", x);
if (d.uucode) |x| m.addImport("uucode", x);
- if (d.wuffs) |x| m.addImport("wuffs", x);
if (d.xitdb) |x| m.addImport("xitdb", x);
}