# -*- 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

gitlab.instance     https://gitlab.gnome.org
gitlab.setup        World lollypop 1.4.45
revision            0
categories          gnome audio
license             GPL-3
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer

description         Lollypop music player
long_description    {*}${description}

fetch.type          git
post-fetch {
    system -W ${worksrcpath} "git submodule update --init"
}

set py_ver          3.14
set py_ver_nodot    [string map {. {}} ${py_ver}]

patchfiles          patch-meson.build.diff

set python.prefix   ${frameworks_dir}/Python.framework/Versions/${py_ver}
set python.bin      ${python.prefix}/bin/python${py_ver}
set python.pkgd     ${python.prefix}/lib/python${py_ver}/site-packages

post-patch {
    reinplace "s|@PYTHON@|${python.bin}|" ${worksrcpath}/meson.build
    reinplace "s|@PY_PACKAGES@|${python.pkgd}|" ${worksrcpath}/meson.build
    reinplace "s|/usr/bin/env python3|${python.bin}|" \
        ${worksrcpath}/lollypop.in \
        ${worksrcpath}/meson_post_install.py
}

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

depends_lib-append  port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    port:gstreamer1 \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:libhandy \
                    path:lib/pkgconfig/libsoup-3.0.pc:libsoup \
                    port:py${py_ver_nodot}-beautifulsoup4 \
                    port:py${py_ver_nodot}-cairo \
                    port:py${py_ver_nodot}-gobject3 \
                    port:py${py_ver_nodot}-Pillow \
                    port:python${py_ver_nodot} \
                    port:totem-pl-parser

# This is inconvenient due to a lot of heavy dependencies,
# but we do need the whole zoo, since formats’ support is randomly
# thrown around. For instance, turns out that ALAC needs *gst-libav:
# https://gstreamer.freedesktop.org/documentation/libav/avdec_alac.html
depends_run-append  port:dbus \
                    port:desktop-file-utils \
                    port:gsettings-desktop-schemas \
                    port:gstreamer1-gst-libav \
                    port:gstreamer1-gst-plugins-bad \
                    port:gstreamer1-gst-plugins-base \
                    port:gstreamer1-gst-plugins-good \
                    port:gstreamer1-gst-plugins-ugly \
                    port:libsecret \
                    port:py-gst-python \
                    port:yt-dlp

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

notes "
${name} uses dbus at runtime. If dbus service is not running, please start it with:\
launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
"
