homebrew-core/Formula/folly.rb

90 lines
3.1 KiB
Ruby

class Folly < Formula
desc "Collection of reusable C++ library artifacts developed at Facebook"
homepage "https://github.com/facebook/folly"
url "https://github.com/facebook/folly/archive/v2022.10.03.00.tar.gz"
sha256 "42dd54d17eed17fc0ae1c8ff35e0d11c991801d3220b0a32f82865072fe3f145"
license "Apache-2.0"
head "https://github.com/facebook/folly.git", branch: "main"
bottle do
sha256 cellar: :any, arm64_monterey: "475dc21b15a12ebc9f756b16f6639f019329e1a5878551002a62da07c12766f8"
sha256 cellar: :any, arm64_big_sur: "5bcd94a7dff3cc60047b866dd1b0345bc3ffe97d23cabf3de5c34c55a85288aa"
sha256 cellar: :any, monterey: "98bfca5e3fb0a99e08f7bd7336ae3984eb4ca5cee7a716885a31950fce5cc2e1"
sha256 cellar: :any, big_sur: "79c1c1a6c76028988733e23492708fba0dc1d1f11a6b949ea1e135ebf89e36a0"
sha256 cellar: :any, catalina: "628bbba69fe544ceea14cd27d1c8e37420cdf930e720278207eeddaec08c9c72"
sha256 cellar: :any_skip_relocation, x86_64_linux: "08bca9d09f8e75bde722f10a7a0a8c7725ec7f69490ca23a61b43b57e2af64a6"
end
depends_on "cmake" => :build
depends_on "pkg-config" => :build
depends_on "boost"
depends_on "double-conversion"
depends_on "fmt"
depends_on "gflags"
depends_on "glog"
depends_on "libevent"
depends_on "lz4"
depends_on "openssl@1.1"
depends_on "snappy"
depends_on "xz"
depends_on "zstd"
on_macos do
depends_on "llvm" if DevelopmentTools.clang_build_version <= 1100
end
fails_with :clang do
build 1100
# https://github.com/facebook/folly/issues/1545
cause <<-EOS
Undefined symbols for architecture x86_64:
"std::__1::__fs::filesystem::path::lexically_normal() const"
EOS
end
fails_with gcc: "5"
def install
ENV.llvm_clang if OS.mac? && (DevelopmentTools.clang_build_version <= 1100)
args = std_cmake_args + %W[
-DCMAKE_LIBRARY_ARCHITECTURE=#{Hardware::CPU.arch}
-DFOLLY_USE_JEMALLOC=OFF
]
system "cmake", "-S", ".", "-B", "build/shared",
"-DBUILD_SHARED_LIBS=ON",
"-DCMAKE_INSTALL_RPATH=#{rpath}",
*args
system "cmake", "--build", "build/shared"
system "cmake", "--install", "build/shared"
system "cmake", "-S", ".", "-B", "build/static",
"-DBUILD_SHARED_LIBS=OFF",
*args
system "cmake", "--build", "build/static"
lib.install "build/static/libfolly.a", "build/static/folly/libfollybenchmark.a"
end
test do
# Force use of Clang rather than LLVM Clang
ENV.clang if OS.mac?
(testpath/"test.cc").write <<~EOS
#include <folly/FBVector.h>
int main() {
folly::fbvector<int> numbers({0, 1, 2, 3});
numbers.reserve(10);
for (int i = 4; i < 10; i++) {
numbers.push_back(i * 2);
}
assert(numbers[6] == 12);
return 0;
}
EOS
system ENV.cxx, "-std=c++14", "test.cc", "-I#{include}", "-L#{lib}",
"-lfolly", "-o", "test"
system "./test"
end
end