| ... | @@ -271,12 +271,16 @@ fn serveWasm( | ... | @@ -271,12 +271,16 @@ fn serveWasm( |
| 271 | // Do the compilation every request, so that the user can edit the files | 271 | // Do the compilation every request, so that the user can edit the files |
| 272 | // and see the changes without restarting the server. | 272 | // and see the changes without restarting the server. |
| 273 | const wasm_base_path = try buildWasmBinary(arena, context, optimize_mode); | 273 | const wasm_base_path = try buildWasmBinary(arena, context, optimize_mode); |
| | 274 | const target = std.zig.system.resolveTargetQuery(io, std.Build.parseTargetQuery(.{ |
| | 275 | .arch_os_abi = autodoc_arch_os_abi, |
| | 276 | .cpu_features = autodoc_cpu_features, |
| | 277 | }) catch unreachable) catch unreachable; |
| 274 | const bin_name = try std.zig.binNameAlloc(arena, .{ | 278 | const bin_name = try std.zig.binNameAlloc(arena, .{ |
| 275 | .root_name = autodoc_root_name, | 279 | .root_name = autodoc_root_name, |
| 276 | .target = &(std.zig.system.resolveTargetQuery(io, std.Build.parseTargetQuery(.{ | 280 | .cpu_arch = target.cpu.arch, |
| 277 | .arch_os_abi = autodoc_arch_os_abi, | 281 | .os_tag = target.os.tag, |
| 278 | .cpu_features = autodoc_cpu_features, | 282 | .ofmt = target.ofmt, |
| 279 | }) catch unreachable) catch unreachable), | 283 | .abi = target.abi, |
| 280 | .output_mode = .Exe, | 284 | .output_mode = .Exe, |
| 281 | }); | 285 | }); |
| 282 | // std.http.Server does not have a sendfile API yet. | 286 | // std.http.Server does not have a sendfile API yet. |
| ... | @@ -406,51 +410,26 @@ fn buildWasmBinary( | ... | @@ -406,51 +410,26 @@ fn buildWasmBinary( |
| 406 | child.stdin.?.close(io); | 410 | child.stdin.?.close(io); |
| 407 | child.stdin = null; | 411 | child.stdin = null; |
| 408 | | 412 | |
| 409 | switch (try child.wait(io)) { | 413 | const term = try child.wait(io); |
| 410 | .exited => |code| { | 414 | if (!term.success()) { |
| 411 | if (code != 0) { | 415 | std.log.err("the following command {f}:\n{s}", .{ |
| 412 | std.log.err( | 416 | term, try std.zig.allocPrintCmd(arena, argv.items, .{}), |
| 413 | "the following command exited with error code {d}:\n{s}", | 417 | }); |
| 414 | .{ code, try std.Build.Step.allocPrintCmd(arena, .inherit, null, argv.items) }, | 418 | return error.WasmCompilationFailed; |
| 415 | ); | | |
| 416 | return error.WasmCompilationFailed; | | |
| 417 | } | | |
| 418 | }, | | |
| 419 | .signal => |sig| { | | |
| 420 | std.log.err( | | |
| 421 | "the following command terminated with signal {t}:\n{s}", | | |
| 422 | .{ sig, try std.Build.Step.allocPrintCmd(arena, .inherit, null, argv.items) }, | | |
| 423 | ); | | |
| 424 | return error.WasmCompilationFailed; | | |
| 425 | }, | | |
| 426 | .stopped => |sig| { | | |
| 427 | std.log.err( | | |
| 428 | "the following command stopped unexpectedly with signal {t}:\n{s}", | | |
| 429 | .{ sig, try std.Build.Step.allocPrintCmd(arena, .inherit, null, argv.items) }, | | |
| 430 | ); | | |
| 431 | return error.WasmCompilationFailed; | | |
| 432 | }, | | |
| 433 | .unknown => { | | |
| 434 | std.log.err( | | |
| 435 | "the following command terminated unexpectedly:\n{s}", | | |
| 436 | .{try std.Build.Step.allocPrintCmd(arena, .inherit, null, argv.items)}, | | |
| 437 | ); | | |
| 438 | return error.WasmCompilationFailed; | | |
| 439 | }, | | |
| 440 | } | 419 | } |
| 441 | | 420 | |
| 442 | if (result_error_bundle.errorMessageCount() > 0) { | 421 | if (result_error_bundle.errorMessageCount() > 0) { |
| 443 | try result_error_bundle.renderToStderr(io, .{}, .auto); | 422 | try result_error_bundle.renderToStderr(io, .{}, .auto); |
| 444 | std.log.err("the following command failed with {d} compilation errors:\n{s}", .{ | 423 | std.log.err("the following command failed with {d} compilation errors:\n{s}", .{ |
| 445 | result_error_bundle.errorMessageCount(), | 424 | result_error_bundle.errorMessageCount(), |
| 446 | try std.Build.Step.allocPrintCmd(arena, .inherit, null, argv.items), | 425 | try std.zig.allocPrintCmd(arena, argv.items, .{}), |
| 447 | }); | 426 | }); |
| 448 | return error.WasmCompilationFailed; | 427 | return error.WasmCompilationFailed; |
| 449 | } | 428 | } |
| 450 | | 429 | |
| 451 | return result orelse { | 430 | return result orelse { |
| 452 | std.log.err("child process failed to report result\n{s}", .{ | 431 | std.log.err("child process failed to report result\n{s}", .{ |
| 453 | try std.Build.Step.allocPrintCmd(arena, .inherit, null, argv.items), | 432 | try std.zig.allocPrintCmd(arena, argv.items, .{}), |
| 454 | }); | 433 | }); |
| 455 | return error.WasmCompilationFailed; | 434 | return error.WasmCompilationFailed; |
| 456 | }; | 435 | }; |