aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManlio Perillo <[email protected]>2023-05-07 20:01:02 +0200
committerManlio Perillo <[email protected]>2023-05-09 11:07:22 +0200
commit4ae67ebf1b7027cf33ecd96317d745ccf54987fb (patch)
tree97be010b1a92f0a379260f98b074e188cb53de1b
parent185a40eb75689005ace380c7dc9501db4cafe33a (diff)
downloadziglings-4ae67ebf1b7027cf33ecd96317d745ccf54987fb.tar.xz
ziglings-4ae67ebf1b7027cf33ecd96317d745ccf54987fb.zip
build: don't install skipped exercises
Update the code in `zig build install` and `zig build -Dn=n install`, so that exercises that must be skipped are not installed, since it will cause an error. Ensure that a skip message is printed.
-rw-r--r--build.zig16
1 files changed, 12 insertions, 4 deletions
diff --git a/build.zig b/build.zig
index 68f43eb..e6f2688 100644
--- a/build.zig
+++ b/build.zig
@@ -133,17 +133,20 @@ pub fn build(b: *Build) !void {
print("unknown exercise number: {}\n", .{n});
std.os.exit(1);
}
-
const ex = exercises[n - 1];
const build_step = ex.addExecutable(b, work_path);
- b.installArtifact(build_step);
+
+ 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) {
- const skip_step = SkipStep.create(b, ex);
test_step.dependOn(&skip_step.step);
} else {
test_step.dependOn(&run_step.step);
@@ -201,7 +204,12 @@ pub fn build(b: *Build) !void {
var prev_step = &header_step.step;
for (exercises) |ex| {
const build_step = ex.addExecutable(b, work_path);
- b.installArtifact(build_step);
+
+ const skip_step = SkipStep.create(b, ex);
+ if (!ex.skip)
+ b.installArtifact(build_step)
+ else
+ b.getInstallStep().dependOn(&skip_step.step);
const verify_stepn = ZiglingStep.create(b, ex, work_path);
verify_stepn.step.dependOn(prev_step);