| author | |
| committer | |
| log | 5aa35f62c391d34b92445388c5d645d87f9c4621 |
| tree | e04419c70cc8bfd5079420ba7b6b73c85cc02c41 |
| parent | 6235afc63207bae564725adec202fc2e7a3ba930 |
This reverts commit baead472d7641bdd96130354bafadc1fb1ed223b.
Let's go through the proposal process on this one. I want to push back
on this. My position is that, at the very least, a full trace of command
lines of sub-processes should be printed on failure, with the exception
of opt-in flags such as `--prominent-compile-errors`.5 files changed, 1 insertions(+), 58 deletions(-)
lib/std/build.zig-14| ... | @@ -3438,17 +3438,3 @@ test "LibExeObjStep.addPackage" { | ... | @@ -3438,17 +3438,3 @@ test "LibExeObjStep.addPackage" { |
| 3438 | const dupe = exe.packages.items[0]; | 3438 | const dupe = exe.packages.items[0]; |
| 3439 | try std.testing.expectEqualStrings(pkg_top.name, dupe.name); | 3439 | try std.testing.expectEqualStrings(pkg_top.name, dupe.name); |
| 3440 | } | 3440 | } |
| 3441 | |||
| 3442 | /// This exit code from either "zig build" or the build_runner indicates | ||
| 3443 | /// the "full reason" for a build failure has already been reported to stderr. | ||
| 3444 | /// This will prevent 'zig` from piling on errors to the ones reported by the | ||
| 3445 | /// build_runner. | ||
| 3446 | pub const fail_fully_reported_exit_code = 0x3f; | ||
| 3447 | |||
| 3448 | /// Print an error message to stderr and exit with a special exit | ||
| 3449 | /// code that notifies the invoking process that the build error | ||
| 3450 | /// has already been fully reported to stderr. | ||
| 3451 | pub fn fatalFullReport(comptime error_fmt: []const u8, args: anytype) noreturn { | ||
| 3452 | std.log.err(error_fmt, args); | ||
| 3453 | std.os.exit(fail_fully_reported_exit_code); | ||
| 3454 | } |
src/main.zig+1-3| ... | @@ -3616,9 +3616,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi | ... | @@ -3616,9 +3616,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 3616 | .Exited => |code| { | 3616 | .Exited => |code| { |
| 3617 | if (code == 0) return cleanExit(); | 3617 | if (code == 0) return cleanExit(); |
| 3618 | 3618 | ||
| 3619 | if (code == std.build.fail_fully_reported_exit_code) { | 3619 | if (prominent_compile_errors) { |
| 3620 | process.exit(std.build.fail_fully_reported_exit_code); | ||
| 3621 | } else if (prominent_compile_errors) { | ||
| 3622 | fatal("the build command failed with exit code {d}", .{code}); | 3620 | fatal("the build command failed with exit code {d}", .{code}); |
| 3623 | } else { | 3621 | } else { |
| 3624 | const cmd = try std.mem.join(arena, " ", child_argv); | 3622 | const cmd = try std.mem.join(arena, " ", child_argv); |
test/standalone.zig-1| ... | @@ -49,7 +49,6 @@ pub fn addCases(cases: *tests.StandaloneContext) void { | ... | @@ -49,7 +49,6 @@ pub fn addCases(cases: *tests.StandaloneContext) void { |
| 49 | cases.addBuildFile("test/standalone/issue_7030/build.zig", .{}); | 49 | cases.addBuildFile("test/standalone/issue_7030/build.zig", .{}); |
| 50 | cases.addBuildFile("test/standalone/install_raw_hex/build.zig", .{}); | 50 | cases.addBuildFile("test/standalone/install_raw_hex/build.zig", .{}); |
| 51 | cases.addBuildFile("test/standalone/issue_9812/build.zig", .{}); | 51 | cases.addBuildFile("test/standalone/issue_9812/build.zig", .{}); |
| 52 | cases.addBuildFile("test/standalone/fail_full_report/build.zig", .{}); | ||
| 53 | if (builtin.os.tag != .wasi) { | 52 | if (builtin.os.tag != .wasi) { |
| 54 | cases.addBuildFile("test/standalone/load_dynamic_library/build.zig", .{}); | 53 | cases.addBuildFile("test/standalone/load_dynamic_library/build.zig", .{}); |
| 55 | } | 54 | } |
test/standalone/fail_full_report/build.zig deleted-32| ... | @@ -1,32 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const Builder = std.build.Builder; | ||
| 3 | |||
| 4 | pub fn build(b: *Builder) !void { | ||
| 5 | const test_step = b.step("test", "The test"); | ||
| 6 | |||
| 7 | { | ||
| 8 | const run_step = b.addSystemCommand(&[_][]const u8{ | ||
| 9 | b.zig_exe, | ||
| 10 | "build", | ||
| 11 | "--build-file", | ||
| 12 | "build2.zig", | ||
| 13 | }); | ||
| 14 | run_step.stdout_action = .{ .expect_exact = "" }; | ||
| 15 | test_step.dependOn(&run_step.step); | ||
| 16 | } | ||
| 17 | |||
| 18 | { | ||
| 19 | const run_step = b.addSystemCommand(&[_][]const u8{ | ||
| 20 | b.zig_exe, | ||
| 21 | "build", | ||
| 22 | "--build-file", | ||
| 23 | "build2.zig", | ||
| 24 | "-Dbadoption", | ||
| 25 | }); | ||
| 26 | run_step.stderr_action = .{ .expect_exact = "error: got a bad build option!\n" }; | ||
| 27 | run_step.expected_exit_code = std.build.fail_fully_reported_exit_code; | ||
| 28 | test_step.dependOn(&run_step.step); | ||
| 29 | } | ||
| 30 | |||
| 31 | b.default_step.dependOn(test_step); | ||
| 32 | } | ||
test/standalone/fail_full_report/build2.zig deleted-8| ... | @@ -1,8 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const Builder = std.build.Builder; | ||
| 3 | |||
| 4 | pub fn build(b: *Builder) !void { | ||
| 5 | const bad_option = if (b.option(bool, "badoption", "Use this to emulator a bad build option")) |o| o else false; | ||
| 6 | if (bad_option) | ||
| 7 | std.build.fatalFullReport("got a bad build option!", .{}); | ||
| 8 | } | ||