authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-06 14:29:45-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-06 14:29:45-08:00
log9f3b60b23af226c7e62645daa1df27419f0a1b6a
tree829f2d94adae091f3a3ada8b394a4d6ebb99fb77
parent9d0256271758d24354aff7e5ba1d6927f5fe94f9

fetch: ensure that forks are actually used


2 files changed, 25 insertions(+), 0 deletions(-)

src/Package/Fetch.zig+3
......@@ -162,6 +162,7 @@ pub const JobQueue = struct {
162162 path: Cache.Path,
163163 manifest_ast: std.zig.Ast,
164164 manifest: Package.Manifest,
165 uses: usize,
165166
166167 pub const Context = struct {
167168 pub fn hash(_: @This(), a: Fork) u32 {
......@@ -575,6 +576,8 @@ pub fn run(f: *Fetch) RunError!void {
575576 if (remote.hash) |expected_hash| {
576577 const expected_project_id: Package.ProjectId = expected_hash.projectId();
577578 if (job_queue.fork_set.getKeyPtrAdapted(expected_project_id, @as(JobQueue.Fork.Adapter, .{}))) |fork| {
579 log.debug("using fork {f} for {s}", .{ fork.path, fork.manifest.name });
580 fork.uses += 1;
578581 f.package_root = fork.path;
579582 f.manifest_ast = fork.manifest_ast;
580583 f.manifest = fork.manifest;
src/main.zig+22
......@@ -5213,6 +5213,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
52135213 .path = fork.path,
52145214 .manifest_ast = fork.manifest_ast,
52155215 .manifest = fork.manifest,
5216 .uses = 0,
52165217 }, {});
52175218 }
52185219 }
......@@ -5279,6 +5280,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
52795280 .recursive = true,
52805281 .debug_hash = false,
52815282 .unlazy_set = unlazy_set,
5283 .fork_set = fork_set,
52825284 .mode = fetch_mode,
52835285 .prog_node = fetch_prog_node,
52845286 };
......@@ -5344,6 +5346,26 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
53445346 job_queue.group.async(io, Package.Fetch.workerRun, .{ &fetch, "root" });
53455347 try job_queue.group.await(io);
53465348
5349 {
5350 // Ensure that forks were actually used. This is done
5351 // before printing manifest errors because using a fork can
5352 // prevent them.
5353 var any_unused = false;
5354 for (fork_set.keys()) |*fork| {
5355 if (fork.uses == 0) {
5356 std.log.err("fork {f} matched no {s} packages", .{
5357 fork.path, fork.manifest.name,
5358 });
5359 any_unused = true;
5360 } else {
5361 std.log.info("fork {f} matched {d} {s} packages", .{
5362 fork.path, fork.uses, fork.manifest.name,
5363 });
5364 }
5365 }
5366 if (any_unused) process.exit(1);
5367 }
5368
53475369 try job_queue.consolidateErrors();
53485370
53495371 if (fetch.error_bundle.root_list.items.len > 0) {