summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2024-08-09 10:21:08 +0000
committerChris Boesch <chrboesch@noreply.codeberg.org>2024-08-09 10:21:08 +0000
commite2f356d95c08260e14b5f8db26b4f4a3c6a90dba (patch)
tree761b1f5e6859e9fbd0ff79758a26ee83daa27043
parent94d6a4da5f8b79348cd66f0fd2281a7593c91497 (diff)
parent70b0522cb2ab7d886bfd01ec96503b0e21e043a5 (diff)
Merge pull request 'Add build parameter to start at a specific exercise' (#140) from mythmon/ziglings-exercises:build-start-from into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/140
-rw-r--r--README.md8
-rw-r--r--build.zig21
2 files changed, 28 insertions, 1 deletions
diff --git a/README.md b/README.md
index 4336743..5385cff 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ reading these.
## A Note About Versions
**Hint:** To check out Ziglings for a stable release of Zig, you can use
-the appropriate tag.
+the appropriate tag.
The Zig language is under very active development. In order to be
current, Ziglings tracks **development** builds of the Zig
@@ -128,6 +128,12 @@ It can be handy to check just a single exercise:
zig build -Dn=19
```
+Or run all exercises, starting from a specific one:
+
+```
+zig build -Ds=27
+```
+
Or let Ziglings pick an exercise for you:
```
diff --git a/build.zig b/build.zig
index e3fa9ac..abc98b9 100644
--- a/build.zig
+++ b/build.zig
@@ -161,6 +161,7 @@ pub fn build(b: *Build) !void {
const override_healed_path = b.option([]const u8, "healed-path", "Override healed path");
const exno: ?usize = b.option(usize, "n", "Select exercise");
const rand: ?bool = b.option(bool, "random", "Select random exercise");
+ const start: ?usize = b.option(usize, "s", "Start at exercise");
const sep = std.fs.path.sep_str;
const healed_path = if (override_healed_path) |path|
@@ -221,6 +222,26 @@ pub fn build(b: *Build) !void {
return;
}
+ if (start) |s| {
+ if (s == 0 or s > exercises.len - 1) {
+ print("unknown exercise number: {}\n", .{s});
+ std.process.exit(2);
+ }
+ const first = exercises[s - 1];
+ const ziglings_step = b.step("ziglings", b.fmt("Check ziglings starting with {s}", .{first.main_file}));
+ b.default_step = ziglings_step;
+
+ var prev_step = &header_step.step;
+ for (exercises[(s - 1)..]) |ex| {
+ const verify_stepn = ZiglingStep.create(b, ex, work_path, .normal);
+ verify_stepn.step.dependOn(prev_step);
+
+ prev_step = &verify_stepn.step;
+ }
+ ziglings_step.dependOn(prev_step);
+ return;
+ }
+
// Normal build mode: verifies all exercises according to the recommended
// order.
const ziglings_step = b.step("ziglings", "Check all ziglings");