Commit 79440d2b47
Changed files (3)
lib
lib/std/Build/CompileStep.zig
@@ -1888,8 +1888,8 @@ fn make(step: *Step) !void {
try zig_args.append(resolved_args_file);
}
- const output_dir_nl = try builder.execFromStep(zig_args.items, &self.step);
- const build_output_dir = mem.trimRight(u8, output_dir_nl, "\r\n");
+ const output_bin_path = try builder.execFromStep(zig_args.items, &self.step);
+ const build_output_dir = fs.path.dirname(output_bin_path).?;
if (self.output_dir) |output_dir| {
var src_dir = try std.fs.cwd().openIterableDir(build_output_dir, .{});
lib/std/Build.zig
@@ -1154,13 +1154,12 @@ fn allocPrintCmd(ally: Allocator, opt_cwd: ?[]const u8, argv: []const []const u8
for (argv) |arg| {
try buf.writer().print("{s} ", .{arg});
}
- try buf.append('\n');
return buf.toOwnedSlice();
}
fn printCmd(ally: Allocator, cwd: ?[]const u8, argv: []const []const u8) void {
const text = allocPrintCmd(ally, cwd, argv) catch @panic("OOM");
- std.debug.print("{s}", .{text});
+ std.debug.print("{s}\n", .{text});
}
pub fn spawnChildEnvMap(self: *Build, cwd: ?[]const u8, env_map: *const EnvMap, argv: []const []const u8) !void {
@@ -1482,7 +1481,7 @@ pub fn execFromStep(b: *Build, argv: []const []const u8, s: *Step) ![]const u8 {
@panic("TODO handle progress message");
},
.emit_bin_path => {
- @panic("TODO handle emit_bin_path message");
+ result = try b.allocator.dupe(u8, body);
},
_ => {
// Unrecognized message.
@@ -1553,7 +1552,7 @@ fn sendMessage(file: fs.File, tag: std.zig.Client.Message.Tag) !void {
/// a helpful message.
pub fn exec(b: *Build, argv: []const []const u8) []u8 {
if (!process.can_spawn) {
- std.debug.print("unable to spawn the following command: cannot spawn child process\n{s}", .{
+ std.debug.print("unable to spawn the following command: cannot spawn child process\n{s}\n", .{
try allocPrintCmd(b.allocator, null, argv),
});
process.exit(1);
@@ -1562,7 +1561,7 @@ pub fn exec(b: *Build, argv: []const []const u8) []u8 {
var code: u8 = undefined;
return b.execAllowFail(argv, &code, .Inherit) catch |err| {
const printed_cmd = allocPrintCmd(b.allocator, null, argv) catch @panic("OOM");
- std.debug.print("unable to spawn the following command: {s}\n{s}", .{
+ std.debug.print("unable to spawn the following command: {s}\n{s}\n", .{
@errorName(err), printed_cmd,
});
process.exit(1);
lib/build_runner.zig
@@ -364,12 +364,17 @@ fn runStepNames(
}
}
+ // A proper command line application defaults to silently succeeding.
+ // The user may request verbose mode if they have a different preference.
+ if (failure_count == 0 and !b.verbose) return cleanExit();
+
const stderr = std.io.getStdErr();
const total_count = success_count + failure_count + pending_count;
stderr.writer().print("build summary: {d}/{d} steps succeeded; {d} failed\n", .{
success_count, total_count, failure_count,
}) catch {};
+
if (failure_count == 0) return cleanExit();
for (step_stack.items) |s| switch (s.state) {
@@ -493,6 +498,7 @@ fn workerMakeOneStep(
stderr.writeAll("error: ") catch break;
ttyconf.setColor(stderr, .Reset) catch break;
stderr.writeAll(msg) catch break;
+ stderr.writeAll("\n") catch break;
}
}