| author | |
| committer | |
| log | a717ac0340b6d177e4f02d96dff5418e6961391c |
| tree | 91f439cc2a723360be25ea198943641d04272fde |
| parent | 604a332e21f9aaff13c7b13331d9c6926c6c9d52 |
5 files changed, 56 insertions(+), 0 deletions(-)
test/standalone/build.zig.zon+3| ... | @@ -86,6 +86,9 @@ | ... | @@ -86,6 +86,9 @@ |
| 86 | .dirname = .{ | 86 | .dirname = .{ |
| 87 | .path = "dirname", | 87 | .path = "dirname", |
| 88 | }, | 88 | }, |
| 89 | .dep_duplicate_module = .{ | ||
| 90 | .path = "dep_duplicate_module", | ||
| 91 | }, | ||
| 89 | .empty_env = .{ | 92 | .empty_env = .{ |
| 90 | .path = "empty_env", | 93 | .path = "empty_env", |
| 91 | }, | 94 | }, |
test/standalone/dep_duplicate_module/build.zig created+32| ... | @@ -0,0 +1,32 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | pub fn build(b: *std.Build) void { | ||
| 4 | const target = b.standardTargetOptions(.{}); | ||
| 5 | const optimize = b.standardOptimizeOption(.{}); | ||
| 6 | |||
| 7 | const mod = b.addModule("mod", .{ | ||
| 8 | .root_source_file = .{ .path = "mod.zig" }, | ||
| 9 | .target = target, | ||
| 10 | .optimize = optimize, | ||
| 11 | }); | ||
| 12 | |||
| 13 | const lib = b.addStaticLibrary(.{ | ||
| 14 | .name = "lib", | ||
| 15 | .root_source_file = .{ .path = "lib.zig" }, | ||
| 16 | .target = target, | ||
| 17 | .optimize = optimize, | ||
| 18 | }); | ||
| 19 | lib.root_module.addImport("mod", mod); | ||
| 20 | |||
| 21 | const exe = b.addExecutable(.{ | ||
| 22 | .name = "app", | ||
| 23 | .root_source_file = .{ .path = "main.zig" }, | ||
| 24 | .target = target, | ||
| 25 | .optimize = optimize, | ||
| 26 | }); | ||
| 27 | |||
| 28 | exe.root_module.addImport("mod", mod); | ||
| 29 | exe.root_module.linkLibrary(lib); | ||
| 30 | |||
| 31 | b.installArtifact(exe); | ||
| 32 | } | ||
test/standalone/dep_duplicate_module/lib.zig created+6| ... | @@ -0,0 +1,6 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const mod = @import("mod"); | ||
| 3 | |||
| 4 | export fn work(x: u32) u32 { | ||
| 5 | return mod.double(x); | ||
| 6 | } | ||
test/standalone/dep_duplicate_module/main.zig created+8| ... | @@ -0,0 +1,8 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const mod = @import("mod"); | ||
| 3 | |||
| 4 | extern fn work(x: u32) u32; | ||
| 5 | |||
| 6 | pub fn main() !void { | ||
| 7 | _ = work(mod.half(25)); | ||
| 8 | } | ||
test/standalone/dep_duplicate_module/mod.zig created+7| ... | @@ -0,0 +1,7 @@ | ||
| 1 | pub fn double(v: u32) u32 { | ||
| 2 | return v * 2; | ||
| 3 | } | ||
| 4 | |||
| 5 | pub fn half(v: u32) u32 { | ||
| 6 | return v / 2; | ||
| 7 | } | ||