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.
This commit is contained in:
Carl Åstholm 2024-10-22 23:27:16 +02:00 committed by Andrew Kelley
parent e5d9d3f8a1
commit 4fc295dc02

View File

@ -662,6 +662,9 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
// * path-based location is used without a hash.
// - Hash is added to the table based on the path alone before
// calling run(); no need to add it again.
//
// If we add a dep as lazy and then later try to add the same dep as eager,
// eagerness takes precedence and the existing entry is updated.
for (dep_names, deps) |dep_name, dep| {
const new_fetch = &new_fetches[new_fetch_index];
@ -673,7 +676,12 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
const digest_len = @typeInfo(Manifest.MultiHashHexDigest).array.len;
const multihash_digest = h[0..digest_len].*;
const gop = f.job_queue.table.getOrPutAssumeCapacity(multihash_digest);
if (gop.found_existing) continue;
if (gop.found_existing) {
if (!dep.lazy) {
gop.value_ptr.*.lazy_status = .eager;
}
continue;
}
gop.value_ptr.* = new_fetch;
break :h multihash_digest;
},
@ -684,7 +692,12 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
const new_root = try f.package_root.resolvePosix(parent_arena, rel_path);
const multihash_digest = relativePathDigest(new_root, cache_root);
const gop = f.job_queue.table.getOrPutAssumeCapacity(multihash_digest);
if (gop.found_existing) continue;
if (gop.found_existing) {
if (!dep.lazy) {
gop.value_ptr.*.lazy_status = .eager;
}
continue;
}
gop.value_ptr.* = new_fetch;
break :l .{ .relative_path = new_root };
},