diff options
| -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 { |
