# -*- 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
PortGroup           golang 1.0

go.setup            github.com/samyfodil/musql 0.6.0 v
go.offline_build    no
revision            0

categories          databases
license             Apache-2
maintainers         @wu21-web openmaintainer

description         SQLite-compatible database with columnar storage and a JIT compiler
long_description    musql is a SQLite-compatible database written in pure Go, \
                    with columnar storage and just-in-time compilation. It \
                    includes the musqld server for libSQL and Turso clients, \
                    musql-convert for SQLite import and export, and the \
                    musql-doom example.

checksums           rmd160  142c8c100ac02b4df681a9fe501684cec2adefb1 \
                    sha256  bfdfe5b859d895ca9853eb03d07e1c90d18b91a43fd25fb9b50f33d654aff9dc \
                    size    15178531

supported_archs     arm64 x86_64
installs_libs       no

build.env-append    CGO_ENABLED=0 GOTOOLCHAIN=local

build {
    foreach {directory binary package} {
        .               musql-convert   ./cmd/musql-convert
        hrana           musqld          ./cmd/musqld
        examples/doom   musql-doom      ./cmd/doom
    } {
        build.dir       ${worksrcpath}/${directory}
        build.pre_args  -trimpath -ldflags=\"-s -w\" -o ${workpath}/${binary}
        build.args      ${package}
        command_exec build
    }
}

destroot {
    foreach binary {musqld musql-convert musql-doom} {
        xinstall -m 0755 ${workpath}/${binary} ${destroot}${prefix}/bin/
    }
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 0644 ${worksrcpath}/LICENSE ${worksrcpath}/README.md \
        ${destroot}${prefix}/share/doc/${name}/
}
