diff options
author | Manlio Perillo <manlio.perillo@gmail.com> | 2023-05-13 13:58:12 +0200 |
---|---|---|
committer | Manlio Perillo <manlio.perillo@gmail.com> | 2023-05-14 17:22:03 +0200 |
commit | dc2539ec4e9435c9c5dec793ca1e5abcd8cd3014 (patch) | |
tree | 65dddf8aecdb6e52c59642206deb91efa580de4c /build.zig | |
parent | ede6671c27d7ede149bed0f0b8519abf2bc94a18 (diff) |
build: simplify the named build mode
Remove the following steps, since they are rarely (if never) used and
only increase the complexity of the `build.zig` file:
- install step (zig build -Dn=n install)
- test step (zig build -Dn=n test)
- start step (zig build -Dn=n start)
The only remaining step is the default zigling step (zig build -Dn=n),
where the user can choose the exercise to solve.
Update the tests. Additionally, update CheckNamedStep and CheckStep so
that they can share the same functions.
Closes #299
Diffstat (limited to 'build.zig')
-rw-r--r-- | build.zig | 44 |
1 files changed, 5 insertions, 39 deletions
@@ -66,6 +66,8 @@ pub const Exercise = struct { } /// Returns the CompileStep for this exercise. + /// + /// TODO: currently this method is no longer used. pub fn addExecutable(self: Exercise, b: *Build, work_path: []const u8) *CompileStep { const path = join(b.allocator, &.{ work_path, self.main_file }) catch @panic("OOM"); @@ -139,57 +141,21 @@ pub fn build(b: *Build) !void { // If the user pass a number for an exercise if (exno) |n| { + // Named build mode: verifies a single exercise. if (n == 0 or n > exercises.len - 1) { print("unknown exercise number: {}\n", .{n}); std.os.exit(2); } const ex = exercises[n - 1]; - const build_step = ex.addExecutable(b, work_path); - - const skip_step = SkipStep.create(b, ex); - if (!ex.skip) - b.installArtifact(build_step) - else - b.getInstallStep().dependOn(&skip_step.step); - - const run_step = b.addRunArtifact(build_step); - - const test_step = b.step( - "test", - b.fmt("Run {s} without checking output", .{ex.main_file}), - ); - if (ex.skip) { - test_step.dependOn(&skip_step.step); - } else { - test_step.dependOn(&run_step.step); - } - - const verify_step = ZiglingStep.create(b, ex, work_path); - const zigling_step = b.step( "zigling", b.fmt("Check the solution of {s}", .{ex.main_file}), ); - zigling_step.dependOn(&verify_step.step); b.default_step = zigling_step; - const start_step = b.step( - "start", - b.fmt("Check all solutions starting at {s}", .{ex.main_file}), - ); - - var prev_step = verify_step; - for (exercises) |exn| { - const nth = exn.number(); - if (nth > n) { - const verify_stepn = ZiglingStep.create(b, exn, work_path); - verify_stepn.step.dependOn(&prev_step.step); - - prev_step = verify_stepn; - } - } - start_step.dependOn(&prev_step.step); + const verify_step = ZiglingStep.create(b, ex, work_path); + zigling_step.dependOn(&verify_step.step); return; } |