mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-27 19:16:27 +00:00
build: build produces a broken object file for iOS
This gets `zig build -Dtarget=aarch64-ios` working. By "working" I mean it produces an object file without compiler errors. However, the object file certainly isn't useful since it uses a number of features that will not work in the iOS sandbox. This is just an experiment more than anything to see how hard it would be to get libghostty working within iOS to render a terminal. Note iOS doesn't support ptys so this wouldn't be a true on-device terminal. The challenge right now is to just get a terminal rendering (not usable).
This commit is contained in:
@@ -290,7 +290,7 @@ fn setupFd(src: File.Handle, target: i32) !void {
|
||||
}
|
||||
}
|
||||
},
|
||||
.macos => {
|
||||
.ios, .macos => {
|
||||
// Mac doesn't support dup3 so we use dup2. We purposely clear
|
||||
// CLO_ON_EXEC for this fd.
|
||||
const flags = try os.fcntl(src, os.F.GETFD, 0);
|
||||
|
||||
@@ -17,7 +17,7 @@ pub const SplitResizeDirection = Binding.Action.SplitResizeDirection;
|
||||
// Keymap is only available on macOS right now. We could implement it
|
||||
// in theory for XKB too on Linux but we don't need it right now.
|
||||
pub const Keymap = switch (builtin.os.tag) {
|
||||
.macos => @import("input/KeymapDarwin.zig"),
|
||||
.ios, .macos => @import("input/KeymapDarwin.zig"),
|
||||
else => struct {},
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ const Key = @import("key.zig").Key;
|
||||
/// The full list of entries for the current platform.
|
||||
pub const entries: []const Entry = entries: {
|
||||
const native_idx = switch (builtin.os.tag) {
|
||||
.macos => 4, // mac
|
||||
.ios, .macos => 4, // mac
|
||||
.windows => 3, // win
|
||||
.linux => 2, // xkb
|
||||
else => @compileError("unsupported platform"),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const std = @import("std");
|
||||
pub const cursor = @import("cursor.zig");
|
||||
pub const key = @import("key.zig");
|
||||
pub const termio = @import("termio.zig");
|
||||
|
||||
@@ -52,6 +52,9 @@ pub fn launchedFromDesktop() bool {
|
||||
// TODO: This should have some logic to detect this. Perhaps std.builtin.subsystem
|
||||
.windows => false,
|
||||
|
||||
// iPhone/iPad is always launched from the "desktop"
|
||||
.ios => true,
|
||||
|
||||
else => @compileError("unsupported platform"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ pub inline fn home(buf: []u8) !?[]u8 {
|
||||
return switch (builtin.os.tag) {
|
||||
inline .linux, .macos => try homeUnix(buf),
|
||||
.windows => try homeWindows(buf),
|
||||
|
||||
// iOS doesn't have a user-writable home directory
|
||||
.ios => null,
|
||||
|
||||
else => @compileError("unimplemented"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ pub fn open(alloc: Allocator, url: []const u8) !void {
|
||||
.linux => &.{ "xdg-open", url },
|
||||
.macos => &.{ "open", url },
|
||||
.windows => &.{ "rundll32", "url.dll,FileProtocolHandler", url },
|
||||
.ios => return error.Unimplemented,
|
||||
else => @compileError("unsupported OS"),
|
||||
};
|
||||
|
||||
|
||||
39
src/pty.zig
39
src/pty.zig
@@ -14,10 +14,41 @@ pub const winsize = extern struct {
|
||||
ws_ypixel: u16 = 600,
|
||||
};
|
||||
|
||||
pub const Pty = if (builtin.os.tag == .windows)
|
||||
WindowsPty
|
||||
else
|
||||
PosixPty;
|
||||
pub const Pty = switch (builtin.os.tag) {
|
||||
.windows => WindowsPty,
|
||||
.ios => NullPty,
|
||||
else => PosixPty,
|
||||
};
|
||||
|
||||
// A pty implementation that does nothing.
|
||||
//
|
||||
// TODO: This should be removed. This is only temporary until we have
|
||||
// a termio that doesn't use a pty. This isn't used in any user-facing
|
||||
// artifacts, this is just a stopgap to get compilation to work on iOS.
|
||||
const NullPty = struct {
|
||||
pub const Fd = std.os.fd_t;
|
||||
|
||||
master: Fd,
|
||||
slave: Fd,
|
||||
|
||||
pub fn open(size: winsize) !Pty {
|
||||
_ = size;
|
||||
return .{ .master = 0, .slave = 0 };
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Pty) void {
|
||||
_ = self;
|
||||
}
|
||||
|
||||
pub fn setSize(self: *Pty, size: winsize) !void {
|
||||
_ = self;
|
||||
_ = size;
|
||||
}
|
||||
|
||||
pub fn childPreExec(self: Pty) !void {
|
||||
_ = self;
|
||||
}
|
||||
};
|
||||
|
||||
/// Linux PTY creation and management. This is just a thin layer on top
|
||||
/// of Linux syscalls. The caller is responsible for detail-oriented handling
|
||||
|
||||
Reference in New Issue
Block a user