build: replace lib-vt step with -Demit-lib-vt option

Remove the dedicated `zig build lib-vt` step and replace it with a
`-Demit-lib-vt` build option. This fixes two problems:

1. We can default XCFramework, app, etc. steps to false if emit-lib-vt
   is true, so that the lib-vt build doesn't pull in unrelated
   artifacts. **Most importantly, lib-vt alone can be build without
   full Xcode installations.**

2. We can build lib-vt as part of a bundle with other artifacts if we
   really want.
This commit is contained in:
Mitchell Hashimoto
2026-03-20 20:59:27 -07:00
parent e8fb7eabad
commit 3fc04fd4ae
9 changed files with 43 additions and 40 deletions

View File

@@ -51,6 +51,7 @@ emit_bench: bool = false,
emit_docs: bool = false,
emit_exe: bool = false,
emit_helpgen: bool = false,
emit_lib_vt: bool = false,
emit_macos_app: bool = false,
emit_terminfo: bool = false,
emit_termcap: bool = false,
@@ -314,11 +315,17 @@ pub fn init(b: *std.Build, appVersion: []const u8) !Config {
//---------------------------------------------------------------
// Artifacts to Emit
config.emit_lib_vt = b.option(
bool,
"emit-lib-vt",
"Set defaults for a libghostty-vt-only build (disables xcframework, macOS app, and docs).",
) orelse false;
config.emit_exe = b.option(
bool,
"emit-exe",
"Build and install main executables with 'build'",
) orelse true;
) orelse !config.emit_lib_vt;
config.emit_test_exe = b.option(
bool,
@@ -352,7 +359,8 @@ pub fn init(b: *std.Build, appVersion: []const u8) !Config {
// If we are emitting any other artifacts then we default to false.
if (config.emit_bench or
config.emit_test_exe or
config.emit_helpgen) break :emit_docs false;
config.emit_helpgen or
config.emit_lib_vt) break :emit_docs false;
// We always emit docs in system package mode.
if (system_package) break :emit_docs true;
@@ -401,7 +409,8 @@ pub fn init(b: *std.Build, appVersion: []const u8) !Config {
bool,
"emit-xcframework",
"Build and install the xcframework for the macOS library.",
) orelse builtin.target.os.tag.isDarwin() and
) orelse !config.emit_lib_vt and
builtin.target.os.tag.isDarwin() and
target.result.os.tag == .macos and
config.app_runtime == .none and
(!config.emit_bench and
@@ -412,7 +421,7 @@ pub fn init(b: *std.Build, appVersion: []const u8) !Config {
bool,
"emit-macos-app",
"Build and install the macOS app bundle.",
) orelse config.emit_xcframework;
) orelse !config.emit_lib_vt and config.emit_xcframework;
//---------------------------------------------------------------
// System Packages

View File

@@ -29,8 +29,9 @@ pub fn init(b: *std.Build, cfg: *const Config, deps: *const SharedDeps) !Ghostty
// Set PIE if requested
if (cfg.pie) exe.pie = true;
// Add the shared dependencies
_ = try deps.add(exe);
// Add the shared dependencies. When building only lib-vt we skip
// heavy deps so cross-compilation doesn't pull in GTK, etc.
if (!cfg.emit_lib_vt) _ = try deps.add(exe);
// Check for possible issues
try checkNixShell(exe, cfg);

View File

@@ -121,7 +121,7 @@ pub fn add(
// We don't support cross-compiling to Darwin but due to the way
// lazy dependencies work with Zig, we call this function. So we just
// bail. The build will fail but the build would've failed anyways.
// And this lets other non-platform-specific targets like `lib-vt`
// And this lets other non-platform-specific targets like `-Demit-lib-vt`
// cross-compile properly.
if (!builtin.target.os.tag.isDarwin() and
self.config.target.result.os.tag.isDarwin())