@@ -478,7 +478,7 @@ function jointail(dir, tail)
478
478
end
479
479
end
480
480
481
- function _artifact_str (__module__, artifacts_toml, name, path_tail, artifact_dict, hash)
481
+ function _artifact_str (__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform )
482
482
if haskey (Base. module_keys, __module__)
483
483
# Process overrides for this UUID, if we know what it is
484
484
process_overrides (artifact_dict, Base. module_keys[__module__]. uuid)
@@ -495,7 +495,7 @@ function _artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dic
495
495
# If not, we need to download it. We look up the Pkg module through `Base.loaded_modules()`
496
496
# then invoke `ensure_artifact_installed()`:
497
497
Pkg = first (filter (p-> p[1 ]. name == " Pkg" , Base. loaded_modules))[2 ]
498
- return jointail (Pkg. Artifacts. ensure_artifact_installed (string (name), artifacts_toml), path_tail)
498
+ return jointail (Pkg. Artifacts. ensure_artifact_installed (string (name), artifacts_toml; platform ), path_tail)
499
499
end
500
500
501
501
"""
@@ -539,16 +539,19 @@ function split_artifact_slash(name::String)
539
539
end
540
540
541
541
"""
542
- artifact_slash_lookup(name::String, artifacts_toml::String)
542
+ artifact_slash_lookup(name::String, atifact_dict::Dict,
543
+ artifacts_toml::String, platform::Platform)
543
544
544
545
Returns `artifact_name`, `artifact_path_tail`, and `hash` by looking the results up in
545
546
the given `artifacts_toml`, first extracting the name and path tail from the given `name`
546
547
to support slash-indexing within the given artifact.
547
548
"""
548
- function artifact_slash_lookup (name:: String , artifact_dict:: Dict , artifacts_toml:: String )
549
+ function artifact_slash_lookup (name:: String , artifact_dict:: Dict ,
550
+ artifacts_toml:: String , platform:: Platform )
549
551
artifact_name, artifact_path_tail = split_artifact_slash (name)
550
552
551
- meta = artifact_meta (artifact_name, artifact_dict, artifacts_toml)
553
+ @show platform
554
+ meta = artifact_meta (artifact_name, artifact_dict, artifacts_toml; platform)
552
555
if meta === nothing
553
556
error (" Cannot locate artifact '$(name) ' in '$(artifacts_toml) '" )
554
557
end
@@ -577,7 +580,7 @@ access a single file/directory within an artifact. Example:
577
580
!!! compat "Julia 1.6"
578
581
Slash-indexing requires at least Julia 1.6.
579
582
"""
580
- macro artifact_str (name)
583
+ macro artifact_str (name, platform = nothing )
581
584
# Find Artifacts.toml file we're going to load from
582
585
srcfile = string (__source__. file)
583
586
if ((isinteractive () && startswith (srcfile, " REPL[" )) || (! isinteractive () && srcfile == " none" )) && ! isfile (srcfile)
@@ -601,18 +604,23 @@ macro artifact_str(name)
601
604
# Invalidate calling .ji file if Artifacts.toml file changes
602
605
Base. include_dependency (artifacts_toml)
603
606
604
- # If `name` is a constant, we can actually load and parse the `Artifacts.toml` file now,
605
- # saving the work from runtime.
606
- if isa (name, AbstractString)
607
+ # If `name` is a constant, ( and we're using the default `Platform`) we can actually load
608
+ # and parse the `Artifacts.toml` file now, saving the work from runtime.
609
+ if isa (name, AbstractString) && platform === nothing
607
610
# To support slash-indexing, we need to split the artifact name from the path tail:
608
- local artifact_name, artifact_path_tail, hash = artifact_slash_lookup (name, artifact_dict, artifacts_toml)
611
+ platform = HostPlatform ()
612
+ local artifact_name, artifact_path_tail, hash = artifact_slash_lookup (name, artifact_dict, artifacts_toml, platform)
609
613
return quote
610
- Base. invokelatest (_artifact_str, $ (__module__), $ (artifacts_toml), $ (artifact_name), $ (artifact_path_tail), $ (artifact_dict), $ (hash))
614
+ Base. invokelatest (_artifact_str, $ (__module__), $ (artifacts_toml), $ (artifact_name), $ (artifact_path_tail), $ (artifact_dict), $ (hash), $ (platform) )
611
615
end
612
616
else
617
+ if platform === nothing
618
+ platform = :($ (HostPlatform)())
619
+ end
613
620
return quote
614
- local artifact_name, artifact_path_tail, hash = artifact_slash_lookup ($ (esc (name)), $ (artifact_dict), $ (artifacts_toml))
615
- Base. invokelatest (_artifact_str, $ (__module__), $ (artifacts_toml), artifact_name, artifact_path_tail, $ (artifact_dict), hash)
621
+ local platform = $ (esc (platform))
622
+ local artifact_name, artifact_path_tail, hash = artifact_slash_lookup ($ (esc (name)), $ (artifact_dict), $ (artifacts_toml), platform)
623
+ Base. invokelatest (_artifact_str, $ (__module__), $ (artifacts_toml), artifact_name, artifact_path_tail, $ (artifact_dict), hash, platform)
616
624
end
617
625
end
618
626
end
0 commit comments