aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/build/XCFrameworkStep.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-04-04 19:22:04 +0300
committerCan Celik <ogulcancelik@gmail.com>2026-04-05 01:23:06 +0300
commit41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch)
tree3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/src/build/XCFrameworkStep.zig
parent55c138263e190a1e79d4b997bfb9397306c0ec1f (diff)
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/src/build/XCFrameworkStep.zig')
-rw-r--r--vendor/libghostty-vt/src/build/XCFrameworkStep.zig77
1 files changed, 77 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/build/XCFrameworkStep.zig b/vendor/libghostty-vt/src/build/XCFrameworkStep.zig
new file mode 100644
index 00000000..39f0f9ba
--- /dev/null
+++ b/vendor/libghostty-vt/src/build/XCFrameworkStep.zig
@@ -0,0 +1,77 @@
+//! A zig builder step that runs "swift build" in the context of
+//! a Swift project managed with SwiftPM. This is primarily meant to build
+//! executables currently since that is what we build.
+const XCFrameworkStep = @This();
+
+const std = @import("std");
+const Step = std.Build.Step;
+const RunStep = std.Build.Step.Run;
+const LazyPath = std.Build.LazyPath;
+
+pub const Options = struct {
+ /// The name of the xcframework to create.
+ name: []const u8,
+
+ /// The path to write the framework
+ out_path: []const u8,
+
+ /// The libraries to bundle
+ libraries: []const Library,
+};
+
+/// A single library to bundle into the xcframework.
+pub const Library = struct {
+ /// Library file (dylib, a) to package.
+ library: LazyPath,
+
+ /// Path to a directory with the headers.
+ headers: LazyPath,
+
+ /// Path to a debug symbols file (.dSYM) if available.
+ dsym: ?LazyPath,
+};
+
+step: *Step,
+
+pub fn create(b: *std.Build, opts: Options) *XCFrameworkStep {
+ const self = b.allocator.create(XCFrameworkStep) catch @panic("OOM");
+
+ // We have to delete the old xcframework first since we're writing
+ // to a static path.
+ const run_delete = run: {
+ const run = RunStep.create(b, b.fmt("xcframework delete {s}", .{opts.name}));
+ run.has_side_effects = true;
+ run.addArgs(&.{ "rm", "-rf", opts.out_path });
+ break :run run;
+ };
+
+ // Then we run xcodebuild to create the framework.
+ const run_create = run: {
+ const run = RunStep.create(b, b.fmt("xcframework {s}", .{opts.name}));
+ run.has_side_effects = true;
+ run.addArgs(&.{ "xcodebuild", "-create-xcframework" });
+ for (opts.libraries) |lib| {
+ run.addArg("-library");
+ run.addFileArg(lib.library);
+ run.addArg("-headers");
+ run.addFileArg(lib.headers);
+ if (lib.dsym) |dsym| {
+ run.addArg("-debug-symbols");
+ run.addFileArg(dsym);
+ }
+ }
+ run.addArg("-output");
+ run.addArg(opts.out_path);
+ run.expectExitCode(0);
+ _ = run.captureStdOut();
+ _ = run.captureStdErr();
+ break :run run;
+ };
+ run_create.step.dependOn(&run_delete.step);
+
+ self.* = .{
+ .step = &run_create.step,
+ };
+
+ return self;
+}