diff options
| author | Mitchell Hashimoto <m@mitchellh.com> | 2025-09-19 14:23:33 -0700 |
|---|---|---|
| committer | Mitchell Hashimoto <m@mitchellh.com> | 2025-09-19 14:50:33 -0700 |
| commit | bf047032b52401be9bb12ab2ca08fdcb2b0d2ba7 (patch) | |
| tree | 279129b2634b0a745a507d19cf2d73d06300e86e /src/main_build_data.zig | |
| parent | 999b6051459e718a6fb72879f5a7d78630361ebd (diff) | |
build: generate various resources at build run, not build graph
This is stomping towards minimizing our build.zig dependencies so that
it can be cached more often. Right now, touching almost any file in the
project forces the build.zig to rebuild which is destroying my
productivity.
Diffstat (limited to 'src/main_build_data.zig')
| -rw-r--r-- | src/main_build_data.zig | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main_build_data.zig b/src/main_build_data.zig new file mode 100644 index 000000000..13e604389 --- /dev/null +++ b/src/main_build_data.zig @@ -0,0 +1,48 @@ +//! 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() !void { + const alloc = std.heap.c_allocator; + const action_ = try cli.action.detectArgs(Action, alloc); + const action = action_ orelse return error.NoAction; + + // Our output always goes to stdout. + const writer = std.io.getStdOut().writer(); + 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), + } +} |
