homebrew-core/Formula/folly.rb

91 lines
3.2 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.17.00.tar.gz"
sha256 "d7ae2a74139db6a8dd68e6ac03cc64a01cec4b0a972f83cabb42d089bc1a01bc"
license "Apache-2.0"
head "https://github.com/facebook/folly.git", branch: "main"
bottle do
sha256 cellar: :any, arm64_ventura: "0894943d3077826e0d17246a1c708d9a8f716077b48a8203eabe11bd91e035c4"
sha256 cellar: :any, arm64_monterey: "b7b3fddb3f9198f207c5d5dcca28ad0c1f240776d889c813744ab2b333614c96"
sha256 cellar: :any, arm64_big_sur: "9e9c7be2c5dc1f194331f864700c68fac278687800aef6d2173b745dde99c256"
sha256 cellar: :any, monterey: "089b05f9dbbbdb7982e8edff17e3c4d6a19808437a2d97cde4798e9d337d5d61"
sha256 cellar: :any, big_sur: "2b105d73a276b930a30165f9454345f1ccba9bdb84fa79a1e266271003f923fa"
sha256 cellar: :any, catalina: "b3a10d4f87b62ba42f2152eef19f58293962410eb3cc2d03c6ad3bd0be7b905a"
sha256 cellar: :any_skip_relocation, x86_64_linux: "ef1a2a837567603074bf5dfcccbc354b880a2ceb4120724590440006acfb9930"
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