authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-10-14 19:00:42-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-10-14 19:00:42-07:00
logf6a00a4751c7d49f7a4406e9c640ebaee85662f9
tree46e0c3f57a4d7e352c7cb478a1573b64e6842c93
parent6cecad145d569bf9794760ca13bd2bf479a357c7

Maker: guard project id construction with have_manifest


2 files changed, 40 insertions(+), 36 deletions(-)

lib/compiler/Maker.zig+26-24
...@@ -1446,32 +1446,34 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig {...@@ -1446,32 +1446,34 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig {
1446 }1446 }
1447 if (!f.has_build_zig) continue;1447 if (!f.has_build_zig) continue;
14481448
1449 const project_id: Package.ProjectId = .init(f.manifest.name, f.manifest.id);1449 if (f.have_manifest) {
1450 if (fork_set.getKeyPtrAdapted(project_id, @as(Fetch.JobQueue.Fork.Adapter, .{}))) |fork| {1450 const project_id: Package.ProjectId = .init(f.manifest.name, f.manifest.id);
1451 const path = try fork.path.toString(arena);1451 if (fork_set.getKeyPtrAdapted(project_id, @as(Fetch.JobQueue.Fork.Adapter, .{}))) |fork| {
1452 const gop = deps_mod.deps.getOrPutAssumeCapacity(path);1452 const path = try fork.path.toString(arena);
1453 if (gop.found_existing) {1453 const gop = deps_mod.deps.getOrPutAssumeCapacity(path);
1454 assert(fork.uses > 1);1454 if (gop.found_existing) {
1455 f.cli_module = gop.value_ptr.*;1455 assert(fork.uses > 1);
1456 } else {1456 f.cli_module = gop.value_ptr.*;
1457 const m = try arena.create(CliModule);1457 } else {
1458 m.* = .{1458 const m = try arena.create(CliModule);
1459 .root_path = try f.package_root.toString(arena),1459 m.* = .{
1460 .name = path,1460 .root_path = try f.package_root.toString(arena),
1461 };1461 .name = path,
1462 gop.value_ptr.* = m;1462 };
1463 f.cli_module = m;1463 gop.value_ptr.* = m;
1464 f.cli_module = m;
1465 }
1466 continue;
1464 }1467 }
1465 } else {
1466 const hash_slice = try arena.dupe(u8, hash.toSlice());
1467 const m = try arena.create(CliModule);
1468 m.* = .{
1469 .root_path = try f.package_root.toString(arena),
1470 .name = hash_slice,
1471 };
1472 deps_mod.deps.putAssumeCapacityNoClobber(hash_slice, m);
1473 f.cli_module = m;
1474 }1468 }
1469 const hash_slice = try arena.dupe(u8, hash.toSlice());
1470 const m = try arena.create(CliModule);
1471 m.* = .{
1472 .root_path = try f.package_root.toString(arena),
1473 .name = hash_slice,
1474 };
1475 deps_mod.deps.putAssumeCapacityNoClobber(hash_slice, m);
1476 f.cli_module = m;
1475 }1477 }
14761478
1477 // Each build.zig module needs access to each of its dependencies' build.zig modules by1479 // Each build.zig module needs access to each of its dependencies' build.zig modules by
lib/compiler/Maker/Fetch.zig+14-12
...@@ -289,19 +289,21 @@ pub const JobQueue = struct {...@@ -289,19 +289,21 @@ pub const JobQueue = struct {
289 \\289 \\
290 , .{std.fmt.alt(fetch.package_root, .formatEscapeString)});290 , .{std.fmt.alt(fetch.package_root, .formatEscapeString)});
291291
292 if (fetch.has_build_zig) {292 if (fetch.has_build_zig) b: {
293 const project_id: Package.ProjectId = .init(fetch.manifest.name, fetch.manifest.id);293 if (fetch.have_manifest) {
294 if (jq.fork_set.getKeyPtrAdapted(project_id, @as(JobQueue.Fork.Adapter, .{}))) |fork| {294 const project_id: Package.ProjectId = .init(fetch.manifest.name, fetch.manifest.id);
295 try w.print(295 if (jq.fork_set.getKeyPtrAdapted(project_id, @as(JobQueue.Fork.Adapter, .{}))) |fork| {
296 \\ pub const build_zig = @import({qf});296 try w.print(
297 \\297 \\ pub const build_zig = @import({qf});
298 , .{fork.path});298 \\
299 } else {299 , .{fork.path});
300 try w.print(300 }
301 \\ pub const build_zig = @import({q});301 break :b;
302 \\
303 , .{hash_slice});
304 }302 }
303 try w.print(
304 \\ pub const build_zig = @import({q});
305 \\
306 , .{hash_slice});
305 }307 }
306308
307 if (fetch.have_manifest) {309 if (fetch.have_manifest) {