@@ -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
7883
7984Base. 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) "
101115end
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 )
116129end
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+
118140const ALL_SHARDS = Ref {Union{Vector{CompilerShard},Nothing}} (nothing )
119141function 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}
0 commit comments