build: xcodebuild properly sets up resources

This commit is contained in:
Mitchell Hashimoto
2025-07-05 13:36:26 -07:00
parent 8653229607
commit 0929f39e89
3 changed files with 39 additions and 12 deletions

View File

@ -104,7 +104,12 @@ pub fn build(b: *std.Build) !void {
const macos_app = try buildpkg.GhosttyXcodebuild.init(
b,
&config,
&xcframework,
.{
.xcframework = &xcframework,
.docs = &docs,
.i18n = &i18n,
.resources = &resources,
},
);
if (config.emit_macos_app) {
macos_app.install();
@ -144,15 +149,14 @@ pub fn build(b: *std.Build) !void {
const macos_app_native_only = try buildpkg.GhosttyXcodebuild.init(
b,
&config,
&xcframework_native,
.{
.xcframework = &xcframework_native,
.docs = &docs,
.i18n = &i18n,
.resources = &resources,
},
);
// The app depends on the resources and i18n to be in the
// install directory too.
resources.addStepDependencies(&macos_app_native_only.build.step);
i18n.addStepDependencies(&macos_app_native_only.build.step);
docs.installDummy(&macos_app_native_only.build.step);
const run_step = b.step("run", "Run the app");
run_step.dependOn(&macos_app_native_only.open.step);
}

View File

@ -90,5 +90,12 @@ pub fn init(
pub fn install(self: *const GhosttyXCFramework) void {
const b = self.xcframework.step.owner;
b.getInstallStep().dependOn(self.xcframework.step);
self.addStepDependencies(b.getInstallStep());
}
pub fn addStepDependencies(
self: *const GhosttyXCFramework,
other_step: *std.Build.Step,
) void {
other_step.dependOn(self.xcframework.step);
}

View File

@ -4,16 +4,26 @@ const std = @import("std");
const builtin = @import("builtin");
const RunStep = std.Build.Step.Run;
const Config = @import("Config.zig");
const Docs = @import("GhosttyDocs.zig");
const I18n = @import("GhosttyI18n.zig");
const Resources = @import("GhosttyResources.zig");
const XCFramework = @import("GhosttyXCFramework.zig");
build: *std.Build.Step.Run,
open: *std.Build.Step.Run,
copy: *std.Build.Step.Run,
pub const Deps = struct {
xcframework: *const XCFramework,
docs: *const Docs,
i18n: *const I18n,
resources: *const Resources,
};
pub fn init(
b: *std.Build,
config: *const Config,
xcframework: *const XCFramework,
deps: Deps,
) !Ghostty {
const xc_config = switch (config.optimize) {
.Debug => "Debug",
@ -44,7 +54,7 @@ pub fn init(
xc_config,
});
switch (xcframework.target) {
switch (deps.xcframework.target) {
// Universal is our default target, so we don't have to
// add anything.
.universal => {},
@ -62,7 +72,13 @@ pub fn init(
}
// We need the xcframework
build.step.dependOn(xcframework.xcframework.step);
deps.xcframework.addStepDependencies(&build.step);
// We also need all these resources because the xcode project
// references them via symlinks.
deps.resources.addStepDependencies(&build.step);
deps.i18n.addStepDependencies(&build.step);
deps.docs.installDummy(&build.step);
// Expect success
build.expectExitCode(0);