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

github.setup        google jsonnet 0.21.0 v
github.tarball_from archive
revision            0

categories          devel
license             Apache-2
maintainers         nomaintainer

description         The data templating language
long_description    A data templating language for app and tool developers

homepage            https://jsonnet.org/

checksums           rmd160  ede35215597fb03123292a80c0feb24263ad393b \
                    sha256  a12ebca72e43e7061ffe4ef910e572b95edd7778a543d6bf85f6355bd290300e \
                    size    22128398

patchfiles-append   patch-Makefile.diff

post-patch {
    reinplace "s|@@PREFIX@@|${prefix}|g" Makefile
}

compiler.c_standard 1999
compiler.cxx_standard 2017

if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} ne ""} {
    configure.ldflags-append -stdlib=${configure.cxx_stdlib}
}

if {${name} eq ${subport}} {
    PortGroup       makefile 1.0

    depends_lib-append \
                    port:nlohmann-json

    # needed for tests
    configure.ldflags-append \
                    "-I${worksrcpath}/include"

    build.target

    test.run        yes
}

# Python Bindings
# Name consistency with ${python.branch} and ${python.version} in
# ${prefix}/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/group/python-1.0.tcl

set python_branches {3.9 3.10 3.11 3.12 3.13}
foreach python_branch ${python_branches} {
    set python_version [join [lrange [split ${python_branch} .] 0 1] ""]
    subport py${python_version}-${name} {
        PortGroup   python 1.0

        python.default_version ${python_version}

        categories      devel python

        master_sites \
                    ${github.master_sites}
    }
}

if {[string match "py*" ${subport}]} {
    depends_lib-append \
                    port:jsonnet

    test.run        yes
    depends_test-append \
                    port:py${python.version}-yaml
}

github.livecheck.regex {([0-9.]+)}
