mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-09-22 13:37:37 +00:00
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>
57 lines
1.5 KiB
Zig
57 lines
1.5 KiB
Zig
const HelpStrings = @This();
|
|
|
|
const std = @import("std");
|
|
const Config = @import("Config.zig");
|
|
|
|
/// The "helpgen" exe.
|
|
exe: *std.Build.Step.Compile,
|
|
|
|
/// The output path for the help strings.
|
|
output: std.Build.LazyPath,
|
|
|
|
pub fn init(b: *std.Build, cfg: *const Config) !HelpStrings {
|
|
const exe = b.addExecutable(.{
|
|
.name = "helpgen",
|
|
.root_module = b.createModule(.{
|
|
.root_source_file = b.path("src/helpgen.zig"),
|
|
.target = b.graph.host,
|
|
.strip = false,
|
|
.omit_frame_pointer = false,
|
|
.unwind_tables = .sync,
|
|
}),
|
|
});
|
|
|
|
const help_config = config: {
|
|
var copy = cfg.*;
|
|
copy.exe_entrypoint = .helpgen;
|
|
break :config copy;
|
|
};
|
|
const options = b.addOptions();
|
|
try help_config.addOptions(options);
|
|
exe.root_module.addOptions("build_options", options);
|
|
|
|
const help_run = b.addRunArtifact(exe);
|
|
|
|
// Generated Zig files have to end with .zig
|
|
const wf = b.addWriteFiles();
|
|
const output = wf.addCopyFile(help_run.captureStdOut(.{}), "helpgen.zig");
|
|
|
|
return .{
|
|
.exe = exe,
|
|
.output = output,
|
|
};
|
|
}
|
|
|
|
/// Add the "help_strings" import.
|
|
pub fn addImport(self: *const HelpStrings, step: *std.Build.Step.Compile) void {
|
|
self.output.addStepDependencies(&step.step);
|
|
step.root_module.addAnonymousImport("help_strings", .{
|
|
.root_source_file = self.output,
|
|
});
|
|
}
|
|
|
|
/// Install the help exe
|
|
pub fn install(self: *const HelpStrings) void {
|
|
self.exe.step.owner.installArtifact(self.exe);
|
|
}
|