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

name                gedit-plugins
version             50.0
revision            0

gitlab.instance     https://gitlab.gnome.org
gitlab.setup        World/gedit ${name} ${version}

categories          gnome editors
license             GPL-2+
maintainers         {mascguy @mascguy} openmaintainer
description         Plug-ins for GEdit
long_description    Various additional plug-ins for GEdit

# Disable unexpected download of subprojects
meson.wrap_mode     nodownload

checksums           rmd160  7b382073b42ca4ce11d0900ef7af6d6f6611bc9e \
                    sha256  ef9d0c2a50b6b7f90aa2342d64c9fed5fcea43388ffaf2e514d9ab0e6f88dc1d \
                    size    1023253

depends_build-append \
                    port:appstream-glib \
                    port:gettext \
                    port:itstool \
                    path:bin/pkg-config:pkgconfig \
                    path:bin/vala:vala

depends_lib-append \
                    port:gedit \
                    port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:libpeas1

# Enabled plugins:
#     bookmarks
#     bracketcompletion
#     codecomment
#     colorpicker
#     colorschemer
#     commander
#     drawspaces
#     findinfiles
#     joinlines
#     multiedit
#     sessionsaver
#     smartspaces
#     textsize
#     translate
#     wordcompletion
#
# disabled plugins, enabled via variant:
#     charmap
#     git
#     synctex
#     terminal

# require C11 compiler
compiler.c_standard   2011

proc py_setup {py_ver} {
    global env prefix frameworks_dir
    set py_ver_nodot [string map {. {}} ${py_ver}]

    set python_frameworks_dir \
                    ${frameworks_dir}/Python.framework/Versions/${py_ver}

    configure.python \
                    ${prefix}/bin/python${py_ver}

    configure.pkg_config_path-append \
                    ${python_frameworks_dir}/lib/pkgconfig

    configure.env-append \
                    PATH=${python_frameworks_dir}/bin:$env(PATH)
    build.env-append \
                    PATH=${python_frameworks_dir}/bin:$env(PATH)
    destroot.env-append \
                    PATH=${python_frameworks_dir}/bin:$env(PATH)

    depends_lib-append \
                    port:dbus-python${py_ver_nodot} \
                    port:py${py_ver_nodot}-gobject3
}

variant python310 conflicts python311 python312 python313 python314 \
        description {Use python 3.10} {
    py_setup 3.10
}

variant python311 conflicts python310 python312 python313 python314 \
        description {Use python 3.11} {
    py_setup 3.11
}

variant python312 conflicts python310 python311 python313 python314 \
        description {Use python 3.12} {
    py_setup 3.12
}

variant python313 conflicts python310 python311 python312 python314 \
        description {Use python 3.13} {
    py_setup 3.13
}

variant python314 conflicts python310 python311 python312 python313 \
        description {Use python 3.14} {
    py_setup 3.14
}

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

# libpeas expects plugin modules with .so extensions
# make .so symlink for each plugin module built as .dylib
post-destroot {
    set plugindir lib/gedit/plugins
    foreach pluginlib {libbookmarks libdrawspaces libfindinfiles libwordcompletion} {
        ln -s ${prefix}/${plugindir}/${pluginlib}.dylib ${destroot}${prefix}/${plugindir}/${pluginlib}.so
    }
}

post-activate {
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
}
