Skip to content

Commit 4adbc62

Browse files
committed
micro-optimize the non augmented case
1 parent 6584bb0 commit 4adbc62

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/toplevel_generators.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,13 @@ function generate_imports(src_name)
3131
using Pkg.Artifacts: load_artifacts_toml, unpack_platform
3232
using Pkg.BinaryPlatforms: triplet, select_platform
3333
HostPlatform() = platform_key_abi()
34-
if !@isdefined(augment_platform!)
35-
augment_platform!(platform) = platform
36-
end
3734
end
3835
else
3936
# Use fast stdlib-based Artifacts + Preferences
4037
return quote
4138
using Libdl, Artifacts, JLLWrappers.Preferences, Base.BinaryPlatforms
4239
using Artifacts: load_artifacts_toml, unpack_platform
4340
using Base.BinaryPlatforms: triplet, select_platform
44-
if !@isdefined(augment_platform!)
45-
augment_platform!(platform) = platform
46-
end
4741
end
4842
end
4943
end
@@ -126,7 +120,11 @@ function generate_wrapper_load(src_name, pkg_uuid, __source__)
126120
# running at toplevel, and therefore will be run completely at compile-time. We use
127121
# a `let` block here to avoid storing unnecessary data in our `.ji` files
128122

129-
const host_platform = augment_platform!(HostPlatform())
123+
if @isdefined(augment_platform!)
124+
const host_platform = augment_platform!(HostPlatform())
125+
else
126+
const host_platform = nothing
127+
end
130128
best_wrapper = let
131129
artifacts_toml = joinpath($(pkg_dir), "..", "Artifacts.toml")
132130
valid_wrappers = Dict{Platform,String}()
@@ -165,7 +163,11 @@ function generate_wrapper_load(src_name, pkg_uuid, __source__)
165163
end
166164

167165
# From the available options, choose the best wrapper script
168-
select_platform(valid_wrappers, host_platform)
166+
if host_platform !== nothing
167+
select_platform(valid_wrappers, host_platform)
168+
else
169+
select_platform(valid_wrappers)
170+
end
169171
end
170172
end
171173

src/wrapper_generators.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@ include("products/library_generators.jl")
44

55
macro generate_wrapper_header(src_name)
66
pkg_dir = dirname(dirname(String(__source__.file)))
7-
if VERSION >= v"1.6"
8-
artifact_expr = Expr(:macrocall, Symbol("@artifact_str"), __source__, src_name, :(host_platform))
9-
else
10-
artifact_expr = Expr(:macrocall, Symbol("@artifact_str"), __source__, src_name)
11-
end
127
return esc(quote
138
function find_artifact_dir()
149
# We determine at compile-time whether our JLL package has been dev'ed and overridden
1510
@static if isdir(joinpath(dirname($(pkg_dir)), "override"))
1611
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)))
1714
else
1815
# We explicitly use `macrocall` here so that we can manually pass the `__source__`
1916
# argument, to avoid `@artifact_str` trying to lookup `Artifacts.toml` here.
20-
return $(artifact_expr)
17+
return $(Expr(:macrocall, Symbol("@artifact_str"), __source__, src_name))
2118
end
2219
end
2320
function find_or_instantiate_artifact_dir()

0 commit comments

Comments
 (0)