diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-02-26 14:33:31 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-02-28 14:51:54 -0500 |
| commit | cf233bad5884b9bd782256eb6808fcc6abda645c (patch) | |
| tree | 9800d1a20c0b71e675ae7952d7095bd44259ce68 /lib | |
| parent | c8669a4cf834a6d1dadd9260e94f1781ceed0ec3 (diff) | |
| download | zig-cf233bad5884b9bd782256eb6808fcc6abda645c.tar.gz zig-cf233bad5884b9bd782256eb6808fcc6abda645c.zip | |
fix target parsing
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/zig/cross_target.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/std/zig/cross_target.zig b/lib/std/zig/cross_target.zig index e785c40073..6654635b89 100644 --- a/lib/std/zig/cross_target.zig +++ b/lib/std/zig/cross_target.zig @@ -177,6 +177,9 @@ pub const CrossTarget = struct { /// If the architecture was determined, this will be populated. arch: ?Target.Cpu.Arch = null, + /// If the OS name was determined, this will be populated. + os_name: ?[]const u8 = null, + /// If the OS tag was determined, this will be populated. os_tag: ?Target.Os.Tag = null, @@ -219,6 +222,7 @@ pub const CrossTarget = struct { var abi_it = mem.separate(abi_text, "."); const abi = std.meta.stringToEnum(Target.Abi, abi_it.next().?) orelse return error.UnknownApplicationBinaryInterface; + result.abi = abi; diags.abi = abi; const abi_ver_text = abi_it.rest(); @@ -614,6 +618,7 @@ pub const CrossTarget = struct { fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const u8) !void { var it = mem.separate(text, "."); const os_name = it.next().?; + diags.os_name = os_name; const os_is_native = mem.eql(u8, os_name, "native"); if (!os_is_native) { result.os_tag = std.meta.stringToEnum(Target.Os.Tag, os_name) orelse @@ -703,6 +708,16 @@ pub const CrossTarget = struct { test "CrossTarget.parse" { { + const cross_target = try CrossTarget.parse(.{ .arch_os_abi = "native" }); + + std.testing.expect(cross_target.cpu_arch == null); + std.testing.expect(cross_target.isNative()); + + const text = try cross_target.zigTriple(std.testing.allocator); + defer std.testing.allocator.free(text); + std.testing.expectEqualSlices(u8, "native", text); + } + { const cross_target = try CrossTarget.parse(.{ .arch_os_abi = "x86_64-linux-gnu", .cpu_features = "x86_64-sse-sse2-avx-cx8", |
