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

# GitHub version lags behind.
R.setup             cran jeroen protolite 2.3.1
revision            0
categories-append   devel
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             MIT
description         Highly optimized protocol buffer serializers
long_description    {*}${description}
homepage-append     https://jeroen.r-universe.dev/protolite
checksums           rmd160  103df4c85db24c4b4def91e5ef58b59a1361f0c8 \
                    sha256  eed46fd63f9d183f974f420e9351f64e45c9edba00f56cc8c132c7aeb21697cc \
                    size    25019

patchfiles          patch-configure.diff

if {${os.platform} eq "darwin" && ${configure.cxx_stdlib} ne "libc++"} {
    # Symbol not found: __ZN6google8protobuf8internal26fixed_address_empty_stringB5cxx11E
    patchfiles-append \
                    patch-cxx11.diff
}

depends_build-append \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:protobuf3-cpp \
                    port:R-jsonlite \
                    port:R-Rcpp

# To build against a non-default version of protobuf, pass the following to destroot.cmd:
# --configure-vars='INCLUDE_DIR=/.../include LIB_DIR=/.../lib'

compiler.cxx_standard 2017

depends_test-append port:R-curl \
                    port:R-sf \
                    port:R-spelling \
                    port:R-testthat

test.run            yes
