# -*- 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           github 1.0
PortGroup           cxx11 1.1
PortGroup           cmake 1.1
PortGroup           compiler_blacklist_versions 1.0

github.setup        facebook folly 2019.09.16.00 v
revision            0

categories          devel
platforms           darwin
license             Apache-2

maintainers         nomaintainer

description         An open-source C++ library developed and used at Facebook.
long_description    Folly (acronymed loosely after Facebook Open Source Library) is a library of \
                    C++14 components designed with practicality and efficiency in mind. Folly contains \
                    a variety of core library components used extensively at Facebook. In particular, \
                    it's often a dependency of Facebook's other open source C++ efforts and place where \
                    those projects can share code. \
                    It complements (as opposed to competing against) offerings such as Boost and of course \
                    std. In fact, we embark on defining our own component only when something we need is \
                    either not available, or does not meet the needed performance profile. We endeavor to \
                    remove things from folly if or when std or Boost obsoletes them.\
                    Performance concerns permeate much of Folly, sometimes leading to designs that are \
                    more idiosyncratic than they would otherwise be (see e.g. PackedSyncPtr.h, SmallLocks.h). \
                    Good performance at large scale is a unifying theme in all of Folly.

checksums           rmd160  4146c1e95e307ae755f0997a27a879891dd73f51 \
                    sha256  3f7daeb1755246a92b890079dd3881070be8478e1ccfb0dc21037a54de87edbb \
                    size    3033459

# doesn't build with libressl as of 2016-09-05
depends_lib-append  port:boost \
                    port:bzip2 \
                    port:python27 \
                    port:gflags \
                    port:google-glog \
                    port:double-conversion \
                    port:libevent \
                    port:snappy \
                    port:lz4 \
                    port:lzma \
                    port:xz \
                    path:lib/libssl.dylib:openssl \
                    port:zlib \
                    port:zstd \
                    port:libsodium

compiler.blacklist-append {clang < 920} macports-clang-3.* {macports-clang-[4-6].0}

configure.args-append -DBUILD_SHARED_LIBS=ON -DFOLLY_USE_JEMALLOC=0

configure.cxxflags-append -std=c++14

platform darwin {
    # https://github.com/facebook/folly/issues/864
    if {${os.major} <= 16} {
        configure.args-append     -DCOMPILER_HAS_F_ALIGNED_NEW=OFF
        configure.cxxflags-append -fno-aligned-allocation
    }
    # Support for TCP fast-open was only added to macOS 10.11+
    if {${os.major} < 15} {
        configure.cxxflags-append -DFOLLY_ALLOW_TFO=0
    }
}

variant jemalloc description {Use je_malloc} {
    depends_lib-append       port:jemalloc
    configure.args-append    -DFOLLY_HAVE_WEAK_SYMBOLS=ON
    configure.args-replace   -DFOLLY_USE_JEMALLOC=0 -DFOLLY_USE_JEMALLOC=1
    configure.ldflags-append -ljemalloc
}

variant native description {Build with best native support for local CPU capabilities} {
    configure.cxxflags-append -march=native
}