| ... | ... | @@ -525,7 +525,7 @@ pub const Builder = struct { |
| 525 | 525 | pub const StandardTargetOptionsArgs = struct { |
| 526 | 526 | whitelist: ?[]const CrossTarget = null, |
| 527 | 527 | |
| 528 | | default_target: CrossTarget = .{}, |
| 528 | default_target: CrossTarget = CrossTarget{}, |
| 529 | 529 | }; |
| 530 | 530 | |
| 531 | 531 | /// Exposes standard `zig build` options for choosing a target. |
| ... | ... | @@ -533,12 +533,12 @@ pub const Builder = struct { |
| 533 | 533 | const triple = self.option( |
| 534 | 534 | []const u8, |
| 535 | 535 | "target", |
| 536 | | "The Arch, OS, and ABI to build for.", |
| 536 | "The CPU architecture, OS, and ABI to build for.", |
| 537 | 537 | ) orelse return args.default_target; |
| 538 | 538 | |
| 539 | 539 | // TODO add cpu and features as part of the target triple |
| 540 | 540 | |
| 541 | | var diags: std.Target.ParseOptions.Diagnostics = .{}; |
| 541 | var diags: CrossTarget.ParseOptions.Diagnostics = .{}; |
| 542 | 542 | const selected_target = CrossTarget.parse(.{ |
| 543 | 543 | .arch_os_abi = triple, |
| 544 | 544 | .diagnostics = &diags, |
| ... | ... | @@ -567,7 +567,21 @@ pub const Builder = struct { |
| 567 | 567 | } |
| 568 | 568 | process.exit(1); |
| 569 | 569 | }, |
| 570 | | else => |e| return e, |
| 570 | error.UnknownOperatingSystem => { |
| 571 | std.debug.warn( |
| 572 | \\Unknown OS: '{}' |
| 573 | \\Available operating systems: |
| 574 | \\ |
| 575 | , .{diags.os_name}); |
| 576 | inline for (std.meta.fields(std.Target.Os.Tag)) |field| { |
| 577 | std.debug.warn(" {}\n", .{field.name}); |
| 578 | } |
| 579 | process.exit(1); |
| 580 | }, |
| 581 | else => |e| { |
| 582 | std.debug.warn("Unable to parse target '{}': {}\n", .{ triple, @errorName(e) }); |
| 583 | process.exit(1); |
| 584 | }, |
| 571 | 585 | }; |
| 572 | 586 | |
| 573 | 587 | const selected_canonicalized_triple = selected_target.zigTriple(self.allocator) catch unreachable; |
| ... | ... | @@ -585,7 +599,7 @@ pub const Builder = struct { |
| 585 | 599 | }); |
| 586 | 600 | for (list) |t| { |
| 587 | 601 | const t_triple = t.zigTriple(self.allocator) catch unreachable; |
| 588 | | std.debug.warn(" {}\n", t_triple); |
| 602 | std.debug.warn(" {}\n", .{t_triple}); |
| 589 | 603 | } |
| 590 | 604 | // TODO instead of process exit, return error and have a zig build flag implemented by |
| 591 | 605 | // the build runner that turns process exits into error return traces |