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.

addPathForDynLibs

Run.addPathForDynLibs
fn addPathForDynLibs(
    maker: *Maker,
    arena: Allocator,
    artifact: Configuration.Step.Index,
    environ_map: *process.Environ.Map,
    argv0: []const u8,
) !void

File

Code

fn addPathForDynLibs(
    maker: *Maker,
    arena: Allocator,
    artifact: Configuration.Step.Index,
    environ_map: *process.Environ.Map,
    argv0: []const u8,
) !void {
    const conf = &maker.scanned_config.configuration;
    const graph = maker.graph;
    const use_wine = graph.enable_wine and builtin.os.tag != .windows and std.ascii.endsWithIgnoreCase(argv0, ".exe");
    const path_key = if (use_wine) "WINEPATH" else "PATH";
    const path_delimiter: u8 = if (builtin.os.tag == .windows or use_wine)
        Dir.path.delimiter_windows
    else
        Dir.path.delimiter;

    var module_graph: Step.Compile.ModuleGraph = .empty;
    const compile_deps = try Step.Compile.getCompileDependencies(arena, &module_graph, conf, artifact, true);

    for (compile_deps) |dep_index| {
        const conf_comp_step = dep_index.ptr(conf);
        const conf_comp = conf_comp_step.extended.get(conf.extra).compile;
        const root_module = conf_comp.root_module.get(conf);
        const target = root_module.resolved_target.get(conf).?.result.get(conf);
        if (target.flags.os_tag == .windows and conf_comp.isDynamicLibrary()) {
            const dll_path = try maker.generatedPath(conf_comp.generated_bin.value.?).toString(arena);
            const search_path = Dir.path.dirname(dll_path).?;
            if (environ_map.get(path_key)) |prev_path| {
                const new_path = try arena.print("{s}{c}{s}", .{ prev_path, path_delimiter, search_path });
                try environ_map.put(path_key, new_path);
            } else {
                try environ_map.put(path_key, search_path);
            }
        }
    }
}