|
1 | | -module libpolymake_julia_jll |
2 | | - |
3 | | -if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@optlevel")) |
4 | | - @eval Base.Experimental.@optlevel 0 |
5 | | -end |
6 | | - |
7 | | -if VERSION < v"1.3.0-rc4" |
8 | | - # We lie a bit in the registry that JLL packages are usable on Julia 1.0-1.2. |
9 | | - # This is to allow packages that might want to support Julia 1.0 to get the |
10 | | - # benefits of a JLL package on 1.3 (requiring them to declare a dependence on |
11 | | - # this JLL package in their Project.toml) but engage in heroic hacks to do |
12 | | - # something other than actually use a JLL package on 1.0-1.2. By allowing |
13 | | - # this package to be installed (but not loaded) on 1.0-1.2, we enable users |
14 | | - # to avoid splitting their package versions into pre-1.3 and post-1.3 branches |
15 | | - # if they are willing to engage in the kinds of hoop-jumping they might need |
16 | | - # to in order to install binaries in a JLL-compatible way on 1.0-1.2. One |
17 | | - # example of this hoop-jumping being to express a dependency on this JLL |
18 | | - # package, then import it within a `VERSION >= v"1.3"` conditional, and use |
19 | | - # the deprecated `build.jl` mechanism to download the binaries through e.g. |
20 | | - # `BinaryProvider.jl`. This should work well for the simplest packages, and |
21 | | - # require greater and greater heroics for more and more complex packages. |
22 | | - error("Unable to import libpolymake_julia_jll on Julia versions older than 1.3!") |
23 | | -end |
24 | | - |
25 | | -using Pkg, Pkg.BinaryPlatforms, Pkg.Artifacts, Libdl |
26 | | -import Base: UUID |
27 | | - |
28 | | -wrapper_available = false |
29 | | -""" |
30 | | - is_available() |
31 | | -
|
32 | | -Return whether the artifact is available for the current platform. |
33 | | -""" |
34 | | -is_available() = wrapper_available |
35 | | - |
36 | | -# We put these inter-JLL-package API values here so that they are always defined, even if there |
37 | | -# is no underlying wrapper held within this JLL package. |
38 | | -const PATH_list = String[] |
39 | | -const LIBPATH_list = String[] |
40 | | - |
41 | | -# We determine, here, at compile-time, whether our JLL package has been dev'ed and overridden |
42 | | -override_dir = joinpath(dirname(@__DIR__), "override") |
43 | | -if isdir(override_dir) |
44 | | - function find_artifact_dir() |
45 | | - return override_dir |
46 | | - end |
47 | | -else |
48 | | - function find_artifact_dir() |
49 | | - return artifact"libpolymake_julia" |
50 | | - end |
51 | | - |
52 | | - """ |
53 | | - dev_jll() |
54 | | -
|
55 | | - Check this package out to the dev package directory (usually ~/.julia/dev), |
56 | | - copying the artifact over to a local `override` directory, allowing package |
57 | | - developers to experiment with a locally-built binary. |
58 | | - """ |
59 | | - function dev_jll() |
60 | | - # First, `dev` out the package, but don't effect the current project |
61 | | - mktempdir() do temp_env |
62 | | - Pkg.activate(temp_env) do |
63 | | - Pkg.develop("libpolymake_julia_jll") |
64 | | - end |
65 | | - end |
66 | | - # Create the override directory |
67 | | - override_dir = joinpath(Pkg.devdir(), "libpolymake_julia_jll", "override") |
68 | | - # Copy the current artifact contents into that directory |
69 | | - if !isdir(override_dir) |
70 | | - cp(artifact"libpolymake_julia", override_dir) |
71 | | - end |
72 | | - # Force recompilation of that package, just in case it wasn't dev'ed before |
73 | | - touch(joinpath(Pkg.devdir(), "libpolymake_julia_jll", "src", "libpolymake_julia_jll.jl")) |
74 | | - @info("libpolymake_julia_ll dev'ed out to /depot/dev/libpolymake_julia_jll with pre-populated override directory") |
75 | | - end |
76 | | -end |
77 | | -# Load Artifacts.toml file |
78 | | -artifacts_toml = joinpath(@__DIR__, "..", "Artifacts.toml") |
79 | | - |
80 | | -# Extract all platforms |
81 | | -artifacts = Pkg.Artifacts.load_artifacts_toml(artifacts_toml; pkg_uuid=UUID("4d8266f6-2b3b-57e3-ad7a-d431eaaac945")) |
82 | | -platforms = [Pkg.Artifacts.unpack_platform(e, "libpolymake_julia", artifacts_toml) for e in artifacts["libpolymake_julia"]] |
83 | | - |
84 | | -# Filter platforms based on what wrappers we've generated on-disk |
85 | | -filter!(p -> isfile(joinpath(@__DIR__, "wrappers", replace(triplet(p), "arm-" => "armv7l-") * ".jl")), platforms) |
86 | | - |
87 | | -# From the available options, choose the best platform |
88 | | -best_platform = select_platform(Dict(p => triplet(p) for p in platforms)) |
89 | | - |
90 | | -# Silently fail if there's no binaries for this platform |
91 | | -if best_platform === nothing |
92 | | - @debug("Unable to load libpolymake_julia; unsupported platform $(triplet(platform_key_abi()))") |
93 | | -else |
94 | | - # Load the appropriate wrapper. Note that on older Julia versions, we still |
95 | | - # say "arm-linux-gnueabihf" instead of the more correct "armv7l-linux-gnueabihf", |
96 | | - # so we manually correct for that here: |
97 | | - best_platform = replace(best_platform, "arm-" => "armv7l-") |
98 | | - include(joinpath(@__DIR__, "wrappers", "$(best_platform).jl")) |
99 | | -end |
100 | | - |
| 1 | +# Use baremodule to shave off a few KB from the serialized `.ji` file |
| 2 | +baremodule libpolymake_julia_jll |
| 3 | +using Base |
| 4 | +using Base: UUID |
| 5 | +import JLLWrappers |
| 6 | + |
| 7 | +JLLWrappers.@generate_main_file_header("libpolymake_julia") |
| 8 | +JLLWrappers.@generate_main_file("libpolymake_julia", UUID("4d8266f6-2b3b-57e3-ad7a-d431eaaac945")) |
101 | 9 | end # module libpolymake_julia_jll |
0 commit comments