homebrew-core/Formula/wangle.rb

83 lines
2.4 KiB
Ruby

class Wangle < Formula
desc "Modular, composable client/server abstractions framework"
homepage "https://github.com/facebook/wangle"
url "https://github.com/facebook/wangle/releases/download/v2021.03.22.00/wangle-v2021.03.22.00.tar.gz"
sha256 "de7998c927c15f0859316b94596d2a17074e8b2b6843f2b402c859231cbc6ebe"
license "Apache-2.0"
head "https://github.com/facebook/wangle.git"
bottle do
sha256 cellar: :any, arm64_big_sur: "0a33d5a6f8316c3fc6f91b2d34c1b7c5e8883f30a90ea37c2dae8183d4c37fad"
sha256 cellar: :any, big_sur: "016ad6c1668a1d024f103d9d2fc91000ca46058c996b52472159de02b185a3d9"
sha256 cellar: :any, catalina: "76f0c6c376b4d0f8015491ae79986e1e4b077a5ec21aeee7592245e03d26202a"
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"
# https://github.com/facebook/folly/issues/1545
depends_on macos: :catalina
depends_on "openssl@1.1"
depends_on "snappy"
depends_on "zstd"
uses_from_macos "bzip2"
uses_from_macos "zlib"
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++14
-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
]
system ENV.cxx, *cxx_flags, "-o", "EchoClient", pkgshare/"EchoClient.cpp"
system ENV.cxx, *cxx_flags, "-o", "EchoServer", pkgshare/"EchoServer.cpp"
port = free_port
fork { exec testpath/"EchoServer", "-port", port.to_s }
sleep 2
require "pty"
r, w, pid = PTY.spawn(testpath/"EchoClient", "-port", port.to_s)
w.write "Hello from Homebrew!\nAnother test line.\n"
sleep 1
Process.kill("TERM", pid)
output = r.read
assert_match("Hello from Homebrew!", output)
assert_match("Another test line.", output)
end
end