summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig56
1 files changed, 50 insertions, 6 deletions
diff --git a/build.zig b/build.zig
index 14066cf3..9bc1d2b6 100644
--- a/build.zig
+++ b/build.zig
@@ -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);