mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
fetch: ensure that forks are actually used
This commit is contained in:
@@ -162,6 +162,7 @@ pub const JobQueue = struct {
|
||||
path: Cache.Path,
|
||||
manifest_ast: std.zig.Ast,
|
||||
manifest: Package.Manifest,
|
||||
uses: usize,
|
||||
|
||||
pub const Context = struct {
|
||||
pub fn hash(_: @This(), a: Fork) u32 {
|
||||
@@ -575,6 +576,8 @@ pub fn run(f: *Fetch) RunError!void {
|
||||
if (remote.hash) |expected_hash| {
|
||||
const expected_project_id: Package.ProjectId = expected_hash.projectId();
|
||||
if (job_queue.fork_set.getKeyPtrAdapted(expected_project_id, @as(JobQueue.Fork.Adapter, .{}))) |fork| {
|
||||
log.debug("using fork {f} for {s}", .{ fork.path, fork.manifest.name });
|
||||
fork.uses += 1;
|
||||
f.package_root = fork.path;
|
||||
f.manifest_ast = fork.manifest_ast;
|
||||
f.manifest = fork.manifest;
|
||||
|
||||
@@ -5213,6 +5213,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
|
||||
.path = fork.path,
|
||||
.manifest_ast = fork.manifest_ast,
|
||||
.manifest = fork.manifest,
|
||||
.uses = 0,
|
||||
}, {});
|
||||
}
|
||||
}
|
||||
@@ -5279,6 +5280,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
|
||||
.recursive = true,
|
||||
.debug_hash = false,
|
||||
.unlazy_set = unlazy_set,
|
||||
.fork_set = fork_set,
|
||||
.mode = fetch_mode,
|
||||
.prog_node = fetch_prog_node,
|
||||
};
|
||||
@@ -5344,6 +5346,26 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
|
||||
job_queue.group.async(io, Package.Fetch.workerRun, .{ &fetch, "root" });
|
||||
try job_queue.group.await(io);
|
||||
|
||||
{
|
||||
// Ensure that forks were actually used. This is done
|
||||
// before printing manifest errors because using a fork can
|
||||
// prevent them.
|
||||
var any_unused = false;
|
||||
for (fork_set.keys()) |*fork| {
|
||||
if (fork.uses == 0) {
|
||||
std.log.err("fork {f} matched no {s} packages", .{
|
||||
fork.path, fork.manifest.name,
|
||||
});
|
||||
any_unused = true;
|
||||
} else {
|
||||
std.log.info("fork {f} matched {d} {s} packages", .{
|
||||
fork.path, fork.uses, fork.manifest.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (any_unused) process.exit(1);
|
||||
}
|
||||
|
||||
try job_queue.consolidateErrors();
|
||||
|
||||
if (fetch.error_bundle.root_list.items.len > 0) {
|
||||
|
||||
Reference in New Issue
Block a user