Skip to content

Commit

Permalink
Ensure binary wrappers are set up each time GAP.jl is loaded (#1100)
Browse files Browse the repository at this point in the history
... not just during precompilation
  • Loading branch information
fingolfin authored Dec 19, 2024
1 parent 54fc158 commit 199f11d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/GAP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ function initialize(argv::Vector{String})
GAP.Globals.Read(GapObj(joinpath(@__DIR__, "..", "gap", "exec.g")))
@debug "finished reading gap/exec.g"

# setup JLL overrides
setup_overrides()

# If we are in "stand-alone mode", stop here
if handle_signals
ccall((:SyInstallAnswerIntr, libgap), Cvoid, ())
Expand Down
46 changes: 28 additions & 18 deletions src/GAP_pkg.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import Artifacts: @artifact_str
using BinaryWrappers

function gap_pkg_artifact_dir(pkgname)
d = @artifact_str("GAP_pkg_$(pkgname)")
return joinpath(d, only(readdir(d)))
end

const pkg_bindirs = Dict{String, String}()

for pkg in [
const gap_pkgs_with_overrides = [
"ace"
"anupq"
"browse"
Expand Down Expand Up @@ -42,26 +35,43 @@ for pkg in [
#"xgap" # useful?
"zeromqinterface"
]

# import JLLs from above
for pkg in gap_pkgs_with_overrides
jll = Symbol("GAP_pkg_$(pkg)_jll")
@eval begin
import $jll
@eval import $jll
end

# GAP package "grape" uses `dreadnaut` from nauty_jll
import nauty_jll

const pkg_bindirs = Dict{String, String}()

function gap_pkg_artifact_dir(pkgname)
d = @artifact_str("GAP_pkg_$(pkgname)")
return joinpath(d, only(readdir(d)))
end

function setup_overrides()
for pkg in gap_pkgs_with_overrides
jll = getproperty(GAP, Symbol("GAP_pkg_$(pkg)_jll"))

# Crude heuristic: if the JLL has a `bin` directory then we assume it
# contains executables the packages uses; otherwise assume it contains
# a kernel extension `lib/gap/BLAH.so`.
#
# This fails if a package has both executables and a kernel extension.
pkg_bindirs[realpath(gap_pkg_artifact_dir($pkg))] =
if isdir(joinpath($jll.find_artifact_dir(), "bin"))
@generate_wrappers($jll)
pkg_bindirs[realpath(gap_pkg_artifact_dir(pkg))] =
if isdir(joinpath(jll.find_artifact_dir(), "bin"))
@generate_wrappers(jll)
else
joinpath($jll.find_artifact_dir(), "lib", "gap")
joinpath(jll.find_artifact_dir(), "lib", "gap")
end
end
end

# Special case for GAP package "grape" which uses `dreadnaut` from nauty_jll
import nauty_jll
pkg_bindirs[realpath(gap_pkg_artifact_dir("grape"))] = @generate_wrappers(nauty_jll)
# GAP package "grape" uses `dreadnaut` from nauty_jll
pkg_bindirs[realpath(gap_pkg_artifact_dir("grape"))] = @generate_wrappers(nauty_jll)
end

function find_override(installationpath::String)
rp = realpath(installationpath)
Expand Down

0 comments on commit 199f11d

Please sign in to comment.