mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
build: zig build run only builds xcframework for current arch
This commit is contained in:
16
build.zig
16
build.zig
@ -95,7 +95,11 @@ pub fn build(b: *std.Build) !void {
|
||||
if (!config.emit_xcframework) break :none;
|
||||
|
||||
// Build the xcframework
|
||||
const xcframework = try buildpkg.GhosttyXCFramework.init(b, &deps);
|
||||
const xcframework = try buildpkg.GhosttyXCFramework.init(
|
||||
b,
|
||||
&deps,
|
||||
.universal,
|
||||
);
|
||||
xcframework.install();
|
||||
|
||||
// The xcframework build always installs resources because our
|
||||
@ -113,16 +117,24 @@ pub fn build(b: *std.Build) !void {
|
||||
}
|
||||
|
||||
// Build our macOS app
|
||||
{
|
||||
const xcframework_native = try buildpkg.GhosttyXCFramework.init(
|
||||
b,
|
||||
&deps,
|
||||
.native,
|
||||
);
|
||||
|
||||
const app = try buildpkg.GhosttyXcodebuild.init(
|
||||
b,
|
||||
&config,
|
||||
&xcframework,
|
||||
&xcframework_native,
|
||||
);
|
||||
|
||||
// Add a run command that opens our mac app.
|
||||
const run_step = b.step("run", "Run the app");
|
||||
run_step.dependOn(&app.open.step);
|
||||
}
|
||||
}
|
||||
|
||||
// Tests
|
||||
{
|
||||
|
@ -7,11 +7,23 @@ const GhosttyLib = @import("GhosttyLib.zig");
|
||||
const XCFrameworkStep = @import("XCFrameworkStep.zig");
|
||||
|
||||
xcframework: *XCFrameworkStep,
|
||||
macos: GhosttyLib,
|
||||
target: Target,
|
||||
|
||||
pub fn init(b: *std.Build, deps: *const SharedDeps) !GhosttyXCFramework {
|
||||
// Create our universal macOS static library.
|
||||
const macos = try GhosttyLib.initMacOSUniversal(b, deps);
|
||||
pub const Target = enum { native, universal };
|
||||
|
||||
pub fn init(
|
||||
b: *std.Build,
|
||||
deps: *const SharedDeps,
|
||||
target: Target,
|
||||
) !GhosttyXCFramework {
|
||||
// Universal macOS build
|
||||
const macos_universal = try GhosttyLib.initMacOSUniversal(b, deps);
|
||||
|
||||
// Native macOS build
|
||||
const macos_native = try GhosttyLib.initStatic(b, &try deps.retarget(
|
||||
b,
|
||||
Config.genericMacOSTarget(b, null),
|
||||
));
|
||||
|
||||
// iOS
|
||||
const ios = try GhosttyLib.initStatic(b, &try deps.retarget(
|
||||
@ -47,9 +59,10 @@ pub fn init(b: *std.Build, deps: *const SharedDeps) !GhosttyXCFramework {
|
||||
const xcframework = XCFrameworkStep.create(b, .{
|
||||
.name = "GhosttyKit",
|
||||
.out_path = "macos/GhosttyKit.xcframework",
|
||||
.libraries = &.{
|
||||
.libraries = switch (target) {
|
||||
.universal => &.{
|
||||
.{
|
||||
.library = macos.output,
|
||||
.library = macos_universal.output,
|
||||
.headers = b.path("include"),
|
||||
},
|
||||
.{
|
||||
@ -61,11 +74,17 @@ pub fn init(b: *std.Build, deps: *const SharedDeps) !GhosttyXCFramework {
|
||||
.headers = b.path("include"),
|
||||
},
|
||||
},
|
||||
|
||||
.native => &.{.{
|
||||
.library = macos_native.output,
|
||||
.headers = b.path("include"),
|
||||
}},
|
||||
},
|
||||
});
|
||||
|
||||
return .{
|
||||
.xcframework = xcframework,
|
||||
.macos = macos,
|
||||
.target = target,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
const Ghostty = @This();
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const RunStep = std.Build.Step.Run;
|
||||
const Config = @import("Config.zig");
|
||||
const XCFramework = @import("GhosttyXCFramework.zig");
|
||||
@ -40,6 +41,23 @@ pub fn init(
|
||||
xc_config,
|
||||
});
|
||||
|
||||
switch (xcframework.target) {
|
||||
// Universal is our default target, so we don't have to
|
||||
// add anything.
|
||||
.universal => {},
|
||||
|
||||
// Native we need to override the architecture in the Xcode
|
||||
// project with the -arch flag.
|
||||
.native => build.addArgs(&.{
|
||||
"-arch",
|
||||
switch (builtin.cpu.arch) {
|
||||
.aarch64 => "arm64",
|
||||
.x86_64 => "x86_64",
|
||||
else => @panic("unsupported macOS arch"),
|
||||
},
|
||||
}),
|
||||
}
|
||||
|
||||
// We need the xcframework
|
||||
build.step.dependOn(xcframework.xcframework.step);
|
||||
|
||||
|
Reference in New Issue
Block a user