build: add iOS simulator target

This commit is contained in:
Mitchell Hashimoto
2024-01-13 22:11:13 -08:00
parent 468ba9ef86
commit 3c7fe08d87

View File

@ -438,6 +438,7 @@ pub fn build(b: *std.Build) !void {
// Create the universal iOS lib. // Create the universal iOS lib.
const ios_lib_step, const ios_lib_path = try createIOSLib( const ios_lib_step, const ios_lib_path = try createIOSLib(
b, b,
null,
optimize, optimize,
config, config,
exe_options, exe_options,
@ -450,6 +451,22 @@ pub fn build(b: *std.Build) !void {
); );
b.getInstallStep().dependOn(&ios_lib_install.step); b.getInstallStep().dependOn(&ios_lib_install.step);
// Create the iOS simulator lib.
const ios_sim_lib_step, const ios_sim_lib_path = try createIOSLib(
b,
.simulator,
optimize,
config,
exe_options,
);
// Add our library to zig-out
const ios_sim_lib_install = b.addInstallLibFile(
ios_lib_path,
"libghostty-ios-simulator.a",
);
b.getInstallStep().dependOn(&ios_sim_lib_install.step);
// Copy our ghostty.h to include. The header file is shared by // Copy our ghostty.h to include. The header file is shared by
// all embedded targets. // all embedded targets.
const header_install = b.addInstallHeaderFile( const header_install = b.addInstallHeaderFile(
@ -472,9 +489,14 @@ pub fn build(b: *std.Build) !void {
.library = ios_lib_path, .library = ios_lib_path,
.headers = .{ .path = "include" }, .headers = .{ .path = "include" },
}, },
.{
.library = ios_sim_lib_path,
.headers = .{ .path = "include" },
},
}, },
}); });
xcframework.step.dependOn(ios_lib_step); xcframework.step.dependOn(ios_lib_step);
xcframework.step.dependOn(ios_sim_lib_step);
xcframework.step.dependOn(macos_lib_step); xcframework.step.dependOn(macos_lib_step);
xcframework.step.dependOn(&header_install.step); xcframework.step.dependOn(&header_install.step);
b.default_step.dependOn(xcframework.step); b.default_step.dependOn(xcframework.step);
@ -737,6 +759,7 @@ fn createMacOSLib(
/// Create an Apple iOS/iPadOS build. /// Create an Apple iOS/iPadOS build.
fn createIOSLib( fn createIOSLib(
b: *std.Build, b: *std.Build,
abi: ?std.Target.Abi,
optimize: std.builtin.OptimizeMode, optimize: std.builtin.OptimizeMode,
config: BuildConfig, config: BuildConfig,
exe_options: *std.Build.Step.Options, exe_options: *std.Build.Step.Options,
@ -755,6 +778,7 @@ fn createIOSLib(
.cpu_arch = .aarch64, .cpu_arch = .aarch64,
.os_tag = .ios, .os_tag = .ios,
.os_version_min = osVersionMin(.ios), .os_version_min = osVersionMin(.ios),
.abi = abi,
}), }),
}); });
lib.bundle_compiler_rt = true; lib.bundle_compiler_rt = true;