homebrew-core/Formula/libgusb.rb

74 lines
2.1 KiB
Ruby

class Libgusb < Formula
include Language::Python::Shebang
desc "GObject wrappers for libusb1"
homepage "https://github.com/hughsie/libgusb"
url "https://people.freedesktop.org/~hughsient/releases/libgusb-0.3.6.tar.xz"
sha256 "13277948a2ee06861234938089aea21bce6ad862f14c81a2efa85340ed701efd"
license "LGPL-2.1-only"
head "https://github.com/hughsie/libgusb.git"
bottle do
sha256 arm64_big_sur: "4345b7a2ea031611554a8610cd77d5a957c08476dca7e3fbf8919f5d33a7108b"
sha256 big_sur: "0dae54cccd585022764e8eceb6dcb9006dead2e0417f056e3f767746e180fbb3"
sha256 catalina: "8a5d3d83ddfeb5fb0bc81aee83bd45a9e80e7fc2f03780c32757e53c4b5c0fe1"
sha256 mojave: "168bdde013b4c4757be1398cadbd0227c788e52766cb418cbf60a79a8806bd7b"
end
depends_on "gobject-introspection" => :build
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "python@3.9" => :build
depends_on "vala" => :build
depends_on "glib"
depends_on "libusb"
depends_on "usb.ids"
def install
rewrite_shebang detected_python_shebang, "contrib/generate-version-script.py"
mkdir "build" do
system "meson", *std_meson_args, "-Ddocs=false", "-Dusb_ids=#{Formula["usb.ids"].opt_share}/misc/usb.ids", ".."
system "ninja"
system "ninja", "install"
end
end
test do
system "#{bin}/gusbcmd", "-h"
(testpath/"test.c").write <<~EOS
#include <gusb.h>
int main(int argc, char *argv[]) {
GUsbContext *context = g_usb_context_new(NULL);
g_assert_nonnull(context);
return 0;
}
EOS
gettext = Formula["gettext"]
glib = Formula["glib"]
libusb = Formula["libusb"]
flags = %W[
-I#{gettext.opt_include}
-I#{glib.opt_include}/glib-2.0
-I#{glib.opt_lib}/glib-2.0/include
-I#{libusb.opt_include}/libusb-1.0
-I#{include}/gusb-1
-D_REENTRANT
-L#{gettext.opt_lib}
-L#{glib.opt_lib}
-L#{libusb.opt_lib}
-L#{lib}
-lgio-2.0
-lglib-2.0
-lgobject-2.0
-lintl
-lusb-1.0
-lgusb
]
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end