mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
std.Build: add addAnonymousDependency
This is for bypassing the package manager and directly depending on another package via the build system. For this to work the anonymous package must be found on the file system relative to the current package's build.zig.
This commit is contained in:
parent
263aaf0e66
commit
8510f9e2bc
@ -1457,7 +1457,26 @@ pub fn dependency(b: *Build, name: []const u8, args: anytype) *Dependency {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
fn dependencyInner(
|
||||
pub fn anonymousDependency(
|
||||
b: *Build,
|
||||
/// The path to the directory containing the dependency's build.zig file,
|
||||
/// relative to the current package's build.zig.
|
||||
relative_build_root: []const u8,
|
||||
/// A direct `@import` of the build.zig of the dependency.
|
||||
comptime build_zig: type,
|
||||
args: anytype,
|
||||
) *Dependency {
|
||||
const arena = b.allocator;
|
||||
const build_root = b.build_root.join(arena, &.{relative_build_root}) catch @panic("OOM");
|
||||
const name = arena.dupe(u8, relative_build_root) catch @panic("OOM");
|
||||
for (name) |*byte| switch (byte.*) {
|
||||
'/', '\\' => byte.* = '.',
|
||||
else => continue,
|
||||
};
|
||||
return dependencyInner(b, name, build_root, build_zig, args);
|
||||
}
|
||||
|
||||
pub fn dependencyInner(
|
||||
b: *Build,
|
||||
name: []const u8,
|
||||
build_root_string: []const u8,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user