aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Ã…stholm <carl@astholm.se>2024-10-22 23:27:16 +0200
committerAndrew Kelley <andrew@ziglang.org>2024-11-13 14:59:46 -0800
commit4fc295dc02dd0b311a22b3b8b962015138dde4c9 (patch)
tree7babe71acd0eb0c8d0e91093cff79fe5cec42a18
parente5d9d3f8a128ccf38b7e2f82c6abe70fb34e9eec (diff)
downloadzig-4fc295dc02dd0b311a22b3b8b962015138dde4c9.tar.gz
zig-4fc295dc02dd0b311a22b3b8b962015138dde4c9.zip
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.
-rw-r--r--src/Package/Fetch.zig17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Package/Fetch.zig b/src/Package/Fetch.zig
index 6e7469425b..6017a234e4 100644
--- a/src/Package/Fetch.zig
+++ b/src/Package/Fetch.zig
@@ -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 };
},