From 4ae67ebf1b7027cf33ecd96317d745ccf54987fb Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Sun, 7 May 2023 20:01:02 +0200 Subject: [PATCH] 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. --- build.zig | 16 ++++++++++++---- 1 file 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);