mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
fix(build): solve issue with building tests on certain apple cpus.
This commit is contained in:
24
build.zig
24
build.zig
@ -3,6 +3,7 @@ const builtin = @import("builtin");
|
|||||||
const fs = std.fs;
|
const fs = std.fs;
|
||||||
const CompileStep = std.Build.Step.Compile;
|
const CompileStep = std.Build.Step.Compile;
|
||||||
const RunStep = std.Build.Step.Run;
|
const RunStep = std.Build.Step.Run;
|
||||||
|
const ResolvedTarget = std.Build.ResolvedTarget;
|
||||||
|
|
||||||
const apprt = @import("src/apprt.zig");
|
const apprt = @import("src/apprt.zig");
|
||||||
const font = @import("src/font/main.zig");
|
const font = @import("src/font/main.zig");
|
||||||
@ -706,10 +707,15 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const test_step = b.step("test", "Run all tests");
|
const test_step = b.step("test", "Run all tests");
|
||||||
const test_filter = b.option([]const u8, "test-filter", "Filter for test");
|
const test_filter = b.option([]const u8, "test-filter", "Filter for test");
|
||||||
|
|
||||||
|
// Force all Mac builds to use a `generic` CPU. This avoids
|
||||||
|
// potential issues with `highway` compile errors due to missing
|
||||||
|
// `arm_neon` features (see for example https://github.com/mitchellh/ghostty/issues/1640).
|
||||||
|
const test_target = if (target.result.os.tag == .macos and builtin.target.isDarwin()) genericMacOSTarget(b) else target;
|
||||||
|
|
||||||
const main_test = b.addTest(.{
|
const main_test = b.addTest(.{
|
||||||
.name = "ghostty-test",
|
.name = "ghostty-test",
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
.root_source_file = .{ .path = "src/main.zig" },
|
||||||
.target = target,
|
.target = test_target,
|
||||||
.filter = test_filter,
|
.filter = test_filter,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -754,6 +760,16 @@ fn osVersionMin(tag: std.Target.Os.Tag) ?std.Target.Query.OsVersion {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a ResolvedTarget for a mac with a `target.result.cpu.model.name` of `generic`.
|
||||||
|
// `b.standardTargetOptions()` returns a more specific cpu like `apple_a15`.
|
||||||
|
fn genericMacOSTarget(b: *std.Build) ResolvedTarget {
|
||||||
|
return b.resolveTargetQuery(.{
|
||||||
|
.cpu_arch = .aarch64,
|
||||||
|
.os_tag = .macos,
|
||||||
|
.os_version_min = osVersionMin(.macos),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a universal macOS libghostty library and returns the path
|
/// Creates a universal macOS libghostty library and returns the path
|
||||||
/// to the final library.
|
/// to the final library.
|
||||||
///
|
///
|
||||||
@ -781,11 +797,7 @@ fn createMacOSLib(
|
|||||||
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 = b.resolveTargetQuery(.{
|
.target = genericMacOSTarget(b),
|
||||||
.cpu_arch = .aarch64,
|
|
||||||
.os_tag = .macos,
|
|
||||||
.os_version_min = osVersionMin(.macos),
|
|
||||||
}),
|
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
lib.bundle_compiler_rt = true;
|
lib.bundle_compiler_rt = true;
|
||||||
|
Reference in New Issue
Block a user