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

# strnlen, lutimes
# TARGET_OS_* macros
legacysupport.newest_darwin_requires_legacy 14

# Revert to GitHub once updated there.
R.setup             cran r-lib fs 1.6.7
revision            1
# libuv version used:
set uv_ver          1.44.2
categories-append   sysutils
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license             MIT
description         Cross-platform uniform interface to file system operations
long_description    fs provides a cross-platform, uniform interface to file system operations. \
                    It shares the same back-end component as nodejs, the libuv C library, \
                    which brings the benefit of extensive real-world use and rigorous cross-platform testing. \
                    The name, and some of the interface, is partially inspired by Rust’s fs module.
homepage            https://fs.r-lib.org
checksums           rmd160  b0e6c3d9b9d46e6c09354f1ef8809194837b4a23 \
                    sha256  e8f0a8f4b15177166c9530cd922e38705421467f05ec55500b28bca5864be411 \
                    size    1203287

patch.pre_args-replace  -p0 -p1

if {${os.platform} eq "darwin" && ${os.major} < 15} {
    patchfiles-append \
                    0001-libuv-link-to-legacysupport.patch
    post-patch {
        # https://trac.macports.org/ticket/69853
        if {[string match *clang* ${configure.compiler}]} {
            reinplace "s|@MP_FLAGS@|-I${prefix}/include/LegacySupport -Wno-error=incompatible-function-pointer-types|" ${worksrcpath}/src/Makevars
        } else {
            reinplace "s|@MP_FLAGS@|-I${prefix}/include/LegacySupport|" ${worksrcpath}/src/Makevars
        }
    }
}

depends_test-append port:R-covr \
                    port:R-crayon \
                    port:R-knitr \
                    port:R-pillar \
                    port:R-rmarkdown \
                    port:R-spelling \
                    port:R-testthat \
                    port:R-tibble \
                    port:R-vctrs \
                    port:R-withr

test.run            yes
