diff --git a/pkg/apple-sdk/build.zig b/pkg/apple-sdk/build.zig index 2f883e129..34a1e92ce 100644 --- a/pkg/apple-sdk/build.zig +++ b/pkg/apple-sdk/build.zig @@ -9,7 +9,7 @@ pub fn build(b: *std.Build) !void { pub fn addPaths(b: *std.Build, m: *std.Build.Module) !void { // The active SDK we want to use - const sdk = "MacOSX14.sdk"; + const sdk = try SDK.fromTarget(m.resolved_target.?.result); // Get the path to our active Xcode installation. If this fails then // the zig build will fail. @@ -19,22 +19,30 @@ pub fn addPaths(b: *std.Build, m: *std.Build.Module) !void { " \r\n", ); - m.addSystemFrameworkPath(.{ - .cwd_relative = b.pathJoin(&.{ - path, - "Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/System/Library/Frameworks", - }), - }); - m.addSystemIncludePath(.{ - .cwd_relative = b.pathJoin(&.{ - path, - "Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/usr/include", - }), - }); - m.addLibraryPath(.{ - .cwd_relative = b.pathJoin(&.{ - path, - "Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/usr/lib", - }), + // Base path + const base = b.fmt("{s}/Platforms/{s}.platform/Developer/SDKs/{s}{s}.sdk", .{ + path, + sdk.platform, + sdk.platform, + sdk.version, }); + + m.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ base, "/System/Library/Frameworks" }) }); + m.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ base, "/usr/include" }) }); + m.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ base, "/usr/lib" }) }); } + +const SDK = struct { + platform: []const u8, + version: []const u8, + + pub fn fromTarget(target: std.Target) !SDK { + return switch (target.os.tag) { + .macos => .{ .platform = "MacOSX", .version = "14.2" }, + else => { + std.log.err("unsupported os={}", .{target.os.tag}); + return error.UnsupportedOS; + }, + }; + } +}; diff --git a/pkg/cimgui/build.zig b/pkg/cimgui/build.zig index b846671fa..34585bac9 100644 --- a/pkg/cimgui/build.zig +++ b/pkg/cimgui/build.zig @@ -5,7 +5,11 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const module = b.addModule("cimgui", .{ .root_source_file = .{ .path = "main.zig" } }); + const module = b.addModule("cimgui", .{ + .root_source_file = .{ .path = "main.zig" }, + .target = target, + .optimize = optimize, + }); const imgui = b.dependency("imgui", .{}); const freetype = b.dependency("freetype", .{ diff --git a/pkg/harfbuzz/build.zig b/pkg/harfbuzz/build.zig index 8efd532d9..280b66a57 100644 --- a/pkg/harfbuzz/build.zig +++ b/pkg/harfbuzz/build.zig @@ -18,6 +18,8 @@ pub fn build(b: *std.Build) !void { const module = b.addModule("harfbuzz", .{ .root_source_file = .{ .path = "main.zig" }, + .target = target, + .optimize = optimize, .imports = &.{ .{ .name = "freetype", .module = freetype.module("freetype") }, .{ .name = "macos", .module = macos.module("macos") }, @@ -59,7 +61,7 @@ pub fn build(b: *std.Build) !void { "-DHAVE_FT_DONE_MM_VAR=1", "-DHAVE_FT_GET_TRANSFORM=1", }); - if (coretext_enabled) { + if (coretext_enabled and target.result.isDarwin()) { try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"}); try apple_sdk.addPaths(b, &lib.root_module); try apple_sdk.addPaths(b, module); diff --git a/pkg/macos/build.zig b/pkg/macos/build.zig index 5d2108ed2..3891553f2 100644 --- a/pkg/macos/build.zig +++ b/pkg/macos/build.zig @@ -6,7 +6,11 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const module = b.addModule("macos", .{ .root_source_file = .{ .path = "main.zig" } }); + const module = b.addModule("macos", .{ + .root_source_file = .{ .path = "main.zig" }, + .target = target, + .optimize = optimize, + }); const lib = b.addStaticLibrary(.{ .name = "macos",