From 0929f39e890438126b599a9937d1222b31a906f6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 5 Jul 2025 13:36:26 -0700 Subject: [PATCH] build: xcodebuild properly sets up resources --- build.zig | 20 ++++++++++++-------- src/build/GhosttyXCFramework.zig | 9 ++++++++- src/build/GhosttyXcodebuild.zig | 22 +++++++++++++++++++--- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/build.zig b/build.zig index a5e5407b6..024e2db61 100644 --- a/build.zig +++ b/build.zig @@ -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); } diff --git a/src/build/GhosttyXCFramework.zig b/src/build/GhosttyXCFramework.zig index 707d5e4e2..7debd6906 100644 --- a/src/build/GhosttyXCFramework.zig +++ b/src/build/GhosttyXCFramework.zig @@ -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); } diff --git a/src/build/GhosttyXcodebuild.zig b/src/build/GhosttyXcodebuild.zig index b340619e8..9b472eda8 100644 --- a/src/build/GhosttyXcodebuild.zig +++ b/src/build/GhosttyXcodebuild.zig @@ -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);