| ... | @@ -525,7 +525,7 @@ pub const Builder = struct { | ... | @@ -525,7 +525,7 @@ pub const Builder = struct { |
| 525 | pub const StandardTargetOptionsArgs = struct { | 525 | pub const StandardTargetOptionsArgs = struct { |
| 526 | whitelist: ?[]const CrossTarget = null, | 526 | whitelist: ?[]const CrossTarget = null, |
| 527 | | 527 | |
| 528 | default_target: CrossTarget = .{}, | 528 | default_target: CrossTarget = CrossTarget{}, |
| 529 | }; | 529 | }; |
| 530 | | 530 | |
| 531 | /// Exposes standard `zig build` options for choosing a target. | 531 | /// Exposes standard `zig build` options for choosing a target. |
| ... | @@ -533,12 +533,12 @@ pub const Builder = struct { | ... | @@ -533,12 +533,12 @@ pub const Builder = struct { |
| 533 | const triple = self.option( | 533 | const triple = self.option( |
| 534 | []const u8, | 534 | []const u8, |
| 535 | "target", | 535 | "target", |
| 536 | "The Arch, OS, and ABI to build for.", | 536 | "The CPU architecture, OS, and ABI to build for.", |
| 537 | ) orelse return args.default_target; | 537 | ) orelse return args.default_target; |
| 538 | | 538 | |
| 539 | // TODO add cpu and features as part of the target triple | 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 | const selected_target = CrossTarget.parse(.{ | 542 | const selected_target = CrossTarget.parse(.{ |
| 543 | .arch_os_abi = triple, | 543 | .arch_os_abi = triple, |
| 544 | .diagnostics = &diags, | 544 | .diagnostics = &diags, |
| ... | @@ -567,7 +567,21 @@ pub const Builder = struct { | ... | @@ -567,7 +567,21 @@ pub const Builder = struct { |
| 567 | } | 567 | } |
| 568 | process.exit(1); | 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 | const selected_canonicalized_triple = selected_target.zigTriple(self.allocator) catch unreachable; | 587 | const selected_canonicalized_triple = selected_target.zigTriple(self.allocator) catch unreachable; |
| ... | @@ -585,7 +599,7 @@ pub const Builder = struct { | ... | @@ -585,7 +599,7 @@ pub const Builder = struct { |
| 585 | }); | 599 | }); |
| 586 | for (list) |t| { | 600 | for (list) |t| { |
| 587 | const t_triple = t.zigTriple(self.allocator) catch unreachable; | 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 | // TODO instead of process exit, return error and have a zig build flag implemented by | 604 | // TODO instead of process exit, return error and have a zig build flag implemented by |
| 591 | // the build runner that turns process exits into error return traces | 605 | // the build runner that turns process exits into error return traces |