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

boost.version       1.81

github.setup        facebook fbthrift 2026.07.27.00 v
revision            0
categories          devel
license             Apache-2

maintainers         {@barracuda156 macos-powerpc.org:barracuda}

description         Facebook's branch of Apache Thrift, including a new C++ server.
long_description    {*}${description}

checksums           rmd160  005414e148c3fe4dcfc6c4e9ef9caeaba984c115 \
                    sha256  c7d827b1e85b92794a8b85461cfe08b9bea789a47b2cc850716d3f0eae3c38e7 \
                    size    20090595
github.tarball_from archive

set libfmt_v        12
cmake.prefix_path-append \
                    ${prefix}/lib/libfmt${libfmt_v}/cmake
depends_build-append \
                    port:bison \
                    port:flex
depends_lib-append  port:fizz \
                    port:gflags \
                    port:google-glog \
                    port:libfmt${libfmt_v} \
                    port:libsodium \
                    port:mstch \
                    port:mvfst \
                    port:wangle \
                    port:xxhashlib \
                    port:zstd

patchfiles          patch-cpp2.diff

# https://github.com/facebook/fbthrift/issues/707
patchfiles-append   dynamic-string-no-pmr.patch

# Fix error: invalid output constraint '=@ccc' in asm
compiler.blacklist-append \
                    {clang < 1200}
# As of 2025.08.04.00, still uses C++17:
compiler.cxx_standard   2020

cmake.generator     Ninja

legacysupport.newest_darwin_requires_legacy 19

if {[string match *clang* ${configure.compiler}]} {
    # Don’t use libcxx with gcc.
    legacysupport.use_mp_libcxx yes
}

configure.args-append \
                    -Dthriftpy=OFF

platform darwin {
    # Disable aligned_alloc support for 10.13 and earlier
    if {${os.major} < 18} {
        # gcc does not recognize -fno-aligned-allocation
        if {[string match *clang* ${configure.compiler}]} {
            configure.cxxflags-append \
                            -fno-aligned-allocation
        }
    }
}

if {[string match *gcc* ${configure.compiler}] \
    && (${configure.build_arch} in [list arm i386 ppc])} {
    configure.ldflags-append \
                            -latomic
}
