# -*- 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.4 3.3 3.2 3.1
ruby.setup          concurrent-ruby-ext 1.3.6 gem {} rubygems
revision            1
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  ae5433527e0350e6bf626c0dc1ec3f579def0828 \
                    sha256  ec8bcbb14bbd98eabdb08f76bf0b203b9657255d69eaa51a6751c33b4b174443 \
                    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"
    }

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