# -*- 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.1.1 v
# Delete this on next update to use golang PortGroup's default ('archive')
github.tarball_from tarball
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  27a683a138e6e6ce33c17d2718e1defacb7aa78d \
                    sha256  02d2a0adaefe13c82289a279d0addc071d9bb7b91a0ae65869796a3569ab4ac2 \
                    size    10136227

# 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.-]+)}
