Skip to content
44 changes: 39 additions & 5 deletions src/VersionsJSONUtil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ struct WindowsPortable
windows::Windows
end
WindowsPortable(arch::Symbol) = WindowsPortable(Windows(arch))
@forward WindowsPortable.windows (up_os, tar_os, triplet, arch)
@forward WindowsPortable.windows (up_os, tar_os, triplet, arch, extract_platform)

struct WindowsTarball
windows::Windows
end
WindowsTarball(arch::Symbol) = WindowsTarball(Windows(arch))
@forward WindowsTarball.windows (up_os, tar_os, triplet, arch)
@forward WindowsTarball.windows (up_os, tar_os, triplet, arch, extract_platform)

"Wrapper type to define two jlext methods for macOS DMG and macOS tarball"
struct MacOSTarball
macos::MacOS
end
MacOSTarball(arch::Symbol) = MacOSTarball(MacOS(arch))
@forward MacOSTarball.macos (up_os, tar_os, triplet, arch)
@forward MacOSTarball.macos (up_os, tar_os, triplet, arch, extract_platform)

up_os(p::Windows) = "winnt"
up_os(p::MacOS) = "mac"
Expand Down Expand Up @@ -132,6 +132,35 @@ function get_tags()
JSON.parse(String(read(tags_json_path)))
end

# Like `in`, but enforces that types match
function typed_in(x::T, collection::Vector{T}) where {T}
return x in collection
end

extract_platform(x::Base.BinaryPlatforms.AbstractPlatform) = (x.p)::Platform
platform_is_tier_1(x::Any, version::VersionNumber) = platform_is_tier_1(extract_platform(x), version)
function platform_is_tier_1(p::Platform, version::VersionNumber)
# For older Julia versions (prior to 1.0.0), we just return false
# This is because older Julia versions didn't always conform to the same naming convention for S3 downloads
# And e.g. tarballs didn't always exist for all platforms
if version < v"1.0.0"
return false
end
tier1_list = [
# These are always Tier 1, regardless of the Julia version:
Platform("x86_64", "linux"; libc = "glibc"),
Platform("x86_64", "windows"),
]
if version >= v"1.7.0-beta3"
# macOS Apple Silicon is only a Tier 1 for newer Julia versions
# Older Julia versions don't have native builds for Apple Silicon
apple_silicon = Platform("aarch64", "macos")
push!(tier1_list, apple_silicon)
end
return typed_in(p, tier1_list)
end


function main(out_path)
tags = get_tags()
tag_versions = filter(x -> x !== nothing, [vnum_maybe(basename(t["ref"])) for t in tags])
Expand All @@ -152,7 +181,12 @@ function main(out_path)
filepath = WebCacheUtilities.download_to_cache(filename, url)
catch ex
if isa(ex, InterruptException)
rethrow(ex)
rethrow()
end
if platform_is_tier_1(platform, version)
msg = "Unable to download binary for Tier 1 platform; this error is fatal"
@error msg platform version url
rethrow()
end
println(stdout, " ✗")
continue
Expand Down Expand Up @@ -188,7 +222,7 @@ function main(out_path)
println(stdout, " ✓")
catch ex
if isa(ex, InterruptException)
rethrow(ex)
rethrow()
end
println(stdout, " ✗")
end
Expand Down
Loading