homebrew-core/Formula/gtk4.rb

95 lines
2.9 KiB
Ruby

class Gtk4 < Formula
desc "Toolkit for creating graphical user interfaces"
homepage "https://gtk.org/"
url "https://download.gnome.org/sources/gtk/4.2/gtk-4.2.1.tar.xz"
sha256 "023169775de43f0a1fde066fbc19d78545ea6a7562c1915abde9b8ae4a7309e6"
license "LGPL-2.0-or-later"
livecheck do
url :stable
regex(/gtk[._-](4\.([0-8]\d*?)?[02468](?:\.\d+)*?)\.t/i)
end
bottle do
sha256 arm64_big_sur: "3f972250f4ca4773a4982c9c9ef8fc735726948f9f590013defaee848d6f197a"
sha256 big_sur: "320d37f84ff986624ccccd27511e5980324441052ee8568f1a2f6268f24cc346"
sha256 catalina: "2d2f1e05dfc833ee33197c6f0e5435a7613960575b7f39be12d865fec56881b2"
sha256 mojave: "0763960bb97db821d98e2bdd81b3bb1219b61f3e7a7732cf00cb0538ace000fc"
sha256 x86_64_linux: "b933018ef1db05c649cf69954a7ed81731edc84eafd7aad37a12f2c31bd83e75"
end
depends_on "docbook" => :build
depends_on "docbook-xsl" => :build
depends_on "gobject-introspection" => :build
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => [:build, :test]
depends_on "sassc" => :build
depends_on "gdk-pixbuf"
depends_on "glib"
depends_on "graphene"
depends_on "hicolor-icon-theme"
depends_on "libepoxy"
depends_on "pango"
uses_from_macos "libxslt" => :build # for xsltproc
uses_from_macos "cups"
on_linux do
depends_on "libxkbcommon"
end
def install
args = std_meson_args + %w[
-Dgtk_doc=false
-Dman-pages=true
-Dintrospection=enabled
-Dbuild-examples=false
-Dbuild-tests=false
]
if OS.mac?
args << "-Dx11-backend=false"
args << "-Dmacos-backend=true"
args << "-Dprint-cups=disabled" if MacOS.version <= :mojave
end
# ensure that we don't run the meson post install script
ENV["DESTDIR"] = "/"
# Find our docbook catalog
ENV["XML_CATALOG_FILES"] = "#{etc}/xml/catalog"
# Disable asserts and cast checks explicitly
ENV.append "CPPFLAGS", "-DG_DISABLE_ASSERT -DG_DISABLE_CAST_CHECKS"
mkdir "build" do
system "meson", *args, ".."
system "ninja", "-v"
system "ninja", "install", "-v"
end
end
def post_install
system "#{Formula["glib"].opt_bin}/glib-compile-schemas", "#{HOMEBREW_PREFIX}/share/glib-2.0/schemas"
system bin/"gtk4-update-icon-cache", "-f", "-t", "#{HOMEBREW_PREFIX}/share/icons/hicolor"
system "#{Formula["glib"].opt_bin}/gio-querymodules", "#{HOMEBREW_PREFIX}/lib/gtk-4.0/4.0.0/printbackends"
end
test do
(testpath/"test.c").write <<~EOS
#include <gtk/gtk.h>
int main(int argc, char *argv[]) {
gtk_disable_setlocale();
return 0;
}
EOS
flags = shell_output("#{Formula["pkg-config"].opt_bin}/pkg-config --cflags --libs gtk4").strip.split
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
# include a version check for the pkg-config files
assert_match version.to_s, shell_output("cat #{lib}/pkgconfig/gtk4.pc").strip
end
end