Skip to content

Commit 7e323af

Browse files
giordanovchuravy
authored andcommitted
[AutoBuild] Implement platform-dependent dependencies in JLLs
1 parent 0f2e95c commit 7e323af

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/AutoBuild.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
264264
# If the user passed in a platform (or a few, comma-separated) on the
265265
# command-line, use that instead of our default platforms
266266
if length(ARGS) > 0
267-
parse_platform(p::AbstractString) = p == "any" ? AnyPlatform() : parse(Platform, p; validate_strict=true)
268-
platforms = parse_platform.(split(ARGS[1], ","))
267+
platforms = BinaryBuilderBase.parse_platform.(split(ARGS[1], ","))
269268
end
270269

271270
# Check to make sure we have the necessary environment stuff
@@ -723,8 +722,10 @@ function autobuild(dir::AbstractString,
723722
default_host_platform;
724723
verbose=verbose,
725724
)
726-
host_artifact_paths = setup_dependencies(prefix, Pkg.Types.PackageSpec[getpkg(d) for d in dependencies if is_host_dependency(d)], default_host_platform; verbose=verbose)
727-
target_artifact_paths = setup_dependencies(prefix, Pkg.Types.PackageSpec[getpkg(d) for d in dependencies if is_target_dependency(d)], concrete_platform; verbose=verbose)
725+
setup_deps(f, prefix, dependencies, platform, verbose) =
726+
setup_dependencies(prefix, Pkg.Types.PackageSpec[getpkg(d) for d in filter_platforms(dependencies, platform) if f(d)], platform; verbose)
727+
host_artifact_paths = setup_deps(is_host_dependency, prefix, dependencies, default_host_platform, verbose)
728+
target_artifact_paths = setup_deps(is_target_dependency, prefix, dependencies, concrete_platform, verbose)
728729

729730
# Create a runner to work inside this workspace with the nonce built-in
730731
ur = preferred_runner()(
@@ -1174,7 +1175,7 @@ function build_jll_package(src_name::String,
11741175
export $(join(sort(variable_name.(first.(collect(products_info)))), ", "))
11751176
""")
11761177
end
1177-
for dep in dependencies
1178+
for dep in filter_platforms(dependencies, platform)
11781179
println(io, "using $(getname(dep))")
11791180
end
11801181

@@ -1205,7 +1206,7 @@ function build_jll_package(src_name::String,
12051206

12061207
print(io, """
12071208
function __init__()
1208-
JLLWrappers.@generate_init_header($(join(getname.(dependencies), ", ")))
1209+
JLLWrappers.@generate_init_header($(join(getname.(filter_platforms(dependencies, platform)), ", ")))
12091210
""")
12101211

12111212
for (p, p_info) in sort(products_info)
@@ -1307,7 +1308,7 @@ function build_jll_package(src_name::String,
13071308
# In this case we can easily add a direct link to the repo
13081309
println(io, "* [`", depname, "`](https://github.com/JuliaBinaryWrappers/", depname, ".jl)")
13091310
else
1310-
println(io, "* `", depname, ")`")
1311+
println(io, "* `", depname, "`")
13111312
end
13121313
end
13131314
print_product(io, p::Product) = println(io, "* `", typeof(p), "`: `", variable_name(p), "`")
@@ -1343,6 +1344,8 @@ function build_jll_package(src_name::String,
13431344
for p in sort(collect(platforms), by = triplet)
13441345
println(io, "* `", p, "` (`", triplet(p), "`)")
13451346
end
1347+
# Note: here we list _all_ runtime dependencies, including those that may be
1348+
# required only for some platforms.
13461349
if length(dependencies) > 0
13471350
println(io)
13481351
println(io, """
@@ -1393,7 +1396,8 @@ function build_jll_package(src_name::String,
13931396
# We used to have a duplicate license file, remove it.
13941397
rm(joinpath(code_dir, "LICENSE.md"); force=true)
13951398

1396-
# Add a Project.toml
1399+
# Add a Project.toml. Note: here we list _all_ runtime dependencies, including those
1400+
# that may be required only for some platforms.
13971401
project = build_project_dict(src_name, build_version, dependencies, julia_compat; lazy_artifacts=lazy_artifacts)
13981402
open(joinpath(code_dir, "Project.toml"), "w") do io
13991403
Pkg.TOML.print(io, project)

0 commit comments

Comments
 (0)