Skip to content
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

Support augment_platform in JLLWrappers #35

Merged
merged 6 commits into from
Jan 12, 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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
- "1.3"
- "1.4"
- "1.5"
- "^1.6.0-0"
- "1.6"
- "1.7"
- "nightly"
os:
- ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JLLWrappers"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
authors = ["Mosè Giordano", "Elliot Saba"]
version = "1.3.0"
version = "1.4.0"

[deps]
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Expand Down
17 changes: 14 additions & 3 deletions src/toplevel_generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ This method generates the toplevel definitions common to all JLL packages, such
`is_available()`, the `PATH` and `LIBPATH` symbols, etc....
"""
function generate_toplevel_definitions(src_name, __source__)
pkg_dir = dirname(String(__source__.file))
vchuravy marked this conversation as resolved.
Show resolved Hide resolved
return quote
"""
is_available()
Expand Down Expand Up @@ -120,6 +119,12 @@ function generate_wrapper_load(src_name, pkg_uuid, __source__)
# Load Artifacts.toml file and select best platform at compile-time, since this is
# running at toplevel, and therefore will be run completely at compile-time. We use
# a `let` block here to avoid storing unnecessary data in our `.ji` files

if @isdefined(augment_platform!)
const host_platform = augment_platform!(HostPlatform())
else
const host_platform = nothing
staticfloat marked this conversation as resolved.
Show resolved Hide resolved
end
best_wrapper = let
artifacts_toml = joinpath($(pkg_dir), "..", "Artifacts.toml")
valid_wrappers = Dict{Platform,String}()
Expand Down Expand Up @@ -158,13 +163,19 @@ function generate_wrapper_load(src_name, pkg_uuid, __source__)
end

# From the available options, choose the best wrapper script
select_platform(valid_wrappers)
# The two argument `select_platform` is notably slower, so micro-optimize this by
# only calling it when necessary.
if host_platform !== nothing
vchuravy marked this conversation as resolved.
Show resolved Hide resolved
select_platform(valid_wrappers, host_platform)
else
select_platform(valid_wrappers)
end
staticfloat marked this conversation as resolved.
Show resolved Hide resolved
end
end

# Load in the wrapper, if it's not `nothing`!
if best_wrapper === nothing
@debug(string("Unable to load ", $(src_name), "; unsupported platform ", triplet(HostPlatform())))
@debug(string("Unable to load ", $(src_name), "; unsupported platform ", triplet(host_platform)))
is_available() = false
else
Base.include($(Symbol("$(src_name)_jll")), best_wrapper)
Expand Down
6 changes: 4 additions & 2 deletions src/wrapper_generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ macro generate_wrapper_header(src_name)
# We determine at compile-time whether our JLL package has been dev'ed and overridden
@static if isdir(joinpath(dirname($(pkg_dir)), "override"))
return joinpath(dirname($(pkg_dir)), "override")
elseif @isdefined(augment_platform!) && VERSION >= v"1.6"
$(Expr(:macrocall, Symbol("@artifact_str"), __source__, src_name, :(host_platform)))
else
# We explicitly use `macrocall` here so that we can manually pass the `__source__`
# argument, to avoid `@artifact_str` trying to lookup `Artifacts.toml` here.
Expand All @@ -24,8 +26,8 @@ macro generate_init_header(dependencies...)
if !isempty(dependencies)
for dep in dependencies
push!(deps_path_add, quote
append!(PATH_list, $(dep).PATH_list)
append!(LIBPATH_list, $(dep).LIBPATH_list)
isdefined($(dep), :PATH_list) && append!(PATH_list, $(dep).PATH_list)
isdefined($(dep), :LIBPATH_list) && append!(LIBPATH_list, $(dep).LIBPATH_list)
vchuravy marked this conversation as resolved.
Show resolved Hide resolved
end)
end
end
Expand Down
11 changes: 11 additions & 0 deletions test/LAMMPS_jll/.pkg/platform_augmentation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Base.BinaryPlatforms

function augment_platform!(platform)
vchuravy marked this conversation as resolved.
Show resolved Hide resolved
# Can't use Preferences since we might be running this very early with a non-existing Manifest
LAMMPS_UUID = Base.UUID("5b3ab26d-9607-527c-88ea-8fe5ba57cafe")
abi = get(Base.get_preferences(LAMMPS_UUID), "abi", Sys.iswindows() ? "microsoftmpi" : "mpich")
if !haskey(platform, "mpi")
staticfloat marked this conversation as resolved.
Show resolved Hide resolved
platform["mpi"] = abi
end
return platform
end
22 changes: 22 additions & 0 deletions test/LAMMPS_jll/.pkg/select_artifacts.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Note: This file is executed from `Pkg` in an isolated environment.
# Warn: Since this is executed in a sandbox, the current preferences are not
vchuravy marked this conversation as resolved.
Show resolved Hide resolved
# propagated and thus no decision can be made based on them.
# Use LazyArtifacts in this case.
# Fixed in https://github.com/JuliaLang/Pkg.jl/pull/2920

push!(Base.LOAD_PATH, dirname(@__DIR__))
vchuravy marked this conversation as resolved.
Show resolved Hide resolved
using TOML, Artifacts, Base.BinaryPlatforms
include("./platform_augmentation.jl")
artifacts_toml = joinpath(dirname(@__DIR__), "Artifacts.toml")

# Get "target triplet" from ARGS, if given (defaulting to the host triplet otherwise)
target_triplet = get(ARGS, 1, Base.BinaryPlatforms.host_triplet())

# Augment this platform object with any special tags we require
platform = augment_platform!(HostPlatform(parse(Platform, target_triplet)))

# Select all downloadable artifacts that match that platform
artifacts = select_downloadable_artifacts(artifacts_toml; platform, include_lazy = true)
vchuravy marked this conversation as resolved.
Show resolved Hide resolved

#Output the result to `stdout` as a TOML dictionary
TOML.print(stdout, artifacts)
Loading