| author | |
| committer | |
| log | 2b63ba31e9757347b4e8d10c435396f94367ef45 |
| tree | ee01cc8fc879cbb4029c1ff4c7187f5fb96ded4b |
| parent | d5c1e7f7b1381036f7d98c1944607cb0e1c0d4da |
4 files changed, 43 insertions(+), 0 deletions(-)
test/standalone.zig+4| ... | @@ -258,6 +258,10 @@ pub const build_cases = [_]BuildCase{ | ... | @@ -258,6 +258,10 @@ pub const build_cases = [_]BuildCase{ |
| 258 | .build_root = "test/standalone/ios", | 258 | .build_root = "test/standalone/ios", |
| 259 | .import = @import("standalone/ios/build.zig"), | 259 | .import = @import("standalone/ios/build.zig"), |
| 260 | }, | 260 | }, |
| 261 | .{ | ||
| 262 | .build_root = "test/standalone/depend_on_main_mod", | ||
| 263 | .import = @import("standalone/depend_on_main_mod/build.zig"), | ||
| 264 | }, | ||
| 261 | }; | 265 | }; |
| 262 | 266 | ||
| 263 | const std = @import("std"); | 267 | const std = @import("std"); |
test/standalone/depend_on_main_mod/build.zig created+28| ... | @@ -0,0 +1,28 @@ | ||
| 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 target = b.standardTargetOptions(.{}); | ||
| 8 | const optimize = b.standardOptimizeOption(.{}); | ||
| 9 | |||
| 10 | const exe = b.addExecutable(.{ | ||
| 11 | .name = "depend_on_main_mod", | ||
| 12 | .root_source_file = .{ .path = "src/main.zig" }, | ||
| 13 | .target = target, | ||
| 14 | .optimize = optimize, | ||
| 15 | }); | ||
| 16 | |||
| 17 | const foo_module = b.addModule("foo", .{ | ||
| 18 | .root_source_file = .{ .path = "src/foo.zig" }, | ||
| 19 | }); | ||
| 20 | |||
| 21 | foo_module.addImport("root2", &exe.root_module); | ||
| 22 | exe.root_module.addImport("foo", foo_module); | ||
| 23 | |||
| 24 | const run_cmd = b.addRunArtifact(exe); | ||
| 25 | run_cmd.expectExitCode(0); | ||
| 26 | |||
| 27 | test_step.dependOn(&run_cmd.step); | ||
| 28 | } | ||
test/standalone/depend_on_main_mod/src/foo.zig created+6| ... | @@ -0,0 +1,6 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const assert = std.debug.assert; | ||
| 3 | |||
| 4 | pub fn run() void { | ||
| 5 | comptime assert(@import("root") == @import("root2")); | ||
| 6 | } | ||
test/standalone/depend_on_main_mod/src/main.zig created+5| ... | @@ -0,0 +1,5 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | pub fn main() !void { | ||
| 4 | @import("foo").run(); | ||
| 5 | } | ||