mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-12-22 14:03:10 -05:00
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.
This commit is contained in:
parent
185a40eb75
commit
4ae67ebf1b
1 changed files with 12 additions and 4 deletions
16
build.zig
16
build.zig
|
@ -133,17 +133,20 @@ pub fn build(b: *Build) !void {
|
||||||
print("unknown exercise number: {}\n", .{n});
|
print("unknown exercise number: {}\n", .{n});
|
||||||
std.os.exit(1);
|
std.os.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ex = exercises[n - 1];
|
const ex = exercises[n - 1];
|
||||||
|
|
||||||
const build_step = ex.addExecutable(b, work_path);
|
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 run_step = b.addRunArtifact(build_step);
|
||||||
|
|
||||||
const test_step = b.step("test", b.fmt("Run {s} without checking output", .{ex.main_file}));
|
const test_step = b.step("test", b.fmt("Run {s} without checking output", .{ex.main_file}));
|
||||||
if (ex.skip) {
|
if (ex.skip) {
|
||||||
const skip_step = SkipStep.create(b, ex);
|
|
||||||
test_step.dependOn(&skip_step.step);
|
test_step.dependOn(&skip_step.step);
|
||||||
} else {
|
} else {
|
||||||
test_step.dependOn(&run_step.step);
|
test_step.dependOn(&run_step.step);
|
||||||
|
@ -201,7 +204,12 @@ pub fn build(b: *Build) !void {
|
||||||
var prev_step = &header_step.step;
|
var prev_step = &header_step.step;
|
||||||
for (exercises) |ex| {
|
for (exercises) |ex| {
|
||||||
const build_step = ex.addExecutable(b, work_path);
|
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);
|
const verify_stepn = ZiglingStep.create(b, ex, work_path);
|
||||||
verify_stepn.step.dependOn(prev_step);
|
verify_stepn.step.dependOn(prev_step);
|
||||||
|
|
Loading…
Reference in a new issue