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.

getCompileDependencies

Return the full set of Step.Compile which start depends on, recursively. start itself is always returned as the first element. If chase_dynamic is false, then dynamic libraries are not included, and their dependencies are not considered; if chase_dynamic is true, dynamic libraries are treated the same as other linked Compiles.

Compile.getCompileDependencies
pub fn getCompileDependencies(start: *Compile, chase_dynamic: bool) []const *Compile

File

lib/std/Build/Step/Compile.zig:755

Code

pub fn getCompileDependencies(start: *Compile, chase_dynamic: bool) []const *Compile {
    const arena = start.step.owner.graph.arena;

    var compiles: std.array_hash_map.Auto(*Compile, void) = .empty;
    var next_idx: usize = 0;

    compiles.putNoClobber(arena, start, {}) catch @panic("OOM");

    while (next_idx < compiles.count()) {
        const compile = compiles.keys()[next_idx];
        next_idx += 1;

        for (compile.root_module.getGraph().modules) |mod| {
            for (mod.link_objects.items) |lo| {
                switch (lo) {
                    .other_step => |other_compile| {
                        if (!chase_dynamic and other_compile.isDynamicLibrary()) continue;
                        compiles.put(arena, other_compile, {}) catch @panic("OOM");
                    },
                    else => {},
                }
            }
        }
    }

    return compiles.keys();
}