Files
ghostty/src/build/XCFrameworkStep.zig
Chris Marchesi e8525c0fd9 Update to Zig 0.16.0
This commit represents the majority of the work necessary to upgrade
Ghostty to use Zig 0.16.0.

Key parts:

* In addition to its previous responsibilities, the global state now
  houses state for global I/O implementations and the process
  environment. It is now also utilized in the main application along
  with the C library. Where necessary, global state is isolated from key
  parts of the implementation (e.g., in libghostty subsystems), and it's
  expected that this list will grow.

* We currently manage our own C translation layer where necessary. In
  these cases, cImport has been removed in favor of the new external
  translate-c package. Due to fixes that have needed be made to properly
  translate the dependencies that were swapped out, as mentioned, we
  have had to backport fixes from the current translate-c package (and
  the upstream Arocc dependency). We will host this ourselves until Zig
  0.17.0 is released with these fixes.

* Where necessary (only a small number of cases), some stdlib code from
  0.15.2 (and even from 0.17.0) has been taken, adopted, and vendored in
  lib/compat.

Co-authored-by: Leah Amelia Chen <hi@pluie.me>
2026-07-21 12:35:05 -07:00

78 lines
2.3 KiB
Zig

//! 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;
}