homebrew-core/Formula/gtk4.rb

103 lines
3.5 KiB
Ruby

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.2.tar.xz"
sha256 "85b7a160b6e02eafa4e7d38f046f8720fab537d3fe73c01c864333a983a692a9"
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: "089c4910495b12bc499c03b43d7104b5a08b4a32feb1e95cdd8293999a00daa7"
sha256 arm64_monterey: "9b2cc47587ba3588815c96229d82ad5d77199cc9a7b81750545e8f26b2553d1d"
sha256 arm64_big_sur: "ede3901da6fa0d04529fef6d7ce2cbe3ce6c274dfb2e7f3fcf8446b5883d1613"
sha256 ventura: "c99295645c5eb7280bb95cf01a0f1e1c3b27078bab0c49d1707ccdd817990300"
sha256 monterey: "26e679a751038269581c6b87f2551216dc0aedf8469062f6d8fe52c3711519f6"
sha256 big_sur: "5a74446a65ebca85b0a0e8a92137f62fa0e95d9f8ca0e5a6469a21338d449012"
sha256 catalina: "34de48c6434e13cf7c8cf4faa10749d09d94a2a0ef50b4f0e9fe73d2364aad0d"
sha256 x86_64_linux: "c973dc27ac1dd7edf0d785404c303edef93203ba11f77305cc5085131b2c2d09"
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 <gtk/gtk.h>
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