Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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

dependencyLazy

Public Function
std.Build.dependencyLazy
pub fn dependencyLazy(b: *Build, name: []const u8, args: anytype) error

Declares that the current configuration does in fact require a potentially lazy dependency.

If the dependency is already fetched, it is returned. However if the dependency is not yet fetched, then when the build script is finished running, the toolchain will not proceed to the make phase. Instead, the parent process will additionally fetch all the lazy dependencies that were actually required by running the build script, recompile the build script, and then run it again. In other words, if this function returns error.LazyDependencyNeeded it means that the only purpose of completing the configure phase is to find out all the other lazy dependencies that are also required. In this case, one must propagate the error all the way up and return it from the main build function.

For non-lazy dependencies, this always succeeds.

Params

  • b: *Build
  • name: []const u8
  • args

File

Build.zig:1963
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
pub fn dependencyLazy(b: *Build, name: []const u8, args: anytype) error{LazyDependencyNeeded}!*Dependency {
    const pkg_hash = findPkgHashOrFatal(b, name);
    const entry = package_map.get(pkg_hash) orelse unreachable;
    if (!entry.available) {
        markNeededLazyDep(b, pkg_hash);
        return error.LazyDependencyNeeded;
    }
    var map: PackageOptions.Map = .empty;
    PackageOptions.fromArgs(b.graph.arena, &map, args);
    return dependencyResolved(b, name, entry, &map);
}