Merge pull request #19689 from nektro/nektro-patch-29794

std: fix and add test for Build.dependencyFromBuildZig
This commit is contained in:
Andrew Kelley 2024-04-18 16:38:11 -07:00 committed by GitHub
commit 3c221463fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 42 additions and 1 deletions

View File

@ -1975,7 +1975,7 @@ pub fn dependencyFromBuildZig(
const dep_name = for (b.available_deps) |dep| {
if (mem.eql(u8, dep[1], pkg_hash)) break dep[1];
} else break :find_dep;
return dependencyInner(b, dep_name, pkg.build_root, pkg.build_zig, pkg.deps, args);
return dependencyInner(b, dep_name, pkg.build_root, pkg.build_zig, pkg_hash, pkg.deps, args);
}
const full_path = b.pathFromRoot("build.zig.zon");

View File

@ -158,6 +158,9 @@
.install_headers = .{
.path = "install_headers",
},
.dependencyFromBuildZig = .{
.path = "dependencyFromBuildZig",
},
},
.paths = .{
"build.zig",

View File

@ -0,0 +1,12 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Test it");
b.default_step = test_step;
const dep1 = b.dependency("other", .{});
const dep2 = b.dependencyFromBuildZig(@import("other"), .{});
std.debug.assert(dep1.module("add") == dep2.module("add"));
}

View File

@ -0,0 +1,10 @@
.{
.name = "dependencyFromBuildZig",
.version = "0.0.0",
.dependencies = .{
.other = .{
.path = "other",
},
},
.paths = .{""},
}

View File

@ -0,0 +1,3 @@
pub fn add(x: u32, y: u32) u32 {
return x + y;
}

View File

@ -0,0 +1,7 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
_ = b.addModule("add", .{
.root_source_file = b.path("add.add.zig"),
});
}

View File

@ -0,0 +1,6 @@
.{
.name = "other",
.version = "0.0.0",
.dependencies = .{},
.paths = .{""},
}