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

Compile.getCompileDependencies
pub fn getCompileDependencies(
    arena: Allocator,
    module_graph: *ModuleGraph,
    conf: *const Configuration,
    start: Configuration.Step.Index,
    chase_dynamic: bool,
) ![]const Configuration.Step.Index

File

lib/compiler/Maker/Step/Compile.zig:1156

Code

pub fn getCompileDependencies(
    arena: Allocator,
    module_graph: *ModuleGraph,
    conf: *const Configuration,
    start: Configuration.Step.Index,
    chase_dynamic: bool,
) ![]const Configuration.Step.Index {
    var compiles: std.array_hash_map.Auto(Configuration.Step.Index, void) = .empty;
    var compiles_i: usize = 0;

    try compiles.putNoClobber(arena, start, {});

    while (compiles_i < compiles.count()) : (compiles_i += 1) {
        const step = compiles.keys()[compiles_i].ptr(conf);
        const compile = step.extended.get(conf.extra).compile;
        const modules = try getModuleList(arena, module_graph, compile.root_module, conf);

        for (modules.keys()) |mod_index| {
            const mod = mod_index.get(conf);
            for (0..mod.link_objects.len) |i| {
                switch (mod.link_objects.get(conf.extra, i)) {
                    .other_step => |other_compile_index| {
                        const other_compile = other_compile_index.ptr(conf).extended.get(conf.extra).compile;
                        if (!chase_dynamic and other_compile.isDynamicLibrary()) continue;
                        try compiles.put(arena, other_compile_index, {});
                    },
                    else => {},
                }
            }
        }
    }

    return compiles.keys();
}