# -*- 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                   github 1.0

github.setup                XiaoYouChR Python-eD2k 0.1.0 v
github.tarball_from         archive
name                        [string tolower ${github.project}]
revision                    0
categories                  net
license                     MIT
maintainers                 {i0ntempest @i0ntempest} openmaintainer

checksums                   ${distname}${extract.suffix} \
                            rmd160  3fadc4589131bfe4d611e146a8aa0d7e19753984 \
                            sha256  a833b1126a411b9aa26806940656c8e31b90c101a631f6fdedce3e03c83917ec \
                            size    13203

set go_exec_name            goed2kd

if {${name} eq ${subport}} {
    PortGroup               python 1.0

    categories-append       python
    description             typed asyncio client and Go sidecar for monkeyWie/goed2k
    long_description        ${name} is a typed asyncio client for monkeyWie/goed2k.\
                            It runs goed2k in one small Go sidecar and communicates through stdio NDJSON.

    github.setup            ${github.author} ${github.project} ${github.version} ${github.tag_prefix}

    python.default_version  314

    depends_run-append      port:${name}-${go_exec_name}
}

subport ${name}-${go_exec_name} {
    PortGroup               golang 1.0

    go.setup                github.com/${github.author}/${github.project} ${github.version} ${github.tag_prefix}
    description             minimal Go sidecar daemon for monkeyWie/goed2k
    long_description        ${name} is a ${description}.

    go.vendors              github.com/monkeyWie/goed2k \
                                lock    f2a71d599dee \
                                rmd160  8f30231e3c61c154c30f242f0530d04fab65bd00 \
                                sha256  015fdf869b1de05a9cea0c4286b7ac0b2c9afcfd32375ec94515596156ce449f \
                                size    724996

    build.args              -o ./${go_exec_name} \
                            -ldflags '-s -w' \
                            ./cmd/${go_exec_name}

    destroot {
        # binary is meant to be called programmatically only, install into libexec
        xinstall -d ${destroot}${prefix}/libexec/${go_exec_name}
        xinstall -m 755 ${worksrcpath}/${go_exec_name} ${destroot}${prefix}/libexec/${go_exec_name}/
    }
}
