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