diff --git a/lib/std/Build.zig b/lib/std/Build.zig index fc22deea06411de705d0a364486764bb0ba97c37..5516a5555645c04683ecddaac467fc7a0bd114ff 100644 --- a/lib/std/Build.zig +++ b/lib/std/Build.zig @@ -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"); diff --git a/test/standalone/build.zig.zon b/test/standalone/build.zig.zon index 8f5a061fe2e074dc0000590f2a9ab38a21143bf5..a307c0a528df1fa4f1f7ba315786177bab0a4360 100644 --- a/test/standalone/build.zig.zon +++ b/test/standalone/build.zig.zon @@ -158,6 +158,9 @@ .install_headers = .{ .path = "install_headers", }, + .dependencyFromBuildZig = .{ + .path = "dependencyFromBuildZig", + }, }, .paths = .{ "build.zig", diff --git a/test/standalone/dependencyFromBuildZig/build.zig b/test/standalone/dependencyFromBuildZig/build.zig new file mode 100644 index 0000000000000000000000000000000000000000..f02140327f794fd83fc88788828ebc093fc58034 --- /dev/null +++ b/test/standalone/dependencyFromBuildZig/build.zig @@ -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")); +} diff --git a/test/standalone/dependencyFromBuildZig/build.zig.zon b/test/standalone/dependencyFromBuildZig/build.zig.zon new file mode 100644 index 0000000000000000000000000000000000000000..085ae2c80b45d4393640895dda8a8f9e4c39db35 --- /dev/null +++ b/test/standalone/dependencyFromBuildZig/build.zig.zon @@ -0,0 +1,10 @@ +.{ + .name = "dependencyFromBuildZig", + .version = "0.0.0", + .dependencies = .{ + .other = .{ + .path = "other", + }, + }, + .paths = .{""}, +} diff --git a/test/standalone/dependencyFromBuildZig/other/add.zig b/test/standalone/dependencyFromBuildZig/other/add.zig new file mode 100644 index 0000000000000000000000000000000000000000..d850921cac801538f878a129a6b5cb73338d2655 --- /dev/null +++ b/test/standalone/dependencyFromBuildZig/other/add.zig @@ -0,0 +1,3 @@ +pub fn add(x: u32, y: u32) u32 { + return x + y; +} diff --git a/test/standalone/dependencyFromBuildZig/other/build.zig b/test/standalone/dependencyFromBuildZig/other/build.zig new file mode 100644 index 0000000000000000000000000000000000000000..7aac0387f903b4782901df25ccc47535ca5f0f50 --- /dev/null +++ b/test/standalone/dependencyFromBuildZig/other/build.zig @@ -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"), + }); +} diff --git a/test/standalone/dependencyFromBuildZig/other/build.zig.zon b/test/standalone/dependencyFromBuildZig/other/build.zig.zon new file mode 100644 index 0000000000000000000000000000000000000000..204abdbbba3d5361a66a24ebc5c2454f437f9a7a --- /dev/null +++ b/test/standalone/dependencyFromBuildZig/other/build.zig.zon @@ -0,0 +1,6 @@ +.{ + .name = "other", + .version = "0.0.0", + .dependencies = .{}, + .paths = .{""}, +}