mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 23:22:44 +00:00
std: fix and add test for Build.dependencyFromBuildZig
This commit is contained in:
parent
21a6a1b0f2
commit
0820aa4a46
@ -1974,7 +1974,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");
|
||||
|
@ -158,6 +158,9 @@
|
||||
.install_headers = .{
|
||||
.path = "install_headers",
|
||||
},
|
||||
.dependencyFromBuildZig = .{
|
||||
.path = "dependencyFromBuildZig",
|
||||
},
|
||||
},
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
|
16
test/standalone/dependencyFromBuildZig/build.zig
Normal file
16
test/standalone/dependencyFromBuildZig/build.zig
Normal file
@ -0,0 +1,16 @@
|
||||
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 build_runner = @import("root");
|
||||
const deps = build_runner.dependencies;
|
||||
const zon_decls = @typeInfo(deps.packages).Struct.decls;
|
||||
const pkg = @field(deps.packages, zon_decls[0].name);
|
||||
const dep2 = b.dependencyFromBuildZig(pkg.build_zig, .{});
|
||||
|
||||
std.debug.assert(dep1.module("add") == dep2.module("add"));
|
||||
}
|
10
test/standalone/dependencyFromBuildZig/build.zig.zon
Normal file
10
test/standalone/dependencyFromBuildZig/build.zig.zon
Normal file
@ -0,0 +1,10 @@
|
||||
.{
|
||||
.name = "dependencyFromBuildZig",
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{
|
||||
.other = .{
|
||||
.path = "other",
|
||||
},
|
||||
},
|
||||
.paths = .{""},
|
||||
}
|
3
test/standalone/dependencyFromBuildZig/other/add.zig
Normal file
3
test/standalone/dependencyFromBuildZig/other/add.zig
Normal file
@ -0,0 +1,3 @@
|
||||
pub fn add(x: u32, y: u32) u32 {
|
||||
return x + y;
|
||||
}
|
7
test/standalone/dependencyFromBuildZig/other/build.zig
Normal file
7
test/standalone/dependencyFromBuildZig/other/build.zig
Normal 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"),
|
||||
});
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
.{
|
||||
.name = "other",
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{},
|
||||
.paths = .{""},
|
||||
}
|
Loading…
Reference in New Issue
Block a user