Skip to content

Commit

Permalink
Move code out of regenerate_gaproot()
Browse files Browse the repository at this point in the history
Computing the list of GAP roots and the package dir now are
separate from regenerating sysinfo.gap

Also drop unused `gap_include2` -- we removed the code creating
a `src/compiled.h` file in the mutable gap root some time ago
  • Loading branch information
fingolfin committed Feb 10, 2025
1 parent 50aca12 commit e70c302
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
19 changes: 15 additions & 4 deletions src/GAP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Artifacts: find_artifacts_toml, @artifact_str
import TOML

import GAP_jll: GAP_jll, libgap
import GAP_lib_jll

GAP_jll.is_available() ||
error("""This platform or julia version is currently not supported by GAP:
Expand Down Expand Up @@ -63,6 +64,7 @@ import Random
# the startup time a little bit
const sysinfo = Setup.regenerate_gaproot()

const GAP_VERSION = VersionNumber(sysinfo["GAP_VERSION"])

include("types.jl")

Expand Down Expand Up @@ -253,13 +255,22 @@ function __init__()

real_JuliaInterface_path[] = Setup.locate_JuliaInterface_so(sysinfo)

gaproots = sysinfo["GAPROOTS"]
cmdline_options = ["", "-l", gaproots]
roots = [
# GAP root with custom sysinfo.gap
Setup.gaproot(),
# GAP root for the the actual GAP library, from GAP_lib_jll
abspath(GAP_lib_jll.find_artifact_dir(), "share", "gap"),
# GAP root into which PackageManager installs packages by default
Packages.gap_pkgdir(),
]
cmdline_options = ["", "-l", join(roots, ";")]

# tell GAP about all artifacts that contain GAP packages
pkg_artifacts = filter(startswith("GAP_pkg_"), keys(TOML.parsefile(find_artifacts_toml(@__FILE__))))
pkgdirs = join((realpath(@artifact_str(name)) for name in pkg_artifacts), ';')
append!(cmdline_options, ["--packagedirs", pkgdirs])
pkgdirs = [realpath(@artifact_str(name)) for name in pkg_artifacts]
push!(pkgdirs, abspath(@__DIR__, "..", "pkg", "JuliaInterface"))
push!(pkgdirs, abspath(@__DIR__, "..", "pkg", "JuliaExperimental"))
push!(cmdline_options, "--packagedirs", join(pkgdirs, ';'))

if isdefined(Main, :__GAP_ARGS__)
# we were started via gap.sh, handle user command line arguments
Expand Down
13 changes: 9 additions & 4 deletions src/packages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ module Packages
import Downloads
import Pidfile
import ...GAP: disable_error_handler, Globals, GapObj, replace_global!, RNamObj, sysinfo, Wrappers
import ...GAP: gap_pkg_jlls, Compat, Setup
import ...GAP: gap_pkg_jlls, Compat, Setup, GAP_VERSION, GAP_jll, GAP_lib_jll

const DEFAULT_PKGDIR = Ref{String}()
gap_pkgdir() = joinpath(Base.DEPOT_PATH[1], "gaproot", "v$(GAP_VERSION.major).$(GAP_VERSION.minor)")

const DEFAULT_PKGDIR = Ref(joinpath(gap_pkgdir(), "pkg"))
const DOWNLOAD_HELPER = Ref{Downloads.Downloader}()

function init_packagemanager()
Expand All @@ -17,9 +19,12 @@ function init_packagemanager()
res = load("PackageManager")
@assert res

global DEFAULT_PKGDIR[] = sysinfo["DEFAULT_PKGDIR"]
global DOWNLOAD_HELPER[] = Downloads.Downloader(; grace=0.1)

# ensure DEFAULT_PKGDIR exists, otherwise GAP will skip it when populating
# the list of package directories
mkpath(DEFAULT_PKGDIR[])

# overwrite PKGMAN_DownloadURL
replace_global!(:PKGMAN_DownloadURL, function(url)
try
Expand Down Expand Up @@ -563,7 +568,7 @@ function versioninfo(io::IO = stdout; GAP::Bool = false, jll::Bool = false, full
if jll
deps = gap_pkg_jlls
if GAP
deps = vcat(deps, [Setup.GAP_jll, Setup.GAP_lib_jll])
deps = vcat(deps, [GAP_jll, GAP_lib_jll])
end
jlldeps = [(name = string(nameof(x)), version = Compat.pkgversion(x)) for x in deps]
sort!(jlldeps, by = x -> x.name)
Expand Down
18 changes: 1 addition & 17 deletions src/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Setup

using Pkg: GitTools
import GAP_jll
import GAP_lib_jll
import GAP_pkg_juliainterface_jll
import Scratch: @get_scratch!
import Pidfile
Expand Down Expand Up @@ -87,7 +86,6 @@ include("julia-config.jl")
function regenerate_gaproot()
gaproot_mutable = gaproot()

gaproot_gapjl = abspath(@__DIR__, "..")
@debug "Set up gaproot at $(gaproot_mutable)"

gap_prefix = GAP_jll.find_artifact_dir()
Expand All @@ -113,27 +111,13 @@ function regenerate_gaproot()

# set include flags
gap_include = joinpath(gap_prefix, "include", "gap")
gap_include2 = joinpath(gaproot_mutable) # for code doing `#include "src/compiled.h"`
sysinfo["GAP_CPPFLAGS"] = "-I$(gap_include) -I$(gap_include2) -DUSE_JULIA_GC=1"
sysinfo["GAP_CPPFLAGS"] = "-I$(gap_include) -DUSE_JULIA_GC=1"

# set linker flags; since these are meant for use for GAP packages,
# add the necessary flags to link against libgap
gap_lib = joinpath(gap_prefix, "lib")
sysinfo["GAP_LDFLAGS"] = "-L$(gap_lib) -lgap"

GAP_VERSION = VersionNumber(sysinfo["GAP_VERSION"])
gaproot_packages = joinpath(Base.DEPOT_PATH[1], "gaproot", "v$(GAP_VERSION.major).$(GAP_VERSION.minor)")
sysinfo["DEFAULT_PKGDIR"] = joinpath(gaproot_packages, "pkg")
mkpath(sysinfo["DEFAULT_PKGDIR"])
gap_lib_dir = abspath(GAP_lib_jll.find_artifact_dir(), "share", "gap")
roots = [
gaproot_gapjl, # for JuliaInterface and JuliaExperimental
gaproot_packages, # default installation dir for PackageManager
gaproot_mutable,
gap_lib_dir, # the actual GAP library, from GAP_lib_jll
]
sysinfo["GAPROOTS"] = join(roots, ";")

# path to gap & gac (used by some package build systems)
sysinfo["GAP"] = joinpath(gaproot_mutable, "bin", "gap.sh")
sysinfo["GAC"] = joinpath(gaproot_mutable, "gac")
Expand Down

0 comments on commit e70c302

Please sign in to comment.