summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig27
1 files changed, 26 insertions, 1 deletions
diff --git a/build.zig b/build.zig
index 22dd7158..f9aa1070 100644
--- a/build.zig
+++ b/build.zig
@@ -59,6 +59,10 @@ pub fn build(b: *std.Build) void {
// static archives the emcc link needs beyond the zig object (grammars, SDL)
var wasm_libs: std.ArrayList(std.Build.LazyPath) = .empty;
+ // forkpty: in libc proper on glibc>=2.34 and darwin; the BSDs keep it in libutil
+ if (target.result.os.tag == .freebsd or target.result.os.tag == .netbsd or target.result.os.tag == .openbsd)
+ root_mod.linkSystemLibrary("util", .{});
+
const opts = b.addOptions();
opts.addOption(Platform, "platform", platform);
opts.addOption(bool, "syntax_highlighting", tree_sitter_grammars != .disabled);
@@ -171,7 +175,26 @@ pub fn build(b: *std.Build) void {
}).module("vaxis");
var ghostty_vt_for_snap: ?*std.Build.Module = null;
- if (b.lazyDependency("ghostty", .{ .simd = target.result.os.tag != .emscripten })) |dep| {
+ // ghostty's simd libs (simdutf/highway, C++) locate the Apple SDK via
+ // xcrun on darwin targets, so cross-compiling to macOS from elsewhere
+ // uses the scalar fallback (the same configuration the web shell ships).
+ // Native/cross builds hand ghostty the real target (it defaults to the
+ // host otherwise); the web path keeps its original no-target fetch, whose
+ // zig object never uses ghostty's artifacts.
+ // NOTE: darwin targets also need two one-line zig-0.16 fixes in the
+ // pinned ghostty (applied in the zig-pkg cache; re-apply after a fresh
+ // fetch, or bump the pin once upstream carries them):
+ // src/os/mach.zig — std.heap.next_mmap_addr_hint is gone (make the hint
+ // var module-local) and posix.mmap prot is now a packed struct
+ // (.{ .READ = true, .WRITE = true });
+ // src/terminal/kitty/graphics_image.zig:185 — shm_open's variadic mode
+ // literal 0 must be @as(std.c.mode_t, 0).
+ const ghostty_simd = !target.result.os.tag.isDarwin() or b.graph.host.result.os.tag.isDarwin();
+ const ghostty_dep = if (is_emscripten)
+ b.lazyDependency("ghostty", .{ .simd = false })
+ else
+ b.lazyDependency("ghostty", .{ .target = target, .optimize = optimize, .simd = ghostty_simd });
+ if (ghostty_dep) |dep| {
const ghostty_vt = dep.module("ghostty-vt");
ghostty_vt_for_snap = ghostty_vt;
ghostty_vt.addImport("uucode", uucode_mod);
@@ -309,6 +332,8 @@ pub fn build(b: *std.Build) void {
}),
});
if (ghostty_vt_for_snap) |vt| snap.root_module.addImport("ghostty-vt", vt);
+ if (target.result.os.tag == .freebsd or target.result.os.tag == .netbsd or target.result.os.tag == .openbsd)
+ snap.root_module.linkSystemLibrary("util", .{});
b.installArtifact(snap);
const run_snap = b.addRunArtifact(snap);
run_snap.addArtifactArg(exe);