libghostty-vt-sys: use pkg-config when available#27
Conversation
|
Now I see that this landed upstream: https://github.com/ghostty-org/ghostty/pull/12210/changes |
b948e4b to
01c9182
Compare
|
lets make this an opt-in feature. @domenkozar |
01c9182 to
b04c32c
Compare
I've made it optional if pkg-config is around, do you want to make it a feature to have one dependency less? |
b04c32c to
a2b09ee
Compare
Yes. |
a2b09ee to
430ada0
Compare
|
Done - CI fails because of github errors. |
430ada0 to
a158463
Compare
Add a `pkg-config` cargo feature (off by default) that tries pkg-config first to locate libghostty-vt. If found (e.g. on NixOS where the pkg-config wrapper adds rpath automatically), skip the zig build entirely. Otherwise fall back to building from source. Bump pinned ghostty commit to include ghostty-org/ghostty#12210 which generates libghostty-vt.pc and libghostty-vt-static.pc during the zig build. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a158463 to
7c0d748
Compare
|
Sorry for the delay in the last round of review. Doing it now :) |
Update the checked-in export manifest to match the regenerated bindings from the new Ghostty pin.
Turn off doctests for the generated sys crate so rustdoc stops treating imported C prose from bindgen as runnable Rust examples. The handwritten crate-level docs stay covered elsewhere, while the generated bindings no longer fail cargo test for reasons unrelated to the FFI code itself.
Use Debug formatting for ImageFormat in the Kitty graphics example. The type does not implement Display
Keep an explicit GHOSTTY_SOURCE_DIR override authoritative even when the pkg-config feature is enabled. The build script now checks for GHOSTTY_SOURCE_DIR before probing pkg-config, and the README files now describe the resulting behavior. The pkg-config path remains opt-in, but it is only used when no source override is set.
|
Gonna do one last round of review tomorrow before merging. I expect it to need more edits. FWIW @domenkozar instead of just slopping out a half-assed PR I’d appreciate it if either you use your AI in a more skilful manner, or just open an issue instead. |
|
@domenkozar I'm struggling to see how the rpath stuff applied to libghostty-vt. Isn't rpath for like runtime path detection, i.e dlopen etc. Another thing is that we need stronger compat. guard on the pkg-config path.
This risks turning into link failures for newer symbols or, worse, ABI mismatches. |
rpath isn't just for dlopen — it's the runtime library search path the dynamic loader uses for any DT_NEEDED entry (including normal -lghostty-vt
Given that C API is unstable, I'm not sure if restricting versioning makes sense, but I'm open to change it however you'd like. |
|
Honestly with the C API being unstable, I'm unsure if pkg-config makes sense at all. me and @pluiedev gotta discuss when pre-1.0.0 means a bit more, and the 'guarantees'. i'll come back to this PR |
|
Note that libghostty ships pkg-config, and here we're just consuming it. It's the only way on linux to make packaging sane, but we can maintain our fork if you decide not to use. |
|
Replaced with #29 |

Summary
ghostty-vt.pcso downstream consumers can discover the library via pkg-configTest plan
cargo build)PKG_CONFIG_PATHpoints at the generated.pcfile🤖 Generated with Claude Code