1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
const std = @import("std");
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
const exe = b.addExecutable(.{
.name = "pardes",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("main.zig"),
}),
});
const tests = b.addExecutable(.{
.name = "pardes-e2e",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("tests.zig"),
.link_libc = true,
}),
});
// 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);
const run = b.step("run", "descend to the pardes");
run.dependOn(&run_exe.step);
const run_tests = b.addRunArtifact(tests);
run_tests.addArtifactArg(exe);
const test_step = b.step("test", "run deterministic tests");
test_step.dependOn(&run_tests.step);
}
|