class JsonrpcGlib < Formula desc "GNOME library to communicate with JSON-RPC based peers" homepage "https://gitlab.gnome.org/GNOME/jsonrpc-glib" url "https://download.gnome.org/sources/jsonrpc-glib/3.28/jsonrpc-glib-3.28.0.tar.xz" sha256 "ba0b0f05d58ba47d5938a54787b44ea875648214f032f75d4344162d8f736a25" depends_on "gobject-introspection" => :build depends_on "meson-internal" => :build depends_on "ninja" => :build depends_on "pkg-config" => :build depends_on "python" => :build depends_on "glib" depends_on "json-glib" def install ENV.refurbish_args mkdir "build" do system "meson", "--prefix=#{prefix}", "-Dwith_vapi=false", ".." system "ninja" system "ninja", "install" end end test do (testpath/"test.c").write <<~EOS #include int main(int argc, char *argv[]) { JsonrpcInputStream *stream = jsonrpc_input_stream_new(NULL); return 0; } EOS gettext = Formula["gettext"] glib = Formula["glib"] json_glib = Formula["json-glib"] pcre = Formula["pcre"] flags = (ENV.cflags || "").split + (ENV.cppflags || "").split + (ENV.ldflags || "").split flags += %W[ -I#{gettext.opt_include} -I#{glib.opt_include}/glib-2.0 -I#{glib.opt_lib}/glib-2.0/include -I#{include}/jsonrpc-glib-1.0 -I#{json_glib.opt_include}/json-glib-1.0 -I#{pcre.opt_include} -D_REENTRANT -L#{gettext.opt_lib} -L#{glib.opt_lib} -L#{json_glib.opt_lib} -L#{lib} -lgio-2.0 -lglib-2.0 -lgobject-2.0 -lintl -ljson-glib-1.0 -ljsonrpc-glib-1.0 -Wl,-framework -Wl,CoreFoundation ] system ENV.cc, "test.c", "-o", "test", *flags system "./test" end end