diff options
| author | Gabriel Schneider <[email protected]> | 2026-06-16 23:04:59 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-06-25 11:23:20 -0300 |
| commit | 6833b39ffe311f0f1e39b6669b946d712d7dcd93 (patch) | |
| tree | 135a1016e1d9a957e73a92087d8e4afbadb79033 /build.zig | |
| parent | 7e3240817c888ec3fa4c553cd77695e8d106598f (diff) | |
| download | pardes-6833b39ffe311f0f1e39b6669b946d712d7dcd93.tar.gz pardes-6833b39ffe311f0f1e39b6669b946d712d7dcd93.zip | |
ghostty setup
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 56 |
1 files changed, 50 insertions, 6 deletions
@@ -4,11 +4,6 @@ pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const target = b.standardTargetOptions(.{}); - const vaxis_dep = b.dependency("vaxis", .{ - .target = target, - .optimize = optimize, - }); - const exe = b.addExecutable(.{ .name = "pardes", .root_module = b.createModule(.{ @@ -18,7 +13,56 @@ pub fn build(b: *std.Build) void { }), }); - exe.root_module.addImport("vaxis", vaxis_dep.module("vaxis")); + // 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 + // own uucode_config.zig) and hand it to both. + // + // Our config matches ghostty's exactly except the tables are `.unpacked`; + // see uucode_config.zig for why that's required on Zig 0.16. + const uucode_config = b.path("uucode_config.zig"); + const uucode_tables = b.dependency("uucode", .{ + .target = target, + .optimize = optimize, + .build_config_path = uucode_config, + }).namedLazyPath("tables.zig"); + const uucode_mod = b.dependency("uucode", .{ + .target = target, + .optimize = optimize, + .build_config_path = uucode_config, + .tables_path = uucode_tables, + }).module("uucode"); + + // vaxis is built with `external_uucode = true` so it skips its built-in + // uucode dependency and lets us wire one in. + const vaxis_dep = b.dependency("vaxis", .{ + .target = target, + .optimize = optimize, + .external_uucode = true, + }); + const vaxis_mod = vaxis_dep.module("vaxis"); + + // You'll want to use a lazy dependency here so that ghostty is only + // downloaded if you actually need it. + if (b.lazyDependency("ghostty", .{ + // Setting simd to false will force a pure static build that + // doesn't even require libc, but it has a significant performance + // penalty. If your embedding app requires libc anyway, you should + // always keep simd enabled. + // .simd = false, + })) |dep| { + // Accessing ghostty's modules runs its build(), which (because vaxis is + // a shared dependency, deduplicated to the same module) wires ghostty's + // own uucode into vaxis. We undo that below by overriding both imports + // with ours — order matters, so this must happen after this point. + const ghostty_vt = dep.module("ghostty-vt"); + ghostty_vt.addImport("uucode", uucode_mod); + exe.root_module.addImport("ghostty-vt", ghostty_vt); + } + + // Override uucode on vaxis last, so it wins over ghostty's build() above. + vaxis_mod.addImport("uucode", uucode_mod); + exe.root_module.addImport("vaxis", vaxis_mod); const run_exe = b.addRunArtifact(exe); |
