Files
ghostty-rs/build.rs
T
ddidderr e4cdd8e007 feat(dist): website data, library installs, XCFramework, dist tarball
Closes the remaining artifact rows of the final audit
(docs/rewrite/notes/final-Z4.md):
- webgen: config.mdx, actions.mdx, commands.mdx (byte-identical to
  Zig's webgen output once its missing stdout flush is added)
- `just install-lib`: libghostty (+ ghostty.h, modulemap) and
  libghostty-vt with versioned symlinks, headers and libghostty-vt.pc
- scripts/xcframework.sh: per-arch builds, lipo and
  xcodebuild -create-xcframework for GhosttyKit (dry-run verified only)
- `just install` builds --profile production so the installed app id is
  com.mitchellh.ghostty; other profiles install the -debug id/name
- `just update-translations`: xgettext/msgmerge pipeline; extracted
  msgids equal upstream's .pot (found and fixed an untranslated string
  in the child-exited banner)
- `just dist` / `distcheck`: versioned source tarball with VERSION and a
  prebuilt GTK resource bundle
- Windows: icon, version resource and DPI/common-controls manifest
  embedded via embed-resource, GUI subsystem

Test Plan:
- just install-lib /tmp/p release all && pkg-config --cflags \
  --libs /tmp/p/share/pkgconfig/libghostty-vt.pc
- just distcheck
2026-10-12 08:14:02 +02:00

45 lines
2.0 KiB
Rust

//! Root build script.
//!
//! * Linux: link the final binary with lazy symbol binding. Rust links
//! executables with `-z now` (eager binding) by default. The GTK apprt
//! compiles in code for newer GTK/libadwaita API (e.g. the GTK 4.16 CSS
//! diagnostics) that is only ever called after a runtime `at_least` check,
//! exactly like the Zig build, which links GTK dynamically with lazy
//! binding. With eager binding the dynamic loader would refuse to start the
//! program on an older library that merely lacks such a symbol; with lazy
//! binding the symbol is only resolved if the guarded code actually runs.
//! * Windows (Zig: `GhosttyExe.zig`): use the GUI subsystem and embed
//! `dist/windows/ghostty.rc` (icon, version resource and the manifest that
//! declares per-monitor DPI awareness and the common-controls v6 activation
//! context).
fn main() {
println!("cargo:rerun-if-changed=build.rs");
match std::env::var("CARGO_CFG_TARGET_OS").as_deref() {
Ok("linux") => println!("cargo:rustc-link-arg-bins=-Wl,-z,lazy"),
Ok("windows") => windows(),
_ => {}
}
}
fn windows() {
println!("cargo:rerun-if-changed=dist/windows/ghostty.rc");
println!("cargo:rerun-if-changed=dist/windows/ghostty.ico");
println!("cargo:rerun-if-changed=dist/windows/ghostty.manifest");
// `exe.subsystem = .Windows`.
if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") {
println!("cargo:rustc-link-arg-bins=/SUBSYSTEM:WINDOWS");
println!("cargo:rustc-link-arg-bins=/ENTRY:mainCRTStartup");
} else {
println!("cargo:rustc-link-arg-bins=-Wl,--subsystem,windows");
}
// `exe.addWin32ResourceFile(.{ .file = "dist/windows/ghostty.rc" })`.
// The resource is only linked into the binary targets, not the
// (nonexistent) library target of this package.
embed_resource::compile_for("dist/windows/ghostty.rc", ["ghostty"], embed_resource::NONE)
.manifest_required()
.expect("failed to embed the Windows resource file");
}