Skip to content

Commit fc26f0f

Browse files
committed
Avoid dirname(), use a baremodule
1 parent 86201e1 commit fc26f0f

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

src/AutoBuild.jl

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,10 +1115,6 @@ function build_jll_package(src_name::String,
11151115
for (p, p_info) in sort(products_info)
11161116
vp = variable_name(p)
11171117
println(io, """
1118-
# Relative path to `$(vp)`
1119-
const $(vp)_splitpath = $(repr(splitpath(p_info["path"])))
1120-
const $(vp)_joinpath = joinpath($(vp)_splitpath...)
1121-
11221118
# This will be filled out by __init__() for all products, as it must be done at runtime
11231119
$(vp)_path = ""
11241120
@@ -1171,7 +1167,13 @@ function build_jll_package(src_name::String,
11711167
if p isa LibraryProduct || p isa FrameworkProduct
11721168
println(io, """
11731169
global $(vp)_path, $(vp)_handle
1174-
$(vp)_path, $(vp)_handle = get_lib_path_handle!(LIBPATH_list, artifact_dir, $(vp)_joinpath, $(BinaryBuilderBase.dlopen_flags_str(p)))
1170+
$(vp)_path, $(vp)_handle = get_lib_path_handle!(
1171+
LIBPATH_list,
1172+
artifact_dir,
1173+
$(repr(p_info["path"])),
1174+
$(repr(dirname(p_info["path"]))),
1175+
$(BinaryBuilderBase.dlopen_flags_str(p)),
1176+
)
11751177
""")
11761178
# println(io, """
11771179
# global $(vp)_path = normpath(joinpath(artifact_dir, $(vp)_joinpath))
@@ -1180,7 +1182,12 @@ function build_jll_package(src_name::String,
11801182
# """)
11811183
elseif p isa ExecutableProduct
11821184
println(io, """
1183-
global $(vp)_path = get_exe_path!(PATH_list, artifact_dir, $(vp)_joinpath)
1185+
global $(vp)_path = get_exe_path!(
1186+
PATH_list,
1187+
artifact_dir,
1188+
$(repr(p_info["path"])),
1189+
$(repr(dirname(p_info["path"]))),
1190+
)
11841191
""")
11851192
elseif p isa FileProduct
11861193
println(io, " global $(vp) = $(vp)_path")
@@ -1247,12 +1254,9 @@ function build_jll_package(src_name::String,
12471254

12481255
# Generate target-demuxing main source file.
12491256
jll_jl = """
1250-
module $(src_name)_jll
1251-
1252-
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@optlevel"))
1253-
@eval Base.Experimental.@optlevel 0
1254-
end
1255-
1257+
# Use baremodule to shave a few pieces of data off
1258+
baremodule $(src_name)_jll
1259+
using Base
12561260
if VERSION < v"1.6.0-DEV"
12571261
# We lie a bit in the registry that JLL packages are usable on Julia 1.0-1.2.
12581262
# This is to allow packages that might want to support Julia 1.0 to get the
@@ -1272,15 +1276,19 @@ function build_jll_package(src_name::String,
12721276
end
12731277
12741278
using Base.BinaryPlatforms, Artifacts, Libdl, JLLWrappers
1275-
import Base: UUID
1279+
using Base: UUID
1280+
1281+
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@optlevel"))
1282+
Core.eval($(src_name)_jll, :(Base.Experimental.@optlevel 0))
1283+
end
12761284
1277-
wrapper_available = false
12781285
\"\"\"
12791286
is_available()
12801287
12811288
Return whether the artifact is available for the current platform.
12821289
\"\"\"
1283-
is_available() = wrapper_available
1290+
function is_available end
1291+
12841292
12851293
# We put these inter-JLL-package API values here so that they are always defined, even if there
12861294
# is no underlying wrapper held within this JLL package.
@@ -1326,8 +1334,10 @@ function build_jll_package(src_name::String,
13261334
# Silently fail if there's no binaries for this platform
13271335
if best_wrapper === nothing
13281336
@debug("Unable to load $(src_name); unsupported platform \$(triplet(platform_key_abi()))")
1337+
is_available() = false
13291338
else
13301339
Base.include($(src_name)_jll, best_wrapper)
1340+
is_available() = true
13311341
end
13321342
"""
13331343
end

0 commit comments

Comments
 (0)