diff --git a/src/build/Config.zig b/src/build/Config.zig index 43db20971..b412aaa42 100644 --- a/src/build/Config.zig +++ b/src/build/Config.zig @@ -73,6 +73,11 @@ pub fn init(b: *std.Build, appVersion: []const u8, libVersion: []const u8) !Conf // Setup our standard Zig target and optimize options, i.e. // `-Doptimize` and `-Dtarget`. const optimize = b.standardOptimizeOption(.{}); + const emit_lib_vt = b.option( + bool, + "emit-lib-vt", + "Set defaults for a libghostty-vt-only build (disables xcframework, macOS app, and docs).", + ) orelse false; const target = target: { var result = b.standardTargetOptions(.{}); @@ -100,7 +105,10 @@ pub fn init(b: *std.Build, appVersion: []const u8, libVersion: []const u8) !Conf // If we have no minimum OS version, we set the default based on // our tag. Not all tags have a minimum so this may be null. if (result.query.os_version_min == null) { - result.query.os_version_min = osVersionMin(result.result.os.tag); + result.query.os_version_min = if (emit_lib_vt) + osVersionMinLibVt(result.result.os.tag) + else + osVersionMin(result.result.os.tag); } break :target result; @@ -364,11 +372,7 @@ pub fn init(b: *std.Build, appVersion: []const u8, libVersion: []const u8) !Conf //--------------------------------------------------------------- // Artifacts to Emit - config.emit_lib_vt = b.option( - bool, - "emit-lib-vt", - "Set defaults for a libghostty-vt-only build (disables xcframework, macOS app, and docs).", - ) orelse false; + config.emit_lib_vt = emit_lib_vt; config.emit_exe = b.option( bool, @@ -692,9 +696,9 @@ pub fn osVersionMin(tag: std.Target.Os.Tag) ?std.Target.Query.OsVersion { .patch = 0, } }, - // iOS 17 picked arbitrarily + // The full Ghostty path compiles metal shaders that require iOS 14. .ios => .{ .semver = .{ - .major = 17, + .major = 14, .minor = 0, .patch = 0, } }, @@ -705,6 +709,15 @@ pub fn osVersionMin(tag: std.Target.Os.Tag) ?std.Target.Query.OsVersion { }; } +/// Returns the minimum OS version for lib-vt build. +/// +/// This should only be used for Darwin targets. +pub fn osVersionMinLibVt(tag: std.Target.Os.Tag) ?std.Target.Query.OsVersion { + // lib-vt has no newer deployment target requirement. + if (tag == .ios) return .{ .semver = .{ .major = 13, .minor = 0, .patch = 0 } }; + return osVersionMin(tag); +} + // Returns a ResolvedTarget for a mac with a `target.result.cpu.model.name` of `generic`. // `b.standardTargetOptions()` returns a more specific cpu like `apple_a15`. // diff --git a/src/build/GhosttyLibVt.zig b/src/build/GhosttyLibVt.zig index 0ef7d6937..7010a7837 100644 --- a/src/build/GhosttyLibVt.zig +++ b/src/build/GhosttyLibVt.zig @@ -183,7 +183,7 @@ pub fn initStaticAppleUniversal( const target_query: std.Target.Query = .{ .cpu_arch = .aarch64, .os_tag = p.os_tag, - .os_version_min = Config.osVersionMin(p.os_tag), + .os_version_min = Config.osVersionMinLibVt(p.os_tag), }; if (detectAppleSDK( b.graph.io, @@ -197,7 +197,7 @@ pub fn initStaticAppleUniversal( const sim_zig = try zig.retarget(b, cfg, deps, b.resolveTargetQuery(.{ .cpu_arch = .aarch64, .os_tag = p.os_tag, - .os_version_min = Config.osVersionMin(p.os_tag), + .os_version_min = Config.osVersionMinLibVt(p.os_tag), .abi = .simulator, .cpu_model = .{ .explicit = &std.Target.aarch64.cpu.apple_a17 }, }));