1
0
Fork 0
mirror of https://github.com/ratfactor/ziglings synced 2024-05-26 20:26:03 +02:00

Make "check and halt" the default for zig build NN (#15)

The "start with NN" action is now NN_start.

Also formatting output for improved clarity (hopefully).
This commit is contained in:
Dave Gauer 2021-02-14 16:42:42 -05:00
parent 0d618f4dda
commit 95c8ea3cb3
2 changed files with 24 additions and 18 deletions

View File

@ -38,17 +38,17 @@ $ zig version
Clone this repository with Git:
```bash
git clone https://github.com/ratfactor/ziglings
cd ziglings
$ git clone https://github.com/ratfactor/ziglings
$ cd ziglings
```
Then run `zig build` and follow the instructions to begin!
```bash
zig build
$ zig build
```
## A Note About Compiler Versions
## A Note About Versions
The Zig language is under very active development. Ziglings will attempt to
be current, but not bleeding-edge. However, sometimes fundamental changes
@ -61,25 +61,31 @@ Once you have a version of the Zig compiler that works with your copy of
Ziglings, they'll continue to work together forever. But if you update one,
keep in mind that you may need to also update the other.
## Manual Usage
## Advanced Usage
If you want to run a single file for testing, you can do so with this command:
It can be handy to check just a single exercise or _start_ from a single
exercise:
```bash
zig run exercises/01_hello.zig
zig build 19
zig build 19_start
```
or, alternatively
You can also run without checking for correctness:
```bash
zig build 01_test
```
To verify a single file, use
Or skip the build system entirely and interact directly with the compiler
if you're into that sort of thing:
```bash
zig build 01_only
zig run exercises/01_hello.zig
```
To prepare an executable for debugging, install it to zig-cache/bin with
Calling all wizards: To prepare an executable for debugging, install it
to zig-cache/bin with:
```bash
zig build 01_install

View File

@ -324,7 +324,7 @@ pub fn build(b: *Builder) void {
\\
, .{});
const verify_all = b.step("ziglings", "Verify all ziglings");
const verify_all = b.step("ziglings", "Check all ziglings");
verify_all.dependOn(&header_step.step);
b.default_step = verify_all;
@ -342,21 +342,21 @@ pub fn build(b: *Builder) void {
const key = ex.key();
const named_test = b.step(b.fmt("{s}_test", .{key}), b.fmt("Run {s} without verifying output", .{ex.main_file}));
const named_test = b.step(b.fmt("{s}_test", .{key}), b.fmt("Run {s} without checking output", .{ex.main_file}));
const run_step = build_step.run();
named_test.dependOn(&run_step.step);
const named_install = b.step(b.fmt("{s}_install", .{key}), b.fmt("Install {s} to zig-cache/bin", .{ex.main_file}));
named_install.dependOn(&build_step.install_step.?.step);
const named_verify = b.step(b.fmt("{s}_only", .{key}), b.fmt("Verify {s} only", .{ex.main_file}));
const named_verify = b.step(key, b.fmt("Check {s} only", .{ex.main_file}));
named_verify.dependOn(&verify_step.step);
const chain_verify = b.allocator.create(Step) catch unreachable;
chain_verify.* = Step.initNoOp(.Custom, b.fmt("chain {s}", .{key}), b.allocator);
chain_verify.dependOn(&verify_step.step);
const named_chain = b.step(key, b.fmt("Verify all solutions starting at {s}", .{ex.main_file}));
const named_chain = b.step(b.fmt("{s}_start", .{key}), b.fmt("Check all solutions starting at {s}", .{ex.main_file}));
named_chain.dependOn(&header_step.step);
named_chain.dependOn(chain_verify);
@ -390,7 +390,7 @@ const ZiglingStep = struct {
const self = @fieldParentPtr(@This(), "step", step);
self.makeInternal() catch {
if (self.exercise.hint.len > 0) {
print("\n{s}hint: {s}{s}", .{ bold_text, self.exercise.hint, reset_text });
print("\n{s}HINT: {s}{s}", .{ bold_text, self.exercise.hint, reset_text });
}
print("\n{s}Edit exercises/{s} and run this again.{s}", .{ red_text, self.exercise.main_file, reset_text });
@ -404,7 +404,7 @@ const ZiglingStep = struct {
const exe_file = try self.doCompile();
print("Verifying {s}...\n", .{self.exercise.main_file});
print("Checking {s}...\n", .{self.exercise.main_file});
const cwd = self.builder.build_root;
@ -471,7 +471,7 @@ const ZiglingStep = struct {
return error.InvalidOutput;
}
print("{s}{s}{s}\n", .{ green_text, output, reset_text });
print("{s}PASSED: {s}{s}\n", .{ green_text, output, reset_text });
}
// The normal compile step calls os.exit, so we can't use it as a library :(