Skip to content

Commit f5cd48e

Browse files
committed
Support augment_platform in JLLWrappers
1 parent d3c1bf5 commit f5cd48e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/toplevel_generators.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ This method generates the toplevel definitions common to all JLL packages, such
7474
`is_available()`, the `PATH` and `LIBPATH` symbols, etc....
7575
"""
7676
function generate_toplevel_definitions(src_name, __source__)
77-
pkg_dir = dirname(String(__source__.file))
7877
return quote
7978
"""
8079
is_available()
@@ -120,6 +119,12 @@ function generate_wrapper_load(src_name, pkg_uuid, __source__)
120119
# Load Artifacts.toml file and select best platform at compile-time, since this is
121120
# running at toplevel, and therefore will be run completely at compile-time. We use
122121
# a `let` block here to avoid storing unnecessary data in our `.ji` files
122+
123+
if @isdefined(augment_platform!)
124+
const host_platform = augment_platform!(HostPlatform())
125+
else
126+
const host_platform = nothing
127+
end
123128
best_wrapper = let
124129
artifacts_toml = joinpath($(pkg_dir), "..", "Artifacts.toml")
125130
valid_wrappers = Dict{Platform,String}()
@@ -158,13 +163,19 @@ function generate_wrapper_load(src_name, pkg_uuid, __source__)
158163
end
159164

160165
# From the available options, choose the best wrapper script
161-
select_platform(valid_wrappers)
166+
# The two argument `select_platform` is notably slower, so micro-optimize this by
167+
# only calling it when necessary.
168+
if host_platform !== nothing
169+
select_platform(valid_wrappers, host_platform)
170+
else
171+
select_platform(valid_wrappers)
172+
end
162173
end
163174
end
164175

165176
# Load in the wrapper, if it's not `nothing`!
166177
if best_wrapper === nothing
167-
@debug(string("Unable to load ", $(src_name), "; unsupported platform ", triplet(HostPlatform())))
178+
@debug(string("Unable to load ", $(src_name), "; unsupported platform ", triplet(host_platform)))
168179
is_available() = false
169180
else
170181
Base.include($(Symbol("$(src_name)_jll")), best_wrapper)

src/wrapper_generators.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ macro generate_wrapper_header(src_name)
99
# We determine at compile-time whether our JLL package has been dev'ed and overridden
1010
@static if isdir(joinpath(dirname($(pkg_dir)), "override"))
1111
return joinpath(dirname($(pkg_dir)), "override")
12+
elseif @isdefined(augment_platform!) && VERSION >= v"1.6"
13+
$(Expr(:macrocall, Symbol("@artifact_str"), __source__, src_name, :(host_platform)))
1214
else
1315
# We explicitly use `macrocall` here so that we can manually pass the `__source__`
1416
# argument, to avoid `@artifact_str` trying to lookup `Artifacts.toml` here.

0 commit comments

Comments
 (0)