From f4bfe1a541383b466b64a57a0a1f5da48909587e Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 25 Jun 2023 01:12:33 -0700 Subject: [PATCH] glfw: workaround macOS zig libc __kernel_ptr_semantics Signed-off-by: Stephen Gutekanst --- libs/glfw/build.zig | 1 + libs/glfw/src/glfw_native.h | 5 +++++ libs/glfw/src/native.zig | 3 +-- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 libs/glfw/src/glfw_native.h diff --git a/libs/glfw/build.zig b/libs/glfw/build.zig index 0835497b..e9453bf5 100644 --- a/libs/glfw/build.zig +++ b/libs/glfw/build.zig @@ -116,6 +116,7 @@ fn buildLibrary(b: *Build, optimize: std.builtin.OptimizeMode, target: std.zig.C fn addGLFWIncludes(step: *std.build.CompileStep) void { step.addIncludePath(sdkPath("/upstream/glfw/include")); step.addIncludePath(sdkPath("/upstream/vulkan_headers/include")); + step.addIncludePath(sdkPath("/src")); } fn addGLFWSources(b: *Build, lib: *std.build.CompileStep, options: Options) std.mem.Allocator.Error!void { diff --git a/libs/glfw/src/glfw_native.h b/libs/glfw/src/glfw_native.h new file mode 100644 index 00000000..fe6c9a0a --- /dev/null +++ b/libs/glfw/src/glfw_native.h @@ -0,0 +1,5 @@ +// MacOS: this must be defined for system-sdk-13.3 and older. +#define __kernel_ptr_semantics + +#include +#include diff --git a/libs/glfw/src/native.zig b/libs/glfw/src/native.zig index 392f60ff..51e1fb99 100644 --- a/libs/glfw/src/native.zig +++ b/libs/glfw/src/native.zig @@ -40,7 +40,6 @@ pub const BackendOptions = struct { pub fn Native(comptime options: BackendOptions) type { const native = @cImport({ @cDefine("GLFW_INCLUDE_VULKAN", "1"); - @cInclude("GLFW/glfw3.h"); if (options.win32) @cDefine("GLFW_EXPOSE_NATIVE_WIN32", "1"); if (options.wgl) @cDefine("GLFW_EXPOSE_NATIVE_WGL", "1"); if (options.cocoa) @cDefine("GLFW_EXPOSE_NATIVE_COCOA", "1"); @@ -50,7 +49,7 @@ pub fn Native(comptime options: BackendOptions) type { if (options.wayland) @cDefine("GLFW_EXPOSE_NATIVE_WAYLAND", "1"); if (options.egl) @cDefine("GLFW_EXPOSE_NATIVE_EGL", "1"); if (options.osmesa) @cDefine("GLFW_EXPOSE_NATIVE_OSMESA", "1"); - @cInclude("GLFW/glfw3native.h"); + @cInclude("glfw_native.h"); }); return struct {