You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// The version ranges here represent the minimum OS version to be supported
/// and the maximum OS version to be supported. The default values represent
/// the range that the Zig Standard Library bases its abstractions on.
///
/// The minimum version of the range is the main setting to tweak for a target.
/// Usually, the maximum target OS version will remain the default, which is
/// the latest released version of the OS.
///
/// To test at compile time if the target is guaranteed to support a given OS feature,
/// one should check that the minimum version of the range is greater than or equal to
/// the version the feature was introduced in.
///
/// To test at compile time if the target certainly will not support a given OS feature,
/// one should check that the maximum version of the range is less than the version the
/// feature was introduced in.
///
/// If neither of these cases apply, a runtime check should be used to determine if the
/// target supports a given OS feature.
///
/// Binaries built with a given maximum version will continue to function on newer operating system
/// versions. However, such a binary may not take full advantage of the newer operating system APIs.
pubconstVersionRange=union {
none: void,
semver: Version.Range,
linux: LinuxVersionRange,
windows: WindowsVersion.Range,
/// The default `VersionRange` represents the range that the Zig Standard Library
/// bases its abstractions on.
pubfndefault(tag: Tag) VersionRange {
switch (tag) {
.freestanding,
.ananas,
.cloudabi,
.dragonfly,
.fuchsia,
.kfreebsd,
.lv2,
.solaris,
.haiku,
.minix,
.rtems,
.nacl,
.cnk,
.aix,
.cuda,
.nvcl,
.amdhsa,
.ps4,
.elfiamcu,
.mesa3d,
.contiki,
.amdpal,
.hermit,
.hurd,
.wasi,
.emscripten,
.uefi,
.other,
=>return .{ .none= {} },
.freebsd=>return .{
.semver=Version.Range{
.min= .{ .major=12, .minor=0 },
.max= .{ .major=12, .minor=1 },
},
},
.macosx=>return .{
.semver= .{
.min= .{ .major=10, .minor=13 },
.max= .{ .major=10, .minor=15, .patch=3 },
},
},
sw_vers -productVersion gives the correct answer, however, it would be better to avoid depending on this binary existing and maintaining this behavior. Furthermore, a peek at the source code (thanks @fengb for finding it) for this file reveals that it depends on the CoreFoundation framework to function, which is another dependency it would be nice to avoid here.
It looks like the answer is in /System/Library/CoreServices/SystemVersion.plist (thanks @mikdusan for finding it), which is in a simple XML format. Perhaps a prerequisite to this issue would be an XML tokenizer.
This is a follow-up task from #4550.
zig/lib/std/zig/system.zig
Lines 226 to 228 in 7617610
zig/lib/std/target.zig
Lines 115 to 187 in 7617610
sw_vers -productVersiongives the correct answer, however, it would be better to avoid depending on this binary existing and maintaining this behavior. Furthermore, a peek at the source code (thanks @fengb for finding it) for this file reveals that it depends on the CoreFoundation framework to function, which is another dependency it would be nice to avoid here.It looks like the answer is in
/System/Library/CoreServices/SystemVersion.plist(thanks @mikdusan for finding it), which is in a simple XML format. Perhaps a prerequisite to this issue would be an XML tokenizer.