diff options
| author | Gabriel Schneider <[email protected]> | 2026-07-02 21:41:13 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-01 15:02:07 -0300 |
| commit | 81992cc92743a98066ee1a9025bc74f91cf0e967 (patch) | |
| tree | 12c07f68f8ad030f6c6f8a2b3415998d0a87eee7 /build.zig | |
| parent | bead9f0b78380d1428f40fdab339c1c8f88fa626 (diff) | |
| download | pardes-81992cc92743a98066ee1a9025bc74f91cf0e967.tar.gz pardes-81992cc92743a98066ee1a9025bc74f91cf0e967.zip | |
storage and replay
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -1,5 +1,7 @@ const std = @import("std"); +const AppKind = enum { main, replay }; + pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const target = b.standardTargetOptions(.{}); @@ -33,6 +35,16 @@ pub fn build(b: *std.Build) void { .strip = strip, }), }); + const replay = b.addExecutable(.{ + .name = "pardes-replay", + .linkage = exe_linkage, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .root_source_file = b.path("replay.zig"), + .strip = strip, + }), + }); const tests = b.addExecutable(.{ .name = "pardes-e2e", .linkage = exe_linkage, @@ -44,6 +56,14 @@ pub fn build(b: *std.Build) void { }), }); + const main_app_config = b.addOptions(); + main_app_config.addOption(AppKind, "app_kind", .main); + exe.root_module.addOptions("app_config", main_app_config); + + const replay_app_config = b.addOptions(); + replay_app_config.addOption(AppKind, "app_kind", .replay); + replay.root_module.addOptions("app_config", replay_app_config); + // ghostty-vt and vaxis both depend on uucode, but Zig 0.16 forbids the // same source file from belonging to two modules, so they can't each have // their own uucode instance. We build a single uucode module here (with our @@ -89,6 +109,7 @@ pub fn build(b: *std.Build) void { const ghostty_vt = dep.module("ghostty-vt"); ghostty_vt.addImport("uucode", uucode_mod); exe.root_module.addImport("ghostty-vt", ghostty_vt); + replay.root_module.addImport("ghostty-vt", ghostty_vt); // The e2e test harness parses the app's pty output with its own ghostty // terminal (reads the 2D screen grid, not raw bytes), so it needs the // same module. @@ -111,6 +132,7 @@ pub fn build(b: *std.Build) void { }); ui_mod.addImport("vaxis", vaxis_mod); exe.root_module.addImport("ui", ui_mod); + replay.root_module.addImport("ui", ui_mod); // SDL3 GPU backend wiring (`-Dsdl`). The sdl package builds SDL3 from source // as a static lib + emits the SDL3/ headers; we @cImport those headers in @@ -150,12 +172,14 @@ pub fn build(b: *std.Build) void { // C source + include path + libc, so importing it is all that's needed. const zstbi_mod = b.dependency("zstbi", .{ .target = target, .optimize = optimize }).module("root"); exe.root_module.addImport("zstbi", zstbi_mod); + replay.root_module.addImport("zstbi", zstbi_mod); // tree-sitter syntax highlighting for file panes: the Zig bindings + C runtime // (the `tree-sitter` module), each grammar's parser.c linked as a static lib, // and its highlights.scm read at build time into the `ts_queries` options module. const tree_sitter = b.dependency("tree_sitter", .{ .target = target, .optimize = optimize }); exe.root_module.addImport("tree-sitter", tree_sitter.module("tree_sitter")); + replay.root_module.addImport("tree-sitter", tree_sitter.module("tree_sitter")); const Grammar = struct { name: []const u8, @@ -209,18 +233,26 @@ pub fn build(b: *std.Build) void { if (g.scanner) lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/scanner.c") }); lib.root_module.addIncludePath(dep.path(g.src)); exe.root_module.linkLibrary(lib); + replay.root_module.linkLibrary(lib); } exe.root_module.addOptions("ts_queries", ts_queries); + replay.root_module.addOptions("ts_queries", ts_queries); // Install the exe so `zig build` (and `zig build install`) produces it in // zig-out/bin for global install, not just as a hidden dep of `run`/`test`. b.installArtifact(exe); + b.installArtifact(replay); const run_exe = b.addRunArtifact(exe); const run = b.step("run", "descend to the pardes"); run.dependOn(&run_exe.step); + const run_replay = b.addRunArtifact(replay); + if (b.args) |args| run_replay.addArgs(args); + const replay_step = b.step("replay", "replay a pardes dump: zig build replay -- <dump.zon>"); + replay_step.dependOn(&run_replay.step); + // tutor_gen: a separate binary that parses tutor.txt and writes // tutor_cases.zig (a file of `test` blocks, one per practice block). // `zig build tutor-gen` runs it; the unit-test step depends on the output. @@ -241,6 +273,7 @@ pub fn build(b: *std.Build) void { const run_tests = b.addRunArtifact(tests); run_tests.addArtifactArg(exe); + run_tests.addArtifactArg(replay); // Expose build-time flags (e.g. -Dtrace) to the test runner as an importable // `config` module. tests.zig reads `config.trace` and hands it to the harness. @@ -302,6 +335,18 @@ pub fn build(b: *std.Build) void { unit_step.dependOn(&run_petscii.step); test_step.dependOn(&run_petscii.step); + const dump_tests = b.addTest(.{ + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .root_source_file = b.path("dump.zig"), + }), + }); + dump_tests.linkage = exe_linkage; + const run_dump = b.addRunArtifact(dump_tests); + unit_step.dependOn(&run_dump.step); + test_step.dependOn(&run_dump.step); + // Tutor practice blocks as unit tests: a second `zig test` target over the // generated tutor_cases.zig (which imports modal.zig). Depends on tutor-gen // so the file is (re)generated first. |
