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

ruby.branches       3.3 3.2 3.1
ruby.setup          concurrent-ruby-ext 1.3.4 gem {} rubygems
license             MIT
categories-append   devel
maintainers         nomaintainer
description         C extensions to optimize the concurrent-ruby gem
long_description    {*}${description} when running under MRI.
homepage            https://github.com/ruby-concurrency/concurrent-ruby
checksums           rmd160  38378e5a53eafccac2d72951a61095cec67e9143 \
                    sha256  873369551743523d235e3e76bcfa3aaa1bc5cd0a7050b6174df0f156ed7de4d7 \
                    size    24576

if {${name} ne ${subport}} {
    depends_extract port:rb${ruby.suffix}-gem-patch

    # https://github.com/ruby-concurrency/concurrent-ruby/pull/1064
    post-patch {
        copy ${filespath}/patch-atomic_reference.c.diff ${worksrcpath}
        reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/patch-atomic_reference.c.diff
        system -W ${worksrcpath} "${ruby.gem} patch ${ruby.filename}.gem patch-atomic_reference.c.diff -o ${ruby.filename}.gem -p0"
    }

    if {${ruby.branch} < 3.3} {
        destroot.post_args-append \
                    -- --with-cflags="-Wno-incompatible-pointer-types"
    }

    depends_run-append \
                    port:rb${ruby.suffix}-concurrent-ruby
}
