# -*- 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
PortGroup               ocaml 1.1

github.setup            stan-dev stanc3 2.35.0 v
epoch                   1
revision                0
categories              math lang ocaml
maintainers             {@barracuda156 gmail.com:vital.had} openmaintainer
license                 BSD
description             New compiler for Stan, written in OCaml
long_description        {*}${description}
homepage                https://mc-stan.org/stanc3/stanc
checksums               rmd160  065782d71577cea2ca65eabdf39e8a2199622989 \
                        sha256  cc194400f64b9010094f25289c210e65b6ed740a117165acdc4a6c98b00ec56f \
                        size    3628370
github.tarball_from     archive

set py_ver              3.11

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

depends_lib-append      port:ocaml-core \
                        port:ocaml-core_kernel \
                        port:ocaml-fmt \
                        port:ocaml-menhir \
                        port:ocaml-ppx_deriving \
                        port:ocaml-yojson \
                        port:python${py_ver_nodot}

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

post-patch {
    reinplace "s|/usr/bin/python3|${configure.python}|" \
                        ${worksrcpath}/src/frontend/parser_add_missing_messages.py \
                        ${worksrcpath}/src/frontend/parser_strip_redundant_state.py
    reinplace "s|python3|${configure.python}|" \
                        ${worksrcpath}/test/integration/cli-args/debug-generation.t/run.t
}

depends_test-append     port:ocaml-bisect_ppx \
                        port:ocaml-merlin \
                        port:ocaml-ocamlformat \
                        port:ocaml-ocp-indent \
                        port:ocaml-patdiff \
                        port:ocaml-utop

ocaml.build_type        dune
dune.packages           stanc

test.run                yes
