Files
ghostty/src/build/GhosttyFrameData.zig
Chris Marchesi e8525c0fd9 Update to Zig 0.16.0
This commit represents the majority of the work necessary to upgrade
Ghostty to use Zig 0.16.0.

Key parts:

* In addition to its previous responsibilities, the global state now
  houses state for global I/O implementations and the process
  environment. It is now also utilized in the main application along
  with the C library. Where necessary, global state is isolated from key
  parts of the implementation (e.g., in libghostty subsystems), and it's
  expected that this list will grow.

* We currently manage our own C translation layer where necessary. In
  these cases, cImport has been removed in favor of the new external
  translate-c package. Due to fixes that have needed be made to properly
  translate the dependencies that were swapped out, as mentioned, we
  have had to backport fixes from the current translate-c package (and
  the upstream Arocc dependency). We will host this ourselves until Zig
  0.17.0 is released with these fixes.

* Where necessary (only a small number of cases), some stdlib code from
  0.15.2 (and even from 0.17.0) has been taken, adopted, and vendored in
  lib/compat.

Co-authored-by: Leah Amelia Chen <hi@pluie.me>
2026-07-21 12:35:05 -07:00

76 lines
2.3 KiB
Zig

//! 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,
.link_libc = true,
}),
});
exe.root_module.addCSourceFile(.{
.file = b.path("src/build/framegen/main.c"),
.flags = &.{},
});
if (b.systemIntegrationOption("zlib", .{})) {
exe.root_module.linkSystemLibrary("zlib", .{
.preferred_link_mode = .dynamic,
.search_strategy = .mode_first,
});
} else {
if (b.lazyDependency("zlib", .{
.target = b.graph.host,
.optimize = .ReleaseFast,
})) |zlib_dep| {
exe.root_module.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,
},
};
}