aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/target.zig30
-rw-r--r--lib/std/zig/cross_target.zig4
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/std/target.zig b/lib/std/target.zig
index 9df3e21e52..8edc4acea8 100644
--- a/lib/std/target.zig
+++ b/lib/std/target.zig
@@ -101,6 +101,36 @@ pub const Target = struct {
return @enumToInt(ver) >= @enumToInt(self.min) and @enumToInt(ver) <= @enumToInt(self.max);
}
};
+
+ pub fn format(
+ self: WindowsVersion,
+ comptime fmt: []const u8,
+ options: std.fmt.FormatOptions,
+ out_stream: var,
+ ) !void {
+ if (fmt.len > 0 and fmt[0] == 's') {
+ if (
+ @enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)
+ ) {
+ try std.fmt.format(out_stream, ".{}", .{@tagName(self)});
+ } else {
+ try std.fmt.format(out_stream,
+ "@intToEnum(Target.Os.WindowsVersion, {})",
+ .{ @enumToInt(self) }
+ );
+ }
+ } else {
+ if (
+ @enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)
+ ) {
+ try std.fmt.format(out_stream, "WindowsVersion.{}", .{@tagName(self)});
+ } else {
+ try std.fmt.format(out_stream, "WindowsVersion(", .{@typeName(@This())});
+ try std.fmt.format(out_stream, "{}", .{@enumToInt(self)});
+ try out_stream.writeAll(")");
+ }
+ }
+ }
};
pub const LinuxVersionRange = struct {
diff --git a/lib/std/zig/cross_target.zig b/lib/std/zig/cross_target.zig
index 910d263c6a..5466b39f0b 100644
--- a/lib/std/zig/cross_target.zig
+++ b/lib/std/zig/cross_target.zig
@@ -514,14 +514,14 @@ pub const CrossTarget = struct {
switch (self.getOsVersionMin()) {
.none => {},
.semver => |v| try result.outStream().print(".{}", .{v}),
- .windows => |v| try result.outStream().print(".{}", .{@tagName(v)}),
+ .windows => |v| try result.outStream().print("{s}", .{v}),
}
}
if (self.os_version_max) |max| {
switch (max) {
.none => {},
.semver => |v| try result.outStream().print("...{}", .{v}),
- .windows => |v| try result.outStream().print("...{}", .{@tagName(v)}),
+ .windows => |v| try result.outStream().print("..{s}", .{v}),
}
}