# -*- 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/ddev/ddev 1.24.4 v
go.offline_build    no

checksums           rmd160  2575cb97d8484b0fd125ae5695b60473ba1c16dd \
                    sha256  728b97d1bd82f29b2941efe5ee79810a7d31dcd0ed9de3e5c225f9622119e6e5 \
                    size    19466914

categories          devel
license             Apache-2
maintainers         {@jlorenzetti} openmaintainer

description         Local PHP development environment management tool
long_description    DDEV is an open source tool for launching local PHP web development \
                    environments in minutes. It helps developers create and manage \
                    Docker-based development environments with support for multiple PHP \
                    versions, web servers, databases, and other tools.

homepage            https://ddev.com

# Dependencies
depends_build-append \
                    port:gmake

depends_run         port:mkcert

# Build configuration
build.env-append    CGO_ENABLED=0

build.env-append    GOFLAGS=-mod=vendor\ -buildvcs=false

build.cmd           ${prefix}/bin/gmake

# Set build target based on architecture
if {${build_arch} eq "x86_64"} {
    set go_arch "amd64"
} elseif {${build_arch} eq "arm64"} {
    set go_arch "arm64"
} else {
    set go_arch "unsupported"
}

build.target    darwin_${go_arch}

destroot {
    # Install binary
    xinstall -m 755 ${worksrcpath}/.gotmp/bin/darwin_${go_arch}/ddev ${destroot}${prefix}/bin/
    
    # Generate shell completions
    system -W ${worksrcpath} "GOFLAGS=-buildvcs=false ${build.cmd} completions"
    
    # Extract completions
    system -W ${worksrcpath} "mkdir -p .gotmp/bin/completions_extracted"
    system -W ${worksrcpath} "tar xzf .gotmp/bin/completions.tar.gz -C .gotmp/bin/completions_extracted"
    
    # Install shell completions
    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    xinstall -m 644 ${worksrcpath}/.gotmp/bin/completions_extracted/ddev_bash_completion.sh \
        ${destroot}${prefix}/share/bash-completion/completions/ddev
        
    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    xinstall -m 644 ${worksrcpath}/.gotmp/bin/completions_extracted/ddev_zsh_completion.sh \
        ${destroot}${prefix}/share/zsh/site-functions/_ddev
        
    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d
    xinstall -m 644 ${worksrcpath}/.gotmp/bin/completions_extracted/ddev_fish_completion.sh \
        ${destroot}${prefix}/share/fish/vendor_completions.d/ddev.fish
}

test.run            yes
test.cmd            ${build.cmd}
test.target         test

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