mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
pkg/apple-sdk: detect apple sdk based on target
This commit is contained in:
@ -9,7 +9,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
|
|
||||||
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
|
// 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
|
// Get the path to our active Xcode installation. If this fails then
|
||||||
// the zig build will fail.
|
// the zig build will fail.
|
||||||
@ -19,22 +19,30 @@ pub fn addPaths(b: *std.Build, m: *std.Build.Module) !void {
|
|||||||
" \r\n",
|
" \r\n",
|
||||||
);
|
);
|
||||||
|
|
||||||
m.addSystemFrameworkPath(.{
|
// Base path
|
||||||
.cwd_relative = b.pathJoin(&.{
|
const base = b.fmt("{s}/Platforms/{s}.platform/Developer/SDKs/{s}{s}.sdk", .{
|
||||||
path,
|
path,
|
||||||
"Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/System/Library/Frameworks",
|
sdk.platform,
|
||||||
}),
|
sdk.platform,
|
||||||
});
|
sdk.version,
|
||||||
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",
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -5,7 +5,11 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
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 imgui = b.dependency("imgui", .{});
|
||||||
const freetype = b.dependency("freetype", .{
|
const freetype = b.dependency("freetype", .{
|
||||||
|
@ -18,6 +18,8 @@ pub fn build(b: *std.Build) !void {
|
|||||||
|
|
||||||
const module = b.addModule("harfbuzz", .{
|
const module = b.addModule("harfbuzz", .{
|
||||||
.root_source_file = .{ .path = "main.zig" },
|
.root_source_file = .{ .path = "main.zig" },
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
.imports = &.{
|
.imports = &.{
|
||||||
.{ .name = "freetype", .module = freetype.module("freetype") },
|
.{ .name = "freetype", .module = freetype.module("freetype") },
|
||||||
.{ .name = "macos", .module = macos.module("macos") },
|
.{ .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_DONE_MM_VAR=1",
|
||||||
"-DHAVE_FT_GET_TRANSFORM=1",
|
"-DHAVE_FT_GET_TRANSFORM=1",
|
||||||
});
|
});
|
||||||
if (coretext_enabled) {
|
if (coretext_enabled and target.result.isDarwin()) {
|
||||||
try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"});
|
try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"});
|
||||||
try apple_sdk.addPaths(b, &lib.root_module);
|
try apple_sdk.addPaths(b, &lib.root_module);
|
||||||
try apple_sdk.addPaths(b, module);
|
try apple_sdk.addPaths(b, module);
|
||||||
|
@ -6,7 +6,11 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
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(.{
|
const lib = b.addStaticLibrary(.{
|
||||||
.name = "macos",
|
.name = "macos",
|
||||||
|
Reference in New Issue
Block a user