Skip to content

Commit 49fd1ae

Browse files
committed
build: default dependencies to lib-vt mode
Related to ghostty-org#10651 Default Ghostty dependency builds to libghostty-vt-only mode and avoid initializing anything that would trigger broader dependency requirements. The impact of this is that Zig consumers can import ghostty-vt without requiring Xcode on macOS.
1 parent 8eecb8f commit 49fd1ae

3 files changed

Lines changed: 42 additions & 7 deletions

File tree

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
- build-bench
8787
- build-dist
8888
- build-dist-lib-vt
89+
- build-example-zig-vt-macos-no-sdk
8990
- build-examples-zig
9091
- build-examples-cmake
9192
- build-examples-cmake-windows
@@ -239,6 +240,38 @@ jobs:
239240
cd example/${{ matrix.dir }}
240241
nix develop -c zig build
241242
243+
build-example-zig-vt-macos-no-sdk:
244+
name: Example zig-vt (macOS, no SDK)
245+
runs-on: namespace-profile-ghostty-macos-tahoe
246+
needs: test
247+
env:
248+
ZIG_LOCAL_CACHE_DIR: /Users/runner/zig/local-cache
249+
ZIG_GLOBAL_CACHE_DIR: /Users/runner/zig/global-cache
250+
steps:
251+
- name: Checkout code
252+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
253+
254+
- name: Setup Cache
255+
uses: namespacelabs/nscloud-cache-action@c5f8dab7560444c4bf8dbc64f1b203431873c547 # v1.6.1
256+
with:
257+
cache: |
258+
xcode
259+
path: |
260+
/Users/runner/zig
261+
262+
# TODO(tahoe): https://github.com/NixOS/nix/issues/13342
263+
- uses: DeterminateSystems/nix-installer-action@main
264+
with:
265+
determinate: true
266+
- uses: cachix/cachix-action@5f2d7c5294214f71b873db4b969586b980625e71 # v17
267+
with:
268+
name: ghostty
269+
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
270+
271+
- name: Build Example without SDK
272+
working-directory: example/zig-vt
273+
run: nix develop -c env DEVELOPER_DIR=/nonexistent zig build
274+
242275
build-examples-cmake:
243276
strategy:
244277
fail-fast: false

build.zig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ pub fn build(b: *std.Build) !void {
101101
if (config.emit_webdata) webdata.install();
102102

103103
// Ghostty bench tools
104-
const bench = try buildpkg.GhosttyBench.init(b, &deps);
105-
if (config.emit_bench) bench.install();
104+
if (config.emit_bench) {
105+
const bench = try buildpkg.GhosttyBench.init(b, &deps);
106+
bench.install();
107+
}
106108

107109
// Ghostty dist tarball
108110
const dist = try buildpkg.GhosttyDist.init(b, &config);

src/build/Config.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@ pub fn init(b: *std.Build, appVersion: []const u8, libVersion: []const u8) !Conf
7373
// Setup our standard Zig target and optimize options, i.e.
7474
// `-Doptimize` and `-Dtarget`.
7575
const optimize = b.standardOptimizeOption(.{});
76+
77+
// Default dependency builds to libghostty-vt-only mode. Consumers can
78+
// still explicitly disable this to request the full Ghostty build.
79+
const is_dep = b.dep_prefix.len > 0;
7680
const emit_lib_vt = b.option(
7781
bool,
7882
"emit-lib-vt",
7983
"Set defaults for a libghostty-vt-only build (disables xcframework, macOS app, and docs).",
80-
) orelse false;
84+
) orelse is_dep;
8185
const target = target: {
8286
var result = b.standardTargetOptions(.{});
8387

@@ -114,10 +118,6 @@ pub fn init(b: *std.Build, appVersion: []const u8, libVersion: []const u8) !Conf
114118
break :target result;
115119
};
116120

117-
// Detect if Ghostty is a dependency of another project.
118-
// dep_prefix is non-empty when this build is running as a dependency.
119-
const is_dep = b.dep_prefix.len > 0;
120-
121121
// This is set to true when we're building a system package. For now
122122
// this is trivially detected using the "system_package_mode" bool
123123
// but we may want to make this more sophisticated in the future.

0 commit comments

Comments
 (0)