fix macos zig build test failures

This commit is contained in:
Mitchell Hashimoto
2024-01-07 12:10:48 -08:00
parent c1bde28af4
commit a8a42c8658
4 changed files with 30 additions and 30 deletions

View File

@ -445,21 +445,21 @@ pub fn build(b: *std.Build) !void {
} }
// On Mac we can build the embedding library. // On Mac we can build the embedding library.
if (builtin.target.isDarwin() and target.isDarwin()) { if (builtin.target.isDarwin() and target.result.isDarwin()) {
const static_lib_aarch64 = lib: { const static_lib_aarch64 = lib: {
const lib = b.addStaticLibrary(.{ const lib = b.addStaticLibrary(.{
.name = "ghostty", .name = "ghostty",
.root_source_file = .{ .path = "src/main_c.zig" }, .root_source_file = .{ .path = "src/main_c.zig" },
.target = .{ .target = b.resolveTargetQuery(.{
.cpu_arch = .aarch64, .cpu_arch = .aarch64,
.os_tag = .macos, .os_tag = .macos,
.os_version_min = target.os_version_min, .os_version_min = target.query.os_version_min,
}, }),
.optimize = optimize, .optimize = optimize,
}); });
lib.bundle_compiler_rt = true; lib.bundle_compiler_rt = true;
lib.linkLibC(); lib.linkLibC();
lib.addOptions("build_options", exe_options); lib.root_module.addOptions("build_options", exe_options);
// Create a single static lib with all our dependencies merged // Create a single static lib with all our dependencies merged
var lib_list = try addDeps(b, lib, true); var lib_list = try addDeps(b, lib, true);
@ -479,16 +479,16 @@ pub fn build(b: *std.Build) !void {
const lib = b.addStaticLibrary(.{ const lib = b.addStaticLibrary(.{
.name = "ghostty", .name = "ghostty",
.root_source_file = .{ .path = "src/main_c.zig" }, .root_source_file = .{ .path = "src/main_c.zig" },
.target = .{ .target = b.resolveTargetQuery(.{
.cpu_arch = .x86_64, .cpu_arch = .x86_64,
.os_tag = .macos, .os_tag = .macos,
.os_version_min = target.os_version_min, .os_version_min = target.query.os_version_min,
}, }),
.optimize = optimize, .optimize = optimize,
}); });
lib.bundle_compiler_rt = true; lib.bundle_compiler_rt = true;
lib.linkLibC(); lib.linkLibC();
lib.addOptions("build_options", exe_options); lib.root_module.addOptions("build_options", exe_options);
// Create a single static lib with all our dependencies merged // Create a single static lib with all our dependencies merged
var lib_list = try addDeps(b, lib, true); var lib_list = try addDeps(b, lib, true);

View File

@ -3,9 +3,9 @@
const LibtoolStep = @This(); const LibtoolStep = @This();
const std = @import("std"); const std = @import("std");
const Step = std.build.Step; const Step = std.Build.Step;
const RunStep = std.build.RunStep; const RunStep = std.Build.Step.Run;
const FileSource = std.build.FileSource; const LazyPath = std.Build.LazyPath;
pub const Options = struct { pub const Options = struct {
/// The name of this step. /// The name of this step.
@ -16,14 +16,14 @@ pub const Options = struct {
out_name: []const u8, out_name: []const u8,
/// Library files (.a) to combine. /// Library files (.a) to combine.
sources: []FileSource, sources: []LazyPath,
}; };
/// The step to depend on. /// The step to depend on.
step: *Step, step: *Step,
/// The output file from the libtool run. /// The output file from the libtool run.
output: FileSource, output: LazyPath,
/// Run libtool against a list of library files to combine into a single /// Run libtool against a list of library files to combine into a single
/// static library. /// static library.
@ -33,7 +33,7 @@ pub fn create(b: *std.Build, opts: Options) *LibtoolStep {
const run_step = RunStep.create(b, b.fmt("libtool {s}", .{opts.name})); const run_step = RunStep.create(b, b.fmt("libtool {s}", .{opts.name}));
run_step.addArgs(&.{ "libtool", "-static", "-o" }); run_step.addArgs(&.{ "libtool", "-static", "-o" });
const output = run_step.addOutputFileArg(opts.out_name); const output = run_step.addOutputFileArg(opts.out_name);
for (opts.sources) |source| run_step.addFileSourceArg(source); for (opts.sources) |source| run_step.addFileArg(source);
self.* = .{ self.* = .{
.step = &run_step.step, .step = &run_step.step,

View File

@ -3,9 +3,9 @@
const LipoStep = @This(); const LipoStep = @This();
const std = @import("std"); const std = @import("std");
const Step = std.build.Step; const Step = std.Build.Step;
const RunStep = std.build.RunStep; const RunStep = std.Build.Step.Run;
const FileSource = std.build.FileSource; const LazyPath = std.Build.LazyPath;
pub const Options = struct { pub const Options = struct {
/// The name of the xcframework to create. /// The name of the xcframework to create.
@ -15,14 +15,14 @@ pub const Options = struct {
out_name: []const u8, out_name: []const u8,
/// Library file (dylib, a) to package. /// Library file (dylib, a) to package.
input_a: FileSource, input_a: LazyPath,
input_b: FileSource, input_b: LazyPath,
}; };
step: *Step, step: *Step,
/// Resulting binary /// Resulting binary
output: FileSource, output: LazyPath,
pub fn create(b: *std.Build, opts: Options) *LipoStep { pub fn create(b: *std.Build, opts: Options) *LipoStep {
const self = b.allocator.create(LipoStep) catch @panic("OOM"); const self = b.allocator.create(LipoStep) catch @panic("OOM");
@ -30,8 +30,8 @@ pub fn create(b: *std.Build, opts: Options) *LipoStep {
const run_step = RunStep.create(b, b.fmt("lipo {s}", .{opts.name})); const run_step = RunStep.create(b, b.fmt("lipo {s}", .{opts.name}));
run_step.addArgs(&.{ "lipo", "-create", "-output" }); run_step.addArgs(&.{ "lipo", "-create", "-output" });
const output = run_step.addOutputFileArg(opts.out_name); const output = run_step.addOutputFileArg(opts.out_name);
run_step.addFileSourceArg(opts.input_a); run_step.addFileArg(opts.input_a);
run_step.addFileSourceArg(opts.input_b); run_step.addFileArg(opts.input_b);
self.* = .{ self.* = .{
.step = &run_step.step, .step = &run_step.step,

View File

@ -4,9 +4,9 @@
const XCFrameworkStep = @This(); const XCFrameworkStep = @This();
const std = @import("std"); const std = @import("std");
const Step = std.build.Step; const Step = std.Build.Step;
const RunStep = std.build.RunStep; const RunStep = std.Build.Step.Run;
const FileSource = std.build.FileSource; const LazyPath = std.Build.LazyPath;
pub const Options = struct { pub const Options = struct {
/// The name of the xcframework to create. /// The name of the xcframework to create.
@ -16,10 +16,10 @@ pub const Options = struct {
out_path: []const u8, out_path: []const u8,
/// Library file (dylib, a) to package. /// Library file (dylib, a) to package.
library: std.build.FileSource, library: LazyPath,
/// Path to a directory with the headers. /// Path to a directory with the headers.
headers: std.build.FileSource, headers: LazyPath,
}; };
step: *Step, step: *Step,
@ -42,9 +42,9 @@ pub fn create(b: *std.Build, opts: Options) *XCFrameworkStep {
run.has_side_effects = true; run.has_side_effects = true;
run.addArgs(&.{ "xcodebuild", "-create-xcframework" }); run.addArgs(&.{ "xcodebuild", "-create-xcframework" });
run.addArg("-library"); run.addArg("-library");
run.addFileSourceArg(opts.library); run.addFileArg(opts.library);
run.addArg("-headers"); run.addArg("-headers");
run.addFileSourceArg(opts.headers); run.addFileArg(opts.headers);
run.addArg("-output"); run.addArg("-output");
run.addArg(opts.out_path); run.addArg(opts.out_path);
break :run run; break :run run;