Skip to content

Commit 503f17a

Browse files
committed
Allow for non jll dependencies
1 parent 084d75b commit 503f17a

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

src/AutoBuild.jl

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,29 @@ const uuid_package = UUID("cfb74b52-ec16-5bb7-a574-95d9e393895e")
14251425
# For even more interesting historical reasons, we append an extra
14261426
# "_jll" to the name of the new package before computing its UUID.
14271427
jll_uuid(name) = bb_specific_uuid5(uuid_package, "$(name)_jll")
1428+
1429+
function find_uuid(ctx, pkg)
1430+
if Pkg.Types.has_uuid(pkg)
1431+
return pkg.uuid
1432+
end
1433+
depname = getname(pkg)
1434+
@static if VERSION >= v"1.7"
1435+
uuids = Pkg.Types.registered_uuids(ctx.registries, depname)
1436+
else
1437+
uuids = Pkg.Types.registered_uuids(ctx, depname)
1438+
end
1439+
if isempty(uuids)
1440+
return nothing
1441+
end
1442+
if length(uuids) == 1
1443+
return first(uuids)
1444+
end
1445+
error("""
1446+
Multiple UUIDs found for package `$(depname)`.
1447+
Use `PackageSpec(name = \"$(depname)\", uuid = ..." to specify the UUID explicitly.
1448+
""")
1449+
end
1450+
14281451
function build_project_dict(name, version, dependencies::Array{Dependency}, julia_compat::String=DEFAULT_JULIA_VERSION_SPEC; lazy_artifacts::Bool=false, kwargs...)
14291452
Pkg.Types.semver_spec(julia_compat) # verify julia_compat is valid
14301453
project = Dict(
@@ -1437,9 +1460,16 @@ function build_project_dict(name, version, dependencies::Array{Dependency}, juli
14371460
"compat" => Dict{String,Any}("JLLWrappers" => "1.2.0",
14381461
"julia" => "$(julia_compat)")
14391462
)
1463+
1464+
ctx = Pkg.Types.Context()
14401465
for dep in dependencies
1466+
pkgspec = getpkg(dep)
14411467
depname = getname(dep)
1442-
project["deps"][depname] = string(jll_uuid(depname))
1468+
uuid = find_uuid(ctx, pkgspec)
1469+
if uuid === nothing
1470+
uuid = jll_uuid(depname)
1471+
end
1472+
project["deps"][depname] = string(uuid)
14431473
if dep isa Dependency && length(dep.compat) > 0
14441474
Pkg.Types.semver_spec(dep.compat) # verify dep.compat is valid
14451475
project["compat"][depname] = dep.compat

test/jll.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ module TestJLL end
99
@test jll_uuid("Zlib_jll") == UUID("83775a58-1f1d-513f-b197-d71354ab007a")
1010
@test jll_uuid("FFMPEG_jll") == UUID("b22a6f82-2f65-5046-a5b2-351ab43fb4e5")
1111

12-
project = build_project_dict("LibFoo", v"1.3.5", [Dependency("Zlib_jll"), Dependency(PackageSpec(name = "XZ_jll"), compat = "=2.4.6")])
12+
project = build_project_dict("LibFoo", v"1.3.5",
13+
[Dependency("Zlib_jll"),
14+
Dependency(PackageSpec(name = "XZ_jll"), compat = "=2.4.6"),
15+
Dependency(PackageSpec(name = "Preferences", uuid = parse(UUID, "21216c6a-2e73-6563-6e65-726566657250"))),
16+
Dependency("Scratch"),])
1317
@test project["deps"] == Dict("JLLWrappers" => "692b3bcd-3c85-4b1f-b108-f13ce0eb3210",
1418
"Artifacts" => "56f22d72-fd6d-98f1-02f0-08ddc0907c33",
1519
"Pkg" => "44cfe95a-1eb2-52ea-b672-e2afdf69b78f",
1620
"Zlib_jll" => "83775a58-1f1d-513f-b197-d71354ab007a",
1721
"Libdl" => "8f399da3-3557-5675-b5ff-fb832c97cbdb",
18-
"XZ_jll" => "ffd25f8a-64ca-5728-b0f7-c24cf3aae800")
22+
"XZ_jll" => "ffd25f8a-64ca-5728-b0f7-c24cf3aae800",
23+
"Preferences" => "21216c6a-2e73-6563-6e65-726566657250",
24+
"Scratch" => "6c6a2e73-6563-6170-7368-637461726353")
1925
@test project["name"] == "LibFoo_jll"
2026
@test project["uuid"] == "b250f842-3251-58d3-8ee4-9a24ab2bab3f"
2127
@test project["compat"] == Dict("julia" => "1.0", "XZ_jll" => "=2.4.6", "JLLWrappers" => "1.2.0")

0 commit comments

Comments
 (0)