From e70c3027d0bedc3bbc54cafee6818bf485db25ee Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 7 Feb 2025 09:39:44 +0100 Subject: [PATCH] Move code out of regenerate_gaproot() 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 --- src/GAP.jl | 19 +++++++++++++++---- src/packages.jl | 13 +++++++++---- src/setup.jl | 18 +----------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/GAP.jl b/src/GAP.jl index 879f82d91..64ec9bfe1 100644 --- a/src/GAP.jl +++ b/src/GAP.jl @@ -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: @@ -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") @@ -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 diff --git a/src/packages.jl b/src/packages.jl index a948ae19c..4fa20784b 100644 --- a/src/packages.jl +++ b/src/packages.jl @@ -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() @@ -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 @@ -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) diff --git a/src/setup.jl b/src/setup.jl index 607b2a1b6..cdb09fb0a 100644 --- a/src/setup.jl +++ b/src/setup.jl @@ -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 @@ -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() @@ -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")