diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 52 |
1 files changed, 39 insertions, 13 deletions
@@ -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); } |
