Skip to content

Commit ee26632

Browse files
lazify OpenLibm_jll
1 parent 3e2ac51 commit ee26632

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

stdlib/OpenLibm_jll/src/OpenLibm_jll.jl

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,41 @@
44
baremodule OpenLibm_jll
55
using Base, Libdl
66

7-
const PATH_list = String[]
8-
const LIBPATH_list = String[]
9-
107
export libopenlibm
118

129
# These get calculated in __init__()
1310
const PATH = Ref("")
11+
const PATH_list = String[]
1412
const LIBPATH = Ref("")
13+
const LIBPATH_list = String[]
1514
artifact_dir::String = ""
1615
libopenlibm_path::String = ""
1716

17+
_libopenlibm_dependencies = LazyLibrary[]
18+
1819
if Sys.iswindows()
19-
const libopenlibm = "libopenlibm.dll"
20+
const _libopenlibm_path = BundledLazyLibraryPath("libopenlibm.dll")
2021
elseif Sys.isapple()
21-
const libopenlibm = "@rpath/libopenlibm.4.dylib"
22+
const _libopenlibm_path = BundledLazyLibraryPath("libopenlibm.4.dylib")
2223
else
23-
const libopenlibm = "libopenlibm.so.4"
24+
const _libopenlibm_path = BundledLazyLibraryPath("libopenlibm.so.4")
2425
end
2526

27+
const libopenlibm = LazyLibrary(
28+
_libopenlibm_path,
29+
dependencies=_libopenlibm_dependencies,
30+
)
31+
32+
function eager_mode()
33+
dlopen(libopenlibm)
34+
end
35+
is_available() = true
36+
2637
function __init__()
27-
global libopenlibm_handle = dlopen(libopenlibm)
28-
global libopenlibm_path = dlpath(libopenlibm_handle)
38+
global libopenlibm_path = string(_libopenlibm_path)
2939
global artifact_dir = dirname(Sys.BINDIR)
3040
LIBPATH[] = dirname(libopenlibm_path)
3141
push!(LIBPATH_list, LIBPATH[])
3242
end
3343

34-
# JLLWrappers API compatibility shims. Note that not all of these will really make sense.
35-
# For instance, `find_artifact_dir()` won't actually be the artifact directory, because
36-
# there isn't one. It instead returns the overall Julia prefix.
37-
is_available() = true
38-
find_artifact_dir() = artifact_dir
39-
dev_jll() = error("stdlib JLLs cannot be dev'ed")
40-
best_wrapper = nothing
41-
get_libopenlibm_path() = libopenlibm_path
42-
4344
end # module OpenLibm_jll

0 commit comments

Comments
 (0)