mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
build: use Xcode for the macOS SDK
This commit is contained in:
@ -7,12 +7,34 @@ pub fn build(b: *std.Build) !void {
|
||||
_ = optimize;
|
||||
}
|
||||
|
||||
pub fn addPaths(b: *std.Build, step: *std.Build.Step.Compile) !void {
|
||||
_ = b;
|
||||
@import("macos_sdk").addPaths(step);
|
||||
}
|
||||
pub fn addPaths(b: *std.Build, step: anytype) !void {
|
||||
// The active SDK we want to use
|
||||
const sdk = "MacOSX14.sdk";
|
||||
|
||||
pub fn addPathsModule(b: *std.Build, m: *std.Build.Module) !void {
|
||||
_ = b;
|
||||
@import("macos_sdk").addPathsModule(m);
|
||||
// Get the path to our active Xcode installation. If this fails then
|
||||
// the zig build will fail.
|
||||
const path = std.mem.trim(
|
||||
u8,
|
||||
b.run(&.{ "xcode-select", "--print-path" }),
|
||||
" \r\n",
|
||||
);
|
||||
|
||||
step.addSystemFrameworkPath(.{
|
||||
.cwd_relative = b.pathJoin(&.{
|
||||
path,
|
||||
"Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/System/Library/Frameworks",
|
||||
}),
|
||||
});
|
||||
step.addSystemIncludePath(.{
|
||||
.cwd_relative = b.pathJoin(&.{
|
||||
path,
|
||||
"Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/usr/include",
|
||||
}),
|
||||
});
|
||||
step.addLibraryPath(.{
|
||||
.cwd_relative = b.pathJoin(&.{
|
||||
path,
|
||||
"Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/usr/lib",
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
.{
|
||||
.name = "apple-sdk",
|
||||
.version = "0.1.0",
|
||||
.dependencies = .{
|
||||
.macos_sdk = .{
|
||||
.url = "https://github.com/mitchellh/zig-build-macos-sdk/archive/ee70f27c08680307fa35ada92e6b2c36e0ff84c6.tar.gz",
|
||||
.hash = "1220b415f529f1c04ed876c2b481e9f8119d353d4e3d4d7c8607ee302d2142e13eca",
|
||||
},
|
||||
},
|
||||
.dependencies = .{},
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ pub fn build(b: *std.Build) !void {
|
||||
if (target.result.isDarwin()) {
|
||||
if (!target.query.isNative()) {
|
||||
try @import("apple_sdk").addPaths(b, lib);
|
||||
try @import("apple_sdk").addPathsModule(b, module);
|
||||
try @import("apple_sdk").addPaths(b, module);
|
||||
}
|
||||
lib.addCSourceFile(.{
|
||||
.file = imgui.path("backends/imgui_impl_metal.mm"),
|
||||
|
@ -62,7 +62,7 @@ pub fn build(b: *std.Build) !void {
|
||||
if (coretext_enabled) {
|
||||
try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"});
|
||||
try apple_sdk.addPaths(b, lib);
|
||||
try apple_sdk.addPathsModule(b, module);
|
||||
try apple_sdk.addPaths(b, module);
|
||||
lib.linkFramework("ApplicationServices");
|
||||
module.linkFramework("ApplicationServices", .{});
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ pub fn build(b: *std.Build) !void {
|
||||
|
||||
if (!target.query.isNative()) {
|
||||
try apple_sdk.addPaths(b, lib);
|
||||
try apple_sdk.addPathsModule(b, module);
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
b.installArtifact(lib);
|
||||
|
||||
|
Reference in New Issue
Block a user