From f61eaea4d063c1b0b911594a54a1d8e23cd08611 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 13 Jan 2024 15:29:12 -0800 Subject: [PATCH] build: update our macOS checks to check for macOS specifically --- build.zig | 28 ++++++++++++++++++---------- src/build_config.zig | 8 ++++---- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/build.zig b/build.zig index 898f8d8fe..dbb9ea498 100644 --- a/build.zig +++ b/build.zig @@ -40,10 +40,18 @@ pub fn build(b: *std.Build) !void { const target = target: { var result = b.standardTargetOptions(.{}); - if (result.result.isDarwin()) { - if (result.query.os_version_min == null) { - result.query.os_version_min = .{ .semver = .{ .major = 12, .minor = 0, .patch = 0 } }; - } + // On macOS, we specify a minimum supported version. This is important + // to set since header files will use this to determine the availability + // of certain APIs and I believe it is also encoded in the Mach-O + // binaries. + if (result.result.os.tag == .macos and + result.query.os_version_min == null) + { + result.query.os_version_min = .{ .semver = .{ + .major = 12, + .minor = 0, + .patch = 0, + } }; } break :target result; @@ -261,7 +269,7 @@ pub fn build(b: *std.Build) !void { } // App (Mac) - if (target.result.isDarwin()) { + if (target.result.os.tag == .macos) { const bin_install = b.addInstallFile( exe.getEmittedBin(), "Ghostty.app/Contents/MacOS/ghostty", @@ -282,7 +290,7 @@ pub fn build(b: *std.Build) !void { }); b.getInstallStep().dependOn(&install.step); - if (target.result.isDarwin() and exe_ != null) { + if (target.result.os.tag == .macos and exe_ != null) { const mac_install = b.addInstallDirectory(options: { var copy = install.options; copy.install_dir = .{ @@ -305,7 +313,7 @@ pub fn build(b: *std.Build) !void { }); b.getInstallStep().dependOn(&install.step); - if (target.result.isDarwin() and exe_ != null) { + if (target.result.os.tag == .macos and exe_ != null) { const mac_install = b.addInstallDirectory(options: { var copy = install.options; copy.install_dir = .{ @@ -329,7 +337,7 @@ pub fn build(b: *std.Build) !void { const src_source = wf.add("share/terminfo/ghostty.terminfo", str.items); const src_install = b.addInstallFile(src_source, "share/terminfo/ghostty.terminfo"); b.getInstallStep().dependOn(&src_install.step); - if (target.result.isDarwin() and exe_ != null) { + if (target.result.os.tag == .macos and exe_ != null) { const mac_src_install = b.addInstallFile( src_source, "Ghostty.app/Contents/Resources/terminfo/ghostty.terminfo", @@ -350,7 +358,7 @@ pub fn build(b: *std.Build) !void { const cap_install = b.addInstallFile(out_source, "share/terminfo/ghostty.termcap"); b.getInstallStep().dependOn(&cap_install.step); - if (target.result.isDarwin() and exe_ != null) { + if (target.result.os.tag == .macos and exe_ != null) { const mac_cap_install = b.addInstallFile( out_source, "Ghostty.app/Contents/Resources/terminfo/ghostty.termcap", @@ -379,7 +387,7 @@ pub fn build(b: *std.Build) !void { b.getInstallStep().dependOn(©_step.step); } - if (target.result.isDarwin() and exe_ != null) { + if (target.result.os.tag == .macos and exe_ != null) { const copy_step = RunStep.create(b, "copy terminfo db"); copy_step.addArgs(&.{ "cp", "-R" }); copy_step.addFileArg(path); diff --git a/src/build_config.zig b/src/build_config.zig index 8109cb519..6a9a55085 100644 --- a/src/build_config.zig +++ b/src/build_config.zig @@ -58,15 +58,15 @@ pub const version_string = options.app_version_string; /// building a standalone exe, an embedded lib, etc. pub const artifact = Artifact.detect(); -/// Our build configuration. +/// Our build configuration. We re-export a lot of these back at the +/// top-level so its a bit cleaner to use throughout the code. See the doc +/// comments in BuildConfig for details on each. pub const config = BuildConfig.fromOptions(); +pub const flatpak = options.flatpak; pub const app_runtime: apprt.Runtime = config.app_runtime; pub const font_backend: font.Backend = config.font_backend; pub const renderer: rendererpkg.Impl = config.renderer; -/// We want to integrate with Flatpak APIs. -pub const flatpak = options.flatpak; - pub const Artifact = enum { /// Standalone executable exe,