Skip to content

Commit ad06cef

Browse files
committed
Stuff
1 parent dd1b4fe commit ad06cef

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

src/Rootfs.jl

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ struct CompilerShard
4646
target = abi_agnostic(target)
4747
end
4848

49+
# If this compiler shard has an os_version, that should be interpreted as the bound it is.
50+
if target !== nothing && os_version(target::Platform) !== nothing
51+
set_compare_strategy!(target::Platform, "os_version", compare_version_cap)
52+
end
53+
4954
# Construct our shiny new CompilerShard object
5055
return new(name, version, target, host, archive_type)
5156
end
@@ -78,8 +83,17 @@ end
7883

7984
Base.BinaryPlatforms.platforms_match(p::AbstractPlatform, cs::CompilerShard) = platforms_match(cs, p)
8085

81-
Base.BinaryPlatforms.platforms_match(a::CompilerShard, b::CompilerShard) =
82-
platforms_match(something(a.target, a.host), something(b.target, b.host))
86+
function Base.BinaryPlatforms.platforms_match(a::CompilerShard, b::CompilerShard)
87+
if !platforms_match(a.host, b.host)
88+
return false
89+
elseif a.target === b.target === nothing
90+
return true
91+
elseif a.target !== nothing && b.target !== nothing
92+
return platforms_match(a.target, b.target)
93+
else
94+
return false
95+
end
96+
end
8397

8498
"""
8599
artifact_name(cs::CompilerShard)
@@ -100,11 +114,10 @@ function artifact_name(cs::CompilerShard)
100114
return "$(cs.name)$(target_str).v$(cs.version).$(triplet(cs.host)).$(ext)"
101115
end
102116

103-
# The inverse of `artifact_name(cs)`
104-
function CompilerShard(art_name::String)
117+
function Base.tryparse(::Type{CompilerShard}, art_name::AbstractString)
105118
m = match(r"^([^-]+)(?:-(.+))?\.(v[\d\.]+(?:-[^\.]+)?)\.([^0-9].+-.+)\.(\w+)", art_name)
106119
if m === nothing
107-
error("Unable to parse '$(art_name)'")
120+
return nothing
108121
end
109122
return CompilerShard(
110123
m.captures[1],
@@ -115,6 +128,15 @@ function CompilerShard(art_name::String)
115128
)
116129
end
117130

131+
# The inverse of `artifact_name(cs)`
132+
function CompilerShard(art_name::String)
133+
cs = tryparse(CompilerShard, art_name)
134+
if cs === nothing
135+
error("Unable to parse '$(art_name)'")
136+
end
137+
return cs
138+
end
139+
118140
const ALL_SHARDS = Ref{Union{Vector{CompilerShard},Nothing}}(nothing)
119141
function all_compiler_shards()::Vector{CompilerShard}
120142
if ALL_SHARDS[] === nothing
@@ -131,17 +153,10 @@ function all_compiler_shards()::Vector{CompilerShard}
131153
end
132154
end
133155
for name in names
134-
cs = try
135-
CompilerShard(name)
136-
catch
137-
continue
138-
end
139-
140-
# If this compiler shard has an os_version, that should be interpreted as the bound it is.
141-
if cs.target !== nothing && os_version(cs.target::Platform) !== nothing
142-
set_compare_strategy!(cs.target::Platform, "os_version", compare_version_cap)
156+
cs = tryparse(CompilerShard, name)
157+
if cs !== nothing
158+
push!(ALL_SHARDS[]::Vector{CompilerShard}, cs)
143159
end
144-
push!(ALL_SHARDS[]::Vector{CompilerShard}, cs)
145160
end
146161
end
147162
return ALL_SHARDS[]::Vector{CompilerShard}

test/rootfs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ end
232232
@test !platforms_match(shard, Platform("x86_64", "freebsd"; os_version=v"11.1"))
233233

234234
# We didn't have AArch64 for FreeBSD < 13.2
235-
@test isempty(choose_shards(Platform("aarch64", "freebsd"; os_version=v"11.1")))
235+
@test_throws ErrorException choose_shards(Platform("aarch64", "freebsd"; os_version=v"11.1"))
236236
# Shards built for earlier FreeBSD versions should be available for newer ones
237237
@test !isempty(choose_shards(Platform("aarch64", "freebsd"; os_version=v"69.420")))
238238
end

0 commit comments

Comments
 (0)