Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup Zig
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://ziglang.org/builds/zig-linux-x86_64-0.9.0-dev.1444+e2a2e6c14.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
sudo sh -c 'wget -c https://ziglang.org/builds/zig-linux-x86_64-0.9.0-dev.1785+4cdf5b666.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: x86_64-linux -> x86_64-macos
run: cd ${{ matrix.project }} && zig build test -Dtarget=x86_64-macos
env:
Expand Down Expand Up @@ -53,10 +53,10 @@ jobs:
run: choco install git
- name: Setup Zig
run: |
Invoke-WebRequest -Uri "https://ziglang.org/builds/zig-windows-x86_64-0.9.0-dev.1444+e2a2e6c14.zip" -OutFile "C:\zig.zip"
Invoke-WebRequest -Uri "https://ziglang.org/builds/zig-windows-x86_64-0.9.0-dev.1785+4cdf5b666.zip" -OutFile "C:\zig.zip"
cd C:\
7z x zig.zip
Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.9.0-dev.1444+e2a2e6c14\"
Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.9.0-dev.1785+4cdf5b666\"
- name: x86_64-windows -> x86_64-macos
run: cd ${{ matrix.project }} && zig build test -Dtarget=x86_64-macos
env:
Expand All @@ -83,15 +83,16 @@ jobs:
- name: Setup Zig
run: |
brew install xz
sudo sh -c 'wget -c https://ziglang.org/builds/zig-macos-x86_64-0.9.0-dev.1444+e2a2e6c14.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
sudo sh -c 'wget -c https://ziglang.org/builds/zig-macos-x86_64-0.9.0-dev.1785+4cdf5b666.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: test
run: cd ${{ matrix.project }} && zig build test
env:
AGREE: true
- name: x86_64-macos -> aarch64-macos
run: cd ${{ matrix.project }} && zig build test -Dtarget=aarch64-macos
env:
AGREE: true
# TODO(build-system): https://github.com/hexops/mach/issues/108
# - name: x86_64-macos -> aarch64-macos
# run: cd ${{ matrix.project }} && zig build test -Dtarget=aarch64-macos
# env:
# AGREE: true
- name: x86_64-macos -> x86_64-windows
run: cd ${{ matrix.project }} && zig build test -Dtarget=x86_64-windows
- name: x86_64-macos -> x86_64-linux
Expand Down
17 changes: 9 additions & 8 deletions glfw/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Zig
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://ziglang.org/builds/zig-linux-x86_64-0.9.0-dev.1444+e2a2e6c14.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
sudo sh -c 'wget -c https://ziglang.org/builds/zig-linux-x86_64-0.9.0-dev.1785+4cdf5b666.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: x86_64-linux -> x86_64-macos
run: zig build test -Dtarget=x86_64-macos
env:
Expand Down Expand Up @@ -47,10 +47,10 @@ jobs:
run: choco install git
- name: Setup Zig
run: |
Invoke-WebRequest -Uri "https://ziglang.org/builds/zig-windows-x86_64-0.9.0-dev.1444+e2a2e6c14.zip" -OutFile "C:\zig.zip"
Invoke-WebRequest -Uri "https://ziglang.org/builds/zig-windows-x86_64-0.9.0-dev.1785+4cdf5b666.zip" -OutFile "C:\zig.zip"
cd C:\
7z x zig.zip
Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.9.0-dev.1444+e2a2e6c14\"
Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.9.0-dev.1785+4cdf5b666\"
- name: x86_64-windows -> x86_64-macos
run: zig build test -Dtarget=x86_64-macos
env:
Expand All @@ -74,15 +74,16 @@ jobs:
- name: Setup Zig
run: |
brew install xz
sudo sh -c 'wget -c https://ziglang.org/builds/zig-macos-x86_64-0.9.0-dev.1444+e2a2e6c14.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
sudo sh -c 'wget -c https://ziglang.org/builds/zig-macos-x86_64-0.9.0-dev.1785+4cdf5b666.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: test
run: zig build test
env:
AGREE: true
- name: x86_64-macos -> aarch64-macos
run: zig build test -Dtarget=aarch64-macos
env:
AGREE: true
# TODO(build-system): https://github.com/hexops/mach/issues/108
# - name: x86_64-macos -> aarch64-macos
# run: zig build test -Dtarget=aarch64-macos
# env:
# AGREE: true
- name: x86_64-macos -> x86_64-windows
run: zig build test -Dtarget=x86_64-windows
- name: x86_64-macos -> x86_64-linux
Expand Down
1 change: 0 additions & 1 deletion glfw/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,3 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op
},
}
}

6 changes: 3 additions & 3 deletions glfw/src/Window.zig
Original file line number Diff line number Diff line change
Expand Up @@ -751,15 +751,15 @@ pub inline fn setSizeLimits(self: Window, min: Size, max: Size) Error!void {
/// see also: window_sizelimits, glfw.Window.setSizeLimits
pub inline fn setAspectRatio(self: Window, numerator: usize, denominator: usize) Error!void {
internal_debug.assertInitialized();

std.debug.assert(numerator != 0);
std.debug.assert(denominator != 0);

if (numerator != glfw.dont_care and denominator != glfw.dont_care) {
std.debug.assert(numerator > 0);
std.debug.assert(denominator > 0);
}

c.glfwSetWindowAspectRatio(self.handle, @intCast(c_int, numerator), @intCast(c_int, denominator));
getError() catch |err| return switch (err) {
Error.PlatformError => err,
Expand Down
4 changes: 2 additions & 2 deletions glfw/src/opengl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ pub inline fn swapInterval(interval: isize) Error!void {
/// see also: context_glext, glfw.getProcAddress
pub inline fn extensionSupported(extension: [:0]const u8) Error!bool {
internal_debug.assertInitialized();

std.debug.assert(extension.len != 0);
std.debug.assert(extension[0] != 0);

const supported = c.glfwExtensionSupported(extension);
getError() catch |err| return switch (err) {
Error.NoCurrentContext => err,
Expand Down
18 changes: 13 additions & 5 deletions glfw/system_sdk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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",
Expand All @@ -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");
Expand Down
13 changes: 0 additions & 13 deletions glfw/upstream/glfw/src/cocoa_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@
#include <stdint.h>
#include <dlfcn.h>

// HACK(mach): Zig's C stdlib headers conflict with those in sdk-macos-12.0, in specific _CDEFS_H_
// is already defined once sys/cdefs.h from sdk-macos-12.0 is included. This leads to these not
// being defined as empty, and that leads to syntax errors such as:
//
// sdk-macos-12.0/root/System/Library/Frameworks/IOKit.framework/Headers/IOTypes.h:81:49: error: expected ';' after top level declarator
//
// We patch this here by defining these, which appears to be good enough to workaround the issue for
// now. Presumably Zig's C stdlib headers will define these on macOS once updated for macOS 12.0,
// they're just slightly out of date for now.
#define __kernel_ptr_semantics
#define __kernel_data_semantics
#define __kernel_dual_semantics

#include <Carbon/Carbon.h>

// NOTE: All of NSGL was deprecated in the 10.14 SDK
Expand Down