feat(macos): port Ghostty's macOS code paths (Metal, CoreText, Darwin)
Ports the macOS-specific Zig code behind cfg(target_os = "macos"): - renderer: a GraphicsApi trait with generic::Renderer<G>; Metal backend (all renderer/metal/* files, shaders.metal verbatim, runtime library compile, IOSurface layer, CVDisplayLink), shadertoy -> MSL via naga; OpenGL remains the backend elsewhere. - font: CoreText face, shaper and discovery with build.rs backend selection (coretext default; coretext-freetype / coretext-harfbuzz / coretext-noshape features), no fontconfig/freetype/harfbuzz on Apple. - input: KeymapDarwin via UCKeyTranslate, option-as-alt, mac keycodes. - os: macos, mach, cf_release_thread, NSProcessInfo args and macOS branches; config: macOS defaults, keybinds, Application Support paths. - termio/core: login(1) wrapping, openpty/execvpe, Darwin child exit handling, os_log logging. Compile-checked for aarch64/x86_64-apple-darwin (clippy -D warnings clean) using the cross setup in docs/rewrite/notes/macos-M1.md; cannot run here. The embedded runtime/C API (embedded.zig) is the next step. Also includes the cross-platform integration edits shared by the crash, verification, Windows and macOS work (Cargo target-gating, thread crash-context hooks, apprt-gtk surface/IME refactor, termio/os cfg gates), a cfg fix so ghostty-config builds on wasm32, and an allow for the intentional recursion in the crash overflow test. Test Plan: - cargo test --workspace (3224 passed) - cargo clippy --workspace --all-targets -- -D warnings - cargo check --target aarch64-apple-darwin -p ghostty-renderer (with the documented cross env)
This commit is contained in:
1 parent
3c8fae1089
commit
452b782149
124 files changed
+14936
-1242
No files matched your search
@@ -0,0 +1,60 @@
|
||||
//! Emits the font backend `cfg`s (port of `font/backend.zig`'s `Backend`
|
||||
//! helpers `hasFreetype`/`hasCoretext`/`hasFontconfig`/`hasHarfbuzz`).
|
||||
//!
|
||||
//! Backends (see `src/backend.rs`):
|
||||
//! * Linux & other non-Apple, non-wasm targets: `fontconfig_freetype`.
|
||||
//! * wasm32: `web_canvas`.
|
||||
//! * Apple targets: `coretext` (default), or via cargo features
|
||||
//! `coretext-freetype`, `coretext-harfbuzz`, `coretext-noshape`.
|
||||
//!
|
||||
//! Emitted cfgs:
|
||||
//! * `font_freetype` - FreeType face / library are compiled.
|
||||
//! * `font_fontconfig` - fontconfig discovery is compiled.
|
||||
//! * `font_harfbuzz` - the HarfBuzz shaper is compiled.
|
||||
//! * `font_coretext` - CoreText discovery/deferred face (Apple targets).
|
||||
//! * `font_coretext_face` - the CoreText `Face` is the font face.
|
||||
//! * `font_coretext_shaper` - the CoreText shaper is the shaper.
|
||||
//! * `font_noshape` - the no-op shaper is the shaper.
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
for c in [
|
||||
"font_freetype",
|
||||
"font_fontconfig",
|
||||
"font_harfbuzz",
|
||||
"font_coretext",
|
||||
"font_coretext_face",
|
||||
"font_coretext_shaper",
|
||||
"font_noshape",
|
||||
] {
|
||||
println!("cargo:rustc-check-cfg=cfg({c})");
|
||||
}
|
||||
|
||||
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
|
||||
let vendor = std::env::var("CARGO_CFG_TARGET_VENDOR").unwrap_or_default();
|
||||
let feat = |n: &str| std::env::var_os(format!("CARGO_FEATURE_{n}")).is_some();
|
||||
|
||||
let wasm = arch == "wasm32";
|
||||
let apple = vendor == "apple";
|
||||
let ct_ft = feat("CORETEXT_FREETYPE");
|
||||
let ct_hb = feat("CORETEXT_HARFBUZZ");
|
||||
let ct_noshape = feat("CORETEXT_NOSHAPE");
|
||||
|
||||
let on = |c: &str, v: bool| {
|
||||
if v {
|
||||
println!("cargo:rustc-cfg={c}");
|
||||
}
|
||||
};
|
||||
|
||||
let freetype = !wasm && (!apple || ct_ft);
|
||||
let harfbuzz = !wasm && (!apple || ct_ft || ct_hb);
|
||||
on("font_freetype", freetype);
|
||||
on("font_fontconfig", !wasm && !apple);
|
||||
on("font_harfbuzz", harfbuzz);
|
||||
on("font_coretext", apple);
|
||||
on("font_coretext_face", apple && !ct_ft);
|
||||
// The shaper is CoreText only for the plain `coretext` backend;
|
||||
// `coretext_noshape` uses the no-op shaper.
|
||||
on("font_coretext_shaper", apple && !harfbuzz && !ct_noshape);
|
||||
on("font_noshape", apple && !harfbuzz && ct_noshape);
|
||||
}
|
||||
Reference in new issue
Block a user