| ... | ... | @@ -177,6 +177,9 @@ pub const CrossTarget = struct { |
| 177 | 177 | /// If the architecture was determined, this will be populated. |
| 178 | 178 | arch: ?Target.Cpu.Arch = null, |
| 179 | 179 | |
| 180 | /// If the OS name was determined, this will be populated. |
| 181 | os_name: ?[]const u8 = null, |
| 182 | |
| 180 | 183 | /// If the OS tag was determined, this will be populated. |
| 181 | 184 | os_tag: ?Target.Os.Tag = null, |
| 182 | 185 | |
| ... | ... | @@ -219,6 +222,7 @@ pub const CrossTarget = struct { |
| 219 | 222 | var abi_it = mem.separate(abi_text, "."); |
| 220 | 223 | const abi = std.meta.stringToEnum(Target.Abi, abi_it.next().?) orelse |
| 221 | 224 | return error.UnknownApplicationBinaryInterface; |
| 225 | result.abi = abi; |
| 222 | 226 | diags.abi = abi; |
| 223 | 227 | |
| 224 | 228 | const abi_ver_text = abi_it.rest(); |
| ... | ... | @@ -614,6 +618,7 @@ pub const CrossTarget = struct { |
| 614 | 618 | fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const u8) !void { |
| 615 | 619 | var it = mem.separate(text, "."); |
| 616 | 620 | const os_name = it.next().?; |
| 621 | diags.os_name = os_name; |
| 617 | 622 | const os_is_native = mem.eql(u8, os_name, "native"); |
| 618 | 623 | if (!os_is_native) { |
| 619 | 624 | result.os_tag = std.meta.stringToEnum(Target.Os.Tag, os_name) orelse |
| ... | ... | @@ -702,6 +707,16 @@ pub const CrossTarget = struct { |
| 702 | 707 | }; |
| 703 | 708 | |
| 704 | 709 | test "CrossTarget.parse" { |
| 710 | { |
| 711 | const cross_target = try CrossTarget.parse(.{ .arch_os_abi = "native" }); |
| 712 | |
| 713 | std.testing.expect(cross_target.cpu_arch == null); |
| 714 | std.testing.expect(cross_target.isNative()); |
| 715 | |
| 716 | const text = try cross_target.zigTriple(std.testing.allocator); |
| 717 | defer std.testing.allocator.free(text); |
| 718 | std.testing.expectEqualSlices(u8, "native", text); |
| 719 | } |
| 705 | 720 | { |
| 706 | 721 | const cross_target = try CrossTarget.parse(.{ |
| 707 | 722 | .arch_os_abi = "x86_64-linux-gnu", |