aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/build/GhosttyZig.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-04-04 19:22:04 +0300
committerCan Celik <ogulcancelik@gmail.com>2026-04-05 01:23:06 +0300
commit41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch)
tree3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/src/build/GhosttyZig.zig
parent55c138263e190a1e79d4b997bfb9397306c0ec1f (diff)
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/src/build/GhosttyZig.zig')
-rw-r--r--vendor/libghostty-vt/src/build/GhosttyZig.zig102
1 files changed, 102 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/build/GhosttyZig.zig b/vendor/libghostty-vt/src/build/GhosttyZig.zig
new file mode 100644
index 00000000..4901180d
--- /dev/null
+++ b/vendor/libghostty-vt/src/build/GhosttyZig.zig
@@ -0,0 +1,102 @@
+//! GhosttyZig generates the Zig modules that Ghostty exports
+//! for downstream usage.
+const GhosttyZig = @This();
+
+const std = @import("std");
+const Config = @import("Config.zig");
+const SharedDeps = @import("SharedDeps.zig");
+const TerminalBuildOptions = @import("../terminal/build_options.zig").Options;
+
+/// The `_c`-suffixed modules are built with the C ABI enabled.
+vt: *std.Build.Module,
+vt_c: *std.Build.Module,
+
+/// Static library paths for vendored SIMD dependencies. Populated
+/// only when the dependencies are built from source (not provided
+/// by the system via -Dsystem-integration). Used to produce a
+/// combined static archive for downstream consumers.
+simd_libs: SharedDeps.LazyPathList,
+
+pub fn init(
+ b: *std.Build,
+ cfg: *const Config,
+ deps: *const SharedDeps,
+) !GhosttyZig {
+ // Terminal module build options
+ var vt_options = cfg.terminalOptions();
+ vt_options.artifact = .lib;
+ // We presently don't allow Oniguruma in our Zig module at all.
+ // We should expose this as a build option in the future so we can
+ // conditionally do this.
+ vt_options.oniguruma = false;
+
+ var simd_libs: SharedDeps.LazyPathList = .empty;
+
+ return .{
+ .vt = try initVt(
+ "ghostty-vt",
+ b,
+ cfg,
+ deps,
+ vt_options,
+ null,
+ ),
+
+ .vt_c = try initVt(
+ "ghostty-vt-c",
+ b,
+ cfg,
+ deps,
+ options: {
+ var dup = vt_options;
+ dup.c_abi = true;
+ break :options dup;
+ },
+ &simd_libs,
+ ),
+
+ .simd_libs = simd_libs,
+ };
+}
+
+fn initVt(
+ name: []const u8,
+ b: *std.Build,
+ cfg: *const Config,
+ deps: *const SharedDeps,
+ vt_options: TerminalBuildOptions,
+ simd_libs: ?*SharedDeps.LazyPathList,
+) !*std.Build.Module {
+ // General build options
+ const general_options = b.addOptions();
+ try cfg.addOptions(general_options);
+
+ const vt = b.addModule(name, .{
+ .root_source_file = b.path("src/lib_vt.zig"),
+ .target = cfg.target,
+ .optimize = cfg.optimize,
+
+ // SIMD require libc/libcpp (both) but otherwise we don't care.
+ // On MSVC, we must not use linkLibCpp because Zig passes
+ // -nostdinc++ and adds its bundled libc++/libc++abi headers
+ // which conflict with MSVC's C++ runtime. The MSVC SDK dirs
+ // added via link_libc contain both C and C++ headers.
+ .link_libc = if (cfg.simd) true else null,
+ .link_libcpp = if (cfg.simd and cfg.target.result.abi != .msvc) true else null,
+ });
+ vt.addOptions("build_options", general_options);
+ vt_options.add(b, vt);
+
+ // We always need unicode tables
+ deps.unicode_tables.addModuleImport(vt);
+
+ // We need uucode for grapheme break support
+ deps.addUucode(b, vt, cfg.target, cfg.optimize);
+
+ // If SIMD is enabled, add all our SIMD dependencies.
+ if (cfg.simd) {
+ try SharedDeps.addSimd(b, vt, simd_libs);
+ }
+
+ return vt;
+}