aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Target
diff options
context:
space:
mode:
authorKNnut <hahv@msn.com>2025-08-04 23:07:49 +0800
committerAlex Rønne Petersen <alex@alexrp.com>2025-08-05 06:08:42 +0200
commitfcb088cb6abf8a0a20de2650491c2d9a4b1ba399 (patch)
tree6e16dab5b8ba16d4ac4ae64fe6ff85122f61faf7 /lib/std/Target
parent96be6f6566b19c242220f0f8571dc81ecadf6a79 (diff)
downloadzig-fcb088cb6abf8a0a20de2650491c2d9a4b1ba399.tar.gz
zig-fcb088cb6abf8a0a20de2650491c2d9a4b1ba399.zip
std.Target.Query: fix `WindowsVersion` format in `zigTriple()`
Diffstat (limited to 'lib/std/Target')
-rw-r--r--lib/std/Target/Query.zig20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/std/Target/Query.zig b/lib/std/Target/Query.zig
index 2d3b0f4436..4b0579d34d 100644
--- a/lib/std/Target/Query.zig
+++ b/lib/std/Target/Query.zig
@@ -423,7 +423,7 @@ pub fn zigTriple(self: Query, gpa: Allocator) Allocator.Error![]u8 {
try formatVersion(v, gpa, &result);
},
.windows => |v| {
- try result.print(gpa, "{d}", .{v});
+ try result.print(gpa, "{f}", .{v});
},
}
}
@@ -437,7 +437,7 @@ pub fn zigTriple(self: Query, gpa: Allocator) Allocator.Error![]u8 {
.windows => |v| {
// This is counting on a custom format() function defined on `WindowsVersion`
// to add a prefix '.' and make there be a total of three dots.
- try result.print(gpa, "..{d}", .{v});
+ try result.print(gpa, "..{f}", .{v});
},
}
}
@@ -729,4 +729,20 @@ test parse {
defer std.testing.allocator.free(text);
try std.testing.expectEqualSlices(u8, "aarch64-linux.3.10...4.4.1-android.30", text);
}
+ {
+ const query = try Query.parse(.{
+ .arch_os_abi = "x86-windows.xp...win8-msvc",
+ });
+ const target = try std.zig.system.resolveTargetQuery(query);
+
+ try std.testing.expect(target.cpu.arch == .x86);
+ try std.testing.expect(target.os.tag == .windows);
+ try std.testing.expect(target.os.version_range.windows.min == .xp);
+ try std.testing.expect(target.os.version_range.windows.max == .win8);
+ try std.testing.expect(target.abi == .msvc);
+
+ const text = try query.zigTriple(std.testing.allocator);
+ defer std.testing.allocator.free(text);
+ try std.testing.expectEqualSlices(u8, "x86-windows.xp...win8-msvc", text);
+ }
}