# -*- 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.3.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  50c544b7be5d19cef05a20848900431a4e588d95 \
                    sha256  7977ef114eee32aec3eb2f371c6a5bbcf9b2238b1e923eb2d384c888ad1c1fe0 \
                    size    10986096

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