# -*- 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               legacysupport 1.1

# strnlen
legacysupport.newest_darwin_requires_legacy 10

github.setup            rnpgp rnp 0.18.1 v
revision                0
categories              devel net
maintainers             {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license                 BSD
description             High-performance C++ OpenPGP library
long_description        {*}${description} used by Mozilla Thunderbird.
homepage                https://www.rnpgp.org
checksums               rmd160  606f6e85038efb4cc18a5f067cc1e2c197b7d93e \
                        sha256  8133cb825e6672725b33f93b8f4185d702b7444c58240f00d9f3dc886f5b0aae \
                        size    4294624
github.tarball_from     archive

set py_ver              3.13
set py_ver_nodot        [string map {. {}} ${py_ver}]

depends_build-append    port:gtest \
                        path:bin/pkg-config:pkgconfig \
                        port:python${py_ver_nodot}

depends_lib-append      port:botan3 \
                        port:bzip2 \
                        port:gnupg2 \
                        port:json-c \
                        port:libsexpp \
                        port:zlib

configure.python        ${prefix}/bin/python${py_ver}

post-patch {
    reinplace "s|/usr/bin/env python|${configure.python}|" \
                        ${worksrcpath}/src/tests/cli_perf.py \
                        ${worksrcpath}/src/tests/cli_tests.py
}

# For tests.
compiler.cxx_standard   2014
compiler.c_standard     1999

# TODO: add a variant with OpenSSL backend.
configure.args-append   -DBUILD_TESTING=ON \
                        -DCRYPTO_BACKEND="botan3" \
                        -DDOWNLOAD_GTEST=OFF \
                        -DENABLE_COVERAGE=OFF \
                        -DENABLE_DOC=OFF \
                        -DENABLE_FUZZERS=OFF \
                        -DENABLE_SANITIZERS=OFF \
                        -DPython3_EXECUTABLE=${configure.python} \
                        -DSYSTEM_LIBSEXPP=ON

depends_test-append     port:python${py_ver_nodot}

# FIXME: https://github.com/rnpgp/rnp/issues/2328
# 95% tests passed, 12 tests failed out of 263
test.run                yes
