# -*- 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           cmake 1.1
PortGroup           github 1.0
PortGroup           openssl 1.0

github.setup        LadybugDB ladybug 0.20.2 v
github.tarball_from archive
revision            0

homepage            https://ladybugdb.com/

categories          databases
license             MIT
maintainers         @jrjsmrtn openmaintainer

description         Embedded graph database built for query speed and scalability

long_description    LadybugDB is an embedded property-graph database with a \
                    Cypher query language, forked from Kuzu after its \
                    acquisition. It runs inside the application process rather \
                    than as a server, targets analytical workloads over large \
                    graphs, and provides full-text search and vector indices. \
                    It reads and writes Parquet, Arrow and DuckDB. This port \
                    installs the lbug shell and the C and C++ libraries.

checksums           rmd160  1058544332c43cced047131c808bea05401c19c6 \
                    sha256  c4dc6844479a799247f0cdf749522bb7597b78a97b90dbde0706601b207c928f \
                    size    15691963

# std::atomic_ref and std::format need libc++ 17, which arrived with Xcode
# 16.3; compiler.cxx_standard alone does not express a runtime requirement.
compiler.cxx_standard 2020
compiler.blacklist-append \
                    {clang < 1700}

# scripts/collect-single-file-header.py assembles the installed lbug.hpp. It
# imports only the standard library, and upstream asks for Python 3.9...4.
# It runs at build time only: it emits a header, so nothing it produces is
# architecture-dependent and it never reaches the installed library.
set python_branch   3.14
depends_build-append \
                    port:python[string map {. {}} ${python_branch}]

configure.args-append \
                    -DPython3_EXECUTABLE=${prefix}/bin/python${python_branch}

# BUILD_TESTS is not enabled: it changes the visibility preset, so the shipped
# library would differ from a release build. lbug exits 0 on a parser error, so
# assert on the output.
test.run            yes
test {
    system -W ${build.dir} "printf 'UNWIND \[1,2,3\] AS i RETURN i;\\n' | ./tools/shell/lbug -m csv -s | grep -qx 3"
}

# cppjieba is a vendored build-time dependency of the full-text search
# extension; its headers are not part of the LadybugDB API and would collide
# with a future cppjieba port.
post-destroot {
    delete ${destroot}${prefix}/include/cppjieba \
        ${destroot}${prefix}/share/cppjieba
}
