diff options
| author | sl0p <sl0p@sl0p.foo> | 2026-08-13 22:00:03 +0200 |
|---|---|---|
| committer | sl0p <sl0p@sl0p.foo> | 2026-08-13 22:00:03 +0200 |
| commit | 2c1b855c3cf8cf8841bf25cd939e478a7f0bfac8 (patch) | |
| tree | 7cd6274303ba1da1f8bd57371aec336dd687fb58 /vendor/libghostty-vt/src/build_config.zig | |
| download | slosh-2c1b855c3cf8cf8841bf25cd939e478a7f0bfac8.tar.gz slosh-2c1b855c3cf8cf8841bf25cd939e478a7f0bfac8.tar.xz slosh-2c1b855c3cf8cf8841bf25cd939e478a7f0bfac8.zip | |
sl0ptty: M0 — libghostty-vt vendored, one pane, compositor, diff renderer
Design contract in DESIGN.md. libghostty-vt vendored fresh from ghostty
main@bedb6f2 (zig 0.16), built to a 14MB static lib.
M0: pty spawn (no libutil), a lib-vt terminal per pane, a screen cell buffer,
a diff emitter that repaints only what changed, raw mode, SIGWINCH, and a
~120Hz frame cap that coalesces pty reads.
Also the seed of the headless harness: --headless dumps the composited screen
without a tty, so composition is testable in milliseconds.
tests/live_m0.py covers what headless cannot: raw mode, the diff emitter,
resize propagation, and the quit path. 6/6 green.
Diffstat (limited to 'vendor/libghostty-vt/src/build_config.zig')
| -rw-r--r-- | vendor/libghostty-vt/src/build_config.zig | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/build_config.zig b/vendor/libghostty-vt/src/build_config.zig new file mode 100644 index 0000000..c19f737 --- /dev/null +++ b/vendor/libghostty-vt/src/build_config.zig @@ -0,0 +1,105 @@ +//! Build options, available at comptime. Used to configure features. This +//! will reproduce some of the fields from builtin and build_options just +//! so we can limit the amount of imports we need AND give us the ability +//! to shim logic and values into them later. +const std = @import("std"); +const builtin = @import("builtin"); +const options = @import("build_options"); +const assert = std.debug.assert; +const apprt = @import("apprt.zig"); +const font = @import("font/main.zig"); +const rendererpkg = @import("renderer.zig"); +const BuildConfig = @import("build/Config.zig"); + +pub const ReleaseChannel = BuildConfig.ReleaseChannel; + +/// The semantic version of this build. +pub const version = options.app_version; +pub const version_string = options.app_version_string; + +/// The release channel for this build. +pub const release_channel = std.meta.stringToEnum(ReleaseChannel, @tagName(options.release_channel)).?; + +/// The optimization mode as a string. +pub const mode_string = mode: { + const m = @tagName(builtin.mode); + if (std.mem.lastIndexOfScalar(u8, m, '.')) |i| break :mode m[i..]; + break :mode m; +}; + +/// The artifact we're producing. This can be used to determine if we're +/// building a standalone exe, an embedded lib, etc. +pub const artifact = Artifact.detect(); + +/// Our build configuration. We re-export a lot of these back at the +/// top-level so its a bit cleaner to use throughout the code. See the doc +/// comments in BuildConfig for details on each. +const config = BuildConfig.fromOptions(); +pub const exe_entrypoint = config.exe_entrypoint; +pub const flatpak = options.flatpak; +pub const snap = options.snap; +pub const app_runtime: apprt.Runtime = config.app_runtime; +pub const font_backend: font.Backend = config.font_backend; +pub const renderer: rendererpkg.Backend = config.renderer; +pub const i18n: bool = config.i18n; + +/// The bundle ID for the app. This is used in many places and is currently +/// hardcoded here. We could make this configurable in the future if there +/// is a reason to do so. +/// +/// On macOS, this must match the App bundle ID. We can get that dynamically +/// via an API but I don't want to pay the cost of that at runtime. +/// +/// On GTK, this should match the various folders with resources. +/// +/// There are many places that don't use this variable so simply swapping +/// this variable is NOT ENOUGH to change the bundle ID. I just wanted to +/// avoid it in Zig coe as much as possible. +pub const bundle_id = "com.mitchellh.ghostty"; + +/// True if we should have "slow" runtime safety checks. The initial motivation +/// for this was terminal page/pagelist integrity checks. These were VERY +/// slow but very thorough. But they made it so slow that the terminal couldn't +/// be used for real work. We'd love to have an option to run a build with +/// safety checks that could be used for real work. This lets us do that. +pub const slow_runtime_safety = std.debug.runtime_safety and switch (builtin.mode) { + .Debug => true, + .ReleaseSafe, + .ReleaseSmall, + .ReleaseFast, + => false, +}; + +pub const Artifact = enum { + /// Standalone executable + exe, + + /// Embeddable library + lib, + + /// The WASM-targeted module. + wasm_module, + + pub fn detect() Artifact { + if (builtin.target.cpu.arch.isWasm()) { + assert(builtin.output_mode == .Obj); + assert(builtin.link_mode == .Static); + return .wasm_module; + } + + return switch (builtin.output_mode) { + .Exe => .exe, + .Lib => .lib, + else => { + @compileLog(builtin.output_mode); + @compileError("unsupported artifact output mode"); + }, + }; + } +}; + +/// True if runtime safety checks are enabled. +pub const is_debug = switch (builtin.mode) { + .Debug, .ReleaseSafe => true, + .ReleaseFast, .ReleaseSmall => false, +}; |
