Skip to content

Load top-level dependencies in the main source file #1231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.8.1"
julia_version = "1.8.0"
manifest_format = "2.0"
project_hash = "f35810f1518b3c855e1d8ed4f1522241fc6dcb7a"
project_hash = "1e87134dc5853b26c2f65af5a46eb0a2d987da86"

[[deps.ArgParse]]
deps = ["Logging", "TextWrap"]
Expand Down Expand Up @@ -33,11 +33,11 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[deps.BinaryBuilderBase]]
deps = ["CodecZlib", "Downloads", "InteractiveUtils", "JSON", "LibGit2", "LibGit2_jll", "Libdl", "Logging", "OrderedCollections", "OutputCollectors", "Pkg", "ProgressMeter", "Random", "SHA", "Scratch", "SimpleBufferStream", "TOML", "Tar", "UUIDs", "p7zip_jll", "pigz_jll"]
git-tree-sha1 = "9b1c2e9866fdf353f925693d69aa440dec5b4c60"
git-tree-sha1 = "29d27e44a3eb75a8487e08e7e26cf3873f1759db"
repo-rev = "master"
repo-url = "https://github.com/JuliaPackaging/BinaryBuilderBase.jl.git"
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
version = "1.15.0"
version = "1.17.0"

[[deps.CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ghr_jll = "07c12ed4-43bc-5495-8a2a-d5838ef8d533"

[compat]
ArgParse = "1.1"
BinaryBuilderBase = "1.15"
BinaryBuilderBase = "1.17"
GitHub = "5.1"
HTTP = "0.8, 0.9, 1"
JLD2 = "0.1.6, 0.2, 0.3, 0.4"
Expand Down
10 changes: 9 additions & 1 deletion src/AutoBuild.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,9 @@ function build_jll_package(src_name::String,
""")
end
for dep in filter_platforms(dependencies, platform)
println(io, "using $(getname(dep))")
if !is_top_level_dependency(dep)
println(io, "using $(getname(dep))")
end
end

# Generate header definitions like `find_artifact_dir()`
Expand Down Expand Up @@ -1388,6 +1390,12 @@ function build_jll_package(src_name::String,
println(io, "using LazyArtifacts")
end

for dep in dependencies
if is_top_level_dependency(dep)
println(io, "using $(getname(dep))")
end
end

if !isempty(augment_platform_block)
print(io, """
Base.include(@__MODULE__, joinpath("..", ".pkg", "platform_augmentation.jl"))
Expand Down
9 changes: 8 additions & 1 deletion test/jll.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ end
freebsd = Platform("x86_64", "freebsd")
platforms = [platform, freebsd]
# We depend on Zlib_jll only on the host platform, but not on FreeBSD
dependencies = [Dependency("Zlib_jll"; platforms=[platform])]
dependencies = [
Dependency("Zlib_jll"; platforms=[platform]),
Dependency("Preferences"; top_level=true)
]
# Augment platform
augment_platform_block = """
using Base.BinaryPlatforms
Expand Down Expand Up @@ -176,8 +179,12 @@ end
# platform and not the FreeBSD one.
platform_wrapper = joinpath(code_dir, "src", "wrappers", triplet(platform) * ".jl")
freebsd_wrapper = joinpath(code_dir, "src", "wrappers", triplet(freebsd) * ".jl")
main_src = joinpath(code_dir, "src", name * "_jll.jl")
@test contains(readchomp(platform_wrapper), "using Zlib_jll")
@test !contains(readchomp(freebsd_wrapper), "using Zlib_jll")
@test !contains(readchomp(platform_wrapper), "using Preferences")
@test !contains(readchomp(freebsd_wrapper), "using Preferences")
@test contains(readchomp(main_src), "using Preferences")
# Load JLL package and run some actual code from it.
@eval TestJLL using libfoo_jll
@test 6.08 ≈ @eval TestJLL ccall((:foo, libfoo), Cdouble, (Cdouble, Cdouble), 2.3, 4.5)
Expand Down