# -*- 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           gobject_introspection 1.0
PortGroup           meson 1.0

name                libpeas
version             2.2.1
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  2f4d779455912c7f7dda2d939ca5ebef0d6a85e3 \
                    sha256  589eca89b437006edf3755478df037c740a2a84cfa5d202dbad6095e828e2488 \
                    size    157488

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

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

compiler.cxx_standard   2017

gobject_introspection   yes

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

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

variant gjs description "Build with GJS support" {
    depends_lib-append          port:gjs
    configure.args-replace      -Dgjs=false -Dgjs=true
}

variant python310 conflicts python311 python312 python313 python314 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 python310 python312 python313 python314 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 python310 python311 python313 python314 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 python310 python311 python312 python314 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
}

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

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

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

livecheck.type      gnome
