mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
apple-sdk: use zig's libstd getSdk to get active Apple SDK
This commit is contained in:
@ -11,46 +11,19 @@ pub fn build(b: *std.Build) !void {
|
|||||||
/// The module target is used to determine the SDK to use so it must have
|
/// The module target is used to determine the SDK to use so it must have
|
||||||
/// a resolved target.
|
/// a resolved target.
|
||||||
pub fn addPaths(b: *std.Build, m: *std.Build.Module) !void {
|
pub fn addPaths(b: *std.Build, m: *std.Build.Module) !void {
|
||||||
// The active SDK we want to use
|
// Get the path to our active SDK installation. If this fails then
|
||||||
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. We store this in a struct variable so its
|
// the zig build will fail. We store this in a struct variable so its
|
||||||
// static and only calculated once per build.
|
// static and only calculated once per build.
|
||||||
const Path = struct {
|
const Path = struct {
|
||||||
var value: ?[]const u8 = null;
|
var value: ?[]const u8 = null;
|
||||||
};
|
};
|
||||||
const path = Path.value orelse path: {
|
const path = Path.value orelse path: {
|
||||||
const path = std.mem.trim(u8, b.run(&.{ "xcode-select", "--print-path" }), " \r\n");
|
const path = std.zig.system.darwin.getSdk(b.allocator, m.resolved_target.?.result) orelse "";
|
||||||
Path.value = path;
|
Path.value = path;
|
||||||
break :path path;
|
break :path path;
|
||||||
};
|
};
|
||||||
|
// The active SDK we want to use
|
||||||
// Base path
|
m.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ path, "/System/Library/Frameworks" }) });
|
||||||
const base = b.fmt("{s}/Platforms/{s}.platform/Developer/SDKs/{s}{s}.sdk", .{
|
m.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ path, "/usr/include" }) });
|
||||||
path,
|
m.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ path, "/usr/lib" }) });
|
||||||
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) {
|
|
||||||
.ios => .{ .platform = "iPhoneOS", .version = "" },
|
|
||||||
.macos => .{ .platform = "MacOSX", .version = "14" },
|
|
||||||
else => {
|
|
||||||
std.log.err("unsupported os={}", .{target.os.tag});
|
|
||||||
return error.UnsupportedOS;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
Reference in New Issue
Block a user