diff options
| author | Gabriel Schneider <[email protected]> | 2026-08-16 15:49:12 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-18 23:44:42 -0300 |
| commit | 1551e409c31992437cb2fa864f576d45c8433801 (patch) | |
| tree | e2fae8451f87b735a1360c7c2e383fdc40165789 /tools | |
| parent | be2a9957708cbf0c478ca861c4a1f0f227bbfe10 (diff) | |
| download | pardes-1551e409c31992437cb2fa864f576d45c8433801.tar.gz pardes-1551e409c31992437cb2fa864f576d45c8433801.zip | |
big slow change: prebuilt shaders (SPIR-V/Metal), core gui reflow, docs, web + snapshot refresh
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/embed_zig_sources.zig | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/tools/embed_zig_sources.zig b/tools/embed_zig_sources.zig index 9934d09a..91fd128f 100644 --- a/tools/embed_zig_sources.zig +++ b/tools/embed_zig_sources.zig @@ -1,8 +1,9 @@ //! Build-time generator for the web LOOK filesystem. //! -//! Prefer `git ls-files` so ignored build/cache/vendor files never leak into -//! the browser bundle. A source archive should still be buildable without Git, -//! so a conservative directory walk is the fallback. +//! Prefer Git's tracked-plus-untracked/nonignored view so a new source works in +//! the browser before it is staged, while ignored build/cache/vendor files can +//! never leak into the bundle. A source archive should still be buildable +//! without Git, so a conservative directory walk is the fallback. const std = @import("std"); pub fn main(init: std.process.Init) !void { @@ -13,7 +14,7 @@ pub fn main(init: std.process.Init) !void { const root = args[1]; const output_path = args[2]; - const paths = (try gitTrackedZigFiles(gpa, io, root)) orelse try walkedZigFiles(gpa, io, root); + const paths = (try gitWorkingTreeZigFiles(gpa, io, root)) orelse try walkedZigFiles(gpa, io, root); defer { for (paths) |path| gpa.free(path); gpa.free(paths); @@ -32,10 +33,9 @@ pub fn main(init: std.process.Init) !void { for (paths) |path| { const full_path = try std.Io.Dir.path.join(gpa, &.{ root, path }); defer gpa.free(full_path); - // `git ls-files` reports the INDEX, not the working tree, and the two - // disagree the moment a file is moved or deleted without staging it — - // an ordinary mid-edit state, and in a jj-colocated repo the normal one - // until the change is exported. A path that is no longer on disk is + // Cached entries can still name a file moved or deleted without + // staging it—an ordinary mid-edit state, and in a jj-colocated repo the + // normal one until the change is exported. A path no longer on disk is // simply not a source to embed; failing the whole web build over it // means an unrelated refactor breaks a shell it never touched. const contents = std.Io.Dir.cwd().readFileAlloc(io, full_path, gpa, .limited(64 * 1024 * 1024)) catch |err| switch (err) { @@ -58,15 +58,20 @@ pub fn main(init: std.process.Init) !void { try output.writeStreamingAll(io, generated.written()); } -/// Returns null only when Git cannot supply the tracked-file list. Working-tree -/// contents are read later; Git supplies the path filter, not historical blobs. -fn gitTrackedZigFiles( +/// Returns null only when Git cannot supply the working-tree source list. +/// `--cached --others --exclude-standard` includes a newly-created module +/// before it is staged but retains Git's ignore rules. Contents are read later; +/// Git supplies only the path filter, never historical blobs. +fn gitWorkingTreeZigFiles( gpa: std.mem.Allocator, io: std.Io, root: []const u8, ) !?[][]const u8 { const result = std.process.run(gpa, io, .{ - .argv = &.{ "git", "-C", root, "ls-files", "-z", "--", "*.zig" }, + .argv = &.{ + "git", "-C", root, "ls-files", "-z", + "--cached", "--others", "--exclude-standard", "--", "*.zig", + }, .stdout_limit = .limited(16 * 1024 * 1024), .stderr_limit = .limited(1024 * 1024), }) catch return null; |
