# -*- 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/bufbuild/buf 1.75.0 v
go.toolchain_min    1.26.7
go.offline_build    no
revision            0

categories          devel
license             Apache-2
maintainers         @mikaoj openmaintainer
description         Buf is a tool for working with Protocol Buffers.
long_description    The Buf CLI is a helpful tool for managing Protobuf schemas. \
                    It offers various features, including code generation, breaking change detection, linting, and formatting, \
                    to assist with Protobuf development and maintenance. \
                    It works with your choice of plugins and languages and gives you access to a vast library of certified plugins in the Buf Schema Registry.
homepage            https://buf.build/

checksums           rmd160  4a517702f34e9062e97e59508d66926aec3e701a \
                    sha256  e1b688283938b19ff072789d37f371e9bdfbc866ebb719b20c1f1bdc4a9ca8ff \
                    size    1989091

build.args-append   -ldflags="-s -w" -trimpath ./cmd/buf

post-build {
    foreach shell {bash fish zsh} {
        system -W ${worksrcpath} "./${name} completion ${shell} > buf.${shell}"
    }
}

destroot {
    xinstall -m 755 ${worksrcpath}/buf ${destroot}${prefix}/bin/buf
    foreach {shell completion_path} [list \
        bash    share/bash-completion/completions/${name} \
        fish    share/fish/vendor_completions.d/${name}.fish \
        zsh     share/zsh/site-functions/_${name} \
    ] {
        xinstall -d ${destroot}${prefix}/[file dirname ${completion_path}]
        xinstall -m 644 ${worksrcpath}/${name}.${shell} ${destroot}${prefix}/${completion_path}
    }
}
