Skip to content

Commit 1cc1cdf

Browse files
authored
add support for dynamic artifact selection (#690)
1 parent adbf1df commit 1cc1cdf

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

examples/MyApp/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
99
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
1010
Example = "7876af07-990d-54b4-ab0e-23690620f79a"
1111
HelloWorldC_jll = "dca1746e-5efc-54fc-8249-22745bc95a49"
12+
LLVMExtra_jll = "dad2f222-ce93-54a1-a47d-0025e8a3acab"
1213
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

examples/MyApp/src/MyApp.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using HelloWorldC_jll
55
using Artifacts
66
using Distributed
77
using Random
8+
using LLVMExtra_jll
89

910
const myrand = rand()
1011

@@ -72,13 +73,19 @@ function real_main()
7273
addprocs(4)
7374
@eval @everywhere using MyApp
7475
end
75-
76+
7677
n = @distributed (+) for i = 1:20000000
7778
1
7879
end
7980
println("n = $n")
8081
@eval @everywhere using Example
8182
@everywhere println(Example.domath(3))
83+
84+
if isfile(LLVMExtra_jll.libLLVMExtra_path)
85+
println("LLVMExtra path: ok!")
86+
else
87+
println("LLVMExtra path: fail!")
88+
end
8289
return
8390
end
8491

src/PackageCompiler.jl

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,16 +1072,25 @@ function bundle_artifacts(ctx, dest_dir; include_lazy_artifacts::Bool)
10721072
pkg_source_path = source_path(ctx, pkg)
10731073
pkg_source_path === nothing && continue
10741074
bundled_artifacts_pkg = Pair{String, String}[]
1075-
# Check to see if this package has an (Julia)Artifacts.toml
1076-
for f in Pkg.Artifacts.artifact_names
1077-
artifacts_toml_path = joinpath(pkg_source_path, f)
1078-
if isfile(artifacts_toml_path)
1079-
artifacts = Artifacts.select_downloadable_artifacts(artifacts_toml_path; platform, include_lazy=include_lazy_artifacts)
1080-
for name in keys(artifacts)
1081-
artifact_path = Pkg.ensure_artifact_installed(name, artifacts[name], artifacts_toml_path; platform)
1082-
push!(bundled_artifacts_pkg, name => artifact_path)
1075+
if isdefined(Pkg.Operations, :collect_artifacts)
1076+
for (artifacts_toml, artifacts) in Pkg.Operations.collect_artifacts(pkg_source_path; platform)
1077+
for (name, data) in artifacts
1078+
Pkg.ensure_artifact_installed(name, artifacts[name], artifacts_toml; platform)
1079+
hash = Base.SHA1(data["git-tree-sha1"])
1080+
push!(bundled_artifacts_pkg, name => artifact_path(hash))
1081+
end
1082+
end
1083+
else
1084+
for f in Pkg.Artifacts.artifact_names
1085+
artifacts_toml_path = joinpath(pkg_source_path, f)
1086+
if isfile(artifacts_toml_path)
1087+
artifacts = Artifacts.select_downloadable_artifacts(artifacts_toml_path; platform, include_lazy=include_lazy_artifacts)
1088+
for name in keys(artifacts)
1089+
artifact_path = Pkg.ensure_artifact_installed(name, artifacts[name], artifacts_toml_path; platform)
1090+
push!(bundled_artifacts_pkg, name => artifact_path)
1091+
end
1092+
break
10831093
end
1084-
break
10851094
end
10861095
end
10871096
if !isempty(bundled_artifacts_pkg)

test/runtests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ end
6262
tmp_app_source_dir = joinpath(tmp, "MyApp")
6363
cp(app_source_dir, tmp_app_source_dir)
6464
create_app(tmp_app_source_dir, app_compiled_dir; incremental=incremental, force=true, filter_stdlibs=filter,
65-
precompile_execution_file=joinpath(app_source_dir, "precompile_app.jl"),
66-
executables=["MyApp" => "julia_main",
65+
precompile_execution_file=joinpath(app_source_dir, "precompile_app.jl"),
66+
executables=["MyApp" => "julia_main",
6767
"SecondApp" => "second_main",
6868
"ReturnType" => "wrong_return_type",
6969
"Error" => "erroring",
@@ -111,6 +111,8 @@ end
111111
@test occursin("From worker 4:\t8", app_output)
112112
@test occursin("From worker 5:\t8", app_output)
113113

114+
@test occursin("LLVMExtra path: ok!", app_output)
115+
114116
# Test second app
115117
app_output = read(`$(app_path("SecondApp"))`, String)
116118
@test occursin("Hello from second main", app_output)

0 commit comments

Comments
 (0)