From 73719acb2978069c1c0148db3d85a69416887bb4 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 12 Sep 2021 12:22:15 -0700 Subject: [PATCH] new approach to mac SDK inclusion Signed-off-by: Stephen Gutekanst --- glfw/build.zig | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/glfw/build.zig b/glfw/build.zig index f8a1e2c..cfa01a2 100644 --- a/glfw/build.zig +++ b/glfw/build.zig @@ -229,20 +229,17 @@ fn linkGLFW(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void } fn includeSdkMacOS(b: *Builder, step: *std.build.LibExeObjStep) void { + step.addFrameworkDir("/System/Library/Frameworks"); + step.addSystemIncludeDir("/usr/include"); + step.addLibPath("/usr/lib"); + + // Add the SDK as a sysroot. Using this instead of, say, absolute framework/include/lib paths + // to the SDK without a sysroot ensures that we use the same libraries/frameworks/headers on + // Mac hosts and non-Mac hosts. const sdk_root_dir = getSdkRoot(b.allocator, "sdk-macos-11.3") catch unreachable; defer b.allocator.free(sdk_root_dir); - - var sdk_root_frameworks = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/System/Library/Frameworks" }) catch unreachable; - defer b.allocator.free(sdk_root_frameworks); - step.addFrameworkDir(sdk_root_frameworks); - - var sdk_root_includes = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/usr/include" }) catch unreachable; - defer b.allocator.free(sdk_root_includes); - step.addSystemIncludeDir(sdk_root_includes); - - var sdk_root_libs = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/usr/lib" }) catch unreachable; - defer b.allocator.free(sdk_root_libs); - step.addLibPath(sdk_root_libs); + var sdk_sysroot = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/" }) catch unreachable; + b.sysroot = sdk_sysroot; } fn includeSdkLinuxX8664(b: *Builder, step: *std.build.LibExeObjStep) void {