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

name                meson
version             1.7.0
revision            0

license             Apache-2
categories-prepend  devel
maintainers         {soap.za.net:git @SoapZA} {reneeotten @reneeotten} openmaintainer
supported_archs     noarch
platforms           any
installs_libs       no
homepage            https://mesonbuild.com

description         Meson - A high productivity build system
long_description    Meson is a build system designed to optimize programmer productivity. \
                    It aims to do this by providing simple, out-of-the-box support for modern \
                    software development tools and practices, such as unit tests, coverage reports, \
                    Valgrind, CCache and the like. It is both extremely fast, and, even more importantly, \
                    as user friendly as possible.

distfiles
use_configure       no
build               {}

# keep in sync with the default in the python PortGroup
set py_ver          3.13
set py_ver_nodot    [string map {. {}} ${py_ver}]

depends_lib-append  port:py${py_ver_nodot}-meson

destroot {
    # symlink the meson script
    ln -s ${prefix}/bin/meson-${py_ver} ${destroot}${prefix}/bin/meson

    set python_prefix ${frameworks_dir}/Python.framework/Versions/${py_ver}

    # symlink the manual
    ln -s  ${python_prefix}/share/man/man1/meson.1 ${destroot}${prefix}/share/man/man1

    set bash_completion_dir ${prefix}/share/bash-completion/completions
    xinstall -d ${destroot}${bash_completion_dir}
    xinstall -m 0644 ${prefix}/share/py${py_ver_nodot}-${name}/bash-completion/completions/meson ${destroot}${bash_completion_dir}

    set zsh_completion_dir ${prefix}/share/zsh/site-functions
    xinstall -d ${destroot}${zsh_completion_dir}
    xinstall -m 0644 ${prefix}/share/py${py_ver_nodot}-${name}/zsh/site-functions/_meson ${destroot}${zsh_completion_dir}

    # install editor syntax files
    set vim_dir ${prefix}/share/vim/vimfiles
    foreach d {ftdetect ftplugin syntax indent} {
        xinstall -d ${destroot}${vim_dir}/${d}
        xinstall -m 0644 ${prefix}/share/py${py_ver_nodot}-${name}/vim/vimfiles/${d}/meson.vim ${destroot}${vim_dir}/${d}
    }
}
