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.10.00.tar.gz" sha256 "a3f46dde2b951e8dfc01428ac01d2e1cae482d955242abd74d1f4451450a83b2" license "Apache-2.0" head "https://github.com/facebook/folly.git", branch: "main" bottle do sha256 cellar: :any, arm64_monterey: "d384a94a6f1b43e9ac3329f3c7ce91f40946192df703caca9f1dc75750fd672b" sha256 cellar: :any, arm64_big_sur: "9212ac4182c7e7c40766647f88f83772f479533be9c19cbc41f90f0377764252" sha256 cellar: :any, monterey: "8a00f67b4be7a1f946b035da79d982a4ff0b005b6f91da3e10ae54e5f75bc693" sha256 cellar: :any, big_sur: "b08b37ad4424c41d5102bab98f4a4ede41b43ead128a2855d0a8e72853fcd3d4" sha256 cellar: :any, catalina: "e9b6ac16f3420c71e2fee86f971d586050bdfdfd2db9732aab2a4813c2be51f9" sha256 cellar: :any_skip_relocation, x86_64_linux: "8a07c64df5a6c7fcb312343ee22aeaaf4fe0cc822dd75769d8acb3925c71b9b5" 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 int main() { folly::fbvector 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