diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:51:04 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 09:54:56 -0300 |
| commit | 67c738adfb7261cdf65faf042622b1c723a456a5 (patch) | |
| tree | a7da99486fd5a4dde7edba9cf0b284a7f815358c | |
| parent | 2e244415aca9d3ae1936c89d418e912bea8d68cf (diff) | |
| download | pardes-67c738adfb7261cdf65faf042622b1c723a456a5.tar.gz pardes-67c738adfb7261cdf65faf042622b1c723a456a5.zip | |
build: vendoredThemes lists vendor/themes once, into a list it sorts, where it read the directory twice (to count, then to fill); the comment on a file read while configuring moves to configureRead, which it is about
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
| -rw-r--r-- | build.zig | 32 |
1 files changed, 9 insertions, 23 deletions
@@ -1857,11 +1857,6 @@ fn installHome(b: *std.Build, artifact: *std.Build.Step.Compile, home_bin: ?[]co b.getInstallStep().dependOn(©.step); } -/// A file read while configuring, under a package's root. A dependency's is -/// hash-addressed and never changes under the same pin; this repo's are not -/// tracked one by one, since the configure runs again on every build anyway -/// (findProgram and gitCommit poison its cache). -// ponytail: untracked repo reads; b.dependOnFileContents each one if the configure cache ever stays pure. /// ghostty's kitty graphics loader (src/terminal/kitty/graphics_image.zig), /// patched at build time so a fresh fetch keeps it, for what a program in a /// pane may name with t=f, t=t and t=s (test/kitty.zig): @@ -1941,6 +1936,11 @@ fn patchGhosttyKitty(b: *std.Build, io: std.Io, dep: *std.Build.Dependency, vt: vt.root_source_file = files.getDirectory().path(b, "lib_vt.zig"); } +/// A file read while configuring, under a package's root. A dependency's is +/// hash-addressed and never changes under the same pin; this repo's are not +/// tracked one by one, since the configure runs again on every build anyway +/// (findProgram and gitCommit poison its cache). +// ponytail: untracked repo reads; b.dependOnFileContents each one if the configure cache ever stays pure. fn configureRead(b: *std.Build, io: std.Io, root: std.Build.Cache.Path, sub: []const u8, limit: usize) ![]u8 { return root.root_dir.handle.readFileAlloc(io, b.pathJoin(&.{ root.subPathOrDot(), sub }), b.allocator, .limited(limit)); } @@ -2051,34 +2051,20 @@ fn compileGlsl(b: *std.Build, name: []const u8) std.Build.LazyPath { } fn vendoredThemes(b: *std.Build, io: std.Io) []const []const u8 { - var count: usize = 0; - { - var dir = b.root.root_dir.handle.openDir(io, "vendor/themes", .{ .iterate = true }) catch @panic("open vendor/themes"); - defer dir.close(io); - var it = dir.iterate(); - while (it.next(io) catch @panic("read vendor/themes")) |e| { - if (!std.mem.endsWith(u8, e.name, ".toml") and !std.mem.endsWith(u8, e.name, ".json")) continue; - count += 1; - } - } - - const names = b.allocator.alloc([]const u8, count) catch @panic("OOM"); + var names: std.ArrayList([]const u8) = .empty; var dir = b.root.root_dir.handle.openDir(io, "vendor/themes", .{ .iterate = true }) catch @panic("open vendor/themes"); defer dir.close(io); var it = dir.iterate(); - var index: usize = 0; while (it.next(io) catch @panic("read vendor/themes")) |e| { if (!std.mem.endsWith(u8, e.name, ".toml") and !std.mem.endsWith(u8, e.name, ".json")) continue; - names[index] = b.dupe(e.name); - index += 1; + names.append(b.allocator, b.dupe(e.name)) catch @panic("OOM"); } - std.debug.assert(index == names.len); - std.mem.sort([]const u8, names, {}, struct { + std.mem.sort([]const u8, names.items, {}, struct { fn lt(_: void, a: []const u8, c: []const u8) bool { return std.mem.order(u8, a, c) == .lt; } }.lt); - return names; + return names.items; } fn wireCore(m: *std.Build.Module, d: struct { |
