authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-02-28 17:15:06-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:13-07:00
log79440d2b470b3906bd87334ecd90b2a0f2cea05b
tree254edd976c4e879872b27c333d80ae0875ed6cbe
parent7a3dabdc4738c2816bede92571ccdf481d400997

std.Build.CompileStep: obtain the build output dir from protocol

Now building successfully works again.

3 files changed, 12 insertions(+), 7 deletions(-)

lib/build_runner.zig+6
......@@ -364,12 +364,17 @@ fn runStepNames(
364364 }
365365 }
366366
367 // A proper command line application defaults to silently succeeding.
368 // The user may request verbose mode if they have a different preference.
369 if (failure_count == 0 and !b.verbose) return cleanExit();
370
367371 const stderr = std.io.getStdErr();
368372
369373 const total_count = success_count + failure_count + pending_count;
370374 stderr.writer().print("build summary: {d}/{d} steps succeeded; {d} failed\n", .{
371375 success_count, total_count, failure_count,
372376 }) catch {};
377
373378 if (failure_count == 0) return cleanExit();
374379
375380 for (step_stack.items) |s| switch (s.state) {
......@@ -493,6 +498,7 @@ fn workerMakeOneStep(
493498 stderr.writeAll("error: ") catch break;
494499 ttyconf.setColor(stderr, .Reset) catch break;
495500 stderr.writeAll(msg) catch break;
501 stderr.writeAll("\n") catch break;
496502 }
497503 }
498504
lib/std/Build.zig+4-5
......@@ -1154,13 +1154,12 @@ fn allocPrintCmd(ally: Allocator, opt_cwd: ?[]const u8, argv: []const []const u8
11541154 for (argv) |arg| {
11551155 try buf.writer().print("{s} ", .{arg});
11561156 }
1157 try buf.append('\n');
11581157 return buf.toOwnedSlice();
11591158}
11601159
11611160fn printCmd(ally: Allocator, cwd: ?[]const u8, argv: []const []const u8) void {
11621161 const text = allocPrintCmd(ally, cwd, argv) catch @panic("OOM");
1163 std.debug.print("{s}", .{text});
1162 std.debug.print("{s}\n", .{text});
11641163}
11651164
11661165pub 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 {
14821481 @panic("TODO handle progress message");
14831482 },
14841483 .emit_bin_path => {
1485 @panic("TODO handle emit_bin_path message");
1484 result = try b.allocator.dupe(u8, body);
14861485 },
14871486 _ => {
14881487 // Unrecognized message.
......@@ -1553,7 +1552,7 @@ fn sendMessage(file: fs.File, tag: std.zig.Client.Message.Tag) !void {
15531552/// a helpful message.
15541553pub fn exec(b: *Build, argv: []const []const u8) []u8 {
15551554 if (!process.can_spawn) {
1556 std.debug.print("unable to spawn the following command: cannot spawn child process\n{s}", .{
1555 std.debug.print("unable to spawn the following command: cannot spawn child process\n{s}\n", .{
15571556 try allocPrintCmd(b.allocator, null, argv),
15581557 });
15591558 process.exit(1);
......@@ -1562,7 +1561,7 @@ pub fn exec(b: *Build, argv: []const []const u8) []u8 {
15621561 var code: u8 = undefined;
15631562 return b.execAllowFail(argv, &code, .Inherit) catch |err| {
15641563 const printed_cmd = allocPrintCmd(b.allocator, null, argv) catch @panic("OOM");
1565 std.debug.print("unable to spawn the following command: {s}\n{s}", .{
1564 std.debug.print("unable to spawn the following command: {s}\n{s}\n", .{
15661565 @errorName(err), printed_cmd,
15671566 });
15681567 process.exit(1);
lib/std/Build/CompileStep.zig+2-2
......@@ -1888,8 +1888,8 @@ fn make(step: *Step) !void {
18881888 try zig_args.append(resolved_args_file);
18891889 }
18901890
1891 const output_dir_nl = try builder.execFromStep(zig_args.items, &self.step);
1892 const build_output_dir = mem.trimRight(u8, output_dir_nl, "\r\n");
1891 const output_bin_path = try builder.execFromStep(zig_args.items, &self.step);
1892 const build_output_dir = fs.path.dirname(output_bin_path).?;
18931893
18941894 if (self.output_dir) |output_dir| {
18951895 var src_dir = try std.fs.cwd().openIterableDir(build_output_dir, .{});