Skip to content

Commit 3c22146

Browse files
authored
Merge pull request #19689 from nektro/nektro-patch-29794
std: fix and add test for Build.dependencyFromBuildZig
2 parents 544397c + 1b4ea80 commit 3c22146

File tree

7 files changed

+42
-1
lines changed

7 files changed

+42
-1
lines changed

lib/std/Build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,7 @@ pub fn dependencyFromBuildZig(
19751975
const dep_name = for (b.available_deps) |dep| {
19761976
if (mem.eql(u8, dep[1], pkg_hash)) break dep[1];
19771977
} else break :find_dep;
1978-
return dependencyInner(b, dep_name, pkg.build_root, pkg.build_zig, pkg.deps, args);
1978+
return dependencyInner(b, dep_name, pkg.build_root, pkg.build_zig, pkg_hash, pkg.deps, args);
19791979
}
19801980

19811981
const full_path = b.pathFromRoot("build.zig.zon");

test/standalone/build.zig.zon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@
158158
.install_headers = .{
159159
.path = "install_headers",
160160
},
161+
.dependencyFromBuildZig = .{
162+
.path = "dependencyFromBuildZig",
163+
},
161164
},
162165
.paths = .{
163166
"build.zig",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
const test_step = b.step("test", "Test it");
5+
b.default_step = test_step;
6+
7+
const dep1 = b.dependency("other", .{});
8+
9+
const dep2 = b.dependencyFromBuildZig(@import("other"), .{});
10+
11+
std.debug.assert(dep1.module("add") == dep2.module("add"));
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.{
2+
.name = "dependencyFromBuildZig",
3+
.version = "0.0.0",
4+
.dependencies = .{
5+
.other = .{
6+
.path = "other",
7+
},
8+
},
9+
.paths = .{""},
10+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn add(x: u32, y: u32) u32 {
2+
return x + y;
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
_ = b.addModule("add", .{
5+
.root_source_file = b.path("add.add.zig"),
6+
});
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.{
2+
.name = "other",
3+
.version = "0.0.0",
4+
.dependencies = .{},
5+
.paths = .{""},
6+
}

0 commit comments

Comments
 (0)