Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

dependencyResolved

Build.dependencyResolved
fn dependencyResolved(
    b: *Build,
    name: []const u8,
    entry: PackageEntry,
    user_input_options: UserInputOptionsMap,
) *Dependency

File

lib/std/Build.zig:2364

Code

fn dependencyResolved(
    b: *Build,
    name: []const u8,
    entry: PackageEntry,
    user_input_options: UserInputOptionsMap,
) *Dependency {
    const graph = b.graph;
    const io = graph.io;
    const arena = graph.arena;
    if (graph.dependency_cache.getContext(.{
        .build_root_string = entry.build_root,
        .user_input_options = user_input_options,
    }, .{ .allocator = arena })) |dep| return dep;

    const dep_root: Cache.Path = .{
        .root_dir = .{
            .path = entry.build_root,
            .handle = Io.Dir.cwd().openDir(io, entry.build_root, .{}) catch |err|
                fatal("failed to open {q}: {t}", .{ entry.build_root, err }),
        },
    };

    const sub_builder = b.createChild(name, dep_root, entry.hash, entry.deps, user_input_options) catch @panic("OOM");
    if (entry.run_build) |run_build| {
        run_build(sub_builder);

        if (sub_builder.validateUserInputDidItFail()) {
            std.debug.dumpCurrentStackTrace(.{ .first_address = @returnAddress() });
        }
    }

    const dep = graph.create(Dependency);
    dep.* = .{ .builder = sub_builder };

    graph.dependency_cache.putContext(arena, .{
        .build_root_string = entry.build_root,
        .user_input_options = user_input_options,
    }, dep, .{ .allocator = arena }) catch @panic("OOM");
    return dep;
}