//! Captures the compiler version for `+version` (Zig: `builtin.zig_version_string`). use std::process::Command; fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-env-changed=RUSTC"); let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".into()); let version = Command::new(rustc) .arg("--version") .output() .ok() .and_then(|o| String::from_utf8(o.stdout).ok()) // "rustc 1.99.0 (b940084d7 2026-09-28)" -> "1.99.0" .and_then(|s| s.split_whitespace().nth(1).map(str::to_owned)) .unwrap_or_else(|| "unknown".into()); println!("cargo:rustc-env=GHOSTTY_RUSTC_VERSION={version}"); }