| author | |
| committer | |
| log | dbc54ce67cd0e313cbf8687152302c9b31529e34 |
| tree | 30430179081f2a686b7dc2af3772d81801a43b14 |
| parent | 3c46da14db296beec186c3df4fe3669f6c99b715 |
| signature |
These functions don't actually hand out strings that are commonly understood,
but rather strings that follow Zig's naming conventions. So namespace them
accordingly.3 files changed, 33 insertions(+), 4 deletions(-)
lib/std/Target.zig+4| ... | @@ -2146,18 +2146,22 @@ pub fn zigTriple(target: *const Target, allocator: Allocator) Allocator.Error![] | ... | @@ -2146,18 +2146,22 @@ pub fn zigTriple(target: *const Target, allocator: Allocator) Allocator.Error![] |
| 2146 | return Query.fromTarget(target).zigTriple(allocator); | 2146 | return Query.fromTarget(target).zigTriple(allocator); |
| 2147 | } | 2147 | } |
| 2148 | 2148 | ||
| 2149 | /// Deprecated; to be removed in 0.18.0. Use `std.zig.target.hurdTupleSimple` instead. | ||
| 2149 | pub fn hurdTupleSimple(allocator: Allocator, arch: Cpu.Arch, abi: Abi) ![]u8 { | 2150 | pub fn hurdTupleSimple(allocator: Allocator, arch: Cpu.Arch, abi: Abi) ![]u8 { |
| 2150 | return std.fmt.allocPrint(allocator, "{s}-{s}", .{ @tagName(arch), @tagName(abi) }); | 2151 | return std.fmt.allocPrint(allocator, "{s}-{s}", .{ @tagName(arch), @tagName(abi) }); |
| 2151 | } | 2152 | } |
| 2152 | 2153 | ||
| 2154 | /// Deprecated; to be removed in 0.18.0. Use `std.zig.target.hurdTuple` instead. | ||
| 2153 | pub fn hurdTuple(target: *const Target, allocator: Allocator) ![]u8 { | 2155 | pub fn hurdTuple(target: *const Target, allocator: Allocator) ![]u8 { |
| 2154 | return hurdTupleSimple(allocator, target.cpu.arch, target.abi); | 2156 | return hurdTupleSimple(allocator, target.cpu.arch, target.abi); |
| 2155 | } | 2157 | } |
| 2156 | 2158 | ||
| 2159 | /// Deprecated; to be removed in 0.18.0. Use `std.zig.target.linuxTripleSimple` instead. | ||
| 2157 | pub fn linuxTripleSimple(allocator: Allocator, arch: Cpu.Arch, os_tag: Os.Tag, abi: Abi) ![]u8 { | 2160 | pub fn linuxTripleSimple(allocator: Allocator, arch: Cpu.Arch, os_tag: Os.Tag, abi: Abi) ![]u8 { |
| 2158 | return std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ @tagName(arch), @tagName(os_tag), @tagName(abi) }); | 2161 | return std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ @tagName(arch), @tagName(os_tag), @tagName(abi) }); |
| 2159 | } | 2162 | } |
| 2160 | 2163 | ||
| 2164 | /// Deprecated; to be removed in 0.18.0. Use `std.zig.target.linuxTriple` instead. | ||
| 2161 | pub fn linuxTriple(target: *const Target, allocator: Allocator) ![]u8 { | 2165 | pub fn linuxTriple(target: *const Target, allocator: Allocator) ![]u8 { |
| 2162 | return linuxTripleSimple(allocator, target.cpu.arch, target.os.tag, target.abi); | 2166 | return linuxTripleSimple(allocator, target.cpu.arch, target.os.tag, target.abi); |
| 2163 | } | 2167 | } |
lib/std/zig/system/NativePaths.zig+1-1| ... | @@ -149,7 +149,7 @@ pub fn detect( | ... | @@ -149,7 +149,7 @@ pub fn detect( |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | if (builtin.os.tag != .windows and builtin.os.tag != .wasi) { | 151 | if (builtin.os.tag != .windows and builtin.os.tag != .wasi) { |
| 152 | const triple = try native_target.linuxTriple(arena); | 152 | const triple = try std.zig.target.linuxTriple(arena, native_target); |
| 153 | 153 | ||
| 154 | const qual = native_target.ptrBitWidth(); | 154 | const qual = native_target.ptrBitWidth(); |
| 155 | 155 |
lib/std/zig/target.zig+28-3| ... | @@ -143,6 +143,31 @@ pub fn canBuildLibC(target: *const std.Target) bool { | ... | @@ -143,6 +143,31 @@ pub fn canBuildLibC(target: *const std.Target) bool { |
| 143 | return false; | 143 | return false; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | pub fn hurdTupleSimple( | ||
| 147 | allocator: Allocator, | ||
| 148 | arch: std.Target.Cpu.Arch, | ||
| 149 | abi: std.Target.Abi, | ||
| 150 | ) ![]u8 { | ||
| 151 | return std.fmt.allocPrint(allocator, "{s}-{s}", .{ @tagName(arch), @tagName(abi) }); | ||
| 152 | } | ||
| 153 | |||
| 154 | pub fn hurdTuple(allocator: Allocator, target: *const std.Target) ![]u8 { | ||
| 155 | return hurdTupleSimple(allocator, target.cpu.arch, target.abi); | ||
| 156 | } | ||
| 157 | |||
| 158 | pub fn linuxTripleSimple( | ||
| 159 | allocator: Allocator, | ||
| 160 | arch: std.Target.Cpu.Arch, | ||
| 161 | os_tag: std.Target.Os.Tag, | ||
| 162 | abi: std.Target.Abi, | ||
| 163 | ) ![]u8 { | ||
| 164 | return std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ @tagName(arch), @tagName(os_tag), @tagName(abi) }); | ||
| 165 | } | ||
| 166 | |||
| 167 | pub fn linuxTriple(allocator: Allocator, target: *const std.Target) ![]u8 { | ||
| 168 | return linuxTripleSimple(allocator, target.cpu.arch, target.os.tag, target.abi); | ||
| 169 | } | ||
| 170 | |||
| 146 | /// Returns the subdirectory triple to be used to find the correct glibc for the given `arch`, `os`, | 171 | /// Returns the subdirectory triple to be used to find the correct glibc for the given `arch`, `os`, |
| 147 | /// and `abi` in an installation directory created by glibc's `build-many-glibcs.py` script. | 172 | /// and `abi` in an installation directory created by glibc's `build-many-glibcs.py` script. |
| 148 | /// | 173 | /// |
| ... | @@ -162,8 +187,8 @@ pub fn glibcRuntimeTriple( | ... | @@ -162,8 +187,8 @@ pub fn glibcRuntimeTriple( |
| 162 | } | 187 | } |
| 163 | 188 | ||
| 164 | return switch (os) { | 189 | return switch (os) { |
| 165 | .hurd => std.Target.hurdTupleSimple(allocator, arch, abi), | 190 | .hurd => hurdTupleSimple(allocator, arch, abi), |
| 166 | .linux => std.Target.linuxTripleSimple(allocator, arch, os, abi), | 191 | .linux => linuxTripleSimple(allocator, arch, os, abi), |
| 167 | else => unreachable, | 192 | else => unreachable, |
| 168 | }; | 193 | }; |
| 169 | } | 194 | } |
| ... | @@ -179,7 +204,7 @@ pub fn muslRuntimeTriple( | ... | @@ -179,7 +204,7 @@ pub fn muslRuntimeTriple( |
| 179 | ) Allocator.Error![]const u8 { | 204 | ) Allocator.Error![]const u8 { |
| 180 | assert(abi.isMusl()); | 205 | assert(abi.isMusl()); |
| 181 | 206 | ||
| 182 | return std.Target.linuxTripleSimple(allocator, arch, .linux, abi); | 207 | return linuxTripleSimple(allocator, arch, .linux, abi); |
| 183 | } | 208 | } |
| 184 | 209 | ||
| 185 | pub fn osArchName(target: *const std.Target) [:0]const u8 { | 210 | pub fn osArchName(target: *const std.Target) [:0]const u8 { |