homebrew-core/Formula/libwebsockets.rb

51 lines
1.6 KiB
Ruby

class Libwebsockets < Formula
desc "C websockets server library"
homepage "https://libwebsockets.org"
url "https://github.com/warmcat/libwebsockets/archive/v3.2.2.tar.gz"
sha256 "166d6e17cab64bfc10c2a71799c298284540a1fa63f6ea3de5caccb34502243c"
head "https://github.com/warmcat/libwebsockets.git"
bottle do
sha256 "014a8f16588e87e089414f615a48f3ce6d70aaa062e9b8b080c9fea87cfb3a7c" => :catalina
sha256 "40d0c072fef3f4a65c7466e1e0f90cd38fa125c23a627a8ac6c383622a3e842a" => :mojave
sha256 "41590503343e01d39e968680f165dc79b6c613704e38c6222fe28e16bda61a63" => :high_sierra
end
depends_on "cmake" => :build
depends_on "libevent"
depends_on "libuv"
depends_on "openssl@1.1"
def install
system "cmake", ".", *std_cmake_args,
"-DLWS_IPV6=ON",
"-DLWS_WITH_HTTP2=ON",
"-DLWS_WITH_LIBEVENT=ON",
"-DLWS_WITH_LIBUV=ON",
"-DLWS_WITH_PLUGINS=ON",
"-DLWS_WITHOUT_TESTAPPS=ON",
"-DLWS_UNIX_SOCK=ON"
system "make"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <openssl/ssl.h>
#include <libwebsockets.h>
int main()
{
struct lws_context_creation_info info;
memset(&info, 0, sizeof(info));
struct lws_context *context;
context = lws_create_context(&info);
lws_context_destroy(context);
return 0;
}
EOS
system ENV.cc, "test.c", "-I#{Formula["openssl@1.1"].opt_prefix}/include", "-L#{lib}", "-lwebsockets", "-o", "test"
system "./test"
end
end