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:
parent
f91ceef291
commit
1df13d0509
4 changed files with 18 additions and 11 deletions
|
|
@ -244,4 +244,3 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -751,15 +751,15 @@ pub inline fn setSizeLimits(self: Window, min: Size, max: Size) Error!void {
|
||||||
/// see also: window_sizelimits, glfw.Window.setSizeLimits
|
/// see also: window_sizelimits, glfw.Window.setSizeLimits
|
||||||
pub inline fn setAspectRatio(self: Window, numerator: usize, denominator: usize) Error!void {
|
pub inline fn setAspectRatio(self: Window, numerator: usize, denominator: usize) Error!void {
|
||||||
internal_debug.assertInitialized();
|
internal_debug.assertInitialized();
|
||||||
|
|
||||||
std.debug.assert(numerator != 0);
|
std.debug.assert(numerator != 0);
|
||||||
std.debug.assert(denominator != 0);
|
std.debug.assert(denominator != 0);
|
||||||
|
|
||||||
if (numerator != glfw.dont_care and denominator != glfw.dont_care) {
|
if (numerator != glfw.dont_care and denominator != glfw.dont_care) {
|
||||||
std.debug.assert(numerator > 0);
|
std.debug.assert(numerator > 0);
|
||||||
std.debug.assert(denominator > 0);
|
std.debug.assert(denominator > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
c.glfwSetWindowAspectRatio(self.handle, @intCast(c_int, numerator), @intCast(c_int, denominator));
|
c.glfwSetWindowAspectRatio(self.handle, @intCast(c_int, numerator), @intCast(c_int, denominator));
|
||||||
getError() catch |err| return switch (err) {
|
getError() catch |err| return switch (err) {
|
||||||
Error.PlatformError => err,
|
Error.PlatformError => err,
|
||||||
|
|
|
||||||
|
|
@ -133,10 +133,10 @@ pub inline fn swapInterval(interval: isize) Error!void {
|
||||||
/// see also: context_glext, glfw.getProcAddress
|
/// see also: context_glext, glfw.getProcAddress
|
||||||
pub inline fn extensionSupported(extension: [:0]const u8) Error!bool {
|
pub inline fn extensionSupported(extension: [:0]const u8) Error!bool {
|
||||||
internal_debug.assertInitialized();
|
internal_debug.assertInitialized();
|
||||||
|
|
||||||
std.debug.assert(extension.len != 0);
|
std.debug.assert(extension.len != 0);
|
||||||
std.debug.assert(extension[0] != 0);
|
std.debug.assert(extension[0] != 0);
|
||||||
|
|
||||||
const supported = c.glfwExtensionSupported(extension);
|
const supported = c.glfwExtensionSupported(extension);
|
||||||
getError() catch |err| return switch (err) {
|
getError() catch |err| return switch (err) {
|
||||||
Error.NoCurrentContext => err,
|
Error.NoCurrentContext => err,
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,11 @@
|
||||||
//!
|
//!
|
||||||
//! The SDKs used by this script by default are:
|
//! 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)
|
//! * 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)
|
//! * MacOS (most frameworks you'd find in the XCode SDK):
|
||||||
//! * Windows: not needed
|
//! * 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
|
//! 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.
|
//! will generally work for most OpenGL/Vulkan applications.
|
||||||
|
|
@ -34,8 +36,11 @@ pub const Options = struct {
|
||||||
/// The github org to find repositories in.
|
/// The github org to find repositories in.
|
||||||
github_org: []const u8 = "hexops",
|
github_org: []const u8 = "hexops",
|
||||||
|
|
||||||
/// The MacOS SDK repository name.
|
/// The MacOS 12 SDK repository name.
|
||||||
macos_sdk: []const u8 = "sdk-macos-12.0",
|
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.
|
/// The Linux x86-64 SDK repository name.
|
||||||
linux_x86_64_sdk: []const u8 = "sdk-linux-x86_64",
|
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 {
|
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) {
|
if (options.set_sysroot) {
|
||||||
step.addFrameworkDir("/System/Library/Frameworks");
|
step.addFrameworkDir("/System/Library/Frameworks");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue