homebrew-core/Formula/wangle.rb

104 lines
3.3 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/v2022.02.14.00/wangle-v2022.02.14.00.tar.gz"
sha256 "edf14f80c859c0e598c842667773ee589249f7082d8a7265ab08ba91970a1f15"
license "Apache-2.0"
head "https://github.com/facebook/wangle.git", branch: "master"
bottle do
sha256 cellar: :any, arm64_monterey: "49c7a4ea1d4294a9a6454f042694a3d450467dd847cc8ee9f5d6f280df555cad"
sha256 cellar: :any, arm64_big_sur: "4f69994ea6419f8e198dace2509ed2e6455c5cbf4633b083d946fbe78f212753"
sha256 cellar: :any, monterey: "3b207f80eda943e2eeafd0f66939cddb9ada5ac528c2866eabc01019af0651dd"
sha256 cellar: :any, big_sur: "41c40adfd881a4c7cf65c9fdbb815d65603277347406ed1c3f9ac0939c7805ec"
sha256 cellar: :any, catalina: "8e8518669f99b74535042c87fcaeeaab843f0f58f0a1f55fb711873e30dea96f"
sha256 cellar: :any_skip_relocation, x86_64_linux: "9dcab97233fec494133b67299718d79642af5f7154a83205bb00ca342d8afdc4"
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"
on_linux do
depends_on "gcc"
end
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++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
]
on_linux do
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
ohai "Starting EchoServer on port #{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|
ohai "Sending data via EchoClient"
w.write "Hello from Homebrew!\nAnother test line.\n"
sleep 20
Process.kill "TERM", pid
begin
ohai "Reading received data"
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