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

github.setup            apple pkl 0.25.1
github.tarball_from     archive
revision                0

java.version            17+
java.fallback           openjdk17

categories              lang
maintainers             {sub-pop.net:link @subpop} openmaintainer

license                 Apache-2

description             A configuration as code language with rich validation and tooling
long_description        Pkl (pronounced Pickle) is an embeddable configuration \
                        language which provides rich support for data templating \
                        and validation. It can be used from the command line, \
                        integrated in a build pipeline, or embedded in a program. \
                        Pkl scales from small to large, simple to complex, ad-hoc \
                        to repetitive configuration tasks.

checksums               rmd160  eeaf157c2944116c761c74c1e19afe03dcffb13c \
                        sha256  f60412679a9a8a1740e81cbed89a3ca9ddc9aa2cf0c487ff8a8a9fce70c0bf4a \
                        size    2769725

use_configure           no

supported_archs         arm64 x86_64

build.cmd               ./gradlew --info --stacktrace
if {${configure.build_arch} eq "arm64"} {
    post-patch {
        system "${patch.cmd} -p1 -d ${worksrcpath} < ${worksrcpath}/patches/graalVm23.patch"
    }

    build.target            pkl-cli:macExecutableAarch64
    set arch_name           aarch64
} else {
    build.target            pkl-cli:macExecutableAmd64
    set arch_name           amd64
}
build.post_args         -DreleaseBuild=true
build.env-append        GRADLE_USER_HOME=${worksrcpath}/gradle \
                        GRAALVM_HOME=${workpath}/.graalvm

destroot {
    xinstall -m 0755 ${worksrcpath}/pkl-cli/build/executable/pkl-macos-${arch_name} ${destroot}${prefix}/bin/pkl
}
