Skip to content

Commit 0fb0b9d

Browse files
committed
Upgrade build system to 0.14
This is in preparation of 0.15, where the deprecated root_source_file field is removed from std.Build.ExecutableOptions and friends. In the process, I understood a bit more how things work, and properly run _all_ tests, counting the ones in root.zig as well. They should probably be moved these ones.
1 parent 519866c commit 0fb0b9d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

build.zig

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ pub fn build(b: *std.Build) void {
44
const target = b.standardTargetOptions(.{});
55
const optimize = b.standardOptimizeOption(.{});
66

7-
const sqids_module = b.addModule("sqids", .{ .root_source_file = b.path("src/root.zig") });
7+
const sqids_module = b.addModule("sqids", .{
8+
.root_source_file = b.path("src/root.zig"),
9+
.target = target,
10+
.optimize = optimize,
11+
});
812

9-
const tests = b.addTest(.{
13+
const test_module = b.createModule(.{
1014
.root_source_file = b.path("src/tests/tests.zig"),
1115
.target = target,
1216
.optimize = optimize,
1317
});
14-
tests.root_module.addImport("sqids", sqids_module);
18+
test_module.addImport("sqids", sqids_module);
1519

16-
const run_main_tests = b.addRunArtifact(tests);
20+
const tests = b.addTest(.{ .root_module = test_module });
21+
const root_tests = b.addTest(.{ .root_module = sqids_module });
1722

1823
const test_step = b.step("test", "Run library tests");
19-
test_step.dependOn(&run_main_tests.step);
24+
test_step.dependOn(&b.addRunArtifact(tests).step);
25+
test_step.dependOn(&b.addRunArtifact(root_tests).step);
2026
}

0 commit comments

Comments
 (0)