class Gtk4 < Formula desc "Toolkit for creating graphical user interfaces" homepage "https://gtk.org/" url "https://download.gnome.org/sources/gtk/4.8/gtk-4.8.1.tar.xz" sha256 "5ce8d8de98a23bd0c8eca1a61094e1c009b5f009dcbd60b45e990a8db1b742fd" license "LGPL-2.1-or-later" livecheck do url :stable regex(/gtk[._-](4\.([0-8]\d*?)?[02468](?:\.\d+)*?)\.t/i) end bottle do sha256 arm64_ventura: "df0612711bbfcad45d1c5e139009ed91d70158af4958c80e36967c869dbf7741" sha256 arm64_monterey: "aab2c045916b3b742273bd5b70ed0576f10b85e42f74caa8d485fbdd8f1cc0e8" sha256 arm64_big_sur: "3ee5ccd130c2c2ac7469d1cf2f426ee585e72028bc77d65a64021ae34722ec1e" sha256 monterey: "bee36536e97b1a0b0864eeb1af5d3a5caf453c74f52514b8fd970e62ed31705b" sha256 big_sur: "b1e55151ada8d5f5c439a9f6153085706930cb603f36563e0b5ff0c3f5a0d62f" sha256 catalina: "e04c318241bbec1c561b859dc2fefd478242c15e0580cf2dca4343fc8b7a4a94" sha256 x86_64_linux: "844128e558ed2f2aa1238103028d805db8450fc8e0f837425692783f93abcef8" end depends_on "docbook" => :build depends_on "docbook-xsl" => :build depends_on "docutils" => :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 "jpeg-turbo" depends_on "libepoxy" depends_on "libpng" depends_on "libtiff" depends_on "pango" uses_from_macos "libxslt" => :build # for xsltproc uses_from_macos "cups" on_linux do depends_on "libxcursor" depends_on "libxkbcommon" end def install args = %w[ -Dgtk_doc=false -Dman-pages=true -Dintrospection=enabled -Dbuild-examples=false -Dbuild-tests=false -Dmedia-gstreamer=disabled ] 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" system "meson", *std_meson_args, "build", *args system "meson", "compile", "-C", "build", "-v" system "meson", "install", "-C", "build" 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 int main(int argc, char *argv[]) { gtk_disable_setlocale(); return 0; } EOS ENV.prepend_path "PKG_CONFIG_PATH", Formula["jpeg-turbo"].opt_lib/"pkgconfig" 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