# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           meson 1.0
PortGroup           gobject_introspection 1.0

name                libpeas
version             2.0.7
revision            0
license             LGPL-2
set branch          [join [lrange [split ${version} .] 0 1] .]
description         libpeas is a GObject-based plugins engine
long_description    ${description}
maintainers         {devans @dbevans} openmaintainer
categories          gnome
homepage            https://wiki.gnome.org/Projects/Libpeas
master_sites        gnome:sources/${name}/${branch}/

use_xz              yes

checksums           rmd160  9239a520cdd32c2c0add9110913a728406787efc \
                    sha256  1e9a9d69761d2109eff5b7c11d8c96b4867ccfaca2b921eded49401192769ec9 \
                    size    157468

depends_build-append \
                    port:pkgconfig \
                    port:gettext \
                    port:gi-docgen \
                    path:bin/vala:vala

depends_lib         port:gettext-runtime \
                    port:mozjs128 \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gjs-1.0.pc:gjs

patchfiles          patch-meson-build.diff

gobject_introspection yes

configure.args      -Dlua51=false \
                    -Dpython3=false \
                    -Dvapi=true

pre-configure {
    configure.args-replace  -Dintrospection=enabled -Dintrospection=true
}

variant python39 conflicts python310 python311 python312 python313 description {Enable Python 3.9 plugin support} {
    depends_lib-append          port:python39 port:py39-gobject3
    configure.args-replace      -Dpython3=false -Dpython3=true
    configure.args-append       -Dpython3_path=${prefix}/bin/python3.9
}

variant python310 conflicts python39 python311 python312 python313 description {Enable Python 3.10 plugin support} {
    depends_lib-append          port:python310 port:py310-gobject3
    set python_prefix           ${frameworks_dir}/Python.framework/Versions/3.10
    configure.pkg_config_path-append   ${python_prefix}/lib/pkgconfig
    configure.args-replace      -Dpython3=false -Dpython3=true
    configure.args-append       -Dpython3_path=${prefix}/bin/python3.10
}

variant python311 conflicts python39 python310 python312 python313 description {Enable Python 3.11 plugin support} {
    depends_lib-append          port:python311 port:py311-gobject3
    set python_prefix           ${frameworks_dir}/Python.framework/Versions/3.11
    configure.pkg_config_path-append   ${python_prefix}/lib/pkgconfig
    configure.args-replace      -Dpython3=false -Dpython3=true
    configure.args-append       -Dpython3_path=${prefix}/bin/python3.11
}

variant python312 conflicts python39 python310 python311 python313 description {Enable Python 3.12 plugin support} {
    depends_lib-append          port:python312 port:py312-gobject3
    set python_prefix           ${frameworks_dir}/Python.framework/Versions/3.12
    configure.pkg_config_path-append   ${python_prefix}/lib/pkgconfig
    configure.args-replace      -Dpython3=false -Dpython3=true
    configure.args-append       -Dpython3_path=${prefix}/bin/python3.12
}

variant python313 conflicts python39 python310 python311 python312 description {Enable Python 3.13 plugin support} {
    depends_lib-append          port:python313 port:py313-gobject3
    set python_prefix           ${frameworks_dir}/Python.framework/Versions/3.13
    configure.pkg_config_path-append   ${python_prefix}/lib/pkgconfig
    configure.args-replace      -Dpython3=false -Dpython3=true
    configure.args-append       -Dpython3_path=${prefix}/bin/python3.13
}

if {
    ![variant_isset python39] &&
    ![variant_isset python310] &&
    ![variant_isset python311] &&
    ![variant_isset python312]
} {
    default_variants +python313
}

post-activate {
    system "${prefix}/bin/gtk-update-icon-cache -f -t ${prefix}/share/icons/hicolor"
}

livecheck.type      gnome
