diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-04-04 19:22:04 +0300 |
|---|---|---|
| committer | Can Celik <ogulcancelik@gmail.com> | 2026-04-05 01:23:06 +0300 |
| commit | 41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch) | |
| tree | 3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/src/build/GhosttyFrameData.zig | |
| parent | 55c138263e190a1e79d4b997bfb9397306c0ec1f (diff) | |
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/src/build/GhosttyFrameData.zig')
| -rw-r--r-- | vendor/libghostty-vt/src/build/GhosttyFrameData.zig | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/build/GhosttyFrameData.zig b/vendor/libghostty-vt/src/build/GhosttyFrameData.zig new file mode 100644 index 00000000..8469759f --- /dev/null +++ b/vendor/libghostty-vt/src/build/GhosttyFrameData.zig @@ -0,0 +1,75 @@ +//! GhosttyFrameData generates a compressed file and zig module which contains (and exposes) the +//! Ghostty animation frames for use in `ghostty +boo` +const GhosttyFrameData = @This(); + +const std = @import("std"); +const DistResource = @import("GhosttyDist.zig").Resource; + +/// The output path for the compressed framedata zig file +output: std.Build.LazyPath, + +pub fn init(b: *std.Build) !GhosttyFrameData { + const dist = distResources(b); + + // Generate the Zig source file that embeds the compressed data + const wf = b.addWriteFiles(); + _ = wf.addCopyFile(dist.framedata.path(b), "framedata.compressed"); + const zig_file = wf.add("framedata.zig", + \\//! This file is auto-generated. Do not edit. + \\ + \\pub const compressed = @embedFile("framedata.compressed"); + \\ + ); + + return .{ .output = zig_file }; +} + +/// Add the "framedata" import. +pub fn addImport(self: *const GhosttyFrameData, step: *std.Build.Step.Compile) void { + self.output.addStepDependencies(&step.step); + step.root_module.addAnonymousImport("framedata", .{ + .root_source_file = self.output, + }); +} + +/// Creates the framedata resources that can be prebuilt for our dist build. +pub fn distResources(b: *std.Build) struct { + framedata: DistResource, +} { + const exe = b.addExecutable(.{ + .name = "framegen", + .root_module = b.createModule(.{ + .target = b.graph.host, + }), + }); + exe.addCSourceFile(.{ + .file = b.path("src/build/framegen/main.c"), + .flags = &.{}, + }); + exe.linkLibC(); + + if (b.systemIntegrationOption("zlib", .{})) { + exe.linkSystemLibrary2("zlib", .{ + .preferred_link_mode = .dynamic, + .search_strategy = .mode_first, + }); + } else { + if (b.lazyDependency("zlib", .{ + .target = b.graph.host, + .optimize = .ReleaseFast, + })) |zlib_dep| { + exe.linkLibrary(zlib_dep.artifact("z")); + } + } + + const run = b.addRunArtifact(exe); + run.addDirectoryArg(b.path("src/build/framegen/frames")); + const compressed_file = run.addOutputFileArg("framedata.compressed"); + + return .{ + .framedata = .{ + .dist = "src/build/framegen/framedata.compressed", + .generated = compressed_file, + }, + }; +} |
