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

go.setup            github.com/homeport/dyff 1.10.2 v
go.offline_build    no
revision            0

description         diff tool for YAML files, and sometimes JSON
long_description    {*}${description}

categories          textproc
installs_libs       no
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  5a635b8a9461092fba2db2d045a5b22d7edf1c47 \
                    sha256  36e103c1424e79135bb4ed54d6b66e6c3f057ff422a5838d3a80ffd4d9a3ef27 \
                    size    1218019

build.pre_args-append \
    -ldflags \"-X ${go.package}/internal/cmd.version=${version}\"
build.args          ./cmd/${name}

post-build {
    # Generate completion files
    file mkdir ${worksrcpath}/completion

    foreach _shell {bash fish zsh} {
        system -W ${worksrcpath} \
            "./${name} completion ${_shell} > ./completion/${name}.${_shell}"
    }
}

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/

    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    copy ${worksrcpath}/completion/${name}.bash \
        ${destroot}${prefix}/share/bash-completion/completions/${name}

    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d
    copy ${worksrcpath}/completion/${name}.fish \
        ${destroot}${prefix}/share/fish/vendor_completions.d/

    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    copy ${worksrcpath}/completion/${name}.zsh \
        ${destroot}${prefix}/share/zsh/site-functions/_${name}
}
