# -*- 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/aws/copilot-cli 1.27.0 v
name                copilot
revision            0

homepage            https://aws.github.io/copilot-cli

description         AWS Copilot CLI allows developers to build, release and \
                    operate containerized applications on Amazon ECS and AWS \
                    Fargate.

long_description    The AWS Copilot CLI is a tool for developers to create, \
                    release and manage production ready containerized \
                    applications on Amazon ECS and AWS Fargate. From getting \
                    started, pushing to a test environment and releasing to \
                    production, Copilot helps you through the entire life of \
                    your app development.

categories          devel
installs_libs       no
license             Apache-2
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

depends_build-append \
                    port:go-mockgen \
                    path:bin/npm:npm9 \
                    port:packr

# allow Go to fetch deps at run-time
go.offline_build no

build.cmd           make
build.pre_args      VERSION=${version}
build.args          release

use_parallel_build  no

checksums           rmd160  eea4309655bf1fec3dd0c590846ebc07476711fb \
                    sha256  6a945ee05257959a8a62f7ca421936361046880da1bd8357a9a5633f59473c22 \
                    size    14509620

patch {
    # Remove Windows and Linux builds for the release target
    reinplace -E {/^release:/ s/compile-(linux|windows)[[:space:]]+//g} \
        ${worksrcpath}/Makefile

    # Delete all 'go get' lines, to prohibit the Makefile from installing
    # build utilities on its own (we want it to use those MacPorts provides).
    reinplace -E {/go get/d} ${worksrcpath}/Makefile

    # Modify custom Go tools path to use binaries provided by MacPorts
    reinplace -E "s|^GOBIN=.*|GOBIN=${prefix}/bin|g" ${worksrcpath}/Makefile
}

destroot {
    xinstall -m 0755 \
        ${worksrcpath}/bin/local/${name}-${goos}-${goarch} \
        ${destroot}${prefix}/bin/${name}
}
