Build system implementation detail.
pub fn dependencyFromBuildZig(
b: *Build,
/// The build.zig struct of the dependency, normally obtained by `@import` of the dependency.
/// If called from the build.zig file itself, use `@This` to obtain a reference to the struct.
comptime build_zig: type,
args: anytype,
) *Dependency
pub fn dependencyFromBuildZig(
b: *Build,
/// The build.zig struct of the dependency, normally obtained by `@import` of the dependency.
/// If called from the build.zig file itself, use `@This` to obtain a reference to the struct.
comptime build_zig: type,
args: anytype,
) *Dependency {
const arena = b.graph.arena;
find_dep: {
const pkg_hash = comptime pkgHashFromBuildZig(build_zig) orelse break :find_dep;
const dep_name = for (b.available_deps) |dep| {
if (mem.eql(u8, dep[1], pkg_hash)) break dep[1];
} else break :find_dep;
const entry = package_map.get(pkg_hash) orelse break :find_dep;
return dependencyResolved(b, dep_name, entry, userInputOptionsFromArgs(arena, args));
}
const full_path = b.root.join(arena, "build.zig.zon") catch @panic("OOM");
panic("{} is not a build.zig struct of a dependency in {f}", .{ build_zig, full_path });
}