feat(lib): port libghostty, Ghostty's embedded C API

Ports apprt/embedded.zig, main_c.zig and config/CApi.zig + c_get.zig as
crates/ghostty-lib (cdylib/staticlib/rlib `libghostty`), exporting every
function of the unchanged include/ghostty.h - the ABI Ghostty's Swift
macOS/iOS app links against. The embedded runtime implements the
runtime traits over the host's C callbacks, so the real core drives it.

- ghostty-core selects the renderer per target: Metal on Apple (surface
  NSView/UIView via RtSurface::platform_view), OpenGL elsewhere.
- ghostty_config_get follows Zig's c_get rules via a CValue type (143
  supported keys, checked against the Zig field types).
- The inspector C API is complete; its Metal backend replaces ImGui's
  Metal renderer and has not run.

Verification: generated C ABI probe (sizeof/alignof/offsetof of every
struct/union, 755 enum values, every function linked, nm exports, headers
byte-identical to upstream); a C host on Linux covering init, CLI
actions, config, app, keys, focus and color scheme; an opt-in
test-platform feature creating real surfaces on Linux with headless EGL
and a pty (13 tests). Apple targets are clippy-clean but not run; the
Swift app has not been built against it.

Test Plan:
- cargo test -p ghostty-lib (and --features test-platform)
- cargo clippy --target aarch64-apple-darwin -p ghostty-lib (cross env
  in docs/rewrite/notes/macos-M1.md)
This commit is contained in:
ddidderr committed 2026-10-12 06:38:33 +02:00
1 parent 4787565397
commit 49d4ecefae
47 files changed
+10296 -34

No files matched your search

Generated
+32
View File
@@ -1345,6 +1345,7 @@ dependencies = [
"ghostty-config",
"ghostty-crash",
"ghostty-font",
"ghostty-helpgen",
"ghostty-input",
"ghostty-os",
"ghostty-vt",
@@ -1390,6 +1391,7 @@ dependencies = [
"ghostty-unicode",
"ghostty-vt",
"log",
"objc2-core-foundation",
"onig",
"oslog",
"png",
@@ -1441,10 +1443,15 @@ dependencies = [
"yeslogic-fontconfig-sys",
]
[[package]]
name = "ghostty-helpgen"
version = "0.1.0"
[[package]]
name = "ghostty-input"
version = "0.1.0"
dependencies = [
"ghostty-helpgen",
"ghostty-unicode",
"ghostty-vt",
"indexmap",
@@ -1466,6 +1473,31 @@ dependencies = [
"log",
]
[[package]]
name = "ghostty-lib"
version = "0.1.0"
dependencies = [
"block2",
"dispatch2",
"ghostty-apprt",
"ghostty-bench",
"ghostty-cli",
"ghostty-config",
"ghostty-core",
"ghostty-input",
"ghostty-inspector",
"ghostty-os",
"ghostty-renderer",
"ghostty-terminal",
"ghostty-vt",
"log",
"objc2",
"objc2-core-foundation",
"objc2-foundation",
"objc2-metal",
"tempfile",
]
[[package]]
name = "ghostty-onig"
version = "0.1.0"