diff options
| author | Gabriel Schneider <[email protected]> | 2026-07-07 09:48:05 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-01 15:02:07 -0300 |
| commit | 9da20917b6f4cf98fd9b5c2c0a904e4f6a8380a9 (patch) | |
| tree | c7c8c4d1126def565eb0b1d20ad29782eb49c5e7 /build.zig | |
| parent | b2cdd8ee719961b2f037f20bf0f88fad94ca73b4 (diff) | |
| download | pardes-9da20917b6f4cf98fd9b5c2c0a904e4f6a8380a9.tar.gz pardes-9da20917b6f4cf98fd9b5c2c0a904e4f6a8380a9.zip | |
helix diff testing and feature parity
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 85 |
1 files changed, 71 insertions, 14 deletions
@@ -57,6 +57,17 @@ pub fn build(b: *std.Build) void { .root_source_file = b.path("src/main.zig"), .link_libc = true, }); + // helix differential harness (test/hxdiff.zig): a second compilation of + // the sans-IO core, driven headlessly. Mirrors root_mod's wiring for + // everything src/pardes.zig pulls in (ghostty-vt, tree-sitter, zstbi, the + // option modules); imported as "pardes" by the harness exe below. + const hx_core_mod = b.createModule(.{ + .target = target, + .optimize = optimize, + .root_source_file = b.path("src/pardes.zig"), + .link_libc = true, + }); + // static archives the emcc link needs beyond the zig object (grammars, SDL) var wasm_libs: std.ArrayList(std.Build.LazyPath) = .empty; @@ -71,6 +82,7 @@ pub fn build(b: *std.Build) void { opts.addOption(bool, "syntax_full_grammars", tree_sitter_grammars == .full); opts.addOption(bool, "enable_tracy", tracy != null); root_mod.addOptions("pardes_config", opts); + hx_core_mod.addOptions("pardes_config", opts); // Tracy zones (src/tracy.zig): compile the client into the binary only when // -Dtracy=<path> names a Tracy checkout; otherwise every zone is a no-op. @@ -79,20 +91,22 @@ pub fn build(b: *std.Build) void { // every thread — the app wedges before the first frame. Zones don't need // any of it. if (tracy) |tracy_path| { - root_mod.addIncludePath(.{ .cwd_relative = tracy_path }); - root_mod.addCSourceFile(.{ - .file = .{ .cwd_relative = b.pathJoin(&.{ tracy_path, "public", "TracyClient.cpp" }) }, - .flags = &.{ - "-DTRACY_ENABLE=1", - "-DTRACY_NO_SAMPLING", - "-DTRACY_NO_CALLSTACK", - "-DTRACY_NO_SYSTEM_TRACING", - "-DTRACY_NO_CRASH_HANDLER", - "-DTRACY_NO_CODE_TRANSFER", - "-fno-sanitize=undefined", - }, - }); - root_mod.link_libcpp = true; + for ([_]*std.Build.Module{ root_mod, hx_core_mod }) |mod| { + mod.addIncludePath(.{ .cwd_relative = tracy_path }); + mod.addCSourceFile(.{ + .file = .{ .cwd_relative = b.pathJoin(&.{ tracy_path, "public", "TracyClient.cpp" }) }, + .flags = &.{ + "-DTRACY_ENABLE=1", + "-DTRACY_NO_SAMPLING", + "-DTRACY_NO_CALLSTACK", + "-DTRACY_NO_SYSTEM_TRACING", + "-DTRACY_NO_CRASH_HANDLER", + "-DTRACY_NO_CODE_TRANSFER", + "-fno-sanitize=undefined", + }, + }); + mod.link_libcpp = true; + } } // tree-sitter: the zig bindings + C runtime, one static lib per grammar, @@ -112,6 +126,7 @@ pub fn build(b: *std.Build) void { }; } root_mod.addImport("tree-sitter", tree_sitter_mod); + hx_core_mod.addImport("tree-sitter", tree_sitter_mod); const Grammar = struct { name: []const u8, @@ -176,15 +191,18 @@ pub fn build(b: *std.Build) void { if (g.scanner) lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/scanner.c"), .flags = &ts_cflags }); lib.root_module.addIncludePath(dep.path(g.src)); root_mod.linkLibrary(lib); + hx_core_mod.linkLibrary(lib); if (is_emscripten) wasm_libs.append(b.allocator, lib.getEmittedBin()) catch @panic("OOM"); } } root_mod.addOptions("ts_queries", ts_queries); + hx_core_mod.addOptions("ts_queries", ts_queries); } // zstbi (C stb_image): image pane decode. zigimg crashes the 0.16 compiler. const zstbi_dep = b.dependency("zstbi", .{ .target = target, .optimize = optimize }); root_mod.addImport("zstbi", zstbi_dep.module("root")); + hx_core_mod.addImport("zstbi", zstbi_dep.module("root")); // ghostty-vt and vaxis both depend on uucode, but Zig forbids one source // file in two modules — build a single uucode (our config, unpacked tables) @@ -252,11 +270,13 @@ pub fn build(b: *std.Build) void { ghostty_vt.addOptions("terminal_options", term_opts); } root_mod.addImport("ghostty-vt", ghostty_vt); + hx_core_mod.addImport("ghostty-vt", ghostty_vt); } // override uucode on vaxis LAST so it wins over ghostty's build() wiring. vaxis_mod.addImport("uucode", uucode_mod); root_mod.addImport("vaxis", vaxis_mod); root_mod.addImport("uucode", uucode_mod); + hx_core_mod.addImport("uucode", uucode_mod); // SDL3 shell wiring (-Dplatform=gui and web). The sdl package builds SDL3 // from source as a static lib + emits the SDL3/ headers; gui.zig @cImports @@ -373,6 +393,43 @@ pub fn build(b: *std.Build) void { run_snap.addArtifactArg(exe); if (b.args) |args| run_snap.addArgs(args); b.step("snap", "run the snapshot parity suite (-- --update regenerates goldens)").dependOn(&run_snap.step); + + // helix differential harness: drive the sans-IO core headlessly over + // JSON-Lines cases, one contract result line per case on stdout — + // the pardes half of the pardes-vs-helix diff (helix's hx-harness on + // its pardes-harness branch speaks the same contract). + const hxdiff = b.addExecutable(.{ + .name = "pardes-hxdiff", + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .root_source_file = b.path("test/hxdiff.zig"), + .link_libc = true, + }), + }); + hxdiff.root_module.addImport("pardes", hx_core_mod); + b.installArtifact(hxdiff); + const run_hxdiff = b.addRunArtifact(hxdiff); + if (b.args) |args| run_hxdiff.addArgs(args) else { + // no args: run the checked-in differential suite offline — + // cases vs the helix goldens, waivers exempting the documented + // pardes-isms. Nonzero exit on any unwaivered mismatch. + run_hxdiff.addArgs(&.{ + "test/hxcases/cases.jsonl", + "test/hxcases/goldens.jsonl", + "test/hxcases/waivers.jsonl", + }); + run_hxdiff.setCwd(b.path(".")); + } + b.step("hxdiff", "run the helix differential suite (-- <cases.jsonl> [goldens.jsonl [waivers.jsonl]])").dependOn(&run_hxdiff.step); + + // modal.zig is pure std — its inline unit tests run here + const unit = b.addTest(.{ .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .root_source_file = b.path("src/modal.zig"), + }) }); + b.step("unit-test", "run the modal.zig unit tests").dependOn(&b.addRunArtifact(unit).step); } } |
