- commit
- f756c23
- parent
- be52f14
- author
- Eric Bower
- date
- 2025-12-05 15:32:04 -0500 EST
fix(macos): release build
2 files changed,
+14,
-2
+4,
-0
1@@ -42,6 +42,8 @@ pub fn build(b: *std.Build) void {
2 .name = "zmx",
3 .root_module = exe_mod,
4 });
5+ exe.linkLibC();
6+
7 b.installArtifact(exe);
8
9 // Run
10@@ -75,6 +77,7 @@ pub fn build(b: *std.Build) void {
11 .name = "zmx",
12 .root_module = exe_mod,
13 });
14+ exe_check.linkLibC();
15 // There is no `b.installArtifact(exe_check);` here.
16
17 // Finally we add the "check" step which will be detected
18@@ -106,6 +109,7 @@ pub fn build(b: *std.Build) void {
19 .name = "zmx",
20 .root_module = release_mod,
21 });
22+ release_exe.linkLibC();
23
24 const os_name = @tagName(release_target.os_tag orelse .linux);
25 const arch_name = @tagName(release_target.cpu_arch orelse .x86_64);
+10,
-2
1@@ -24,7 +24,7 @@ fn zmxLogFn(
2 const c = switch (builtin.os.tag) {
3 .macos => @cImport({
4 @cInclude("sys/ioctl.h"); // ioctl and constants
5- @cInclude("util.h"); // openpty()
6+ @cInclude("termios.h");
7 @cInclude("stdlib.h");
8 @cInclude("unistd.h");
9 }),
10@@ -42,6 +42,14 @@ const c = switch (builtin.os.tag) {
11 }),
12 };
13
14+// Manually declare forkpty for macOS since util.h is not available during cross-compilation
15+const forkpty = if (builtin.os.tag == .macos)
16+ struct {
17+ extern "c" fn forkpty(master_fd: *c_int, name: ?[*:0]u8, termp: ?*const c.struct_termios, winp: ?*const c.struct_winsize) c_int;
18+ }.forkpty
19+else
20+ c.forkpty;
21+
22 var sigwinch_received: std.atomic.Value(bool) = std.atomic.Value(bool).init(false);
23
24 const Client = struct {
25@@ -815,7 +823,7 @@ fn spawnPty(daemon: *Daemon) !c_int {
26 };
27
28 var master_fd: c_int = undefined;
29- const pid = c.forkpty(&master_fd, null, null, &ws);
30+ const pid = forkpty(&master_fd, null, null, &ws);
31 if (pid < 0) {
32 return error.ForkPtyFailed;
33 }