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

PortSystem          1.0
PortGroup           meson 1.0
PortGroup           gobject_introspection 1.0
PortGroup           gitlab 1.0

gitlab.instance     https://gitlab.gnome.org
gitlab.setup        GNOME gjs 1.80.1
revision            0

checksums           rmd160  151d8cba3eb10450c1871f4a6caa6efb007c2f65 \
                    sha256  c14f0ac52a29686dc2b5bcece91124c0df0198098d72e200cb39be36ebe8e678 \
                    size    703487

conflicts           gjs-devel
set my_name         gjs

categories          gnome
license             LGPL-2.1+
maintainers         {devans @dbevans} {mascguy @mascguy} openmaintainer

description         GNOME JavaScript/Spidermonkey bindings
long_description    ${description}
homepage            https://gjs-docs.gnome.org/gjs

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

depends_build-append \
                    port:pkgconfig \
                    port:python${py_ver_nodot}

depends_lib-append \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    port:dbus \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:libffi \
                    port:mozjs115 \
                    port:readline

compiler.cxx_standard \
                    2017

# LD_LIBRARY_PATH => DYLD_LIBRARY_PATH
patchfiles-append   patch-gjs-test.diff

# The gobject_introspection PG needs an 'introspection' option
patchfiles-append   patch-gjs-meson_options.diff

post-patch {
    reinplace "s|^#!/usr/bin/env python3|#!${configure.python}|" \
        build/compile-gschemas.py \
        build/symlink-gjs.py
}

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

# profiler currently only supported on Linux
configure.args-append \
                    -Dprofiler=disabled \
                    -Dskip_dbus_tests=true \
                    -Dskip_gtk_tests=true \
                    -Dbsymbolic_functions=false

gobject_introspection yes

# Note that a few tests in the "Scripts / CommandLine" category may fail as the
# typelib (gobject-introspection) expects libgjs.0.dylib to be installed at the
# system level during testing
test.run            yes
test.target         test
