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 standard library. Public Function
Immediately (in the configure phase), searches for an executable on the host that has more than one possible name.
Calling this function poisons the configuration cache, so it is only appropriate when the existence of the program or its output needs to be observed by configuration logic. For more information, see Graph.CachePoison documentation.
Names are searched in order, observing search prefixes first and then PATH environment variable.
Windows file name extensions are searched automatically, respecting the PATHEXT environment variable, so they need not be included in this list. However, even on Windows, the names will be checked without appending extensions first, so that can be used as a priority system.
pubfnfindProgram(b: *Build, options: FindProgramOptions) ?[]constu8 {
constgraph = b.graph;
// Because it observes search prefixes and contents of directories in PATH.graph.poisonCache();
for (options.names) |name| {
if (Io.Dir.path.isAbsolute(name)) {
if (tryFindProgram(b, name)) |found| returnfound;
}
for (graph.search_prefixes.items) |search_prefix| {
constfull_path = b.pathJoin(&.{ search_prefix, "bin", name });
if (tryFindProgram(b, full_path)) |found| returnfound;
}
}
if (b.graph.environ_map.get("PATH")) |PATH| {
for (options.names) |name| {
varit = mem.tokenizeScalar(u8, PATH, Io.Dir.path.delimiter);
while (it.next()) |p| {
constfull_path = b.pathJoin(&.{ p, name });
if (tryFindProgram(b, full_path)) |found| returnfound;
}
}
}
returnnull;
}
Immediately (in the configure phase), searches for an executable on the host that has more than one possible name.
Calling this function poisons the configuration cache, so it is only appropriate when the existence of the program or its output needs to be observed by configuration logic. For more information, see
Graph.CachePoisondocumentation.Names are searched in order, observing search prefixes first and then PATH environment variable.
Windows file name extensions are searched automatically, respecting the PATHEXT environment variable, so they need not be included in this list. However, even on Windows, the names will be checked without appending extensions first, so that can be used as a priority system.
See also:
findProgramLazy