class Wangle < Formula desc "Modular, composable client/server abstractions framework" homepage "https://github.com/facebook/wangle" url "https://github.com/facebook/wangle/releases/download/v2023.05.22.00/wangle-v2023.05.22.00.tar.gz" sha256 "da277062a3ec1a1901bf10cef61d3778949efae94bcef6de628e621ce2790ea1" license "Apache-2.0" head "https://github.com/facebook/wangle.git", branch: "master" bottle do sha256 cellar: :any, arm64_ventura: "9397937bfc972e7f08dcd7cd49821a8b168b1bf95e0a107d047b4b5c571ddca1" sha256 cellar: :any, arm64_monterey: "85e387ca258ce4b9033040835da1932d0b2a99254763010cd538586ec5cf37ab" sha256 cellar: :any, arm64_big_sur: "37b11483a11bbeb58afd0f73d334235611fce24b0bf381d2e00867bb4e709247" sha256 cellar: :any, ventura: "d8b99218a6b7f08f19188a2f6f1a73f0e41b43c727133eaf1517515531f25c74" sha256 cellar: :any, monterey: "6d7f0cfed95dccb8b5c8d3cb54514245298246f532d5e2f2017597f661030db0" sha256 cellar: :any, big_sur: "cfd7d49e33985432445759c8a969b4d185ab4836860354337d27d0a9f8531b63" sha256 cellar: :any_skip_relocation, x86_64_linux: "f2bd64cf1922a160afb0411596e5827a7c611b32d223f57109636bf58add1075" end depends_on "cmake" => :build depends_on "boost" depends_on "double-conversion" depends_on "fizz" depends_on "fmt" depends_on "folly" depends_on "gflags" depends_on "glog" depends_on "libevent" depends_on "libsodium" depends_on "lz4" depends_on "openssl@1.1" depends_on "snappy" depends_on "zstd" uses_from_macos "bzip2" uses_from_macos "zlib" fails_with gcc: "5" def install cd "wangle" do system "cmake", ".", "-DBUILD_TESTS=OFF", "-DBUILD_SHARED_LIBS=ON", *std_cmake_args system "make", "install" system "make", "clean" system "cmake", ".", "-DBUILD_TESTS=OFF", "-DBUILD_SHARED_LIBS=OFF", *std_cmake_args system "make" lib.install "lib/libwangle.a" pkgshare.install Dir["example/echo/*.cpp"] end end test do cxx_flags = %W[ -std=c++17 -I#{include} -I#{Formula["openssl@1.1"].opt_include} -L#{Formula["gflags"].opt_lib} -L#{Formula["glog"].opt_lib} -L#{Formula["folly"].opt_lib} -L#{Formula["fizz"].opt_lib} -L#{lib} -lgflags -lglog -lfolly -lfizz -lwangle ] if OS.linux? cxx_flags << "-L#{Formula["boost"].opt_lib}" cxx_flags << "-lboost_context-mt" cxx_flags << "-ldl" cxx_flags << "-lpthread" end system ENV.cxx, pkgshare/"EchoClient.cpp", *cxx_flags, "-o", "EchoClient" system ENV.cxx, pkgshare/"EchoServer.cpp", *cxx_flags, "-o", "EchoServer" port = free_port fork { exec testpath/"EchoServer", "-port", port.to_s } sleep 10 require "pty" output = "" PTY.spawn(testpath/"EchoClient", "-port", port.to_s) do |r, w, pid| w.write "Hello from Homebrew!\nAnother test line.\n" sleep 20 Process.kill "TERM", pid begin r.each_line { |line| output += line } rescue Errno::EIO # GNU/Linux raises EIO when read is done on closed pty end end assert_match("Hello from Homebrew!", output) assert_match("Another test line.", output) end end