Files
ghostty/src/main_build_data.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

52 lines
1.9 KiB
Zig

//! This CLI is used to generate data that is used by the build process.
//!
//! We used to do this directly in our `build.zig` but the problem with
//! that approach is that any changes to the dependencies of this data would
//! force a rebuild of our build binary. If we're just doing something like
//! running tests and not emitting any of the info below, then that is a
//! complete waste.
const std = @import("std");
const Allocator = std.mem.Allocator;
const cli = @import("cli.zig");
pub const Action = enum {
// Shell completions
bash,
fish,
zsh,
// Editor syntax files
sublime,
@"vim-syntax",
@"vim-ftdetect",
@"vim-ftplugin",
@"vim-compiler",
// Other
terminfo,
};
pub fn main(init: std.process.Init) !void {
const alloc = std.heap.c_allocator;
const action_ = try cli.action.detectArgs(Action, alloc, init.minimal.args);
const action = action_ orelse return error.NoAction;
// Our output always goes to stdout.
var buffer: [1024]u8 = undefined;
var stdout_writer = std.Io.File.stdout().writerStreaming(init.io, &buffer);
const writer = &stdout_writer.interface;
switch (action) {
.bash => try writer.writeAll(@import("extra/bash.zig").completions),
.fish => try writer.writeAll(@import("extra/fish.zig").completions),
.zsh => try writer.writeAll(@import("extra/zsh.zig").completions),
.sublime => try writer.writeAll(@import("extra/sublime.zig").syntax),
.@"vim-syntax" => try writer.writeAll(@import("extra/vim.zig").syntax),
.@"vim-ftdetect" => try writer.writeAll(@import("extra/vim.zig").ftdetect),
.@"vim-ftplugin" => try writer.writeAll(@import("extra/vim.zig").ftplugin),
.@"vim-compiler" => try writer.writeAll(@import("extra/vim.zig").compiler),
.terminfo => try @import("terminfo/ghostty.zig").ghostty.encode(writer),
}
try stdout_writer.end();
}