diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2024-10-30 06:38:44 +0100 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2024-11-01 06:23:59 +0100 |
| commit | af48ce63795ca030a5eebd163af68746b8de2f0a (patch) | |
| tree | f1a94a36ce26707ca0614f65d1266e991aae0b21 /lib/std/Target.zig | |
| parent | ba5f57616f69c01aa6faa5bcabab2d58969cf335 (diff) | |
| download | zig-af48ce63795ca030a5eebd163af68746b8de2f0a.tar.gz zig-af48ce63795ca030a5eebd163af68746b8de2f0a.zip | |
std.Target: Sort some OS switches according to the Os enum.
Diffstat (limited to 'lib/std/Target.zig')
| -rw-r--r-- | lib/std/Target.zig | 214 |
1 files changed, 118 insertions, 96 deletions
diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 49111b761b..8023418f02 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -160,48 +160,58 @@ pub const Os = struct { pub inline fn versionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).@"union".tag_type.? { return switch (tag) { .freestanding, + .other, + + .contiki, + .elfiamcu, .fuchsia, - .ps3, - .zos, + .hermit, + + .aix, .haiku, + .hurd, + .plan9, .rtems, - .aix, - .cuda, - .nvcl, - .amdhsa, + .serenity, + .zos, + + // This should use semver once we determine the version history. + .bridgeos, + + .illumos, + + .uefi, + + .ps3, .ps4, .ps5, - .elfiamcu, - .mesa3d, - .contiki, - .amdpal, - .hermit, - .hurd, + .emscripten, - .uefi, + + .amdhsa, + .amdpal, + .cuda, + .mesa3d, + .nvcl, .opencl, // TODO: OpenCL versions .opengl, // TODO: GLSL versions .vulkan, - .plan9, - .illumos, - .serenity, - .other, => .none, - // This should use semver once we determine the version history. - .bridgeos => .none, + .dragonfly, + .freebsd, + .netbsd, + .openbsd, .driverkit, - .freebsd, .macos, .ios, .tvos, - .watchos, .visionos, - .netbsd, - .openbsd, - .dragonfly, + .watchos, + .solaris, + .wasi, => .semver, @@ -391,41 +401,93 @@ pub const Os = struct { pub fn default(tag: Tag, arch: Cpu.Arch) VersionRange { return switch (tag) { .freestanding, + .other, + + .contiki, + .elfiamcu, .fuchsia, - .ps3, - .zos, + .hermit, + + .aix, .haiku, + .hurd, + .plan9, .rtems, - .aix, - .cuda, - .nvcl, - .amdhsa, + .serenity, + .zos, + + // This should use semver once we determine the version history. + .bridgeos, + + .illumos, + + .uefi, + + .ps3, .ps4, .ps5, - .elfiamcu, - .mesa3d, - .contiki, - .amdpal, - .hermit, - .hurd, + .emscripten, - .uefi, + + .amdhsa, + .amdpal, + .cuda, + .mesa3d, + .nvcl, .opencl, // TODO: OpenCL versions .opengl, // TODO: GLSL versions .vulkan, - .plan9, - .illumos, - .serenity, - .bridgeos, - .other, => .{ .none = {} }, + .linux => .{ + .linux = .{ + .range = .{ + .min = .{ .major = 4, .minor = 19, .patch = 0 }, + .max = .{ .major = 6, .minor = 10, .patch = 3 }, + }, + .glibc = blk: { + const default_min: std.SemanticVersion = .{ .major = 2, .minor = 28, .patch = 0 }; + + for (std.zig.target.available_libcs) |libc| { + // We don't know the ABI here. We can get away with not checking it + // for now, but that may not always remain true. + if (libc.os != tag or libc.arch != arch) continue; + + if (libc.glibc_min) |min| { + if (min.order(default_min) == .gt) break :blk min; + } + } + + break :blk default_min; + }, + }, + }, + + .dragonfly => .{ + .semver = .{ + .min = .{ .major = 5, .minor = 8, .patch = 0 }, + .max = .{ .major = 6, .minor = 4, .patch = 0 }, + }, + }, .freebsd => .{ - .semver = std.SemanticVersion.Range{ + .semver = .{ .min = .{ .major = 12, .minor = 0, .patch = 0 }, .max = .{ .major = 14, .minor = 0, .patch = 0 }, }, }, + .netbsd => .{ + .semver = .{ + .min = .{ .major = 8, .minor = 0, .patch = 0 }, + .max = .{ .major = 10, .minor = 0, .patch = 0 }, + }, + }, + .openbsd => .{ + .semver = .{ + .min = .{ .major = 7, .minor = 3, .patch = 0 }, + .max = .{ .major = 7, .minor = 5, .patch = 0 }, + }, + }, + .driverkit => .{ .semver = .{ .min = .{ .major = 19, .minor = 0, .patch = 0 }, @@ -433,13 +495,13 @@ pub const Os = struct { }, }, .macos => switch (arch) { - .aarch64 => VersionRange{ + .aarch64 => .{ .semver = .{ .min = .{ .major = 11, .minor = 7, .patch = 1 }, .max = .{ .major = 14, .minor = 6, .patch = 1 }, }, }, - .x86_64 => VersionRange{ + .x86_64 => .{ .semver = .{ .min = .{ .major = 11, .minor = 7, .patch = 1 }, .max = .{ .major = 14, .minor = 6, .patch = 1 }, @@ -453,12 +515,6 @@ pub const Os = struct { .max = .{ .major = 17, .minor = 6, .patch = 1 }, }, }, - .watchos => .{ - .semver = .{ - .min = .{ .major = 6, .minor = 0, .patch = 0 }, - .max = .{ .major = 10, .minor = 6, .patch = 0 }, - }, - }, .tvos => .{ .semver = .{ .min = .{ .major = 13, .minor = 0, .patch = 0 }, @@ -471,60 +527,19 @@ pub const Os = struct { .max = .{ .major = 1, .minor = 3, .patch = 0 }, }, }, - .netbsd => .{ - .semver = .{ - .min = .{ .major = 8, .minor = 0, .patch = 0 }, - .max = .{ .major = 10, .minor = 0, .patch = 0 }, - }, - }, - .openbsd => .{ - .semver = .{ - .min = .{ .major = 7, .minor = 3, .patch = 0 }, - .max = .{ .major = 7, .minor = 5, .patch = 0 }, - }, - }, - .dragonfly => .{ + .watchos => .{ .semver = .{ - .min = .{ .major = 5, .minor = 8, .patch = 0 }, - .max = .{ .major = 6, .minor = 4, .patch = 0 }, + .min = .{ .major = 6, .minor = 0, .patch = 0 }, + .max = .{ .major = 10, .minor = 6, .patch = 0 }, }, }, + .solaris => .{ .semver = .{ .min = .{ .major = 11, .minor = 0, .patch = 0 }, .max = .{ .major = 11, .minor = 4, .patch = 0 }, }, }, - .wasi => .{ - .semver = .{ - .min = .{ .major = 0, .minor = 1, .patch = 0 }, - .max = .{ .major = 0, .minor = 1, .patch = 0 }, - }, - }, - - .linux => .{ - .linux = .{ - .range = .{ - .min = .{ .major = 4, .minor = 19, .patch = 0 }, - .max = .{ .major = 6, .minor = 10, .patch = 3 }, - }, - .glibc = blk: { - const default_min: std.SemanticVersion = .{ .major = 2, .minor = 28, .patch = 0 }; - - for (std.zig.target.available_libcs) |libc| { - // We don't know the ABI here. We can get away with not checking it - // for now, but that may not always remain true. - if (libc.os != tag or libc.arch != arch) continue; - - if (libc.glibc_min) |min| { - if (min.order(default_min) == .gt) break :blk min; - } - } - - break :blk default_min; - }, - }, - }, .windows => .{ .windows = .{ @@ -532,6 +547,13 @@ pub const Os = struct { .max = WindowsVersion.latest, }, }, + + .wasi => .{ + .semver = .{ + .min = .{ .major = 0, .minor = 1, .patch = 0 }, + .max = .{ .major = 0, .minor = 1, .patch = 0 }, + }, + }, }; } }; |
