From 96a22f650ce647ccb4d28e638e144e2084902317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 22 Nov 2024 11:55:22 +0100 Subject: [PATCH] Add and use `GAP.Packages.build_recursive` --- .github/workflows/CI-distro.yml | 2 +- docs/src/packages.md | 1 + src/packages.jl | 38 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI-distro.yml b/.github/workflows/CI-distro.yml index 80ead4e2..4f7728e6 100644 --- a/.github/workflows/CI-distro.yml +++ b/.github/workflows/CI-distro.yml @@ -70,6 +70,6 @@ jobs: - name: "Build package" uses: julia-actions/julia-buildpkg@v1 - name: "Build GAP package" - run: julia --color=yes --project=. -e 'using GAP; GAP.Packages.build("${{ matrix.gap-package }}")' + run: julia --color=yes --project=. -e 'using GAP; GAP.Packages.build_recursive("${{ matrix.gap-package }}")' - name: "Run GAP package tests" run: julia --color=yes --project=. -e 'using GAP, Test; GAP.Packages.test("${{ matrix.gap-package }}")' diff --git a/docs/src/packages.md b/docs/src/packages.md index 594db88e..a28dce61 100644 --- a/docs/src/packages.md +++ b/docs/src/packages.md @@ -14,6 +14,7 @@ GAP.Packages.install GAP.Packages.update GAP.Packages.remove GAP.Packages.build +GAP.Packages.build_recursive GAP.Packages.test GAP.Packages.locate_package ``` diff --git a/src/packages.jl b/src/packages.jl index ce17b6e0..41e49283 100644 --- a/src/packages.jl +++ b/src/packages.jl @@ -409,6 +409,44 @@ function build(name::String; quiet::Bool = false, return res end +""" + build_recursive(name::String; quiet::Bool = false, + debug::Bool = false, + pkgdir::AbstractString = GAP.Packages.DEFAULT_PKGDIR[]) + +Build the GAP package with name `name` that is installed in the +`pkgdir` directory, as well as all of its (transitive) dependencies. + +This is achieved by calling [`build`](@ref) for the package `name` and then +all of its `NeededOtherPackages`, recursively. +All keyword arguments are passed on to [`build`](@ref). +""" +function build_recursive(name::String; quiet::Bool = false, + debug::Bool = false, + pkgdir::AbstractString = DEFAULT_PKGDIR[]) + # point PackageManager to the given pkg dir + Globals.PKGMAN_CustomPackageDir = GapObj(pkgdir) + mkpath(pkgdir) + + todo = Set{String}((name,)) + done = Set{String}() + while !isempty(todo) + dep = pop!(todo) + dep in done && continue + + res = build(dep; quiet, debug, pkgdir) + res || return false + gdep = GapObj(dep) + allinfo = collect(Globals.PackageInfo(gdep)) + userinfo = filter(info -> startswith(String(info.InstallationPath), pkgdir), allinfo) + info = only(userinfo) + for (needed, _) in info.Dependencies.NeededOtherPackages + push!(todo, String(needed)) + end + end + return true +end + """ test(name::String)