aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/build.zig
diff options
context:
space:
mode:
authorDave Gauer <dave@ratfactor.com>2023-05-08 09:20:27 -0400
committerDave Gauer <dave@ratfactor.com>2023-05-08 09:20:27 -0400
commitc4f2c6253424b848b3d5f6c7f915f61bd5d46cf0 (patch)
tree1eed553bbc2f369965d65640af32adf4291874f9 /build.zig
parentded01c6adf111a03f6b627fdc4dc85b51c13da3a (diff)
Cleaning up zig build output
* Only show actual Zig compiler errors, not build internals to confused and dismay. * Remove advanced usage instructions not needed in normal operation.
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig58
1 files changed, 35 insertions, 23 deletions
diff --git a/build.zig b/build.zig
index 802f2f5..5168d3d 100644
--- a/build.zig
+++ b/build.zig
@@ -107,7 +107,6 @@ pub fn build(b: *Build) !void {
}
const logo =
- \\
\\ _ _ _
\\ ___(_) __ _| (_)_ __ __ _ ___
\\ |_ | |/ _' | | | '_ \ / _' / __|
@@ -115,6 +114,8 @@ pub fn build(b: *Build) !void {
\\ /___|_|\__, |_|_|_| |_|\__, |___/
\\ |___/ |___/
\\
+ \\ "Look out! Broken programs below!"
+ \\
\\
;
@@ -255,18 +256,24 @@ const ZiglingStep = struct {
const exe_path = self.compile(prog_node) catch {
if (self.exercise.hint) |hint|
- print("\n{s}HINT: {s}{s}", .{ bold_text, hint, reset_text });
+ print("\n{s}Ziglings hint: {s}{s}", .{ bold_text, hint, reset_text });
self.help();
- std.os.exit(1);
+
+ // NOTE: Returning 0 'success' status because the *exercise* failed,
+ // but Ziglings did not. Otherwise the learner will see this message:
+ // "error: the following build command failed with exit code 1:..."
+ std.os.exit(0);
};
self.run(exe_path, prog_node) catch {
if (self.exercise.hint) |hint|
- print("\n{s}HINT: {s}{s}", .{ bold_text, hint, reset_text });
+ print("\n{s}Ziglings hint: {s}{s}", .{ bold_text, hint, reset_text });
self.help();
- std.os.exit(1);
+
+ // NOTE: See note above!
+ std.os.exit(0);
};
}
@@ -393,11 +400,12 @@ const ZiglingStep = struct {
print("\n", .{});
},
error.ZigIPCError => {
- print("{s}{s}: The following command failed to communicate the compilation result:{s}\n", .{
- red_text, self.exercise.main_file, reset_text,
- });
- for (argv) |v| print("{s} ", .{v});
- print("\n", .{});
+ // Commenting this out for now. It always shows up when compilation fails.
+ //print("{s}{s}: The following command failed to communicate the compilation result:{s}\n", .{
+ // red_text, self.exercise.main_file, reset_text,
+ //});
+ //for (argv) |v| print("{s} ", .{v});
+ //print("\n", .{});
},
else => {
print("{s}{s}: Unexpected error: {s}{s}\n", .{
@@ -517,20 +525,22 @@ const ZiglingStep = struct {
fn help(self: *ZiglingStep) void {
const path = self.exercise.main_file;
- const key = self.exercise.key();
print("\n{s}Edit exercises/{s} and run 'zig build' again.{s}\n", .{
red_text, path, reset_text,
});
- const format =
- \\
- \\{s}To compile only this exercise, you can also use this command:{s}
- \\{s}zig build -Dn={s}{s}
- \\
- \\
- ;
- print(format, .{ red_text, reset_text, bold_text, key, reset_text });
+ // NOTE: The README explains this "advanced feature" if anyone wishes to use
+ // it. Otherwise, beginners are thinking they *have* to do this.
+ //const key = self.exercise.key();
+ //const format =
+ // \\
+ // \\{s}To compile only this exercise, you can also use this command:{s}
+ // \\{s}zig build -Dn={s}{s}
+ // \\
+ // \\
+ //;
+ //print(format, .{ red_text, reset_text, bold_text, key, reset_text });
}
fn printErrors(self: *ZiglingStep) void {
@@ -687,10 +697,12 @@ const exercises = [_]Exercise{
.output = "Hello world!",
.hint =
\\DON'T PANIC!
- \\Read the error above.
- \\See how it has something to do with 'main'?
- \\Open up the source file as noted and read the comments.
- \\You can do this!
+ \\Read the compiler messages above. (Something about 'main'?)
+ \\Open up the source file as noted below and read the comments.
+ \\
+ \\(Hints like these will occasionally show up, but for the
+ \\most part, you'll be taking directions from the Zig
+ \\compiler itself.)
\\
,
},