@@ -76,7 +76,7 @@ the override: overriding to an on-disk location through an absolutet path, and
76
76
overriding to another artifact by its content-hash.
77
77
"""
78
78
const ARTIFACT_OVERRIDES = Ref {Union{Dict{Symbol,Any},Nothing}} (nothing )
79
- function load_overrides (;force:: Bool = false )
79
+ function load_overrides (;force:: Bool = false ):: Dict{Symbol, Any}
80
80
if ARTIFACT_OVERRIDES[] != = nothing && ! force
81
81
return ARTIFACT_OVERRIDES[]
82
82
end
@@ -172,11 +172,11 @@ function load_overrides(;force::Bool = false)
172
172
end
173
173
174
174
ARTIFACT_OVERRIDES[] = overrides
175
+ return overrides
175
176
end
176
177
177
178
# Helpers to map an override to an actual path
178
- map_override_path (x:: String ) = x
179
- map_override_path (x:: AbstractString ) = string (x)
179
+ map_override_path (x:: AbstractString ) = String (x):: String
180
180
map_override_path (x:: SHA1 ) = artifact_path (x)
181
181
map_override_path (x:: Nothing ) = nothing
182
182
@@ -186,10 +186,10 @@ map_override_path(x::Nothing) = nothing
186
186
Query the loaded `<DEPOT>/artifacts/Overrides.toml` settings for artifacts that should be
187
187
redirected to a particular path or another content-hash.
188
188
"""
189
- function query_override (hash:: SHA1 ; overrides:: Dict = load_overrides ())
189
+ function query_override (hash:: SHA1 ; overrides:: Dict{Symbol,Any} = load_overrides ())
190
190
return map_override_path (get (overrides[:hash ], hash, nothing ))
191
191
end
192
- function query_override (pkg:: Base.UUID , artifact_name:: String ; overrides:: Dict = load_overrides ())
192
+ function query_override (pkg:: Base.UUID , artifact_name:: String ; overrides:: Dict{Symbol,Any} = load_overrides ())
193
193
if haskey (overrides[:UUID ], pkg)
194
194
return map_override_path (get (overrides[:UUID ][pkg], artifact_name, nothing ))
195
195
end
258
258
Given an `entry` for the artifact named `name`, located within the file `artifacts_toml`,
259
259
returns the `Platform` object that this entry specifies. Returns `nothing` on error.
260
260
"""
261
- function unpack_platform (entry:: Dict , name:: String , artifacts_toml:: String ):: Union{Nothing,Platform}
261
+ function unpack_platform (entry:: Dict{String,Any} , name:: String ,
262
+ artifacts_toml:: String ):: Union{Nothing,Platform}
262
263
if ! haskey (entry, " os" )
263
264
@error (" Invalid artifacts file at '$(artifacts_toml) ': platform-specific artifact entry '$name ' missing 'os' key" )
264
265
return nothing
@@ -270,7 +271,12 @@ function unpack_platform(entry::Dict, name::String, artifacts_toml::String)::Uni
270
271
end
271
272
272
273
# Collect all String-valued mappings in `entry` and use them as tags
273
- tags = Dict (Symbol (k) => v for (k, v) in entry if isa (v, String))
274
+ tags = Dict {Symbol, String} ()
275
+ for (k, v) in entry
276
+ if v isa String
277
+ tags[Symbol (k)] = v
278
+ end
279
+ end
274
280
# Removing some known entries that shouldn't be passed through `tags`
275
281
delete! (tags, :os )
276
282
delete! (tags, :arch )
@@ -376,8 +382,12 @@ function artifact_meta(name::String, artifact_dict::Dict, artifacts_toml::String
376
382
meta = artifact_dict[name]
377
383
378
384
# If it's an array, find the entry that best matches our current platform
379
- if isa (meta, Array)
380
- dl_dict = Dict {AbstractPlatform,Dict{String,Any}} (unpack_platform (x, name, artifacts_toml) => x for x in meta)
385
+ if isa (meta, Vector)
386
+ dl_dict = Dict {AbstractPlatform,Dict{String,Any}} ()
387
+ for x in meta
388
+ x:: Dict{String}
389
+ dl_dict[unpack_platform (x, name, artifacts_toml)] = x
390
+ end
381
391
meta = select_platform (dl_dict, platform)
382
392
# If it's NOT a dict, complain
383
393
elseif ! isa (meta, Dict)
@@ -610,24 +620,24 @@ end
610
620
# Support `AbstractString`s, but avoid compilers needing to track backedges for callers
611
621
# of these functions in case a user defines a new type that is `<: AbstractString`
612
622
with_artifacts_directory (f:: Function , artifacts_dir:: AbstractString ) =
613
- with_artifacts_directory (f, string (artifacts_dir))
614
- query_override (pkg:: Base.UUID , artifact_name:: AbstractString ; kwargs ... ) =
615
- query_override (pkg, string (artifact_name); kwargs ... )
623
+ with_artifacts_directory (f, String (artifacts_dir):: String )
624
+ query_override (pkg:: Base.UUID , artifact_name:: AbstractString ; overrides :: Dict = load_overrides () ) =
625
+ query_override (pkg, String (artifact_name):: String ; overrides = convert ( Dict {Symbol, Any} (overrides)) )
616
626
unpack_platform (entry:: Dict , name:: AbstractString , artifacts_toml:: AbstractString ) =
617
- unpack_platform (entry, string (name), string (artifacts_toml))
627
+ unpack_platform (convert (Dict{String, Any}, entry), String (name):: String , String (artifacts_toml):: String )
618
628
load_artifacts_toml (artifacts_toml:: AbstractString ; kwargs... ) =
619
- load_artifacts_toml (string (artifacts_toml); kwargs... )
629
+ load_artifacts_toml (String (artifacts_toml):: String ; kwargs... )
620
630
artifact_meta (name:: AbstractString , artifacts_toml:: AbstractString ; kwargs... ) =
621
- artifact_meta (string (name), string (artifacts_toml); kwargs... )
631
+ artifact_meta (String (name):: String , String (artifacts_toml):: String ; kwargs... )
622
632
artifact_meta (name:: AbstractString , artifact_dict:: Dict , artifacts_toml:: AbstractString ; kwargs... ) =
623
- artifact_meta (string (name), artifact_dict, string (artifacts_toml); kwargs... )
633
+ artifact_meta (String (name):: String , artifact_dict, String (artifacts_toml):: String ; kwargs... )
624
634
artifact_hash (name:: AbstractString , artifacts_toml:: AbstractString ; kwargs... ) =
625
- artifact_hash (string (name), string (artifacts_toml); kwargs... )
635
+ artifact_hash (String (name):: String , String (artifacts_toml):: String ; kwargs... )
626
636
find_artifacts_toml (path:: AbstractString ) =
627
- find_artifacts_toml (string (path))
637
+ find_artifacts_toml (String (path):: String )
628
638
split_artifact_slash (name:: AbstractString ) =
629
- split_artifact_slash (string (name))
639
+ split_artifact_slash (String (name):: String )
630
640
artifact_slash_lookup (name:: AbstractString , artifact_dict:: Dict , artifacts_toml:: AbstractString ) =
631
- artifact_slash_lookup (string (name), artifact_dict, string (artifacts_toml))
641
+ artifact_slash_lookup (String (name):: String , artifact_dict, String (artifacts_toml):: String )
632
642
633
643
end # module Artifacts
0 commit comments