|
4 | 4 | baremodule GMP_jll |
5 | 5 | using Base, Libdl |
6 | 6 |
|
7 | | -const PATH_list = String[] |
8 | | -const LIBPATH_list = String[] |
9 | | - |
10 | 7 | export libgmp, libgmpxx |
11 | 8 |
|
12 | 9 | # These get calculated in __init__() |
13 | 10 | const PATH = Ref("") |
| 11 | +const PATH_list = String[] |
14 | 12 | const LIBPATH = Ref("") |
| 13 | +const LIBPATH_list = String[] |
15 | 14 | artifact_dir::String = "" |
16 | | -libgmp_handle::Ptr{Cvoid} = C_NULL |
17 | 15 | libgmp_path::String = "" |
18 | | -libgmpxx_handle::Ptr{Cvoid} = C_NULL |
19 | 16 | libgmpxx_path::String = "" |
20 | 17 |
|
| 18 | +_libgmp_dependencies = LazyLibrary[] |
| 19 | +_libgmpxx_dependencies = LazyLibrary[] |
| 20 | + |
21 | 21 | if Sys.iswindows() |
22 | | - const libgmp = "libgmp-10.dll" |
23 | | - const libgmpxx = "libgmpxx-4.dll" |
| 22 | + const _libgmp_path = BundledLazyLibraryPath("libgmp-10.dll") |
| 23 | + const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx-4.dll") |
24 | 24 | elseif Sys.isapple() |
25 | | - const libgmp = "@rpath/libgmp.10.dylib" |
26 | | - const libgmpxx = "@rpath/libgmpxx.4.dylib" |
| 25 | + const _libgmp_path = BundledLazyLibraryPath("libgmp.10.dylib") |
| 26 | + const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx.4.dylib") |
27 | 27 | else |
28 | | - const libgmp = "libgmp.so.10" |
29 | | - const libgmpxx = "libgmpxx.so.4" |
| 28 | + const _libgmp_path = BundledLazyLibraryPath("libgmp.so.10") |
| 29 | + const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx.so.4") |
30 | 30 | end |
31 | 31 |
|
| 32 | +const libgmp = LazyLibrary( |
| 33 | + _libgmp_path, |
| 34 | + dependencies=_libgmp_dependencies, |
| 35 | +) |
| 36 | + |
| 37 | +const libgmpxx = LazyLibrary( |
| 38 | + _libgmpxx_path, |
| 39 | + dependencies=_libgmpxx_dependencies, |
| 40 | +) |
| 41 | + |
| 42 | +function eager_mode() |
| 43 | + dlopen(libgmp) |
| 44 | + dlopen(libgmpxx) |
| 45 | +end |
| 46 | +is_available() = true |
| 47 | + |
32 | 48 | function __init__() |
33 | | - global libgmp_handle = dlopen(libgmp) |
34 | | - global libgmp_path = dlpath(libgmp_handle) |
35 | | - global libgmpxx_handle = dlopen(libgmpxx) |
36 | | - global libgmpxx_path = dlpath(libgmpxx_handle) |
| 49 | + global libgmp_path = string(_libgmp_path) |
| 50 | + global libgmpxx_path = string(_libgmpxx_path) |
37 | 51 | global artifact_dir = dirname(Sys.BINDIR) |
38 | 52 | LIBPATH[] = dirname(libgmp_path) |
39 | 53 | push!(LIBPATH_list, LIBPATH[]) |
40 | 54 | end |
41 | 55 |
|
42 | | -# JLLWrappers API compatibility shims. Note that not all of these will really make sense. |
43 | | -# For instance, `find_artifact_dir()` won't actually be the artifact directory, because |
44 | | -# there isn't one. It instead returns the overall Julia prefix. |
45 | | -is_available() = true |
46 | | -find_artifact_dir() = artifact_dir |
47 | | -dev_jll() = error("stdlib JLLs cannot be dev'ed") |
48 | | -best_wrapper = nothing |
49 | | -get_libgmp_path() = libgmp_path |
50 | | -get_libgmpxx_path() = libgmpxx_path |
51 | | - |
52 | 56 | end # module GMP_jll |
0 commit comments