homebrew-core/Formula/libsigrok.rb

164 lines
4.9 KiB
Ruby

class Libsigrok < Formula
desc "Drivers for logic analyzers and other supported devices"
homepage "https://sigrok.org/"
# libserialport is LGPL3+
# fw-fx2lafw is GPL-2.0-or-later and LGPL-2.1-or-later"
license all_of: ["GPL-3.0-or-later", "LGPL-3.0-or-later", "GPL-2.0-or-later", "LGPL-2.1-or-later"]
revision 2
stable do
url "https://sigrok.org/download/source/libsigrok/libsigrok-0.5.2.tar.gz"
sha256 "4d341f90b6220d3e8cb251dacf726c41165285612248f2c52d15df4590a1ce3c"
resource "libserialport" do
url "https://sigrok.org/download/source/libserialport/libserialport-0.1.1.tar.gz"
sha256 "4a2af9d9c3ff488e92fb75b4ba38b35bcf9b8a66df04773eba2a7bbf1fa7529d"
end
resource "fw-fx2lafw" do
url "https://sigrok.org/download/source/sigrok-firmware-fx2lafw/sigrok-firmware-fx2lafw-0.1.7.tar.gz"
sha256 "a3f440d6a852a46e2c5d199fc1c8e4dacd006bc04e0d5576298ee55d056ace3b"
end
end
livecheck do
url "https://sigrok.org/wiki/Downloads"
regex(/href=.*?libsigrok[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
rebuild 1
sha256 arm64_ventura: "5cb796cad112521c090085f87cda4bafb9855e6c581ff2c04ad8fb41563b46a8"
sha256 arm64_monterey: "3f681eb6dd9e9de1062b048c29321600badf0665cb0a0436390dd33808820153"
sha256 arm64_big_sur: "55ad23a50b5831d13e0138262166606c4c63419ae04ab3baa96b329a389ae5f1"
sha256 ventura: "9f5afd85a8349cd773e36975ec1ca76d7081b62cbab0329095580dd2cdbb9fa1"
sha256 monterey: "22b1440ef8e3ff0f8a402645a82240e108817be368a9eab22db5ea831c09aae9"
sha256 big_sur: "15259f84462573558321e31f32c7260d5ab4fb7845706193c9c18036b4dea1f7"
sha256 x86_64_linux: "7f959e18410ea27731bbbc844103f8354f03e8a0ae395b3c7aef9c9a0ffccd86"
end
head do
url "git://sigrok.org/libsigrok", branch: "master"
resource "libserialport" do
url "git://sigrok.org/libserialport", branch: "master"
end
resource "fw-fx2lafw" do
url "git://sigrok.org/sigrok-firmware-fx2lafw", branch: "master"
end
end
depends_on "autoconf" => :build
depends_on "autoconf-archive" => :build
depends_on "automake" => :build
depends_on "doxygen" => :build
depends_on "graphviz" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => [:build, :test]
depends_on "sdcc" => :build
depends_on "swig" => :build
depends_on "glib"
depends_on "glibmm@2.66"
depends_on "hidapi"
depends_on "libftdi"
depends_on "libusb"
depends_on "libzip"
depends_on "nettle"
depends_on "numpy"
depends_on "pygobject3"
depends_on "python@3.11"
resource "fw-fx2lafw" do
url "https://sigrok.org/download/binary/sigrok-firmware-fx2lafw/sigrok-firmware-fx2lafw-bin-0.1.7.tar.gz"
sha256 "c876fd075549e7783a6d5bfc8d99a695cfc583ddbcea0217d8e3f9351d1723af"
end
def python3
"python3.11"
end
def install
resource("fw-fx2lafw").stage do
if build.head?
system "./autogen.sh"
else
system "autoreconf", "--force", "--install", "--verbose"
end
mkdir "build" do
system "../configure", *std_configure_args
system "make", "install"
end
end
resource("libserialport").stage do
if build.head?
system "./autogen.sh"
else
system "autoreconf", "--force", "--install", "--verbose"
end
mkdir "build" do
system "../configure", *std_configure_args
system "make", "install"
end
end
# We need to use the Makefile to generate all of the dependencies
# for setup.py, so the easiest way to make the Python libraries
# work is to adjust setup.py's arguments here.
prefix_site_packages = prefix/Language::Python.site_packages(python3)
inreplace "Makefile.am" do |s|
s.gsub!(/^(setup_py =.*setup\.py .*)/, "\\1 --no-user-cfg")
s.gsub!(
/(\$\(setup_py\) install)/,
"\\1 --single-version-externally-managed --record=installed.txt --install-lib=#{prefix_site_packages}",
)
end
if build.head?
system "./autogen.sh"
else
system "autoreconf", "--force", "--install", "--verbose"
end
mkdir "build" do
ENV["PYTHON"] = python3
ENV.prepend_path "PKG_CONFIG_PATH", lib/"pkgconfig"
args = %w[
--disable-java
--disable-ruby
]
system "../configure", *std_configure_args, *args
system "make"
system "make", "install"
end
end
test do
(testpath/"test.c").write <<~EOS
#include <libsigrok/libsigrok.h>
int main() {
struct sr_context *ctx;
if (sr_init(&ctx) != SR_OK) {
exit(EXIT_FAILURE);
}
if (sr_exit(ctx) != SR_OK) {
exit(EXIT_FAILURE);
}
return 0;
}
EOS
flags = shell_output("#{Formula["pkg-config"].opt_bin}/pkg-config --cflags --libs libsigrok").strip.split
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
system python3, "-c", <<~EOS
import sigrok.core as sr
sr.Context.create()
EOS
end
end