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)
30 lines
1.1 KiB
Rust
30 lines
1.1 KiB
Rust
//! libghostty: the embedded C API of Ghostty (`include/ghostty.h`), ported
|
|
//! from `ZIG/src/main_c.zig`, `ZIG/src/apprt/embedded.zig`,
|
|
//! `ZIG/src/config/CApi.zig` + `c_get.zig`, the C parts of
|
|
//! `ZIG/src/apprt/action.zig` and `ZIG/src/benchmark/CApi.zig`.
|
|
//!
|
|
//! The header is shipped unchanged in `include/`. The exported symbols and
|
|
//! the struct / enum layouts of [`types`] match it exactly (verified by
|
|
//! `tests/abi.rs`).
|
|
//!
|
|
//! Platform gating follows Zig: on Apple targets surfaces render with the
|
|
//! Metal renderer into the host's `NSView` / `UIView`; elsewhere the
|
|
//! platform independent API (config, app, CLI, key translation, ...) works,
|
|
//! but `ghostty_surface_new` fails with `UnsupportedPlatform` (Zig's
|
|
//! `Platform.init`).
|
|
//!
|
|
//! `unsafe` is denied crate wide and allowed (with `SAFETY:` comments) only
|
|
//! in the FFI modules.
|
|
|
|
#![cfg_attr(test, allow(clippy::unwrap_used, clippy::undocumented_unsafe_blocks))]
|
|
|
|
pub mod action_c;
|
|
pub mod benchmark;
|
|
pub mod config_capi;
|
|
pub mod embedded;
|
|
pub mod inspector;
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod inspector_metal;
|
|
pub mod main_c;
|
|
pub mod types;
|