fix: Windows core build, embedded init, byte-exact paths, version info

Closes the remaining core/lib/termio/GTK rows (final-Z2.md):
- ghostty-core compiles for Windows (Unix-only exec fields and file
  modes gated); checked with cargo check --target x86_64-pc-windows-gnu.
- Embedded init: ensure_locale, SIGPIPE ignored in ghostty_init for
  C/Swift hosts, Apple crash tags; the argv passed to ghostty_init feeds
  ghostty_config_load_cli_args; ghostty_config_load_file accepts
  non-UTF-8 paths.
- OSC 7 pwd, embedded surface cwd/command/env/initial input,
  ghostty_surface_text and GTK file drops keep raw bytes.
- XTVERSION, TERM_PROGRAM_VERSION, the About dialog and crash metadata
  use ghostty_build_info instead of hardcoded versions.

Test Plan:
- cargo test --workspace (3327 passed)
- cargo clippy --workspace --all-targets -- -D warnings
This commit is contained in:
ddidderr committed 2026-10-12 08:14:02 +02:00
1 parent 8519f1ba1b
commit ebefad5031
30 files changed
+863 -80

No files matched your search

+48 -5
View File
@@ -116,7 +116,7 @@ pub struct GlobalState {
static STATE: OnceLock<GlobalState> = OnceLock::new();
/// Options for [`init`].
#[derive(Clone, Copy, Default)]
#[derive(Clone, Default)]
pub struct InitOptions {
/// A CLI action is being executed: disable stderr logging by default
/// since the action writes to stderr/stdout itself.
@@ -126,6 +126,32 @@ pub struct InitOptions {
/// `apprt.runtime.resourcesDir`, e.g. GTK's Flatpak host path lookup).
/// `None` uses the generic `ghostty_os::resourcesdir::resources_dir`.
pub resources_dir: Option<fn() -> std::io::Result<ResourcesDir>>,
/// Crash reporting metadata (version, build mode, runtime, font backend
/// and renderer tags; Zig: `build_config`). `None` uses
/// [`default_crash_options`].
pub crash: Option<ghostty_crash::Options>,
}
/// Crash metadata for this build when the caller supplies none: the
/// version from the shared build info and the compile-time platform
/// defaults (Metal + CoreText on Apple targets, fontconfig + OpenGL
/// elsewhere).
#[must_use]
pub fn default_crash_options() -> ghostty_crash::Options {
let mut o = ghostty_crash::Options {
release: ghostty_build_info::VERSION_STRING.to_owned(),
build_mode: ghostty_build_info::BUILD_MODE
.trim_start_matches('.')
.to_owned(),
..ghostty_crash::Options::default()
};
if cfg!(target_vendor = "apple") {
"none".clone_into(&mut o.app_runtime);
"coretext".clone_into(&mut o.font_backend);
"metal".clone_into(&mut o.renderer);
}
o
}
/// The global state. If [`init`] was never called, a default state (no
@@ -182,13 +208,17 @@ fn init_with(opts: InitOptions, default_logging: Logging) -> &'static GlobalStat
let rlimits = ResourceLimits::init();
// Initialize our crash reporting.
if let Err(err) = ghostty_crash::init(&ghostty_crash::Options {
release: ghostty_termio::stream_handler::VERSION_STRING.to_owned(),
..ghostty_crash::Options::default()
}) {
let crash_opts = opts.crash.clone().unwrap_or_else(default_crash_options);
if let Err(err) = ghostty_crash::init(&crash_opts) {
log::warn!("sentry init failed, no crash capture available err={err}");
}
// We need to make sure the process locale is set properly. Locale
// affects a lot of behaviors in a shell.
if let Some(locale) = ghostty_os::ensure_locale() {
log::debug!("locale set locale={locale}");
}
// Find our resources directory once for the app so every launch
// hereafter can use this cached value.
let discover = opts
@@ -352,6 +382,19 @@ mod tests {
assert_eq!(log_scope("other::x"), "other");
}
#[test]
fn crash_defaults_use_shared_version() {
let o = default_crash_options();
assert_eq!(o.release, ghostty_build_info::VERSION_STRING);
if cfg!(target_vendor = "apple") {
assert_eq!(o.renderer, "metal");
assert_eq!(o.font_backend, "coretext");
assert_eq!(o.app_runtime, "none");
} else {
assert_eq!(o.renderer, "opengl");
}
}
#[test]
fn logging_parse() {
assert!(Logging::parse("stderr").stderr);