# -*- 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/arduino/arduino-cli 1.5.1 v
revision            0

categories          devel electronics
license             GPL-3
maintainers         {judaew @judaew} openmaintainer

description         Arduino command line tool
long_description    \
    Arduino CLI is an all-in-one solution that provides Boards/Library \
    Managers, sketch builder, board detection, uploader, and many other tools \
    needed to use any Arduino compatible board and platform from command line \
    or machine interfaces.
homepage            https://arduino.github.io/arduino-cli

checksums           rmd160  9b1f7e56e366b5f78ee550e9789f163cbb62c303 \
                    sha256  262fbe874f62677d01eb15593144ca82bd6e7c2d0c00f82aa93949ab12924de6 \
                    size    11107004

# FIXME: This port currently can't be built without allowing go mod to fetch
go.offline_build no

# Suppress build date for reproducible builds
# Switch to SOURCE_DATE_EPOCH approach in the future
# See https://trac.macports.org/ticket/59672
build.pre_args      -ldflags \
    \'-X ${go.package}/version.versionString=${version} \
    -X ${go.package}/version.commit=MacPorts \
    -X ${go.package}/version.date=SUPPRESSED\'

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

    set bash_completion ${prefix}/share/bash-completion/completions
    xinstall -d ${destroot}${bash_completion}
    exec ${destroot}${prefix}/bin/${name} completion bash >> \
        ${destroot}${bash_completion}/${name}

    set zsh_completion ${prefix}/share/zsh/site-functions
    xinstall -d ${destroot}${zsh_completion}
    exec ${destroot}${prefix}/bin/${name} completion zsh >> \
        ${destroot}${zsh_completion}/_${name}

    set fish_completion ${prefix}/share/fish/vendor_completions.d
    xinstall -d ${destroot}${fish_completion}
    exec ${destroot}${prefix}/bin/${name} completion fish >> \
        ${destroot}${fish_completion}/${name}.fish
}

github.livecheck.regex {([0-9.-]+)}
