57 lines
1.8 KiB
Ruby
57 lines
1.8 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.31.tar.gz"
|
|
mirror "https://fossies.org/linux/misc/libev-4.31.tar.gz"
|
|
sha256 "ed855d2b52118e32c0c1a6a32bd18c97f9e6711ca511f5ee12de3b9eccc66e5a"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "3170164f0d6e07e06a0cb579696c8074a1167c15350d2e266ba1744a9e905ab0" => :catalina
|
|
sha256 "0f4c71a528e44c264be93514de80f19dc27260e14849c4783e5e761599c14945" => :mojave
|
|
sha256 "2469238f580e481d357531d9cf641566d37c069739d867140b24bb548470ea68" => :high_sierra
|
|
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, "-I#{include}", "-L#{lib}", "-lev", "-o", "test", "test.c"
|
|
input = "hello, world\n"
|
|
assert_equal input, pipe_output("./test", input, 0)
|
|
end
|
|
end
|