glfw: update system_sdk to match latest Zig master macOS version targeting

The latest Zig master supports specifying a specific macOS version for libc, via
the target triple (ziglang/zig#10215):

* x86_64-macos.10 (Catalina)
* x86_64-macos.11 (Big Sur)
* x86_64-macos.12 (Monterey)
* aarch64-macos.11 (Big Sur)
* aarch64-macos.12 (Monterey)

Mach's `system_sdk.zig` can now download the relevant XCode framework stubs
for Big Sur (11) and Monterey (12). Although we don't have an SDK for Catalina (10)
currently, we use the Big Sur (11) SDK in that case and it generally works fine.
By default, Zig targets the N-3 version (e.g. `x86_64-macos` defaults to `x86_64-macos.10`).

Targeting the minimum supported version is useful for compatability, it guarantees the produced
binary will run on any later macOS version. Targeting the newer version can be useful if you
wish to use newer APIs not available in previous versions.

Fixes hexops/mach#102

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-11-26 23:25:50 -07:00 committed by Stephen Gutekanst
parent f91ceef291
commit 1df13d0509
4 changed files with 18 additions and 11 deletions

View file

@ -5,9 +5,11 @@
//!
//! The SDKs used by this script by default are:
//!
//! * Windows: none
//! * Linux: https://github.com/hexops/sdk-linux-x86_64 (~40MB, X11, Wayland, etc. development libraries)
//! * MacOS: https://github.com/hexops/sdk-macos-12.0 (~112MB, most frameworks you'd find in the XCode SDK)
//! * Windows: not needed
//! * MacOS (most frameworks you'd find in the XCode SDK):
//! * https://github.com/hexops/sdk-macos-11.3 (~160MB, default)
//! * https://github.com/hexops/sdk-macos-12.0 (~112MB, only if you specify a macOS 12 target triple.)
//!
//! You may supply your own SDKs via the Options struct if needed, although the Mach versions above
//! will generally work for most OpenGL/Vulkan applications.
@ -34,8 +36,11 @@ pub const Options = struct {
/// The github org to find repositories in.
github_org: []const u8 = "hexops",
/// The MacOS SDK repository name.
macos_sdk: []const u8 = "sdk-macos-12.0",
/// The MacOS 12 SDK repository name.
macos_sdk_12: []const u8 = "sdk-macos-12.0",
/// The MacOS 11 SDK repository name.
macos_sdk_11: []const u8 = "sdk-macos-11.3",
/// The Linux x86-64 SDK repository name.
linux_x86_64_sdk: []const u8 = "sdk-linux-x86_64",
@ -57,7 +62,10 @@ pub fn include(b: *Builder, step: *std.build.LibExeObjStep, options: Options) vo
}
fn includeSdkMacOS(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {
const sdk_root_dir = getSdkRoot(b.allocator, options.github_org, options.macos_sdk) catch unreachable;
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
const mac_12 = target.os.version_range.semver.isAtLeast(.{ .major = 12, .minor = 0 }) orelse false;
const sdk_name = if (mac_12) options.macos_sdk_12 else options.macos_sdk_11;
const sdk_root_dir = getSdkRoot(b.allocator, options.github_org, sdk_name) catch unreachable;
if (options.set_sysroot) {
step.addFrameworkDir("/System/Library/Frameworks");