authorgravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2024-10-22 23:27:16+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-11-13 14:59:46-08:00
log4fc295dc02dd0b311a22b3b8b962015138dde4c9
tree7babe71acd0eb0c8d0e91093cff79fe5cec42a18
parente5d9d3f8a128ccf38b7e2f82c6abe70fb34e9eec

Take eagerness into account when deduplicating dependencies

If the same dependency is first found as lazy and then later as eager, the existing entry needs to be updated to eager in order for `b.dependency()` to work.

1 files changed, 15 insertions(+), 2 deletions(-)

src/Package/Fetch.zig+15-2
......@@ -662,6 +662,9 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
662662 // * path-based location is used without a hash.
663663 // - Hash is added to the table based on the path alone before
664664 // calling run(); no need to add it again.
665 //
666 // If we add a dep as lazy and then later try to add the same dep as eager,
667 // eagerness takes precedence and the existing entry is updated.
665668
666669 for (dep_names, deps) |dep_name, dep| {
667670 const new_fetch = &new_fetches[new_fetch_index];
......@@ -673,7 +676,12 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
673676 const digest_len = @typeInfo(Manifest.MultiHashHexDigest).array.len;
674677 const multihash_digest = h[0..digest_len].*;
675678 const gop = f.job_queue.table.getOrPutAssumeCapacity(multihash_digest);
676 if (gop.found_existing) continue;
679 if (gop.found_existing) {
680 if (!dep.lazy) {
681 gop.value_ptr.*.lazy_status = .eager;
682 }
683 continue;
684 }
677685 gop.value_ptr.* = new_fetch;
678686 break :h multihash_digest;
679687 },
......@@ -684,7 +692,12 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
684692 const new_root = try f.package_root.resolvePosix(parent_arena, rel_path);
685693 const multihash_digest = relativePathDigest(new_root, cache_root);
686694 const gop = f.job_queue.table.getOrPutAssumeCapacity(multihash_digest);
687 if (gop.found_existing) continue;
695 if (gop.found_existing) {
696 if (!dep.lazy) {
697 gop.value_ptr.*.lazy_status = .eager;
698 }
699 continue;
700 }
688701 gop.value_ptr.* = new_fetch;
689702 break :l .{ .relative_path = new_root };
690703 },