| ... | @@ -177,6 +177,9 @@ pub const CrossTarget = struct { | ... | @@ -177,6 +177,9 @@ pub const CrossTarget = struct { |
| 177 | /// If the architecture was determined, this will be populated. | 177 | /// If the architecture was determined, this will be populated. |
| 178 | arch: ?Target.Cpu.Arch = null, | 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 | /// If the OS tag was determined, this will be populated. | 183 | /// If the OS tag was determined, this will be populated. |
| 181 | os_tag: ?Target.Os.Tag = null, | 184 | os_tag: ?Target.Os.Tag = null, |
| 182 | | 185 | |
| ... | @@ -219,6 +222,7 @@ pub const CrossTarget = struct { | ... | @@ -219,6 +222,7 @@ pub const CrossTarget = struct { |
| 219 | var abi_it = mem.separate(abi_text, "."); | 222 | var abi_it = mem.separate(abi_text, "."); |
| 220 | const abi = std.meta.stringToEnum(Target.Abi, abi_it.next().?) orelse | 223 | const abi = std.meta.stringToEnum(Target.Abi, abi_it.next().?) orelse |
| 221 | return error.UnknownApplicationBinaryInterface; | 224 | return error.UnknownApplicationBinaryInterface; |
| | 225 | result.abi = abi; |
| 222 | diags.abi = abi; | 226 | diags.abi = abi; |
| 223 | | 227 | |
| 224 | const abi_ver_text = abi_it.rest(); | 228 | const abi_ver_text = abi_it.rest(); |
| ... | @@ -614,6 +618,7 @@ pub const CrossTarget = struct { | ... | @@ -614,6 +618,7 @@ pub const CrossTarget = struct { |
| 614 | fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const u8) !void { | 618 | fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const u8) !void { |
| 615 | var it = mem.separate(text, "."); | 619 | var it = mem.separate(text, "."); |
| 616 | const os_name = it.next().?; | 620 | const os_name = it.next().?; |
| | 621 | diags.os_name = os_name; |
| 617 | const os_is_native = mem.eql(u8, os_name, "native"); | 622 | const os_is_native = mem.eql(u8, os_name, "native"); |
| 618 | if (!os_is_native) { | 623 | if (!os_is_native) { |
| 619 | result.os_tag = std.meta.stringToEnum(Target.Os.Tag, os_name) orelse | 624 | result.os_tag = std.meta.stringToEnum(Target.Os.Tag, os_name) orelse |
| ... | @@ -702,6 +707,16 @@ pub const CrossTarget = struct { | ... | @@ -702,6 +707,16 @@ pub const CrossTarget = struct { |
| 702 | }; | 707 | }; |
| 703 | | 708 | |
| 704 | test "CrossTarget.parse" { | 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 | const cross_target = try CrossTarget.parse(.{ | 721 | const cross_target = try CrossTarget.parse(.{ |
| 707 | .arch_os_abi = "x86_64-linux-gnu", | 722 | .arch_os_abi = "x86_64-linux-gnu", |