feat(dist): generate completions, editor syntax, man pages, translations

Ports Ghostty's build-data helpers (main_build_data.zig, src/extra/*,
build/mdgen) as the ghostty-build-data binary: bash/zsh/fish
completions, Vim syntax/ftdetect/ftplugin/compiler, Sublime syntax (also
used by bat), terminfo source and ghostty(1)/ghostty(5) markdown. With
the version set to the installed 1.3.1-arch2, all generated files are
byte-identical to the installed Ghostty's.

- `just docs` renders man pages and HTML with pandoc.
- po/: Ghostty's 29 translation catalogs; `just locales` compiles them
  into the com.mitchellh.ghostty gettext domain.
- `just install PREFIX FLATPAK SYSTEM_PACKAGE` installs everything incl.
  terminfo text/termcap outputs and mirrors GhosttyResources.zig install
  modes (Flatpak D-Bus template without systemd; lib/systemd/user for
  system packages).
- Build metadata (version, tip/stable channel, commit, build mode) is
  derived at build time like build_config.zig; GTK/libadwaita
  compile-time versions come from pkg-config instead of constants.

Test Plan:
- cargo run -p ghostty-build-data -- +bash | diff - \
  /usr/share/bash-completion/completions/ghostty (same for zsh/fish/vim)
- just install /tmp/prefix
This commit is contained in:
ddidderr committed 2026-10-12 04:39:14 +02:00
1 parent b65bfc575c
commit b192fdb046
56 files changed
+12614 -16

No files matched your search

+23 -1
View File
@@ -16,7 +16,7 @@ const CSS: &[&str] = &[
"style-hc.css",
"style-hc-dark.css",
];
// (major, minor, name). The inspector / imgui blueprints are deferred.
// (major, minor, name).
const BLUEPRINTS: &[(u32, u32, &str)] = &[
(1, 0, "clipboard-confirmation-dialog"),
(1, 4, "clipboard-confirmation-dialog"),
@@ -36,9 +36,31 @@ const BLUEPRINTS: &[(u32, u32, &str)] = &[
(1, 5, "title-dialog"),
(1, 5, "window"),
(1, 5, "command-palette"),
(1, 5, "imgui-widget"),
(1, 5, "inspector-widget"),
(1, 5, "inspector-window"),
];
/// Emits `GHOSTTY_<name>_VERSION` with the version of a library as reported
/// by pkg-config (the headers we compile against; Zig reads the same values
/// from the C headers). Falls back to the feature level we require.
fn emit_pkg_version(env_name: &str, pkg: &str, fallback: &str) {
println!("cargo:rerun-if-env-changed=PKG_CONFIG_PATH");
let version = Command::new("pkg-config")
.args(["--modversion", pkg])
.output()
.ok()
.filter(|o| o.status.success())
.and_then(|o| String::from_utf8(o.stdout).ok())
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty())
.unwrap_or_else(|| fallback.to_string());
println!("cargo:rustc-env={env_name}={version}");
}
fn main() {
emit_pkg_version("GHOSTTY_GTK_VERSION", "gtk4", "4.14.0");
emit_pkg_version("GHOSTTY_ADW_VERSION", "libadwaita-1", "1.5.0");
let manifest = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
let out = PathBuf::from(std::env::var("OUT_DIR").unwrap());
let res = manifest.join("resources");
+4 -2
View File
@@ -2,8 +2,10 @@
use crate::gtk_version::Version;
/// The libadwaita feature level this crate is compiled against (`v1_5`).
pub const COMPTIME_VERSION: Version = (1, 5, 0);
/// The libadwaita version this crate is compiled against (pkg-config
/// `libadwaita-1`, see `build.rs`).
pub const COMPTIME_VERSION: Version =
crate::gtk_version::parse_version(env!("GHOSTTY_ADW_VERSION"));
/// Returns the runtime libadwaita version.
#[allow(unsafe_code)]
+25 -5
View File
@@ -1,15 +1,35 @@
//! GTK version helpers (port of `apprt/gtk/gtk_version.zig`).
//!
//! Zig reads the compile-time version from the headers; here it is the
//! version of the gtk4-rs `v4_*` feature level this crate is compiled against
//! (see `Cargo.toml`) combined with the system library detected at runtime.
//! version of the GTK development files reported by pkg-config at build time
//! (see `build.rs`) combined with the system library detected at runtime.
/// A (major, minor, micro) version triple.
pub type Version = (u32, u32, u32);
/// The minimum GTK version this crate is compiled against (feature level
/// `v4_14`). Newer symbols must be guarded with [`at_least`]/feature flags.
pub const COMPTIME_VERSION: Version = (4, 14, 0);
/// The GTK version this crate is compiled against (pkg-config `gtk4`).
/// Newer symbols must still be guarded with [`at_least`]/feature flags.
pub const COMPTIME_VERSION: Version = parse_version(env!("GHOSTTY_GTK_VERSION"));
/// Parses a `major.minor[.micro]` string at compile time.
pub(crate) const fn parse_version(s: &str) -> (u32, u32, u32) {
let b = s.as_bytes();
let mut parts = [0u32; 3];
let mut idx = 0;
let mut i = 0;
while i < b.len() && idx < 3 {
let c = b[i];
if c == b'.' {
idx += 1;
} else if c.is_ascii_digit() {
parts[idx] = parts[idx] * 10 + (c - b'0') as u32;
} else {
break;
}
i += 1;
}
(parts[0], parts[1], parts[2])
}
/// Returns the runtime GTK version.
pub fn get_runtime_version() -> Version {