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:
30
build.zig
30
build.zig
@ -95,7 +95,11 @@ pub fn build(b: *std.Build) !void {
|
|||||||
if (!config.emit_xcframework) break :none;
|
if (!config.emit_xcframework) break :none;
|
||||||
|
|
||||||
// Build the xcframework
|
// Build the xcframework
|
||||||
const xcframework = try buildpkg.GhosttyXCFramework.init(b, &deps);
|
const xcframework = try buildpkg.GhosttyXCFramework.init(
|
||||||
|
b,
|
||||||
|
&deps,
|
||||||
|
.universal,
|
||||||
|
);
|
||||||
xcframework.install();
|
xcframework.install();
|
||||||
|
|
||||||
// The xcframework build always installs resources because our
|
// The xcframework build always installs resources because our
|
||||||
@ -113,15 +117,23 @@ pub fn build(b: *std.Build) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build our macOS app
|
// Build our macOS app
|
||||||
const app = try buildpkg.GhosttyXcodebuild.init(
|
{
|
||||||
b,
|
const xcframework_native = try buildpkg.GhosttyXCFramework.init(
|
||||||
&config,
|
b,
|
||||||
&xcframework,
|
&deps,
|
||||||
);
|
.native,
|
||||||
|
);
|
||||||
|
|
||||||
// Add a run command that opens our mac app.
|
const app = try buildpkg.GhosttyXcodebuild.init(
|
||||||
const run_step = b.step("run", "Run the app");
|
b,
|
||||||
run_step.dependOn(&app.open.step);
|
&config,
|
||||||
|
&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
|
// Tests
|
||||||
|
@ -7,11 +7,23 @@ const GhosttyLib = @import("GhosttyLib.zig");
|
|||||||
const XCFrameworkStep = @import("XCFrameworkStep.zig");
|
const XCFrameworkStep = @import("XCFrameworkStep.zig");
|
||||||
|
|
||||||
xcframework: *XCFrameworkStep,
|
xcframework: *XCFrameworkStep,
|
||||||
macos: GhosttyLib,
|
target: Target,
|
||||||
|
|
||||||
pub fn init(b: *std.Build, deps: *const SharedDeps) !GhosttyXCFramework {
|
pub const Target = enum { native, universal };
|
||||||
// Create our universal macOS static library.
|
|
||||||
const macos = try GhosttyLib.initMacOSUniversal(b, deps);
|
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
|
// iOS
|
||||||
const ios = try GhosttyLib.initStatic(b, &try deps.retarget(
|
const ios = try GhosttyLib.initStatic(b, &try deps.retarget(
|
||||||
@ -47,25 +59,32 @@ pub fn init(b: *std.Build, deps: *const SharedDeps) !GhosttyXCFramework {
|
|||||||
const xcframework = XCFrameworkStep.create(b, .{
|
const xcframework = XCFrameworkStep.create(b, .{
|
||||||
.name = "GhosttyKit",
|
.name = "GhosttyKit",
|
||||||
.out_path = "macos/GhosttyKit.xcframework",
|
.out_path = "macos/GhosttyKit.xcframework",
|
||||||
.libraries = &.{
|
.libraries = switch (target) {
|
||||||
.{
|
.universal => &.{
|
||||||
.library = macos.output,
|
.{
|
||||||
.headers = b.path("include"),
|
.library = macos_universal.output,
|
||||||
|
.headers = b.path("include"),
|
||||||
|
},
|
||||||
|
.{
|
||||||
|
.library = ios.output,
|
||||||
|
.headers = b.path("include"),
|
||||||
|
},
|
||||||
|
.{
|
||||||
|
.library = ios_sim.output,
|
||||||
|
.headers = b.path("include"),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
.{
|
|
||||||
.library = ios.output,
|
.native => &.{.{
|
||||||
|
.library = macos_native.output,
|
||||||
.headers = b.path("include"),
|
.headers = b.path("include"),
|
||||||
},
|
}},
|
||||||
.{
|
|
||||||
.library = ios_sim.output,
|
|
||||||
.headers = b.path("include"),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.xcframework = xcframework,
|
.xcframework = xcframework,
|
||||||
.macos = macos,
|
.target = target,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const Ghostty = @This();
|
const Ghostty = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const builtin = @import("builtin");
|
||||||
const RunStep = std.Build.Step.Run;
|
const RunStep = std.Build.Step.Run;
|
||||||
const Config = @import("Config.zig");
|
const Config = @import("Config.zig");
|
||||||
const XCFramework = @import("GhosttyXCFramework.zig");
|
const XCFramework = @import("GhosttyXCFramework.zig");
|
||||||
@ -40,6 +41,23 @@ pub fn init(
|
|||||||
xc_config,
|
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
|
// We need the xcframework
|
||||||
build.step.dependOn(xcframework.xcframework.step);
|
build.step.dependOn(xcframework.xcframework.step);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user