Add support for building on iOS

This commit is contained in:
Carson Katri
2025-09-16 12:41:50 -04:00
committed by Pierre Tachoire
parent 3f2f56d603
commit 8568c821fa
5 changed files with 128 additions and 65 deletions

View File

@@ -98,6 +98,11 @@ fn getAndMakeAppDir(allocator: Allocator) ?[]const u8 {
if (@import("builtin").is_test) {
return allocator.dupe(u8, "/tmp") catch unreachable;
}
if (@import("builtin").os.tag == .ios) {
return null; // getAppDataDir is not available on iOS
}
const app_dir_path = std.fs.getAppDataDir(allocator, "lightpanda") catch |err| {
log.warn(.app, "get data dir", .{ .err = err });
return null;

View File

@@ -75,8 +75,17 @@ pub const Server = struct {
self.listener = listener;
try posix.setsockopt(listener, posix.SOL.SOCKET, posix.SO.REUSEADDR, &std.mem.toBytes(@as(c_int, 1)));
if (@hasDecl(posix.TCP, "NODELAY")) {
try posix.setsockopt(listener, posix.IPPROTO.TCP, posix.TCP.NODELAY, &std.mem.toBytes(@as(c_int, 1)));
switch (builtin.os.tag) {
.ios => {
// TCP.NODELAY is not defined for iOS in posix module
const TCP_NODELAY = 0x01;
try posix.setsockopt(listener, posix.IPPROTO.TCP, TCP_NODELAY, &std.mem.toBytes(@as(c_int, 1)));
},
else => {
if (@hasDecl(posix.TCP, "NODELAY")) {
try posix.setsockopt(listener, posix.IPPROTO.TCP, posix.TCP.NODELAY, &std.mem.toBytes(@as(c_int, 1)));
}
},
}
try posix.bind(listener, &address.any, address.getOsSockLen());