homebrew-core/Formula/libxcb.rb

96 lines
2.6 KiB
Ruby

class Libxcb < Formula
desc "X.Org: Interface to the X Window System protocol"
homepage "https://www.x.org/"
url "https://xcb.freedesktop.org/dist/libxcb-1.14.tar.gz"
sha256 "2c7fcddd1da34d9b238c9caeda20d3bd7486456fc50b3cc6567185dbd5b0ad02"
license "MIT"
bottle do
cellar :any
sha256 "7d5c969ae5d67cba138c36d0ec758ef383763d58a615e1f0d9d8cc86c1c6d16d" => :big_sur
sha256 "8775b3a19f927b57ca4077211b25898c6481318ff1cddb3098c61903ae832b1f" => :catalina
sha256 "8a13efa25000a0695280f5465186f7511e9083685a49560d0dc5d7cc837a1cfa" => :mojave
sha256 "e56b657f223ac78f4f600fe057dd8ab12303be5f4f0f5b61eb94443d10fb4cf4" => :high_sierra
end
depends_on "pkg-config" => :build
depends_on "python@3.9" => :build
depends_on "xcb-proto" => :build
depends_on "libpthread-stubs"
depends_on "libxau"
depends_on "libxdmcp"
def install
args = %W[
--prefix=#{prefix}
--sysconfdir=#{etc}
--localstatedir=#{var}
--enable-dri3
--enable-ge
--enable-xevie
--enable-xprint
--enable-selinux
--disable-dependency-tracking
--disable-silent-rules
--enable-devel-docs=no
--with-doxygen=no
]
system "./configure", *args
system "make"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xcb/xcb.h"
int main() {
xcb_connection_t *connection;
xcb_atom_t *atoms;
xcb_intern_atom_cookie_t *cookies;
int count, i;
char **names;
char buf[100];
count = 200;
connection = xcb_connect(NULL, NULL);
atoms = (xcb_atom_t *) malloc(count * sizeof(atoms));
names = (char **) malloc(count * sizeof(char *));
for (i = 0; i < count; ++i) {
sprintf(buf, "NAME%d", i);
names[i] = strdup(buf);
memset(buf, 0, sizeof(buf));
}
cookies = (xcb_intern_atom_cookie_t *) malloc(count * sizeof(xcb_intern_atom_cookie_t));
for(i = 0; i < count; ++i) {
cookies[i] = xcb_intern_atom(connection, 0, strlen(names[i]), names[i]);
}
for(i = 0; i < count; ++i) {
xcb_intern_atom_reply_t *r;
r = xcb_intern_atom_reply(connection, cookies[i], 0);
if(r)
atoms[i] = r->atom;
free(r);
}
free(atoms);
free(cookies);
xcb_disconnect(connection);
return 0;
}
EOS
system ENV.cc, "test.c", "-o", "test", "-I#{include}", "-L#{lib}", "-lxcb"
system "./test"
assert_equal 0, $CHILD_STATUS.exitstatus
end
end