homebrew-core/Formula/libev.rb

64 lines
2.2 KiB
Ruby

class Libev < Formula
desc "Asynchronous event library"
homepage "http://software.schmorp.de/pkg/libev.html"
url "http://dist.schmorp.de/libev/Attic/libev-4.33.tar.gz"
mirror "https://fossies.org/linux/misc/libev-4.33.tar.gz"
sha256 "507eb7b8d1015fbec5b935f34ebed15bf346bed04a11ab82b8eee848c4205aea"
livecheck do
url "http://dist.schmorp.de/libev/"
regex(/href=.*?libev[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 cellar: :any, arm64_big_sur: "8ed86bdd0ff3b47f8802b251a9ca61770ffc4c9b0be964f41f50955256b5bb53"
sha256 cellar: :any, big_sur: "95ddf4b85924a6a10d4a88b6eb52616fa8375e745c99d0752618d5bb82f5248a"
sha256 cellar: :any, catalina: "e5481e2ba48282bffb5ecc059f0ddddd9807400593e849ed4b48b1fed3a14698"
sha256 cellar: :any, mojave: "f6cfb8c6bb1219f4a54d36113ada7cc7e1e446d5a207bc77d69ac30d9cfe391f"
sha256 cellar: :any, high_sierra: "f623fc2f4dc3a0980b4733945eb2025cd40636a6d4f5e5d75ae5f89e0b7b07bd"
end
def install
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--mandir=#{man}"
system "make", "install"
# Remove compatibility header to prevent conflict with libevent
(include/"event.h").unlink
end
test do
(testpath/"test.c").write <<~'EOS'
/* Wait for stdin to become readable, then read and echo the first line. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ev.h>
ev_io stdin_watcher;
static void stdin_cb (EV_P_ ev_io *watcher, int revents) {
char *buf;
size_t nbytes = 255;
buf = (char *)malloc(nbytes + 1);
getline(&buf, &nbytes, stdin);
printf("%s", buf);
ev_io_stop(EV_A_ watcher);
ev_break(EV_A_ EVBREAK_ALL);
}
int main() {
ev_io_init(&stdin_watcher, stdin_cb, STDIN_FILENO, EV_READ);
ev_io_start(EV_DEFAULT, &stdin_watcher);
ev_run(EV_DEFAULT, 0);
return 0;
}
EOS
system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lev", "-o", "test"
input = "hello, world\n"
assert_equal input, pipe_output("./test", input, 0)
end
end