homebrew-core/Formula/folly.rb

94 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.09.05.00.tar.gz"
sha256 "17a3804dd9aacd8a2440b3e0235cdfc2659f880c439b9a7533555d7061702f64"
license "Apache-2.0"
head "https://github.com/facebook/folly.git", branch: "main"
bottle do
sha256 cellar: :any, arm64_monterey: "16d8b2a23ba7877b5fbe375d40156f3ecde5c61050f7aa6bbe3c613fe69609f9"
sha256 cellar: :any, arm64_big_sur: "8dfffcb76dbec167db3bfb0446c0b79ac0396b28023a57e7ecc610750cbb7700"
sha256 cellar: :any, monterey: "35e5ca905eeb6c4ff3ceaeae565cd47cbeea6a89dac92233ed612ebcb67bd131"
sha256 cellar: :any, big_sur: "31aae77d52ffb6f67f8c5cc49095a2a099eefcef902ca8568a12be1076172459"
sha256 cellar: :any, catalina: "4e65403835b1cabcb33a0fc95ee0321b2df63c35af9d17c580a7090a66a0618f"
sha256 cellar: :any_skip_relocation, x86_64_linux: "ea60b6eccf8fac2c761bef9678c15c05ca18f26c32788e070e4564774cca9c4c"
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
on_linux do
depends_on "gcc"
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