feature. See also
. The project being documented here (as the example) is the Zig library itself.
FindProgram.make
pub fn make(
find_program: *FindProgram,
step_index: Configuration.Step.Index,
maker: *Maker,
progress_node: std.Progress.Node,
) Step.ExtendedMakeError!void
File
Code
pub fn make(
find_program: *FindProgram,
step_index: Configuration.Step.Index,
maker: *Maker,
progress_node: std.Progress.Node,
) Step.ExtendedMakeError!void {
_ = find_program;
_ = progress_node;
const graph = maker.graph;
const step = maker.stepByIndex(step_index);
const arena = graph.arena;
const conf = &maker.scanned_config.configuration;
const conf_step = step_index.ptr(conf);
const conf_fp = conf_step.extended.get(conf.extra).find_program;
const found_path = conf_fp.found_path;
const names = conf_fp.names.slice(conf);
var err_msg: std.ArrayList(u8) = .empty;
try err_msg.appendSlice(arena, "program not found. searched paths:\n");
for (names) |name_index| {
const name = name_index.slice(conf);
if (Io.Dir.path.isAbsolute(name)) {
if (try checkCandidate(maker, step, found_path, &err_msg, name)) return;
continue;
}
for (graph.search_prefixes.items) |search_prefix| {
const full_path = try Io.Dir.path.join(arena, &.{ search_prefix, "bin", name });
if (try checkCandidate(maker, step, found_path, &err_msg, full_path)) return;
}
}
if (graph.environ_map.get("PATH")) |PATH| {
for (names) |name_index| {
const name = name_index.slice(conf);
var it = std.mem.tokenizeScalar(u8, PATH, Io.Dir.path.delimiter);
while (it.next()) |p| {
const full_path = try Io.Dir.path.join(arena, &.{ p, name });
if (try checkCandidate(maker, step, found_path, &err_msg, full_path)) return;
}
}
}
assert(err_msg.items[err_msg.items.len - 1] == '\n');
const chopped = err_msg.items[0 .. err_msg.items.len - 1];
try step.result_error_msgs.append(arena, chopped);
return error.MakeFailed;
}